Conversation
There was a problem hiding this comment.
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'; | |||
There was a problem hiding this comment.
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.
| import {clone, SlateTraceRecorder, type SlateTrace} from './traces'; | |
| import {clone, SlateTraceRecorder, type SlateTrace} from './tools/traces'; |
| @@ -0,0 +1,62 @@ | |||
| import {FromSlate} from '../FromSlate'; | |||
| import * as traces from './traces'; | |||
There was a problem hiding this comment.
The import path './traces' appears incorrect. Based on the file structure, this should likely be './tools/traces' to properly import the trace utilities.
| import * as traces from './traces'; | |
| import * as traces from './tools/traces'; |
| @@ -0,0 +1,1351 @@ | |||
| import type {SlateTrace} from '../traces'; | |||
There was a problem hiding this comment.
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.
| import type {SlateTrace} from '../traces'; | |
| import type {SlateTrace} from '../../tools/traces'; |
| @@ -0,0 +1,49 @@ | |||
| import {createEditor} from 'slate'; | |||
There was a problem hiding this comment.
Unused import createEditor.
| import {createEditor} from 'slate'; |
| @@ -0,0 +1,49 @@ | |||
| import {createEditor} from 'slate'; | |||
| import {clone, SlateTraceRecorder, type SlateTrace} from './traces'; | |||
There was a problem hiding this comment.
Unused import clone.
| import {clone, SlateTraceRecorder, type SlateTrace} from './traces'; | |
| import {SlateTraceRecorder, type SlateTrace} from './traces'; |
| let length = 0; | ||
| if (node && (length = node.length) > 0) this.cont([], node); |
There was a problem hiding this comment.
The value assigned to length here is unused.
| let length = 0; | |
| if (node && (length = node.length) > 0) this.cont([], node); | |
| if (node && node.length > 0) this.cont([], node); |
No description provided.