Skip to content

Peritext Slate.js extension#977

Merged
streamich merged 18 commits intomasterfrom
peritext-slate
Jan 15, 2026
Merged

Peritext Slate.js extension#977
streamich merged 18 commits intomasterfrom
peritext-slate

Conversation

@streamich
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 15, 2026 13:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Slate.js extension to the Peritext CRDT system, enabling rich text editing with Slate.js format support. The implementation upgrades the Slate dependency and creates bidirectional conversion between Slate documents and Peritext's internal representation.

Changes:

  • Upgraded Slate.js from v0.117.2 to v0.120.0 (removing immer and tiny-warning dependencies)
  • Added SlateNode, SlateApi, and FromSlate converter for Slate.js integration
  • Registered the new slate extension (ID 5) in the extensions system

Reviewed changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
yarn.lock Updated Slate dependency to 0.120.0, removed immer and tiny-warning
package.json Updated Slate devDependency version
slate/types.ts Defined Slate document structure, operations, and type aliases
slate/SlateNode.ts Implemented SlateNode extension with view rendering
slate/SlateApi.ts Created API for interacting with Slate nodes
slate/FromSlate.ts Converter from Slate documents to Peritext ViewRange
slate/index.ts Extension registration and exports
slate/constants.ts Extension mnemonic constant
constants.ts Added slate extension ID and name enums
ModelWithExt.ts Registered slate extension
schema/types.ts Added SlateNode type mapping in schema system
model/api/types.ts Added SlateApi type mapping in API system
Test fixtures Added comprehensive test traces and document fixtures

@@ -0,0 +1,49 @@
import {createEditor} from 'slate';
import {clone, SlateTraceRecorder, type SlateTrace} from './traces';
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path './traces' should be './tools/traces' based on the file structure. The SlateTraceRecorder is defined in tools/traces.ts, not a traces.ts file at this level.

Suggested change
import {clone, SlateTraceRecorder, type SlateTrace} from './traces';
import {clone, SlateTraceRecorder, type SlateTrace} from './tools/traces';

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,62 @@
import {FromSlate} from '../FromSlate';
import * as traces from './traces';
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path './traces' appears incorrect. Based on the file structure, this should likely be './tools/traces' to properly import the trace utilities.

Suggested change
import * as traces from './traces';
import * as traces from './tools/traces';

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,1351 @@
import type {SlateTrace} from '../traces';
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path '../traces' should be '../../tools/traces' based on the file structure, as SlateTrace type is defined in the tools directory, not at the parent level.

Suggested change
import type {SlateTrace} from '../traces';
import type {SlateTrace} from '../../tools/traces';

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,49 @@
import {createEditor} from 'slate';
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import createEditor.

Suggested change
import {createEditor} from 'slate';

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,49 @@
import {createEditor} from 'slate';
import {clone, SlateTraceRecorder, type SlateTrace} from './traces';
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import clone.

Suggested change
import {clone, SlateTraceRecorder, type SlateTrace} from './traces';
import {SlateTraceRecorder, type SlateTrace} from './traces';

Copilot uses AI. Check for mistakes.
Comment on lines +83 to +84
let length = 0;
if (node && (length = node.length) > 0) this.cont([], node);
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value assigned to length here is unused.

Suggested change
let length = 0;
if (node && (length = node.length) > 0) this.cont([], node);
if (node && node.length > 0) this.cont([], node);

Copilot uses AI. Check for mistakes.
@streamich streamich merged commit 51da3c3 into master Jan 15, 2026
9 checks passed
@streamich streamich deleted the peritext-slate branch January 15, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants