smartrte-react 0.3.5 → 1.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +106 -14
  3. package/dist/adapters/domChecklistCommandBridge.js +1 -1
  4. package/dist/adapters/domCommandBridge.d.ts +2 -2
  5. package/dist/adapters/domCommandBridge.js +2 -2
  6. package/dist/adapters/domInlineAtomCommandBridge.d.ts +10 -9
  7. package/dist/adapters/domInlineAtomCommandBridge.js +154 -50
  8. package/dist/adapters/domInlineImageCommandBridge.d.ts +7 -7
  9. package/dist/adapters/domInlineImageCommandBridge.js +6 -72
  10. package/dist/adapters/domMoveCommandBridge.js +1 -1
  11. package/dist/adapters/domSelectionBridge.d.ts +3 -3
  12. package/dist/adapters/domSmartDocument.d.ts +4 -4
  13. package/dist/adapters/domSmartDocument.js +2 -2
  14. package/dist/adapters/domTableCommandBridge.d.ts +42 -16
  15. package/dist/adapters/domTableCommandBridge.js +203 -173
  16. package/dist/adapters/internalFlags.d.ts +0 -8
  17. package/dist/adapters/internalFlags.js +0 -24
  18. package/dist/adapters/legacyListShadowComparator.d.ts +1 -1
  19. package/dist/adapters/legacyListShadowComparator.js +1 -1
  20. package/dist/adapters/pdfPrint.d.ts +8 -0
  21. package/dist/adapters/pdfPrint.js +22 -0
  22. package/dist/adapters/shadowMode.d.ts +3 -3
  23. package/dist/adapters/shadowMode.js +1 -1
  24. package/dist/canonicalEditorRuntime.d.ts +53 -1
  25. package/dist/canonicalEditorRuntime.js +61 -4
  26. package/dist/capabilityPresets.d.ts +27 -0
  27. package/dist/capabilityPresets.js +21 -0
  28. package/dist/collabTransport.d.ts +66 -0
  29. package/dist/collabTransport.js +1 -0
  30. package/dist/commentProvider.d.ts +24 -0
  31. package/dist/commentProvider.js +1 -0
  32. package/dist/components/CanonicalAuthorityEditor.d.ts +35 -1
  33. package/dist/components/CanonicalAuthorityEditor.js +1086 -112
  34. package/dist/components/ClassicEditorAuthority.d.ts +93 -22
  35. package/dist/components/ClassicEditorAuthority.js +11 -43
  36. package/dist/components/ColorPickerPopover.d.ts +39 -0
  37. package/dist/components/ColorPickerPopover.js +285 -0
  38. package/dist/components/CommentMarkers.d.ts +25 -0
  39. package/dist/components/CommentMarkers.js +105 -0
  40. package/dist/components/CommentThreadPanel.d.ts +26 -0
  41. package/dist/components/CommentThreadPanel.js +47 -0
  42. package/dist/components/ContextMenu.d.ts +23 -0
  43. package/dist/components/ContextMenu.js +141 -0
  44. package/dist/components/FormulaLibraryPopover.d.ts +16 -0
  45. package/dist/components/FormulaLibraryPopover.js +107 -0
  46. package/dist/components/LinkEditorPopover.d.ts +3 -1
  47. package/dist/components/LinkEditorPopover.js +22 -6
  48. package/dist/components/MediaManager.d.ts +4 -20
  49. package/dist/components/MediaManager.js +35 -6
  50. package/dist/components/MediaOverlay.d.ts +36 -0
  51. package/dist/components/MediaOverlay.js +163 -0
  52. package/dist/components/SpecialCharacterPopover.d.ts +18 -0
  53. package/dist/components/SpecialCharacterPopover.js +99 -0
  54. package/dist/components/StructuralSuggestionMarkers.d.ts +20 -0
  55. package/dist/components/StructuralSuggestionMarkers.js +56 -0
  56. package/dist/components/SuggestionPanel.d.ts +26 -0
  57. package/dist/components/SuggestionPanel.js +33 -0
  58. package/dist/components/TableBorderPopover.d.ts +59 -0
  59. package/dist/components/TableBorderPopover.js +147 -0
  60. package/dist/components/TableResizeHandles.d.ts +25 -0
  61. package/dist/components/TableResizeHandles.js +301 -0
  62. package/dist/components/TableSizePickerPopover.d.ts +16 -0
  63. package/dist/components/TableSizePickerPopover.js +126 -0
  64. package/dist/components/ToolbarPrimitives.d.ts +129 -0
  65. package/dist/components/ToolbarPrimitives.js +146 -0
  66. package/dist/components/VersionHistoryPanel.d.ts +9 -0
  67. package/dist/components/VersionHistoryPanel.js +157 -0
  68. package/dist/formulaLibrary.d.ts +31 -0
  69. package/dist/formulaLibrary.js +90 -0
  70. package/dist/index.d.ts +22 -24
  71. package/dist/index.js +14 -11
  72. package/dist/mediaManagerAdapter.d.ts +12 -0
  73. package/dist/mediaManagerAdapter.js +34 -0
  74. package/dist/mediaProvider.d.ts +21 -1
  75. package/dist/specialCharacters.d.ts +22 -0
  76. package/dist/specialCharacters.js +86 -0
  77. package/dist/standalone/classic-editor-embed.js +19 -12
  78. package/dist/suggestionProvider.d.ts +17 -0
  79. package/dist/suggestionProvider.js +1 -0
  80. package/dist/theme.d.ts +1 -1
  81. package/dist/theme.js +150 -20
  82. package/dist/versionProvider.d.ts +29 -0
  83. package/dist/versionProvider.js +1 -0
  84. package/package.json +28 -14
  85. package/dist/adapters/canonicalInlineCommandBridge.d.ts +0 -15
  86. package/dist/adapters/canonicalInlineCommandBridge.js +0 -269
  87. package/dist/adapters/canonicalListCommandBridge.d.ts +0 -26
  88. package/dist/adapters/canonicalListCommandBridge.js +0 -430
  89. package/dist/adapters/coreBold.d.ts +0 -5
  90. package/dist/adapters/coreBold.js +0 -3
  91. package/dist/adapters/documentFormats.d.ts +0 -26
  92. package/dist/adapters/documentFormats.js +0 -49
  93. package/dist/adapters/docxFormat.d.ts +0 -5
  94. package/dist/adapters/docxFormat.js +0 -272
  95. package/dist/adapters/domBlockCommandBridge.d.ts +0 -19
  96. package/dist/adapters/domBlockCommandBridge.js +0 -79
  97. package/dist/adapters/inlineMarkCoreExecution.d.ts +0 -9
  98. package/dist/adapters/inlineMarkCoreExecution.js +0 -25
  99. package/dist/adapters/pdfFormat.d.ts +0 -23
  100. package/dist/adapters/pdfFormat.js +0 -204
  101. package/dist/adapters/portableDocxAtoms.d.ts +0 -4
  102. package/dist/adapters/portableDocxAtoms.js +0 -58
  103. package/dist/adapters/styledDocxFormat.d.ts +0 -8
  104. package/dist/adapters/styledDocxFormat.js +0 -190
  105. package/dist/builtInFormatDefinitions.d.ts +0 -5
  106. package/dist/builtInFormatDefinitions.js +0 -82
  107. package/dist/canonicalAuthorityFlag.d.ts +0 -32
  108. package/dist/canonicalAuthorityFlag.js +0 -49
  109. package/dist/canonicalClipboardRuntime.d.ts +0 -15
  110. package/dist/canonicalClipboardRuntime.js +0 -76
  111. package/dist/components/ClassicEditor.d.ts +0 -76
  112. package/dist/components/ClassicEditor.js +0 -6729
  113. package/dist/editorController.d.ts +0 -78
  114. package/dist/editorController.js +0 -298
  115. package/dist/formatFidelity.d.ts +0 -14
  116. package/dist/formatFidelity.js +0 -107
  117. package/dist/formatRuntime.d.ts +0 -50
  118. package/dist/formatRuntime.js +0 -20
  119. package/dist/pluginRuntime.d.ts +0 -68
  120. package/dist/pluginRuntime.js +0 -78
  121. package/dist/standalone/editor.js +0 -1068
  122. package/dist/test-harness/atomShadowComparator.d.ts +0 -14
  123. package/dist/test-harness/atomShadowComparator.js +0 -63
  124. package/dist/test-harness/blockShadowComparator.d.ts +0 -30
  125. package/dist/test-harness/blockShadowComparator.js +0 -140
  126. package/dist/test-harness/clipboardShadowComparator.d.ts +0 -12
  127. package/dist/test-harness/clipboardShadowComparator.js +0 -46
  128. package/dist/test-harness/inlineShadowComparator.d.ts +0 -32
  129. package/dist/test-harness/inlineShadowComparator.js +0 -152
  130. package/dist/test-harness/legacyAtomEngine.d.ts +0 -10
  131. package/dist/test-harness/legacyAtomEngine.js +0 -15
  132. package/dist/test-harness/legacyBlockEngine.d.ts +0 -31
  133. package/dist/test-harness/legacyBlockEngine.js +0 -31
  134. package/dist/test-harness/legacyClipboardEngine.d.ts +0 -14
  135. package/dist/test-harness/legacyClipboardEngine.js +0 -67
  136. package/dist/test-harness/legacyInlineEngine.d.ts +0 -19
  137. package/dist/test-harness/legacyInlineEngine.js +0 -49
  138. package/dist/test-harness/legacyTableEngine.d.ts +0 -12
  139. package/dist/test-harness/legacyTableEngine.js +0 -25
  140. package/dist/test-harness/tableShadowComparator.d.ts +0 -29
  141. package/dist/test-harness/tableShadowComparator.js +0 -101
@@ -1,4 +1,5 @@
1
- import { type CanonicalInputPipeline, type ClipboardDiagnosticReport, type CanonicalSubtreeRenderer, type FoundationEditor, type PersistedEditorDocument, type SmartMark, type SmartOperation, type SmartSelection, type SmartTransaction } from "smartrte-core/foundation";
1
+ import { type CanonicalInputPipeline, type ClipboardDiagnosticReport, type CanonicalSubtreeRenderer, type DocumentVersion, type FoundationEditor, type PersistedEditorDocument, type SmartMark, type SmartOperation, type SmartSelection, type SmartTransaction } from "smartrte-core/foundation";
2
+ import { type EditorCapabilityPreset } from "./capabilityPresets.js";
2
3
  export interface SmartEditorCheckpoint {
3
4
  envelope: PersistedEditorDocument;
4
5
  selection: SmartSelection;
@@ -22,6 +23,14 @@ export interface SmartEditorHandle {
22
23
  executeOperations(operations: readonly SmartOperation[], opts?: ExecuteOperationsOptions): void;
23
24
  createCheckpoint(): SmartEditorCheckpoint;
24
25
  restoreCheckpoint(checkpoint: SmartEditorCheckpoint): void;
26
+ saveVersion(opts?: SaveVersionOptions): DocumentVersion;
27
+ restoreVersion(version: DocumentVersion, opts?: {
28
+ keepSelection?: boolean;
29
+ }): void;
30
+ }
31
+ export interface SaveVersionOptions {
32
+ label?: string;
33
+ authorId?: string;
25
34
  }
26
35
  export interface ExecuteOperationsOptions {
27
36
  historyGroup?: string;
@@ -37,6 +46,17 @@ export interface CanonicalEditorRuntimeOptions {
37
46
  onChange?: (change: SmartEditorChange) => void;
38
47
  onHtmlChange?: (html: string) => void;
39
48
  onClipboardDiagnostic?: (report: ClipboardDiagnosticReport) => void;
49
+ /**
50
+ * Renderer-integrated content-visibility (Phase 11 Tier 3, opt-in,
51
+ * default off) - only applies content-visibility:auto to a top-level
52
+ * block the renderer's own diff already proved untouched this render
53
+ * pass and that isn't the actively-selected block. See
54
+ * surface/renderer.ts's syncContentVisibility for why this differs from
55
+ * the disproven naive per-block experiment.
56
+ */
57
+ contentVisibility?: boolean;
58
+ /** Which built-in plugins this instance is constructed with - see capabilityPresets.ts. Defaults to "full" (every plugin), matching this runtime's only behavior before this option existed. */
59
+ preset?: EditorCapabilityPreset;
40
60
  }
41
61
  /** Persistent, React-independent owner for one product editor instance. */
42
62
  export declare class CanonicalEditorRuntime implements SmartEditorHandle {
@@ -49,6 +69,7 @@ export declare class CanonicalEditorRuntime implements SmartEditorHandle {
49
69
  private onChange?;
50
70
  private onHtmlChange?;
51
71
  private readonly onClipboardDiagnostic?;
72
+ private readonly contentVisibility;
52
73
  private htmlChangeTimer;
53
74
  private pendingHtmlDocument;
54
75
  constructor(options?: CanonicalEditorRuntimeOptions);
@@ -67,6 +88,37 @@ export declare class CanonicalEditorRuntime implements SmartEditorHandle {
67
88
  executeOperations(operations: readonly SmartOperation[], opts?: ExecuteOperationsOptions): void;
68
89
  createCheckpoint(): SmartEditorCheckpoint;
69
90
  restoreCheckpoint(checkpoint: SmartEditorCheckpoint): void;
91
+ /**
92
+ * A pure read of current state, like `createCheckpoint` - never touches
93
+ * the undo stack, never a `transact()` call. The runtime doesn't call a
94
+ * `VersionProvider` itself (same division as `mediaProvider.upload`
95
+ * being called directly from the React component, not the runtime) -
96
+ * this just builds the payload a caller then hands to a provider.
97
+ */
98
+ saveVersion(opts?: SaveVersionOptions): DocumentVersion;
99
+ /**
100
+ * Reuses `replaceValue` (the same "load a full snapshot" mechanism
101
+ * `restoreCheckpoint` already uses) rather than replaying the version as
102
+ * a sequence of operations - a version can be arbitrarily old, and
103
+ * `replaceState` already validates/repairs an incoming document the same
104
+ * way loading any document does. Deliberately does NOT reuse the
105
+ * version's own stored `revision`: `replaceState` sets the live
106
+ * revision counter to whatever it's given verbatim, so restoring an old
107
+ * version's envelope as-is would roll a monotonic counter backward -
108
+ * colliding with `StaleTransactionError`'s bookkeeping and this
109
+ * runtime's own `isDirty()` comparison. Always re-stamps to
110
+ * `currentRevision + 1` instead. Not undoable, same as checkpoint
111
+ * restore today (`replaceState`'s emitted transaction always sets
112
+ * `addToHistory: false`). Per the Phase 12a spec's explicit
113
+ * recommendation, restore is non-destructive of version history at the
114
+ * UI layer: the caller (`VersionHistoryPanel`) saves a new version
115
+ * recording the restored state immediately after calling this, rather
116
+ * than this method silently discarding anything - the version list only
117
+ * ever grows, never rewrites.
118
+ */
119
+ restoreVersion(version: DocumentVersion, opts?: {
120
+ keepSelection?: boolean;
121
+ }): void;
70
122
  /** Instrumentation for product-path composition and takeover tests. */
71
123
  get surface(): {
72
124
  root: HTMLElement;
@@ -1,4 +1,5 @@
1
- import { createFoundationEditor, applyOperations, createInputPipeline, createSubtreeRenderer, createTransactionMap, foundationSchema, isTextNode, parseCanonicalListHtml, serializeCanonicalListHtml, } from "smartrte-core/foundation";
1
+ import { createFoundationEditor, applyOperations, createInputPipeline, createNodeId, createSubtreeRenderer, createTransactionMap, foundationSchema, isTextNode, parseCanonicalListHtml, serializeCanonicalListHtml, } from "smartrte-core/foundation";
2
+ import { capabilityPresetRegistry } from "./capabilityPresets.js";
2
3
  const nodeAtPath = (root, path) => {
3
4
  let node = root;
4
5
  for (const index of path) {
@@ -29,7 +30,11 @@ const firstTextSelection = (document) => {
29
30
  return null;
30
31
  const spec = foundationSchema.nodes[node.type];
31
32
  const children = node.children || [];
32
- if (spec?.group === "block" && (children.length === 0 || children.every((child) => isTextNode(child) || foundationSchema.nodes[child.type]?.group === "inline")))
33
+ // Atomic nodes (e.g. block_image) never accept a text caret inside them,
34
+ // even when they report an empty children array - only a genuine
35
+ // text-content container (an empty or all-inline block) is a valid
36
+ // first-text-selection target.
37
+ if (spec?.group === "block" && !spec.atomic && (children.length === 0 || children.every((child) => isTextNode(child) || foundationSchema.nodes[child.type]?.group === "inline")))
33
38
  return { path, offset: 0 };
34
39
  for (let index = 0; index < children.length; index += 1) {
35
40
  const found = visit(children[index], [...path, index]);
@@ -78,15 +83,22 @@ export class CanonicalEditorRuntime {
78
83
  this.htmlChangeTimer = null;
79
84
  this.pendingHtmlDocument = null;
80
85
  const envelope = envelopeFrom(options.initialValue);
86
+ // "full" (the default) intentionally passes no schema/commands/etc., so
87
+ // FoundationEditor's own defaulting (`options.schema || foundationSchema`)
88
+ // applies - every existing consumer who never sets `preset` is
89
+ // byte-for-byte unaffected by this option existing.
90
+ const registry = options.preset && options.preset !== "full" ? capabilityPresetRegistry(options.preset) : null;
81
91
  this.editor = createFoundationEditor({
82
92
  document: envelope.document,
83
93
  revision: envelope.revision,
84
94
  selection: firstTextSelection(envelope.document),
95
+ ...(registry ? { schema: registry.schema, commands: registry.commands, keyboardShortcuts: registry.keyboardShortcuts, contextMenu: registry.contextMenu } : {}),
85
96
  });
86
97
  this.savedRevision = envelope.revision;
87
98
  this.onChange = options.onChange;
88
99
  this.onHtmlChange = options.onHtmlChange;
89
100
  this.onClipboardDiagnostic = options.onClipboardDiagnostic;
101
+ this.contentVisibility = options.contentVisibility === true;
90
102
  }
91
103
  setCallbacks(onChange, onHtmlChange) {
92
104
  this.onChange = onChange;
@@ -124,7 +136,7 @@ export class CanonicalEditorRuntime {
124
136
  return;
125
137
  this.unmount();
126
138
  this.root = root;
127
- this.renderer = createSubtreeRenderer(root);
139
+ this.renderer = createSubtreeRenderer(root, { contentVisibility: this.contentVisibility });
128
140
  this.pipeline = createInputPipeline(this.editor, this.renderer, root, { onClipboardDiagnostic: this.onClipboardDiagnostic });
129
141
  this.unsubscribe = this.editor.subscribe((transaction, state) => {
130
142
  this.renderer?.render(this.editor.document, this.editor.selection);
@@ -251,7 +263,14 @@ export class CanonicalEditorRuntime {
251
263
  addToHistory: opts.addToHistory ?? true,
252
264
  ...(opts.historyGroup ? { historyGroup: opts.historyGroup } : {}),
253
265
  });
254
- this.focus();
266
+ // Skipped for a non-history (preview) operation: focusing the main
267
+ // editor surface would steal keyboard/pointer focus away from whatever
268
+ // UI is driving the preview (e.g. ColorPickerPopover's native color
269
+ // input mid-drag) on every single preview frame - breaking Escape-to-
270
+ // cancel and, in a real browser, potentially interrupting the drag
271
+ // itself. A real, history-eligible commit still focuses as before.
272
+ if (opts.addToHistory ?? true)
273
+ this.focus();
255
274
  }
256
275
  createCheckpoint() {
257
276
  return {
@@ -268,6 +287,44 @@ export class CanonicalEditorRuntime {
268
287
  });
269
288
  this.savedRevision = checkpoint.savedRevision;
270
289
  }
290
+ /**
291
+ * A pure read of current state, like `createCheckpoint` - never touches
292
+ * the undo stack, never a `transact()` call. The runtime doesn't call a
293
+ * `VersionProvider` itself (same division as `mediaProvider.upload`
294
+ * being called directly from the React component, not the runtime) -
295
+ * this just builds the payload a caller then hands to a provider.
296
+ */
297
+ saveVersion(opts = {}) {
298
+ return { id: createNodeId(), createdAt: Date.now(), envelope: this.getValue(), ...(opts.label ? { label: opts.label } : {}), ...(opts.authorId ? { authorId: opts.authorId } : {}) };
299
+ }
300
+ /**
301
+ * Reuses `replaceValue` (the same "load a full snapshot" mechanism
302
+ * `restoreCheckpoint` already uses) rather than replaying the version as
303
+ * a sequence of operations - a version can be arbitrarily old, and
304
+ * `replaceState` already validates/repairs an incoming document the same
305
+ * way loading any document does. Deliberately does NOT reuse the
306
+ * version's own stored `revision`: `replaceState` sets the live
307
+ * revision counter to whatever it's given verbatim, so restoring an old
308
+ * version's envelope as-is would roll a monotonic counter backward -
309
+ * colliding with `StaleTransactionError`'s bookkeeping and this
310
+ * runtime's own `isDirty()` comparison. Always re-stamps to
311
+ * `currentRevision + 1` instead. Not undoable, same as checkpoint
312
+ * restore today (`replaceState`'s emitted transaction always sets
313
+ * `addToHistory: false`). Per the Phase 12a spec's explicit
314
+ * recommendation, restore is non-destructive of version history at the
315
+ * UI layer: the caller (`VersionHistoryPanel`) saves a new version
316
+ * recording the restored state immediately after calling this, rather
317
+ * than this method silently discarding anything - the version list only
318
+ * ever grows, never rewrites.
319
+ */
320
+ restoreVersion(version, opts = {}) {
321
+ const restamped = {
322
+ schemaVersion: version.envelope.schemaVersion,
323
+ revision: this.getRevision() + 1,
324
+ document: version.envelope.document,
325
+ };
326
+ this.replaceValue(restamped, opts);
327
+ }
271
328
  /** Instrumentation for product-path composition and takeover tests. */
272
329
  get surface() { return { root: this.root, renderer: this.renderer, pipeline: this.pipeline }; }
273
330
  }
@@ -0,0 +1,27 @@
1
+ import { type PluginRegistry } from "smartrte-core/foundation";
2
+ /**
3
+ * A named, host-facing restriction of which built-in plugins an editor
4
+ * instance is constructed with - a small extension of Phase 10's existing
5
+ * plugin enable/disable mechanism (`createPluginRegistry`,
6
+ * `docs/PLUGIN_ARCHITECTURE.md`), not new architecture. `FoundationEditor`
7
+ * already accepted a custom `schema`/`commands`/`keyboardShortcuts`/
8
+ * `contextMenu` (`editor.ts`'s `FoundationEditorOptions`) since Phase 10 -
9
+ * nothing here builds new core capability, it just gives the react layer a
10
+ * convenient, named way to reach for it.
11
+ *
12
+ * This is an editor-construction-time, host/integrator-level setting - not
13
+ * end-user-facing toolbar customization. There is no UI for a person typing
14
+ * in the editor to change their own preset.
15
+ *
16
+ * Real-world driver: Sootr's question-style content (MCQ, Anomaly, PYEQ)
17
+ * deliberately excludes tables (`enableTable={false}` in every one of those
18
+ * call sites - see `docs/SOOTR_MIGRATION_READINESS.md` gap #3), while its
19
+ * study-material block editor wants everything. Two presets, not more,
20
+ * because that is the one dimension any real caller has ever needed to
21
+ * vary; nothing in this codebase's history has asked to disable media or
22
+ * formula independently of each other (they're both owned by the single
23
+ * "atom" plugin today, which would need splitting to support that -
24
+ * deliberately out of scope here, since nothing needs it yet).
25
+ */
26
+ export type EditorCapabilityPreset = "simple" | "full";
27
+ export declare const capabilityPresetRegistry: (preset: EditorCapabilityPreset) => PluginRegistry;
@@ -0,0 +1,21 @@
1
+ import { baseSchema, builtInPlugins, createPluginRegistry, foundationSchema } from "smartrte-core/foundation";
2
+ /** Plugin ids to exclude for each preset - "full" excludes nothing, matching today's only behavior exactly (so every existing consumer who never sets `preset` is 100% unaffected). */
3
+ const PRESET_EXCLUDED_PLUGIN_IDS = {
4
+ simple: ["table"],
5
+ full: [],
6
+ };
7
+ /**
8
+ * Registries are real work to build (schema construction + validation, per
9
+ * `createPluginRegistry`) - computed once per preset at module load, not
10
+ * per editor instance, since the preset set is small and fixed.
11
+ */
12
+ const registryCache = new Map();
13
+ export const capabilityPresetRegistry = (preset) => {
14
+ const cached = registryCache.get(preset);
15
+ if (cached)
16
+ return cached;
17
+ const excluded = new Set(PRESET_EXCLUDED_PLUGIN_IDS[preset]);
18
+ const registry = createPluginRegistry(builtInPlugins.filter((plugin) => !excluded.has(plugin.id)), { baseSchema, schemaVersion: foundationSchema.version });
19
+ registryCache.set(preset, registry);
20
+ return registry;
21
+ };
@@ -0,0 +1,66 @@
1
+ import type { SmartSelection, SmartTransaction } from "smartrte-core/foundation";
2
+ /**
3
+ * A remote collaborator's live cursor/selection, mirroring
4
+ * `DocumentVersion`'s "reuse the existing shape, add nothing new" approach:
5
+ * `selection` is the same `SmartSelection` the editor already tracks
6
+ * locally, so it can be mapped through a rebase with the exact same
7
+ * `mapOperation`-based machinery the annotation-range and comment
8
+ * primitives already use (`FoundationTransactionMap`), not a bespoke
9
+ * position type needing its own mapping logic.
10
+ *
11
+ * This is a data shape only - rendering a remote cursor from this
12
+ * (a colored caret, a name label, etc.) is host/UI work, the same boundary
13
+ * `MediaProvider` draws around actual upload UI: the package defines what
14
+ * a presence update *is*, not how it looks on screen.
15
+ */
16
+ export interface PresenceUpdate {
17
+ readonly authorId: string;
18
+ readonly selection?: SmartSelection;
19
+ readonly lastActiveAt: number;
20
+ }
21
+ /**
22
+ * Host-owned realtime transport boundary, mirroring `MediaProvider`'s and
23
+ * `VersionProvider`'s shape and contract: the host implements the actual
24
+ * connection (WebSocket, WebRTC, long-polling, whatever - nothing here
25
+ * assumes a specific transport), the package never holds a socket or
26
+ * server credential itself. There is deliberately no shipped default
27
+ * implementation, exactly like `MediaProvider`/`VersionProvider` - when a
28
+ * host doesn't supply one, the editor behaves exactly as it does today:
29
+ * single-writer, `dispatch()`'s rebase path is never triggered because
30
+ * `baseRevision` always matches (see `FoundationEditor.dispatch`).
31
+ *
32
+ * This interface is Phase 12b-client's contract only - no implementation
33
+ * of it ships from this package. The actual server/socket work
34
+ * (12b-server/transport) is a separate effort building *against* this
35
+ * contract, not part of it.
36
+ */
37
+ export interface CollabTransport {
38
+ /**
39
+ * Submit a local transaction. `accepted: false` (e.g. a server-side
40
+ * permissions check failing) is a distinct outcome from a rebase
41
+ * conflict - see `revision`, present only when accepted, for the
42
+ * transaction's resulting revision as recorded by the transport's own
43
+ * source of truth.
44
+ */
45
+ sendTransaction(transaction: SmartTransaction): Promise<{
46
+ accepted: boolean;
47
+ revision?: number;
48
+ }>;
49
+ /** Fires for every transaction the transport delivers from another author, in commit order. Returns an unsubscribe function. */
50
+ onRemoteTransaction(handler: (transaction: SmartTransaction, revision: number) => void): () => void;
51
+ /** Fires whenever another author's presence changes (selection moved, went idle, etc.). Returns an unsubscribe function. */
52
+ onPresenceUpdate(handler: (presence: PresenceUpdate) => void): () => void;
53
+ /** Broadcast this client's own presence. Fire-and-forget - unlike sendTransaction, presence has no durability or ordering guarantee to report back. */
54
+ sendPresence(update: PresenceUpdate): void;
55
+ /**
56
+ * Transactions committed since `sinceRevision`, oldest first - what a
57
+ * client needs to catch up after a disconnect, or what
58
+ * `FoundationEditor.dispatch`'s own rebase path would ask for if this
59
+ * editor's local revision log had already evicted that far back (see
60
+ * `FoundationEditorOptions.revisionLogLimit`). An empty array means
61
+ * nothing has changed since; the transport signaling "that revision no
62
+ * longer exists" (e.g. server-side history compaction) is a
63
+ * transport-specific error, not modeled here.
64
+ */
65
+ getRevisionHistory(sinceRevision: number): Promise<readonly SmartTransaction[]>;
66
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { CommentThread } from "smartrte-core/foundation";
2
+ /**
3
+ * Host-owned comment-storage boundary, mirroring `VersionProvider`/
4
+ * `MediaProvider`'s shape and "the editor never persists anything itself"
5
+ * contract. Unlike `VersionProvider`, there is no separate cheap-listing
6
+ * projection: a `CommentThread` (an id, a range, a handful of short replies)
7
+ * is already small enough that a host's `list()` can return full threads
8
+ * directly, with no equivalent of `VersionProvider`'s envelope/entry split
9
+ * needed to avoid shipping large payloads up front.
10
+ *
11
+ * `save` both creates a new thread and persists an updated one (a reply
12
+ * added, `resolved` toggled) - the caller always passes the complete
13
+ * `CommentThread` it wants stored, so there is one code path for both,
14
+ * exactly like `CommentReply`'s own "one path for adding a message"
15
+ * decision in `foundation/comments/types.ts`. There is deliberately no
16
+ * shipped default implementation, exactly like `VersionProvider`/
17
+ * `MediaProvider` - when a host doesn't supply one, the comments feature is
18
+ * simply unavailable.
19
+ */
20
+ export interface CommentProvider {
21
+ list(): Promise<readonly CommentThread[]>;
22
+ save(thread: CommentThread): Promise<void>;
23
+ remove(threadId: string): Promise<void>;
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,19 +1,53 @@
1
1
  import React from "react";
2
2
  import { type PersistedEditorDocument, type ClipboardDiagnosticReport } from "smartrte-core/foundation";
3
3
  import type { MediaProvider } from "../mediaProvider.js";
4
+ import type { VersionProvider } from "../versionProvider.js";
5
+ import type { CommentProvider } from "../commentProvider.js";
6
+ import type { SuggestionProvider } from "../suggestionProvider.js";
4
7
  import { type MediaPickerComponent } from "./MediaPicker.js";
8
+ import type { EditorCapabilityPreset } from "../capabilityPresets.js";
5
9
  import { CanonicalEditorRuntime, type SmartEditorChange, type SmartEditorHandle } from "../canonicalEditorRuntime.js";
6
10
  export interface CanonicalAuthorityEditorProps {
7
11
  /** Initial value only. Later replacements must use SmartEditorHandle.replaceValue. */
8
12
  defaultValue?: string | PersistedEditorDocument;
13
+ /**
14
+ * Which built-in plugins this instance is constructed with - see
15
+ * capabilityPresets.ts. Construction-time only, matching `defaultValue`'s
16
+ * own uncontrolled-after-mount contract (the underlying runtime is
17
+ * created once and retained; changing this prop on an already-mounted
18
+ * instance has no effect). Defaults to "full" - every existing consumer
19
+ * that never sets this is unaffected.
20
+ */
21
+ preset?: EditorCapabilityPreset;
9
22
  onChange?: (change: SmartEditorChange) => void;
10
23
  /** Transitional serialization callback for hosts that still persist HTML. */
11
24
  onHtmlChange?: (html: string) => void;
12
25
  onClipboardDiagnostic?: (report: ClipboardDiagnosticReport) => void;
13
26
  /** Host-owned upload/search/remove boundary for canonical media insertion. */
14
27
  mediaProvider?: MediaProvider;
15
- /** Replaceable picker; the default only selects a local file. */
28
+ /** Replaceable picker; the default only selects a local file. Used for video/audio, and for images when mediaManager is false. */
16
29
  mediaPicker?: MediaPickerComponent;
30
+ /**
31
+ * Phase 11.5 §2.1: a library/search/duplicate-detection picker for
32
+ * images, replacing the bare file-input default. Defaults to true
33
+ * (MediaManager, adapted via mediaManagerAdapterFrom) whenever
34
+ * mediaProvider is supplied; set to false to keep the simple mediaPicker
35
+ * for images too.
36
+ */
37
+ mediaManager?: boolean;
38
+ /** Host-owned save/list/load/remove boundary for document version history. Absent hides the version-history toolbar button entirely, mirroring mediaProvider's absent-disables-the-feature contract. */
39
+ versionProvider?: VersionProvider;
40
+ /** Host-owned save/list/remove boundary for comment threads. Absent hides the comment toolbar buttons and markers entirely, mirroring versionProvider's absent-disables-the-feature contract. */
41
+ commentProvider?: CommentProvider;
42
+ /**
43
+ * Host-owned save/list/remove boundary for *structural* suggestions only
44
+ * (see suggestionProvider.ts) - inline suggestions need no provider since
45
+ * they are marks embedded in the document itself. Absent hides the
46
+ * suggestion toolbar buttons, markers, and panel entirely.
47
+ */
48
+ suggestionProvider?: SuggestionProvider;
49
+ /** Attributed to new comment replies and suggestions. Defaults to "anonymous" when absent. */
50
+ authorId?: string;
17
51
  placeholder?: string;
18
52
  minHeight?: number | string;
19
53
  maxHeight?: number | string;