edytor 3.0.0 → 5.0.0

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 (231) hide show
  1. package/README.md +2 -2
  2. package/dist/block/block.svelte.js +6 -21
  3. package/dist/block/inlineBlock.svelte.js +4 -6
  4. package/dist/clipboard/moveText.js +6 -8
  5. package/dist/cloudflare/DocumentRoom.d.ts +23 -12
  6. package/dist/cloudflare/DocumentRoom.js +10 -6
  7. package/dist/cloudflare/index.d.ts +1 -1
  8. package/dist/cloudflare/room/access.d.ts +8 -3
  9. package/dist/cloudflare/room/access.js +44 -20
  10. package/dist/cloudflare/room/admission.js +28 -5
  11. package/dist/cloudflare/room/comments.js +28 -1
  12. package/dist/cloudflare/room/context.d.ts +139 -129
  13. package/dist/cloudflare/room/context.js +11 -4
  14. package/dist/cloudflare/room/forged.d.ts +14 -0
  15. package/dist/cloudflare/room/forged.js +30 -2
  16. package/dist/cloudflare/room/frames.d.ts +4 -0
  17. package/dist/cloudflare/room/frames.js +5 -1
  18. package/dist/cloudflare/room/purge.d.ts +6 -3
  19. package/dist/cloudflare/room/purge.js +45 -19
  20. package/dist/cloudflare/room/replicas.d.ts +4 -2
  21. package/dist/cloudflare/room/replicas.js +8 -3
  22. package/dist/cloudflare/room/suggest.d.ts +7 -0
  23. package/dist/cloudflare/room/suggest.js +143 -0
  24. package/dist/cloudflare/room/updates.d.ts +3 -4
  25. package/dist/cloudflare/room/updates.js +6 -8
  26. package/dist/cloudflare/routeDocumentSocket.d.ts +10 -1
  27. package/dist/cloudflare/routeDocumentSocket.js +5 -3
  28. package/dist/components/Content.svelte +9 -1
  29. package/dist/crdt/anchors.js +3 -2
  30. package/dist/crdt/attribution/attribution.d.ts +34 -12
  31. package/dist/crdt/attribution/attribution.js +59 -21
  32. package/dist/crdt/attribution/block.d.ts +3 -3
  33. package/dist/crdt/attribution/block.js +7 -8
  34. package/dist/crdt/attribution/index.d.ts +1 -1
  35. package/dist/crdt/attribution/index.js +1 -1
  36. package/dist/crdt/data.d.ts +62 -31
  37. package/dist/crdt/data.js +211 -103
  38. package/dist/crdt/doc/capability.js +9 -13
  39. package/dist/crdt/doc/delete.d.ts +1 -1
  40. package/dist/crdt/doc/delete.js +13 -30
  41. package/dist/crdt/doc/funnel.d.ts +1 -1
  42. package/dist/crdt/doc/funnel.js +34 -26
  43. package/dist/crdt/doc/gate.d.ts +3 -3
  44. package/dist/crdt/doc/history.d.ts +31 -9
  45. package/dist/crdt/doc/history.js +204 -73
  46. package/dist/crdt/doc/layout.js +16 -27
  47. package/dist/crdt/doc/meta.js +17 -23
  48. package/dist/crdt/doc/moves.d.ts +1 -1
  49. package/dist/crdt/doc/moves.js +52 -32
  50. package/dist/crdt/doc/reads.d.ts +2 -2
  51. package/dist/crdt/doc/reads.js +20 -30
  52. package/dist/crdt/doc/seed.js +2 -2
  53. package/dist/crdt/doc/split-merge.js +12 -15
  54. package/dist/crdt/doc/steps.d.ts +25 -13
  55. package/dist/crdt/doc/steps.js +55 -125
  56. package/dist/crdt/doc/suggest.d.ts +167 -0
  57. package/dist/crdt/doc/suggest.js +579 -0
  58. package/dist/crdt/doc/types.d.ts +21 -9
  59. package/dist/crdt/document.d.ts +26 -6
  60. package/dist/crdt/document.js +40 -15
  61. package/dist/crdt/edytor-doc.d.ts +410 -390
  62. package/dist/crdt/edytor-doc.js +143 -95
  63. package/dist/crdt/engine-api.d.ts +39 -1
  64. package/dist/crdt/engine.d.ts +2 -2
  65. package/dist/crdt/engine.js +4 -5
  66. package/dist/crdt/flow.d.ts +2 -2
  67. package/dist/crdt/flow.js +29 -37
  68. package/dist/crdt/index.d.ts +134 -127
  69. package/dist/crdt/index.js +4 -1
  70. package/dist/crdt/operations.d.ts +12 -3
  71. package/dist/crdt/parts.d.ts +43 -0
  72. package/dist/crdt/parts.js +44 -0
  73. package/dist/crdt/placement/display.d.ts +6 -31
  74. package/dist/crdt/placement/display.js +41 -146
  75. package/dist/crdt/placement/keys.d.ts +63 -0
  76. package/dist/crdt/placement/keys.js +95 -0
  77. package/dist/crdt/placement/model.d.ts +119 -118
  78. package/dist/crdt/placement/model.js +242 -142
  79. package/dist/crdt/placement/resolve.d.ts +123 -35
  80. package/dist/crdt/placement/resolve.js +188 -153
  81. package/dist/crdt/placement/slots.d.ts +134 -0
  82. package/dist/crdt/placement/slots.js +152 -0
  83. package/dist/crdt/protocol.d.ts +1 -1
  84. package/dist/crdt/protocol.js +1 -1
  85. package/dist/crdt/protocols/auth.d.ts +11 -1
  86. package/dist/crdt/protocols/auth.js +17 -1
  87. package/dist/crdt/protocols/comments.d.ts +16 -1
  88. package/dist/crdt/protocols/comments.js +9 -1
  89. package/dist/crdt/providers/index.d.ts +6 -4
  90. package/dist/crdt/providers/index.js +3 -1
  91. package/dist/crdt/providers/room.d.ts +16 -2
  92. package/dist/crdt/providers/room.js +64 -17
  93. package/dist/crdt/providers/websocket.d.ts +6 -4
  94. package/dist/crdt/providers/websocket.js +14 -7
  95. package/dist/crdt/purge.d.ts +24 -9
  96. package/dist/crdt/purge.js +266 -126
  97. package/dist/crdt/restore.d.ts +4 -3
  98. package/dist/crdt/restore.js +27 -34
  99. package/dist/crdt/schema.d.ts +30 -21
  100. package/dist/crdt/schema.js +39 -23
  101. package/dist/crdt/storage.d.ts +1 -1
  102. package/dist/crdt/storage.js +1 -1
  103. package/dist/crdt/structs.d.ts +17 -15
  104. package/dist/crdt/structs.js +10 -22
  105. package/dist/crdt/text/index/cache.js +4 -0
  106. package/dist/crdt/text/index/claims.js +13 -23
  107. package/dist/crdt/text/index/fold.d.ts +2 -3
  108. package/dist/crdt/text/index/fold.js +194 -44
  109. package/dist/crdt/text/index/layout.d.ts +2 -4
  110. package/dist/crdt/text/index/layout.js +14 -30
  111. package/dist/crdt/text/index/placement.d.ts +26 -18
  112. package/dist/crdt/text/index/placement.js +420 -157
  113. package/dist/crdt/text/index/records.d.ts +3 -3
  114. package/dist/crdt/text/index/records.js +24 -31
  115. package/dist/crdt/text/index/shared.d.ts +11 -3
  116. package/dist/crdt/text/index/shared.js +29 -17
  117. package/dist/crdt/text/index/state.d.ts +21 -17
  118. package/dist/crdt/text/index/state.js +15 -17
  119. package/dist/crdt/text/index/streams.d.ts +10 -5
  120. package/dist/crdt/text/index/streams.js +78 -27
  121. package/dist/crdt/text/items.d.ts +10 -3
  122. package/dist/crdt/text/items.js +7 -0
  123. package/dist/crdt/text/model.d.ts +87 -62
  124. package/dist/crdt/text/model.js +91 -169
  125. package/dist/crdt/text/ranges.d.ts +1 -1
  126. package/dist/crdt/text/ranges.js +3 -3
  127. package/dist/crdt/text/rows.d.ts +13 -7
  128. package/dist/crdt/text/rows.js +24 -7
  129. package/dist/crdt/text/runs.d.ts +51 -42
  130. package/dist/crdt/text/runs.js +24 -7
  131. package/dist/crdt/text/streams.d.ts +26 -13
  132. package/dist/crdt/text/streams.js +41 -14
  133. package/dist/crdt/vendor/yjs/UPSTREAM.md +651 -21
  134. package/dist/crdt/vendor/yjs/dts/global.d.ts +2 -0
  135. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  136. package/dist/crdt/vendor/yjs/dts/structs/AbstractStruct.d.ts +7 -0
  137. package/dist/crdt/vendor/yjs/dts/structs/Item.d.ts +197 -10
  138. package/dist/crdt/vendor/yjs/dts/utils/Doc.d.ts +6 -3
  139. package/dist/crdt/vendor/yjs/dts/utils/StructStore.d.ts +5 -18
  140. package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +15 -1
  141. package/dist/crdt/vendor/yjs/dts/utils/UpdateDecoder.d.ts +14 -6
  142. package/dist/crdt/vendor/yjs/dts/utils/UpdateEncoder.d.ts +33 -6
  143. package/dist/crdt/vendor/yjs/dts/utils/ids.d.ts +1 -65
  144. package/dist/crdt/vendor/yjs/dts/utils/marks.d.ts +6 -1
  145. package/dist/crdt/vendor/yjs/dts/ynode.d.ts +54 -7
  146. package/dist/crdt/vendor/yjs/global.d.ts +2 -0
  147. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  148. package/dist/crdt/vendor/yjs/src/structs/AbstractStruct.js +10 -0
  149. package/dist/crdt/vendor/yjs/src/structs/Item.js +649 -51
  150. package/dist/crdt/vendor/yjs/src/utils/BlockSet.js +18 -9
  151. package/dist/crdt/vendor/yjs/src/utils/Doc.js +5 -3
  152. package/dist/crdt/vendor/yjs/src/utils/StructStore.js +5 -0
  153. package/dist/crdt/vendor/yjs/src/utils/Transaction.js +36 -13
  154. package/dist/crdt/vendor/yjs/src/utils/UpdateDecoder.js +88 -18
  155. package/dist/crdt/vendor/yjs/src/utils/UpdateEncoder.js +119 -32
  156. package/dist/crdt/vendor/yjs/src/utils/encoding.js +13 -1
  157. package/dist/crdt/vendor/yjs/src/utils/ids.js +7 -7
  158. package/dist/crdt/vendor/yjs/src/utils/marks.js +193 -8
  159. package/dist/crdt/vendor/yjs/src/utils/redo.js +1 -1
  160. package/dist/crdt/vendor/yjs/src/utils/transaction-helpers.js +1 -1
  161. package/dist/crdt/vendor/yjs/src/utils/updates.js +3 -3
  162. package/dist/crdt/vendor/yjs/src/ynode.js +199 -12
  163. package/dist/edytor.svelte.d.ts +1 -1
  164. package/dist/edytor.svelte.js +103 -75
  165. package/dist/events/beforeInputCommands.d.ts +2 -2
  166. package/dist/events/beforeInputCommands.js +2 -2
  167. package/dist/events/nativeInteractiveControl.d.ts +11 -1
  168. package/dist/events/nativeInteractiveControl.js +41 -1
  169. package/dist/events/onBeforeInput.js +3 -3
  170. package/dist/events/onFocus.js +9 -11
  171. package/dist/events/onPageHide.d.ts +3 -0
  172. package/dist/events/onPageHide.js +16 -0
  173. package/dist/export/forms.d.ts +50 -50
  174. package/dist/index.d.ts +4 -2
  175. package/dist/index.js +1 -1
  176. package/dist/labels.d.ts +8 -0
  177. package/dist/labels.js +6 -1
  178. package/dist/plugins/comments/CommentsController.svelte.d.ts +5 -1
  179. package/dist/plugins/comments/CommentsController.svelte.js +14 -4
  180. package/dist/plugins/find/search.js +2 -2
  181. package/dist/plugins/index.d.ts +1 -0
  182. package/dist/plugins/index.js +1 -0
  183. package/dist/plugins/suggestions/SuggestionBars.svelte +40 -23
  184. package/dist/plugins/suggestions/SuggestionBars.svelte.d.ts +3 -1
  185. package/dist/plugins/suggestions/SuggestionRuns.svelte +77 -0
  186. package/dist/plugins/suggestions/SuggestionRuns.svelte.d.ts +9 -0
  187. package/dist/plugins/suggestions/shared.svelte.d.ts +58 -0
  188. package/dist/plugins/suggestions/shared.svelte.js +421 -0
  189. package/dist/plugins/suggestions/suggestionsPlugin.d.ts +15 -4
  190. package/dist/selection/domSelection.d.ts +2 -0
  191. package/dist/selection/domSelection.js +6 -2
  192. package/dist/selection/pointer.svelte.js +75 -48
  193. package/dist/selection/replaceSelection.js +2 -6
  194. package/dist/selection/selection.svelte.d.ts +3 -3
  195. package/dist/selection/selection.svelte.js +39 -32
  196. package/dist/selection/selection.utils.d.ts +14 -0
  197. package/dist/selection/selection.utils.js +28 -3
  198. package/dist/session/commands.js +21 -11
  199. package/dist/session/composition.svelte.d.ts +5 -3
  200. package/dist/session/composition.svelte.js +21 -17
  201. package/dist/session/handles.d.ts +4 -17
  202. package/dist/session/handles.js +11 -37
  203. package/dist/session/navigation.js +6 -9
  204. package/dist/session/selection.d.ts +11 -5
  205. package/dist/session/selection.js +14 -48
  206. package/dist/session/suggestions.svelte.d.ts +38 -9
  207. package/dist/session/suggestions.svelte.js +37 -18
  208. package/dist/session/virtual.d.ts +1 -1
  209. package/dist/surface/attributes.d.ts +5 -0
  210. package/dist/surface/attributes.js +2 -2
  211. package/dist/surface/cells.d.ts +2 -26
  212. package/dist/surface/cells.js +2 -33
  213. package/dist/surface/observer.svelte.d.ts +6 -1
  214. package/dist/surface/observer.svelte.js +130 -83
  215. package/dist/surface/pin.svelte.d.ts +9 -9
  216. package/dist/surface/pin.svelte.js +15 -22
  217. package/dist/surface/projector.svelte.d.ts +15 -3
  218. package/dist/surface/projector.svelte.js +67 -22
  219. package/dist/text/text.svelte.js +14 -19
  220. package/dist/themes/notion.css +29 -0
  221. package/package.json +4 -2
  222. package/dist/crdt/placement/rank.d.ts +0 -87
  223. package/dist/crdt/placement/rank.js +0 -332
  224. package/dist/crdt/placement/source.d.ts +0 -43
  225. package/dist/crdt/placement/source.js +0 -66
  226. package/dist/crdt/text/delete-index.d.ts +0 -129
  227. package/dist/crdt/text/delete-index.js +0 -365
  228. package/dist/crdt/text/deletes.d.ts +0 -76
  229. package/dist/crdt/text/deletes.js +0 -362
  230. package/dist/crdt/text/index/anchored.d.ts +0 -17
  231. package/dist/crdt/text/index/anchored.js +0 -197
@@ -46,6 +46,7 @@
46
46
  */
47
47
  export { EdytorDocument, createDocument, loadDocument, attachDocument, SemanticConflictError, DocumentNotReadyError, DocumentDestroyedError, DEFAULT_READINESS_BOUND, type DocumentActor, type DocumentOptions, type DocumentReadiness, type DocumentSemanticsConfig, type CreateDocumentOptions, type LoadDocumentOptions } from './document.js';
48
48
  export { defaultSemantics, richTextSemantics, codeSemantics, imageSemantics, mediaKinds, mediaSemantics, layoutSemantics, pageKinds, pageSemantics, tocKinds, tocSemantics, tableKinds, tableSemantics, equationKinds, equationSemantics, richTextKinds, codeKinds, imageKinds, layoutKinds, richTextMarks, commentMarks, facadeConfigOf, semanticsOf, mergeSemantics, semanticsDigest, semanticsMismatch, type KindSemantics, type KindRecord, type MergedSemantics } from './semantics.js';
49
+ export { adoptSharedSuggestions, type SuggestedChange } from './doc/suggest.js';
49
50
  export { tableBlock, type TableBlockOptions } from './tables.js';
50
51
  export { markName, type MarkEdge } from './text/marks.js';
51
52
  export type { JSONDoc, JSONBlock, JSONText, JSONInlineBlock, SerializableContent } from '../utils/json.js';
@@ -75,7 +76,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
75
76
  Awareness: typeof _Awareness;
76
77
  doc: {
77
78
  SCHEMA: {
78
- readonly version: 6;
79
+ readonly version: 11;
79
80
  readonly name: "edytor-doc";
80
81
  readonly roots: {
81
82
  readonly registry: "blocks";
@@ -86,7 +87,7 @@ export declare const bindCrdt: (Y: EngineApi) => {
86
87
  readonly schema: "schema";
87
88
  };
88
89
  };
89
- SCHEMA_VERSION: 6;
90
+ SCHEMA_VERSION: 11;
90
91
  SCHEMA_NAME: "edytor-doc";
91
92
  META_KEY: "meta";
92
93
  init: (doc: import("./engine-api.js").EngineDoc, opts?: {
@@ -102,77 +103,66 @@ export declare const bindCrdt: (Y: EngineApi) => {
102
103
  assertSchema: (doc: import("./engine-api.js").EngineDoc, docName?: string) => void;
103
104
  SchemaMismatchError: typeof import("./edytor-doc.js").SchemaMismatchError;
104
105
  create: (doc: import("./engine-api.js").EngineDoc, config?: import("./edytor-doc.js").EdytorDocConfig) => {
105
- prepare: {
106
- insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => import("./edytor-doc.js").Prepared;
107
- deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
108
- replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
109
- insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").Prepared;
110
- moveBlocks: (ids: readonly import("./index.js").BlockId[], dest: import("./index.js").Destination) => import("./edytor-doc.js").Prepared;
111
- nestBlock: (id: import("./index.js").BlockId, parent: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
112
- unNestBlock: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
113
- unNestBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
114
- liftOut: (id: import("./index.js").BlockId, kind: string, { keep, after }?: {
115
- keep?: boolean;
116
- after?: readonly import("./index.js").BlockSpec[];
117
- }) => import("./edytor-doc.js").Prepared;
118
- placeBeside: (ids: readonly import("./index.js").BlockId[], target: import("./index.js").BlockId, side: "left" | "right", kind?: string) => import("./edytor-doc.js").Prepared;
119
- wrapInLayout: (ids: readonly import("./index.js").BlockId[], kind?: string, columns?: number) => import("./edytor-doc.js").Prepared;
120
- splitBlock: (id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail?: import("./placement/model.js").SplitTail) => import("./edytor-doc.js").Prepared;
121
- mergeBlocks: (fromId: import("./index.js").BlockId, intoId: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
122
- mergeBackward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
123
- mergeForward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
124
- deleteBlock: (id: import("./index.js").BlockId, opts?: {
125
- keepChildren?: boolean;
126
- }) => import("./edytor-doc.js").Prepared;
127
- setBlock: (id: import("./index.js").BlockId, value: {
128
- type?: string;
129
- data?: Record<string, unknown>;
130
- content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
131
- children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
132
- }) => import("./edytor-doc.js").Prepared;
133
- setBlockType: (id: import("./index.js").BlockId, type: string) => import("./edytor-doc.js").Prepared;
134
- patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").Prepared;
135
- duplicateBlock: (id: import("./index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("./edytor-doc.js").Prepared;
136
- insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
137
- deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
138
- formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
139
- clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
140
- insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").Prepared;
141
- removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
142
- deleteBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
143
- };
144
- apply: (p: import("./edytor-doc.js").Prepared) => import("./edytor-doc.js").OpResult;
145
- compose: (...parts: import("./edytor-doc.js").Prepared[]) => import("./edytor-doc.js").Prepared;
146
- transact: <R>(fn: () => R, origin?: unknown) => R;
106
+ init: (opts?: Parameters<(doc: import("./engine-api.js").EngineDoc, opts?: {
107
+ content?: import("./index.js").BlockSpec[];
108
+ defaultType?: string;
109
+ }) => void>[1]) => void;
110
+ seed: (value: import("./index.js").JSONBlock[], data?: import("./doc/types.js").JsonObj) => void;
111
+ isInitialized: () => boolean;
112
+ schemaVersion: () => number | undefined;
113
+ checkSchema: () => import("./edytor-doc.js").SchemaProblem | null;
114
+ assertSchema: () => void;
115
+ dispose: () => void;
116
+ createUndoManager: (options?: import("./doc/history.js").HistoryOptions) => import("./doc/history.js").UndoManager;
117
+ part: import("./doc/suggest.js").SuggestContext;
118
+ childSlots: (parent: import("./index.js").BlockId | null) => import("./placement/model.js").ChildSlot[];
119
+ slotOf: (id: string) => {
120
+ parent: import("./index.js").BlockId | null;
121
+ rank: string;
122
+ } | null;
123
+ crdtId: (id: string) => string | null;
124
+ resolveBlock: (id: string) => import("./engine-api.js").EngineNode | null;
125
+ followUndo: (anchor: import("./edytor-doc.js").DocAnchor) => import("./edytor-doc.js").DocAnchor;
126
+ rolesChanged: (place?: boolean) => void;
127
+ defaultChild: (id: string | null) => string;
128
+ contentJSON: (id: string) => ({
129
+ text: string;
130
+ marks?: Record<string, unknown>;
131
+ } | {
132
+ id?: string;
133
+ type: string;
134
+ data?: unknown;
135
+ })[];
147
136
  model: {
148
137
  REGISTRY_KEY: string;
149
138
  registryOf: (doc: import("./engine-api.js").EngineDoc) => import("./engine-api.js").EngineNode;
150
139
  blockNodeOf: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => import("./engine-api.js").EngineNode | null;
151
140
  liveNodeOf: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => import("./engine-api.js").EngineNode | null;
152
141
  isLive: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => boolean;
153
- candidatesOf: (node: import("./engine-api.js").EngineNode) => import("./placement/model.js").PlacementCand[];
154
142
  view: (doc: import("./engine-api.js").EngineDoc) => import("./placement/model.js").ModelView;
155
- resolvePlacements: (blocks: Map<import("./index.js").BlockId, import("./placement/model.js").BlockRec>, ownerOf?: (b: import("./index.js").BlockId) => import("./text/model.js").Owner) => Map<import("./index.js").BlockId, import("./placement/model.js").ResolvedPlacement>;
156
143
  childrenIndex: (placements: Map<import("./index.js").BlockId, import("./placement/model.js").ResolvedPlacement>, own: import("./placement/model.js").DisplayOwnership) => Map<import("./index.js").BlockId | null, import("./placement/model.js").ChildSlot[]>;
157
144
  positionInView: (v: import("./placement/model.js").ModelView, id: import("./index.js").BlockId) => import("./index.js").Destination | null;
158
145
  buildInline: (atom: import("./index.js").InlineSpec) => import("./engine-api.js").EngineNode;
159
146
  isSelfOrDescendant: (placements: Map<import("./index.js").BlockId, import("./placement/model.js").ResolvedPlacement>, own: import("./text/model.js").Ownership, id: import("./index.js").BlockId, maybeAncestor: import("./index.js").BlockId) => boolean;
160
- ranksAt: (siblings: readonly {
161
- rank: string;
162
- }[], index: number, count: number, clientId: number, rand?: () => number, run?: boolean) => string[];
163
- writePlacement: (doc: import("./engine-api.js").EngineDoc, node: import("./engine-api.js").EngineNode, p: import("./index.js").BlockId | null, r: string) => void;
147
+ placeBlocks: (doc: import("./engine-api.js").EngineDoc, v: import("./placement/model.js").ModelView, parent: import("./index.js").BlockId | null, left: import("./index.js").BlockId | null, right: import("./index.js").BlockId | null, slots: readonly import("./placement/slots.js").BlockSlot[] | null, moved?: readonly number[] | null, side?: number, part?: number, at?: import("./placement/slots.js").Unit | null) => void;
148
+ moveBlocksTo: (doc: import("./engine-api.js").EngineDoc, v: import("./placement/model.js").ModelView, ids: readonly import("./index.js").BlockId[], parent: import("./index.js").BlockId | null, index: number, side?: number, part?: number, at?: import("./index.js").BlockId | null) => void;
149
+ insertSpecsAt: (doc: import("./engine-api.js").EngineDoc, v: import("./placement/model.js").ModelView, parent: import("./index.js").BlockId | null, index: number, specs: readonly import("./index.js").BlockSpec[], split?: import("./placement/slots.js").Unit | null) => void;
164
150
  withdrawOnUndo: (doc: import("./engine-api.js").EngineDoc) => (item: import("./engine-api.js").EngineItemRef, stackItem: {
165
151
  inserts: {
166
152
  has(client: number, clock: number): boolean;
167
153
  };
168
154
  }) => boolean;
169
- materializeSpec: (doc: import("./engine-api.js").EngineDoc, sp: import("./index.js").BlockSpec, parent: import("./index.js").BlockId | null, rank: string) => void;
170
155
  collides: (doc: import("./engine-api.js").EngineDoc, specs: readonly import("./index.js").BlockSpec[]) => boolean;
171
- writeSplit: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail: import("./placement/model.js").SplitTail, place: import("./placement/model.js").PlacementValue) => void;
156
+ writeSplit: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail: import("./placement/model.js").SplitTail, parent: import("./index.js").BlockId | null, index: number) => import("./placement/slots.js").Unit;
172
157
  ownText: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => {
173
158
  from: unknown;
174
159
  to: number;
175
160
  };
161
+ recordsOf: (doc: import("./engine-api.js").EngineDoc, node: import("./engine-api.js").EngineNode, v?: import("./placement/model.js").ModelView) => {
162
+ item: import("./placement/slots.js").SeqItem;
163
+ stamp: import("./placement/slots.js").Stamp;
164
+ wins: boolean;
165
+ }[];
176
166
  insertBlocks: (doc: import("./engine-api.js").EngineDoc, dest: import("./index.js").Destination, specs: import("./index.js").BlockSpec[]) => boolean;
177
167
  insertBlock: (doc: import("./engine-api.js").EngineDoc, dest: import("./index.js").Destination, spec: import("./index.js").BlockSpec) => boolean;
178
168
  restoreBlocks: (doc: import("./engine-api.js").EngineDoc, specs: import("./index.js").BlockSpec[]) => void;
@@ -204,72 +194,102 @@ export declare const bindCrdt: (Y: EngineApi) => {
204
194
  at: number;
205
195
  node: import("./engine-api.js").EngineNode;
206
196
  } | null;
207
- splitAt: (blocks: ReadonlyMap<import("./text/model.js").BlockId, import("./text/model.js").TextBlockRec>, own: import("./text/model.js").Ownership, b: import("./text/model.js").BlockId, offset: number, newId: import("./text/model.js").BlockId, n: number) => import("./text/model.js").MergeClaim[];
208
- claimInto: (blocks: ReadonlyMap<import("./text/model.js").BlockId, import("./text/model.js").TextBlockRec>, own: Pick<import("./text/model.js").Ownership, "streamOf">, from: import("./text/model.js").BlockId, into: import("./text/model.js").BlockId) => void;
197
+ splitAt: (doc: import("./engine-api.js").EngineDoc, blocks: ReadonlyMap<import("./text/model.js").BlockId, import("./text/model.js").TextBlockRec>, own: import("./text/model.js").Ownership, b: import("./text/model.js").BlockId, offset: number, newId: import("./text/model.js").BlockId, n: number) => void;
198
+ claimInto: (own: Pick<import("./text/model.js").Ownership, "streamOf">, from: import("./text/model.js").BlockId, into: import("./text/model.js").BlockId) => void;
209
199
  ownText: (doc: import("./engine-api.js").EngineDoc, rec: import("./text/model.js").TextBlockRec) => {
210
200
  from: unknown;
211
201
  to: number;
212
202
  };
213
203
  };
214
204
  runsView: import("./text/runs.js").RunView;
205
+ api: object;
206
+ } & {
207
+ prepare: {
208
+ insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView) => import("./edytor-doc.js").Prepared;
209
+ deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
210
+ replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView) => import("./edytor-doc.js").Prepared;
211
+ nestBlock: (id: import("./index.js").BlockId, parent: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
212
+ deleteBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
213
+ insertText: (id: import("./index.js").BlockId, offset: number, text: string, marks?: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
214
+ deleteText: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
215
+ formatRange: (id: import("./index.js").BlockId, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").Prepared;
216
+ clearMarks: (id: import("./index.js").BlockId, offset: number, length: number) => import("./edytor-doc.js").Prepared;
217
+ insertInline: (id: import("./index.js").BlockId, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").Prepared;
218
+ removeInline: (id: import("./index.js").BlockId, inlineId: string) => import("./edytor-doc.js").Prepared;
219
+ setBlockType: (id: import("./index.js").BlockId, type: string) => import("./edytor-doc.js").Prepared;
220
+ patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").Prepared;
221
+ setBlock: (id: import("./index.js").BlockId, value: {
222
+ type?: string;
223
+ data?: Record<string, unknown>;
224
+ content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
225
+ children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
226
+ }) => import("./edytor-doc.js").Prepared;
227
+ deleteBlock: (id: import("./index.js").BlockId, opts?: {
228
+ keepChildren?: boolean;
229
+ }) => import("./edytor-doc.js").Prepared;
230
+ splitBlock: (id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail?: import("./placement/model.js").SplitTail) => import("./edytor-doc.js").Prepared;
231
+ mergeBlocks: (fromId: import("./index.js").BlockId, intoId: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
232
+ mergeBackward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
233
+ mergeForward: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
234
+ placeBeside: (ids: readonly import("./index.js").BlockId[], target: import("./index.js").BlockId, side: "left" | "right", kind?: string) => import("./edytor-doc.js").Prepared;
235
+ wrapInLayout: (ids: readonly import("./index.js").BlockId[], kind?: string, columns?: number) => import("./edytor-doc.js").Prepared;
236
+ insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").Prepared;
237
+ moveBlocks: (ids: readonly import("./index.js").BlockId[], dest: import("./index.js").Destination) => import("./edytor-doc.js").Prepared;
238
+ unNestBlocks: (ids: readonly import("./index.js").BlockId[]) => import("./edytor-doc.js").Prepared;
239
+ unNestBlock: (id: import("./index.js").BlockId) => import("./edytor-doc.js").Prepared;
240
+ liftOut: (id: import("./index.js").BlockId, kind: string, { keep, after }?: {
241
+ keep?: boolean;
242
+ after?: readonly import("./index.js").BlockSpec[];
243
+ }) => import("./edytor-doc.js").Prepared;
244
+ duplicateBlock: (id: import("./index.js").BlockId, freshId?: (oldId: string, kind: "block" | "inline") => string) => import("./edytor-doc.js").Prepared;
245
+ };
246
+ apply: (p: import("./edytor-doc.js").Prepared, quiet?: boolean) => import("./edytor-doc.js").OpResult;
247
+ compose: (...parts: import("./edytor-doc.js").Prepared[]) => import("./edytor-doc.js").Prepared;
248
+ transact: <R>(fn: () => R, origin?: unknown) => R;
215
249
  version: number;
216
250
  insertFlow: (target: import("./flow.js").FlowTarget, flow: import("./flow.js").Flow, view?: import("./flow.js").FlowView | undefined) => import("./edytor-doc.js").OpResult;
217
251
  deleteRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
218
252
  replaceRange: (from: import("./rangeDelete.js").DocPosition, to: import("./rangeDelete.js").DocPosition, view?: import("./rangeDelete.js").RangeView | undefined) => import("./edytor-doc.js").OpResult;
219
- insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[]) => import("./edytor-doc.js").OpResult;
220
- moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => import("./edytor-doc.js").OpResult;
221
253
  nestBlock: (id: string, parent: string) => import("./edytor-doc.js").OpResult;
222
- unNestBlock: (id: string) => import("./edytor-doc.js").OpResult;
223
- unNestBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
224
- liftOut: (id: string, kind: string, args_2?: {
225
- keep?: boolean;
226
- after?: readonly import("./index.js").BlockSpec[];
227
- } | undefined) => import("./edytor-doc.js").OpResult;
228
- placeBeside: (ids: readonly string[], target: string, side: "right" | "left", kind?: string | undefined) => import("./edytor-doc.js").OpResult;
229
- wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("./edytor-doc.js").OpResult;
230
- splitBlock: (id: string, offset: number, newId: string, tail?: import("./placement/model.js").SplitTail | undefined) => import("./edytor-doc.js").OpResult;
231
- mergeBlocks: (fromId: string, intoId: string) => import("./edytor-doc.js").OpResult;
232
- mergeBackward: (id: string) => import("./edytor-doc.js").OpResult;
233
- mergeForward: (id: string) => import("./edytor-doc.js").OpResult;
234
- deleteBlock: (id: string, opts?: {
235
- keepChildren?: boolean;
236
- } | undefined) => import("./edytor-doc.js").OpResult;
254
+ deleteBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
255
+ insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("./edytor-doc.js").OpResult;
256
+ deleteText: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
257
+ formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").OpResult;
258
+ clearMarks: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
259
+ insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").OpResult;
260
+ removeInline: (id: string, inlineId: string) => import("./edytor-doc.js").OpResult;
261
+ setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
262
+ patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
237
263
  setBlock: (id: string, value: {
238
264
  type?: string;
239
265
  data?: Record<string, unknown>;
240
266
  content?: (import("./index.js").ContentItem | import("./index.js").JSONText | import("./index.js").JSONInlineBlock)[];
241
267
  children?: (import("./index.js").BlockSpec | import("./index.js").JSONBlock)[];
242
268
  }) => import("./edytor-doc.js").OpResult;
243
- setBlockType: (id: string, type: string) => import("./edytor-doc.js").OpResult;
244
- patchData: (target: import("./edytor-doc.js").DataTarget, patches: readonly import("./data.js").DataPatch[]) => import("./edytor-doc.js").OpResult;
269
+ deleteBlock: (id: string, opts?: {
270
+ keepChildren?: boolean;
271
+ } | undefined) => import("./edytor-doc.js").OpResult;
272
+ splitBlock: (id: string, offset: number, newId: string, tail?: import("./placement/model.js").SplitTail | undefined) => import("./edytor-doc.js").OpResult;
273
+ mergeBlocks: (fromId: string, intoId: string) => import("./edytor-doc.js").OpResult;
274
+ mergeBackward: (id: string) => import("./edytor-doc.js").OpResult;
275
+ mergeForward: (id: string) => import("./edytor-doc.js").OpResult;
276
+ placeBeside: (ids: readonly string[], target: string, side: "left" | "right", kind?: string | undefined) => import("./edytor-doc.js").OpResult;
277
+ wrapInLayout: (ids: readonly string[], kind?: string | undefined, columns?: number | undefined) => import("./edytor-doc.js").OpResult;
278
+ insertBlocks: (dest: import("./index.js").Destination, specs: readonly (import("./index.js").JSONBlock | import("./index.js").BlockSpec)[]) => import("./edytor-doc.js").OpResult;
279
+ moveBlocks: (ids: readonly string[], dest: import("./index.js").Destination) => import("./edytor-doc.js").OpResult;
280
+ unNestBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
281
+ unNestBlock: (id: string) => import("./edytor-doc.js").OpResult;
282
+ liftOut: (id: string, kind: string, args_2?: {
283
+ keep?: boolean;
284
+ after?: readonly import("./index.js").BlockSpec[];
285
+ } | undefined) => import("./edytor-doc.js").OpResult;
245
286
  duplicateBlock: (id: string, freshId?: ((oldId: string, kind: "block" | "inline") => string) | undefined) => import("./edytor-doc.js").OpResult;
246
- insertText: (id: string, offset: number, text: string, marks?: Record<string, unknown> | undefined) => import("./edytor-doc.js").OpResult;
247
- deleteText: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
248
- formatRange: (id: string, offset: number, length: number, marks: Record<string, unknown>) => import("./edytor-doc.js").OpResult;
249
- clearMarks: (id: string, offset: number, length: number) => import("./edytor-doc.js").OpResult;
250
- insertInline: (id: string, offset: number, atom: import("./doc/content.js").NewInline) => import("./edytor-doc.js").OpResult;
251
- removeInline: (id: string, inlineId: string) => import("./edytor-doc.js").OpResult;
252
- deleteBlocks: (ids: readonly string[]) => import("./edytor-doc.js").OpResult;
253
- init: (opts?: Parameters<(doc: import("./engine-api.js").EngineDoc, opts?: {
254
- content?: import("./index.js").BlockSpec[];
255
- defaultType?: string;
256
- }) => void>[1]) => void;
257
- seed: (value: import("./index.js").JSONBlock[], data?: import("./doc/types.js").JsonObj) => void;
258
- isInitialized: () => boolean;
259
- schemaVersion: () => number | undefined;
260
- checkSchema: () => import("./edytor-doc.js").SchemaProblem | null;
261
- assertSchema: () => void;
262
- dispose: () => void;
263
- createUndoManager: (options?: import("./doc/history.js").HistoryOptions) => import("./doc/history.js").UndoManager;
264
287
  project: () => import("./index.js").ProjectedDoc;
265
- toJSON: () => import("./index.js").JSONDoc;
288
+ toJSON: (options?: {
289
+ suggestions?: boolean;
290
+ } | undefined) => import("./index.js").JSONDoc;
266
291
  blockJSON: (id: string) => import("./index.js").JSONBlock;
267
292
  childrenIds: (id: string | null) => string[];
268
- childSlots: (parent: import("./index.js").BlockId | null) => import("./placement/model.js").ChildSlot[];
269
- slotOf: (id: string) => {
270
- parent: import("./index.js").BlockId | null;
271
- rank: string;
272
- } | null;
273
293
  positionOf: (id: string) => import("./index.js").Destination | null;
274
294
  pathOf: (id: string) => number[] | null;
275
295
  parentOf: (id: string) => string | null;
@@ -287,8 +307,6 @@ export declare const bindCrdt: (Y: EngineApi) => {
287
307
  ids: (path: readonly string[]) => string[];
288
308
  } | null;
289
309
  blockAttribution: (id: string) => import("./index.js").BlockAttribution | undefined;
290
- crdtId: (id: string) => string | null;
291
- resolveBlock: (id: string) => import("./engine-api.js").EngineNode | null;
292
310
  displayLength: (id: string) => number;
293
311
  contentItems: (id: string) => import("./index.js").ContentItem[];
294
312
  hasBlock: (id: string) => boolean;
@@ -302,8 +320,6 @@ export declare const bindCrdt: (Y: EngineApi) => {
302
320
  blockId: import("./index.js").BlockId;
303
321
  offset: number;
304
322
  } | null;
305
- followUndo: (anchor: import("./edytor-doc.js").DocAnchor) => import("./edytor-doc.js").DocAnchor;
306
- rolesChanged: () => void;
307
323
  isVoid: (id: string) => boolean;
308
324
  isIsland: (id: string) => boolean;
309
325
  isLines: (id: string) => boolean;
@@ -335,24 +351,14 @@ export declare const bindCrdt: (Y: EngineApi) => {
335
351
  parent: string | null;
336
352
  levels: string[];
337
353
  };
338
- defaultChild: (id: string | null) => string;
339
354
  runs: (id: string) => readonly import("./index.js").ContentRun[];
340
- contentJSON: (id: string) => ({
341
- text: string;
342
- marks?: Record<string, unknown>;
343
- } | {
344
- id?: string;
345
- type: string;
346
- data?: unknown;
347
- })[];
348
355
  onChange: (cb: (change: import("./edytor-doc.js").DocChange) => void) => (() => void);
349
356
  };
350
357
  newDoc: (opts?: ConstructorParameters<EngineApi["Doc"]>[0]) => YDoc;
351
- keepCopies: (doc: import("./engine-api.js").EngineDoc) => void;
352
- purge: (doc: import("./engine-api.js").EngineDoc, facade: {
358
+ purge: (doc: import("./engine-api.js").EngineDoc, facade: Partial<import("./doc/suggest.js").SuggestFacade> & {
353
359
  model: import("./placement/model.js").PlacementModel;
354
360
  text: import("./text/model.js").TextEngine;
355
- }, horizon: import("./purge.js").Horizon) => import("./purge.js").PurgeReport;
361
+ }, horizon: import("./purge.js").Horizon | null) => import("./purge.js").PurgeReport;
356
362
  horizonOf: (doc: import("./engine-api.js").EngineDoc) => import("./purge.js").Horizon | null;
357
363
  restoreTo: <Plan>(doc: import("./engine-api.js").EngineDoc, facade: import("./restore.js").RestoreFacade<Plan>, json: import("./index.js").JSONDoc) => import("./restore.js").RestoreReport;
358
364
  model: {
@@ -361,29 +367,30 @@ export declare const bindCrdt: (Y: EngineApi) => {
361
367
  blockNodeOf: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => import("./engine-api.js").EngineNode | null;
362
368
  liveNodeOf: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => import("./engine-api.js").EngineNode | null;
363
369
  isLive: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => boolean;
364
- candidatesOf: (node: import("./engine-api.js").EngineNode) => import("./placement/model.js").PlacementCand[];
365
370
  view: (doc: import("./engine-api.js").EngineDoc) => import("./placement/model.js").ModelView;
366
- resolvePlacements: (blocks: Map<import("./index.js").BlockId, import("./placement/model.js").BlockRec>, ownerOf?: (b: import("./index.js").BlockId) => import("./text/model.js").Owner) => Map<import("./index.js").BlockId, import("./placement/model.js").ResolvedPlacement>;
367
371
  childrenIndex: (placements: Map<import("./index.js").BlockId, import("./placement/model.js").ResolvedPlacement>, own: import("./placement/model.js").DisplayOwnership) => Map<import("./index.js").BlockId | null, import("./placement/model.js").ChildSlot[]>;
368
372
  positionInView: (v: import("./placement/model.js").ModelView, id: import("./index.js").BlockId) => import("./index.js").Destination | null;
369
373
  buildInline: (atom: import("./index.js").InlineSpec) => import("./engine-api.js").EngineNode;
370
374
  isSelfOrDescendant: (placements: Map<import("./index.js").BlockId, import("./placement/model.js").ResolvedPlacement>, own: import("./text/model.js").Ownership, id: import("./index.js").BlockId, maybeAncestor: import("./index.js").BlockId) => boolean;
371
- ranksAt: (siblings: readonly {
372
- rank: string;
373
- }[], index: number, count: number, clientId: number, rand?: () => number, run?: boolean) => string[];
374
- writePlacement: (doc: import("./engine-api.js").EngineDoc, node: import("./engine-api.js").EngineNode, p: import("./index.js").BlockId | null, r: string) => void;
375
+ placeBlocks: (doc: import("./engine-api.js").EngineDoc, v: import("./placement/model.js").ModelView, parent: import("./index.js").BlockId | null, left: import("./index.js").BlockId | null, right: import("./index.js").BlockId | null, slots: readonly import("./placement/slots.js").BlockSlot[] | null, moved?: readonly number[] | null, side?: number, part?: number, at?: import("./placement/slots.js").Unit | null) => void;
376
+ moveBlocksTo: (doc: import("./engine-api.js").EngineDoc, v: import("./placement/model.js").ModelView, ids: readonly import("./index.js").BlockId[], parent: import("./index.js").BlockId | null, index: number, side?: number, part?: number, at?: import("./index.js").BlockId | null) => void;
377
+ insertSpecsAt: (doc: import("./engine-api.js").EngineDoc, v: import("./placement/model.js").ModelView, parent: import("./index.js").BlockId | null, index: number, specs: readonly import("./index.js").BlockSpec[], split?: import("./placement/slots.js").Unit | null) => void;
375
378
  withdrawOnUndo: (doc: import("./engine-api.js").EngineDoc) => (item: import("./engine-api.js").EngineItemRef, stackItem: {
376
379
  inserts: {
377
380
  has(client: number, clock: number): boolean;
378
381
  };
379
382
  }) => boolean;
380
- materializeSpec: (doc: import("./engine-api.js").EngineDoc, sp: import("./index.js").BlockSpec, parent: import("./index.js").BlockId | null, rank: string) => void;
381
383
  collides: (doc: import("./engine-api.js").EngineDoc, specs: readonly import("./index.js").BlockSpec[]) => boolean;
382
- writeSplit: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail: import("./placement/model.js").SplitTail, place: import("./placement/model.js").PlacementValue) => void;
384
+ writeSplit: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId, offset: number, newId: import("./index.js").BlockId, tail: import("./placement/model.js").SplitTail, parent: import("./index.js").BlockId | null, index: number) => import("./placement/slots.js").Unit;
383
385
  ownText: (doc: import("./engine-api.js").EngineDoc, id: import("./index.js").BlockId) => {
384
386
  from: unknown;
385
387
  to: number;
386
388
  };
389
+ recordsOf: (doc: import("./engine-api.js").EngineDoc, node: import("./engine-api.js").EngineNode, v?: import("./placement/model.js").ModelView) => {
390
+ item: import("./placement/slots.js").SeqItem;
391
+ stamp: import("./placement/slots.js").Stamp;
392
+ wins: boolean;
393
+ }[];
387
394
  insertBlocks: (doc: import("./engine-api.js").EngineDoc, dest: import("./index.js").Destination, specs: import("./index.js").BlockSpec[]) => boolean;
388
395
  insertBlock: (doc: import("./engine-api.js").EngineDoc, dest: import("./index.js").Destination, spec: import("./index.js").BlockSpec) => boolean;
389
396
  restoreBlocks: (doc: import("./engine-api.js").EngineDoc, specs: import("./index.js").BlockSpec[]) => void;
@@ -415,8 +422,8 @@ export declare const bindCrdt: (Y: EngineApi) => {
415
422
  at: number;
416
423
  node: import("./engine-api.js").EngineNode;
417
424
  } | null;
418
- splitAt: (blocks: ReadonlyMap<import("./text/model.js").BlockId, import("./text/model.js").TextBlockRec>, own: import("./text/model.js").Ownership, b: import("./text/model.js").BlockId, offset: number, newId: import("./text/model.js").BlockId, n: number) => import("./text/model.js").MergeClaim[];
419
- claimInto: (blocks: ReadonlyMap<import("./text/model.js").BlockId, import("./text/model.js").TextBlockRec>, own: Pick<import("./text/model.js").Ownership, "streamOf">, from: import("./text/model.js").BlockId, into: import("./text/model.js").BlockId) => void;
425
+ splitAt: (doc: import("./engine-api.js").EngineDoc, blocks: ReadonlyMap<import("./text/model.js").BlockId, import("./text/model.js").TextBlockRec>, own: import("./text/model.js").Ownership, b: import("./text/model.js").BlockId, offset: number, newId: import("./text/model.js").BlockId, n: number) => void;
426
+ claimInto: (own: Pick<import("./text/model.js").Ownership, "streamOf">, from: import("./text/model.js").BlockId, into: import("./text/model.js").BlockId) => void;
420
427
  ownText: (doc: import("./engine-api.js").EngineDoc, rec: import("./text/model.js").TextBlockRec) => {
421
428
  from: unknown;
422
429
  to: number;
@@ -576,11 +583,11 @@ export declare const bindCrdt: (Y: EngineApi) => {
576
583
  destroy(): void;
577
584
  disconnect(): void;
578
585
  connect(): void;
579
- emit<N extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<import("./protocol.js").WebsocketProviderEvents[N]>): void;
586
+ emit<N extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: N, args: Parameters<import("./protocol.js").WebsocketProviderEvents[N]>): void;
580
587
  _observers: Map<string, Set<any>>;
581
- on<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): import("./protocol.js").WebsocketProviderEvents[NAME];
582
- once<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
583
- off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
588
+ on<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): import("./protocol.js").WebsocketProviderEvents[NAME];
589
+ once<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
590
+ off<NAME extends "refused" | "status" | "failed" | "schema-mismatch" | "message-error" | "protocol-mismatch" | "synced" | "access" | "connection-close" | "connection-error" | "saved" | "permission-denied" | "expired" | "unreachable">(name: NAME, f: import("./protocol.js").WebsocketProviderEvents[NAME]): void;
584
591
  };
585
592
  };
586
593
  watchComments: (server: string | null, roomName: string, listener: (message: import("./protocol.js").CommentMessage) => void) => (() => void);
@@ -61,6 +61,9 @@ export { EdytorDocument, createDocument, loadDocument, attachDocument, SemanticC
61
61
  // `blocks`), `mergeSemantics` merges configs field by field, and the digest
62
62
  // is the dev-time check a room logs mismatches with. Frozen.
63
63
  export { defaultSemantics, richTextSemantics, codeSemantics, imageSemantics, mediaKinds, mediaSemantics, layoutSemantics, pageKinds, pageSemantics, tocKinds, tocSemantics, tableKinds, tableSemantics, equationKinds, equationSemantics, richTextKinds, codeKinds, imageKinds, layoutKinds, richTextMarks, commentMarks, facadeConfigOf, semanticsOf, mergeSemantics, semanticsDigest, semanticsMismatch } from './semantics.js';
64
+ // A document read without a view leaves its pending shared suggestions out
65
+ // of `toJSON()` once they are built over it (`sugg.json.base`).
66
+ export { adoptSharedSuggestions } from './doc/suggest.js';
64
67
  // A new table as document JSON (`table.*`).
65
68
  export { tableBlock } from './tables.js';
66
69
  // Paired marks — a mark's edge as document semantics, the record a key names.
@@ -109,7 +112,7 @@ export { SchemaMismatchError, UndecodableUpdateError } from './admission.js';
109
112
  // the public read vocabulary; ordinary editing writes no per-edit
110
113
  // attribution.
111
114
  export {} from './attribution/index.js';
112
- // Compact per-BLOCK attribution read vocabulary (`b/<blockId>`
115
+ // Compact per-BLOCK attribution read vocabulary (`blockattr` `<blockId>`
113
116
  // records + the block-node `l` attr — see `attribution/block.ts`).
114
117
  // `document.attribution.block(id)` / `document.blockAttribution(id)`
115
118
  // are the read entry points.
@@ -7,8 +7,10 @@
7
7
  * a view (`edytor.insertBlocks(…)`) they are dispatched. The facade a
8
8
  * document binds has more (the index, the engine hooks): those stay
9
9
  * internal. `DOCUMENT_OPERATIONS` lists the names, `DOCUMENT_WRITES` the
10
- * writes, checked against the interfaces here and against the facade in
11
- * `document.ts`. Worker-safe: types and two lists.
10
+ * writes, checked against the interfaces here; the document and the view
11
+ * read the names from the facade itself (its `api` and `prepare`, checked
12
+ * against `DocumentOperations` in `document.ts`). Worker-safe: types and
13
+ * two lists.
12
14
  */
13
15
  import type { BlockAttribution } from './attribution/block.js';
14
16
  import type { AnchorAffinity, DataTarget, DocAnchor, DocChange, JsonObj, OpResult, OrderPolicy, Prepared } from './doc/types.js';
@@ -63,7 +65,14 @@ export interface DocumentWrites {
63
65
  }
64
66
  /** The document's reads (transaction-aware where the reference says so). */
65
67
  export interface DocumentReads {
66
- toJSON(): JSONDoc;
68
+ /**
69
+ * The document as JSON, without its pending suggestions (their inserted
70
+ * text and blocks left out, their proposals not applied); with
71
+ * `suggestions: true`, as shown, pending suggestions included.
72
+ */
73
+ toJSON(options?: {
74
+ suggestions?: boolean;
75
+ }): JSONDoc;
67
76
  docData(): JsonObj;
68
77
  dataItemIds(target: DataTarget, path: readonly string[]): string[];
69
78
  project(): ProjectedDoc;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A block's content as its parts: the text segments between inline atoms
3
+ * and the atoms, alternating, starting and ending with a segment (an empty
4
+ * content is one empty `start` segment), each at its display offsets (an
5
+ * atom counts 1). One pure function of the index's runs, memoized per runs
6
+ * array: the cells render it, the handles and the projection read it.
7
+ */
8
+ import type { ContentRun } from './text/runs.js';
9
+ export declare const START = "start";
10
+ type TextRun = Extract<ContentRun, {
11
+ kind: 'text';
12
+ }>;
13
+ /** The text between two inline atoms (or a content edge), keyed causally. */
14
+ export type Segment = {
15
+ readonly kind: 'text';
16
+ /** The id of the atom before this segment, or {@link START}. */
17
+ readonly key: string;
18
+ readonly text: string;
19
+ readonly runs: readonly TextRun[];
20
+ /** Its position among the block's segments. */
21
+ readonly segOrd: number;
22
+ readonly start: number;
23
+ readonly end: number;
24
+ };
25
+ export type AtomPart = {
26
+ readonly kind: 'inline';
27
+ readonly key: string;
28
+ readonly id: string;
29
+ readonly type: string;
30
+ readonly data: Readonly<Record<string, unknown>> | undefined;
31
+ readonly start: number;
32
+ readonly end: number;
33
+ };
34
+ export type Part = Segment | AtomPart;
35
+ export declare const partsOf: (runs: readonly ContentRun[]) => readonly Part[];
36
+ /** The text segment showing `offset`: the first ending at or after it (a seam belongs to the left text), else the last. */
37
+ export declare const segmentAt: <P extends {
38
+ kind: string;
39
+ end: number;
40
+ }>(parts: readonly P[], offset: number) => Extract<P, {
41
+ kind: "text";
42
+ }>;
43
+ export {};
@@ -0,0 +1,44 @@
1
+ export const START = 'start';
2
+ const memo = new WeakMap();
3
+ export const partsOf = (runs) => {
4
+ const hit = memo.get(runs);
5
+ if (hit)
6
+ return hit;
7
+ const parts = [];
8
+ let [key, segment, start, at, segOrd] = [START, [], 0, 0, 0];
9
+ const close = () => parts.push(Object.freeze({
10
+ kind: 'text',
11
+ key,
12
+ text: segment.map((run) => run.text).join(''),
13
+ runs: Object.freeze(segment),
14
+ segOrd: segOrd++,
15
+ start,
16
+ end: at
17
+ }));
18
+ for (const run of runs) {
19
+ if (run.kind === 'text') {
20
+ segment.push(run);
21
+ at += run.text.length;
22
+ continue;
23
+ }
24
+ close();
25
+ parts.push(Object.freeze({
26
+ kind: 'inline',
27
+ key: run.id,
28
+ id: run.id,
29
+ type: run.type,
30
+ data: run.data,
31
+ start: at,
32
+ end: ++at
33
+ }));
34
+ [key, segment, start] = [run.id, [], at];
35
+ }
36
+ close();
37
+ memo.set(runs, Object.freeze(parts));
38
+ return parts;
39
+ };
40
+ /** The text segment showing `offset`: the first ending at or after it (a seam belongs to the left text), else the last. */
41
+ export const segmentAt = (parts, offset) => {
42
+ const texts = parts.filter((part) => part.kind === 'text');
43
+ return texts.find((part) => offset <= part.end) ?? texts.at(-1);
44
+ };