edytor 5.0.0 → 7.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 (137) hide show
  1. package/README.md +3 -3
  2. package/dist/cloudflare/DocumentRoom.d.ts +77 -2
  3. package/dist/cloudflare/DocumentRoom.js +37 -1
  4. package/dist/cloudflare/index.d.ts +1 -1
  5. package/dist/cloudflare/index.js +1 -1
  6. package/dist/cloudflare/room/access.d.ts +6 -1
  7. package/dist/cloudflare/room/access.js +30 -4
  8. package/dist/cloudflare/room/admission.d.ts +11 -0
  9. package/dist/cloudflare/room/admission.js +43 -10
  10. package/dist/cloudflare/room/context.d.ts +73 -76
  11. package/dist/cloudflare/room/context.js +17 -6
  12. package/dist/cloudflare/room/forged.d.ts +1 -1
  13. package/dist/cloudflare/room/forged.js +11 -9
  14. package/dist/cloudflare/room/frames.d.ts +2 -0
  15. package/dist/cloudflare/room/frames.js +2 -0
  16. package/dist/cloudflare/room/presence.js +1 -4
  17. package/dist/cloudflare/room/reseed.d.ts +93 -0
  18. package/dist/cloudflare/room/reseed.js +500 -0
  19. package/dist/cloudflare/room/scheduler.d.ts +1 -1
  20. package/dist/cloudflare/room/scheduler.js +9 -1
  21. package/dist/cloudflare/room/shared.d.ts +10 -0
  22. package/dist/cloudflare/room/shared.js +10 -0
  23. package/dist/cloudflare/room/storage.d.ts +7 -0
  24. package/dist/cloudflare/room/storage.js +33 -1
  25. package/dist/components/Edytor.svelte +18 -3
  26. package/dist/components/Edytor.svelte.d.ts +10 -1
  27. package/dist/components/EdytorRoot.svelte +17 -0
  28. package/dist/components/EdytorRoot.svelte.d.ts +4 -0
  29. package/dist/components/Suggestion.svelte +1 -1
  30. package/dist/crdt/attribution/block.d.ts +3 -0
  31. package/dist/crdt/attribution/block.js +3 -2
  32. package/dist/crdt/doc/history.js +2 -3
  33. package/dist/crdt/doc/ops.d.ts +81 -0
  34. package/dist/crdt/doc/ops.js +1898 -0
  35. package/dist/crdt/doc/suggest.d.ts +6 -2
  36. package/dist/crdt/doc/suggest.js +6 -5
  37. package/dist/crdt/edytor-doc.d.ts +157 -157
  38. package/dist/crdt/edytor-doc.js +15 -43
  39. package/dist/crdt/engine-room.d.ts +4 -0
  40. package/dist/crdt/engine-room.js +6 -0
  41. package/dist/crdt/flow.d.ts +4 -46
  42. package/dist/crdt/flow.js +2 -262
  43. package/dist/crdt/index.d.ts +64 -75
  44. package/dist/crdt/operations.d.ts +1 -1
  45. package/dist/crdt/placement/resolve.d.ts +1 -1
  46. package/dist/crdt/protocol.d.ts +2 -2
  47. package/dist/crdt/protocol.js +2 -2
  48. package/dist/crdt/protocols/auth.d.ts +8 -1
  49. package/dist/crdt/protocols/auth.js +14 -1
  50. package/dist/crdt/protocols/awareness.js +46 -81
  51. package/dist/crdt/providers/index.d.ts +11 -22
  52. package/dist/crdt/providers/index.js +22 -3
  53. package/dist/crdt/providers/indexeddb.d.ts +6 -10
  54. package/dist/crdt/providers/indexeddb.js +10 -16
  55. package/dist/crdt/providers/room.d.ts +26 -0
  56. package/dist/crdt/providers/room.js +41 -12
  57. package/dist/crdt/providers/websocket.d.ts +10 -14
  58. package/dist/crdt/providers/websocket.js +43 -23
  59. package/dist/crdt/rangeDelete.d.ts +2 -47
  60. package/dist/crdt/rangeDelete.js +1 -169
  61. package/dist/crdt/reseed.d.ts +127 -0
  62. package/dist/crdt/reseed.js +533 -0
  63. package/dist/crdt/restore.d.ts +13 -1
  64. package/dist/crdt/restore.js +8 -3
  65. package/dist/crdt/schema.d.ts +6 -0
  66. package/dist/crdt/schema.js +6 -0
  67. package/dist/crdt/structs.d.ts +8 -11
  68. package/dist/crdt/structs.js +25 -44
  69. package/dist/crdt/text/index/build.d.ts +119 -0
  70. package/dist/crdt/text/index/build.js +2801 -0
  71. package/dist/crdt/text/index/shared.d.ts +2 -6
  72. package/dist/crdt/text/index/shared.js +2 -5
  73. package/dist/crdt/text/model.js +2 -3
  74. package/dist/crdt/text/runs.d.ts +9 -12
  75. package/dist/crdt/text/runs.js +2 -165
  76. package/dist/crdt/vendor/yjs/UPSTREAM.md +101 -5
  77. package/dist/crdt/vendor/yjs/dts/index.d.ts +1 -1
  78. package/dist/crdt/vendor/yjs/dts/utils/Transaction.d.ts +10 -10
  79. package/dist/crdt/vendor/yjs/dts/utils/encoding.d.ts +1 -0
  80. package/dist/crdt/vendor/yjs/src/index.js +1 -1
  81. package/dist/crdt/vendor/yjs/src/structs/Item.js +24 -13
  82. package/dist/crdt/vendor/yjs/src/utils/Transaction.js +12 -10
  83. package/dist/crdt/vendor/yjs/src/utils/encoding.js +42 -1
  84. package/dist/events/domTextOffset.d.ts +2 -0
  85. package/dist/events/domTextOffset.js +8 -0
  86. package/dist/export/forms.d.ts +50 -50
  87. package/dist/index.d.ts +1 -1
  88. package/dist/index.js +1 -1
  89. package/dist/plugins/richtext/RichTextPlugin.svelte +63 -61
  90. package/dist/plugins/richtext/richTextOperations.js +26 -32
  91. package/dist/selection/selection.svelte.d.ts +1 -1
  92. package/dist/selection/selection.svelte.js +87 -106
  93. package/dist/selection/selection.utils.js +5 -8
  94. package/dist/session/commands.js +49 -51
  95. package/dist/session/handles.js +3 -7
  96. package/dist/surface/attributes.d.ts +3 -3
  97. package/dist/surface/attributes.js +2 -2
  98. package/dist/surface/observer.svelte.d.ts +7 -7
  99. package/dist/surface/observer.svelte.js +225 -336
  100. package/dist/surface/projector.svelte.js +2 -2
  101. package/dist/utils.d.ts +5 -0
  102. package/dist/utils.js +7 -0
  103. package/package.json +1 -1
  104. package/dist/crdt/doc/capability.d.ts +0 -56
  105. package/dist/crdt/doc/capability.js +0 -207
  106. package/dist/crdt/doc/content.d.ts +0 -16
  107. package/dist/crdt/doc/content.js +0 -77
  108. package/dist/crdt/doc/delete.d.ts +0 -15
  109. package/dist/crdt/doc/delete.js +0 -84
  110. package/dist/crdt/doc/layout.d.ts +0 -9
  111. package/dist/crdt/doc/layout.js +0 -178
  112. package/dist/crdt/doc/meta.d.ts +0 -19
  113. package/dist/crdt/doc/meta.js +0 -198
  114. package/dist/crdt/doc/moves.d.ts +0 -21
  115. package/dist/crdt/doc/moves.js +0 -274
  116. package/dist/crdt/doc/split-merge.d.ts +0 -10
  117. package/dist/crdt/doc/split-merge.js +0 -179
  118. package/dist/crdt/doc/steps.d.ts +0 -65
  119. package/dist/crdt/doc/steps.js +0 -311
  120. package/dist/crdt/text/index/cache.d.ts +0 -16
  121. package/dist/crdt/text/index/cache.js +0 -175
  122. package/dist/crdt/text/index/claims.d.ts +0 -18
  123. package/dist/crdt/text/index/claims.js +0 -203
  124. package/dist/crdt/text/index/fold.d.ts +0 -21
  125. package/dist/crdt/text/index/fold.js +0 -656
  126. package/dist/crdt/text/index/layout.d.ts +0 -22
  127. package/dist/crdt/text/index/layout.js +0 -258
  128. package/dist/crdt/text/index/placement.d.ts +0 -47
  129. package/dist/crdt/text/index/placement.js +0 -738
  130. package/dist/crdt/text/index/records.d.ts +0 -13
  131. package/dist/crdt/text/index/records.js +0 -139
  132. package/dist/crdt/text/index/report.d.ts +0 -18
  133. package/dist/crdt/text/index/report.js +0 -337
  134. package/dist/crdt/text/index/state.d.ts +0 -197
  135. package/dist/crdt/text/index/state.js +0 -116
  136. package/dist/crdt/text/index/streams.d.ts +0 -25
  137. package/dist/crdt/text/index/streams.js +0 -248
@@ -16,6 +16,7 @@ import { Block } from '../block/block.svelte.js';
16
16
  import { InlineBlock } from '../block/inlineBlock.svelte.js';
17
17
  import { Text } from '../text/text.svelte.js';
18
18
  import { partsOf } from '../crdt/parts.js';
19
+ import { getOr } from '../utils.js';
19
20
  /**
20
21
  * A text segment's items as `JSONText` runs (`text.value`): empty items
21
22
  * dropped, adjacent runs with the same marks joined, each run's marks a
@@ -61,10 +62,7 @@ export class Handles {
61
62
  block = (id) => {
62
63
  if (id === 'root')
63
64
  return this.root;
64
- let block = this.#blocks.get(id);
65
- if (!block)
66
- this.#blocks.set(id, (block = new Block(this.edytor, id)));
67
- return block;
65
+ return getOr(this.#blocks, id, () => new Block(this.edytor, id));
68
66
  };
69
67
  /** The handle of live block `id`; none for a dead or unknown id. */
70
68
  get = (id) => id === 'root' || (id && this.edytor.facade.isVisibleBlock(id)) ? this.block(id) : undefined;
@@ -84,9 +82,7 @@ export class Handles {
84
82
  };
85
83
  /** The handle of atom `atomId`, shown in block `blockId`. */
86
84
  atom = (blockId, atomId) => {
87
- let atom = this.#atoms.get(atomId);
88
- if (!atom)
89
- this.#atoms.set(atomId, (atom = new InlineBlock(this.edytor, blockId, atomId)));
85
+ const atom = getOr(this.#atoms, atomId, () => new InlineBlock(this.edytor, blockId, atomId));
90
86
  atom.blockId = blockId;
91
87
  return atom;
92
88
  };
@@ -32,12 +32,12 @@ export type Kind = 'block' | 'text' | 'mark' | 'atom' | 'anchor' | 'preview';
32
32
  * moves the caret by its paragraph's direction, never an inline run's.
33
33
  */
34
34
  export declare const blockDir: (text: string) => "rtl" | "ltr" | null;
35
- /** The text a cell's runs show (its atoms left out): what `blockDir` reads. */
36
- export declare const ownText: (runs: readonly ContentRun[]) => string;
35
+ /** The text a cell's runs show, each atom as `atom` (left out: what `blockDir` reads). */
36
+ export declare const ownText: (runs: readonly ContentRun[], atom?: string) => string;
37
37
  /** A text inside a void block is its own editing host (the core sets it at attach). */
38
38
  export declare const insideVoid: (edytor: Edytor, block: string) => boolean;
39
39
  /** What the table owns on `element` (the root, or a registered element). */
40
- export declare const ownedOf: (edytor: Edytor, element: Element, entry: {
40
+ export declare const ownedOf: (edytor: Edytor, element: Element, entry?: {
41
41
  kind: Kind;
42
42
  block: string;
43
43
  name?: string;
@@ -20,8 +20,8 @@ export const blockDir = (text) => {
20
20
  const strong = STRONG.exec(text)?.[0];
21
21
  return strong === undefined ? null : RTL.test(strong) ? 'rtl' : 'ltr';
22
22
  };
23
- /** The text a cell's runs show (its atoms left out): what `blockDir` reads. */
24
- export const ownText = (runs) => runs.map((run) => (run.kind === 'text' ? run.text : '')).join('');
23
+ /** The text a cell's runs show, each atom as `atom` (left out: what `blockDir` reads). */
24
+ export const ownText = (runs, atom = '') => runs.map((run) => (run.kind === 'text' ? run.text : atom)).join('');
25
25
  /** A text inside a void block is its own editing host (the core sets it at attach). */
26
26
  export const insideVoid = (edytor, block) => {
27
27
  for (let id = block; id; id = edytor.facade.parentOf(id))
@@ -31,12 +31,12 @@ export declare class SurfaceObserver {
31
31
  * editing host inside a void).
32
32
  */
33
33
  register: (node: Element, kind: Kind, block: string, name?: string, owned?: () => Owned, handle?: Text | InlineBlock) => () => void;
34
- /** The render anchor (`Edytor.svelte`): a registered child of the strict root. */
35
- anchor: (node: HTMLElement) => {
36
- destroy: () => void;
37
- };
38
- /** A suggestion's preview group (`components/Suggestion`): registered, view-only, never compared. */
39
- preview: (node: HTMLElement, id: string) => {
34
+ /**
35
+ * A view-only element the core renders in the host, never compared: the
36
+ * render anchor (`Edytor.svelte`, a registered child of the strict root),
37
+ * or with its suggestion's `id`, a preview group (`components/Suggestion`).
38
+ */
39
+ own: (node: HTMLElement, id?: string) => {
40
40
  destroy: () => void;
41
41
  };
42
42
  /** Extension view state rendered into the host, or a re-display request: an epoch bump. */
@@ -71,4 +71,4 @@ export declare class SurfaceObserver {
71
71
  * The caret lands where the browser put it (`domCaret`), else, for an
72
72
  * attempt, where the change ends — unless a gesture came since.
73
73
  */
74
- export declare const adopt: (edytor: Edytor, text: Text, dom: string, domCaret?: number, prefer?: number) => Promise<boolean>;
74
+ export declare const adopt: (edytor: Edytor, text: Text, dom: string, domCaret?: number, prefer?: number) => Promise<void>;