svedit 0.12.0 → 0.14.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 (88) hide show
  1. package/README.md +35 -22
  2. package/dist/Command.svelte.d.ts +38 -30
  3. package/dist/Command.svelte.d.ts.map +1 -1
  4. package/dist/Command.svelte.js +271 -326
  5. package/dist/CustomProperty.svelte +3 -5
  6. package/dist/CustomProperty.svelte.d.ts +3 -6
  7. package/dist/CustomProperty.svelte.d.ts.map +1 -1
  8. package/dist/KeyMapper.svelte.d.ts +19 -6
  9. package/dist/KeyMapper.svelte.d.ts.map +1 -1
  10. package/dist/KeyMapper.svelte.js +95 -112
  11. package/dist/Node.svelte +16 -13
  12. package/dist/Node.svelte.d.ts +3 -5
  13. package/dist/Node.svelte.d.ts.map +1 -1
  14. package/dist/NodeArrayProperty.svelte +39 -22
  15. package/dist/NodeArrayProperty.svelte.d.ts +3 -5
  16. package/dist/NodeArrayProperty.svelte.d.ts.map +1 -1
  17. package/dist/NodeCaret.svelte +2 -2
  18. package/dist/NodeCaret.svelte.d.ts +6 -14
  19. package/dist/NodeCaret.svelte.d.ts.map +1 -1
  20. package/dist/NodeGap.svelte +12 -6
  21. package/dist/NodeGap.svelte.d.ts +7 -14
  22. package/dist/NodeGap.svelte.d.ts.map +1 -1
  23. package/dist/NodeGapMarkers.svelte +36 -14
  24. package/dist/NodeGapMarkers.svelte.d.ts +6 -11
  25. package/dist/NodeGapMarkers.svelte.d.ts.map +1 -1
  26. package/dist/NodeSelectionMarkers.svelte +21 -7
  27. package/dist/NodeSelectionMarkers.svelte.d.ts +2 -5
  28. package/dist/NodeSelectionMarkers.svelte.d.ts.map +1 -1
  29. package/dist/Session.svelte.d.ts +81 -129
  30. package/dist/Session.svelte.d.ts.map +1 -1
  31. package/dist/Session.svelte.js +542 -648
  32. package/dist/Svedit.svelte +146 -140
  33. package/dist/Svedit.svelte.d.ts +30 -10
  34. package/dist/Svedit.svelte.d.ts.map +1 -1
  35. package/dist/TextProperty.svelte +37 -23
  36. package/dist/TextProperty.svelte.d.ts +3 -5
  37. package/dist/TextProperty.svelte.d.ts.map +1 -1
  38. package/dist/Transaction.svelte.d.ts +64 -127
  39. package/dist/Transaction.svelte.d.ts.map +1 -1
  40. package/dist/Transaction.svelte.js +839 -1001
  41. package/dist/UnknownNode.svelte +4 -3
  42. package/dist/UnknownNode.svelte.d.ts +5 -9
  43. package/dist/UnknownNode.svelte.d.ts.map +1 -1
  44. package/dist/doc_utils.d.ts +67 -155
  45. package/dist/doc_utils.d.ts.map +1 -1
  46. package/dist/doc_utils.js +619 -863
  47. package/dist/index.d.ts +20 -17
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +1 -17
  50. package/dist/node_visibility.svelte.d.ts +110 -9
  51. package/dist/node_visibility.svelte.d.ts.map +1 -1
  52. package/dist/node_visibility.svelte.js +473 -544
  53. package/dist/paste_utils.d.ts +11 -44
  54. package/dist/paste_utils.d.ts.map +1 -1
  55. package/dist/paste_utils.js +111 -152
  56. package/dist/styles/svedit-colors.css +8 -5
  57. package/dist/transforms.svelte.d.ts +9 -7
  58. package/dist/transforms.svelte.d.ts.map +1 -1
  59. package/dist/transforms.svelte.js +125 -150
  60. package/dist/types.d.ts +294 -309
  61. package/dist/types.d.ts.map +1 -0
  62. package/dist/types.js +1 -0
  63. package/dist/utils.d.ts +40 -119
  64. package/dist/utils.d.ts.map +1 -1
  65. package/dist/utils.js +346 -473
  66. package/package.json +70 -70
  67. package/src/lib/{Command.svelte.js → Command.svelte.ts} +29 -17
  68. package/src/lib/CustomProperty.svelte +3 -5
  69. package/src/lib/{KeyMapper.svelte.js → KeyMapper.svelte.ts} +28 -11
  70. package/src/lib/Node.svelte +16 -13
  71. package/src/lib/NodeArrayProperty.svelte +39 -22
  72. package/src/lib/NodeCaret.svelte +2 -2
  73. package/src/lib/NodeGap.svelte +12 -6
  74. package/src/lib/NodeGapMarkers.svelte +36 -14
  75. package/src/lib/NodeSelectionMarkers.svelte +21 -7
  76. package/src/lib/{Session.svelte.js → Session.svelte.ts} +130 -127
  77. package/src/lib/Svedit.svelte +146 -140
  78. package/src/lib/TextProperty.svelte +37 -23
  79. package/src/lib/{Transaction.svelte.js → Transaction.svelte.ts} +139 -143
  80. package/src/lib/UnknownNode.svelte +4 -3
  81. package/src/lib/{doc_utils.js → doc_utils.ts} +247 -206
  82. package/src/lib/{index.js → index.ts} +48 -0
  83. package/src/lib/{node_visibility.svelte.js → node_visibility.svelte.ts} +68 -92
  84. package/src/lib/{paste_utils.js → paste_utils.ts} +47 -58
  85. package/src/lib/styles/svedit-colors.css +8 -5
  86. package/src/lib/{transforms.svelte.js → transforms.svelte.ts} +39 -21
  87. package/src/lib/{types.d.ts → types.ts} +161 -66
  88. package/src/lib/{utils.js → utils.ts} +110 -129
@@ -1 +1 @@
1
- {"version":3,"file":"Svedit.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Svedit.svelte.js"],"names":[],"mappings":";;;;;;;AA+nDA;;eAAqD;iCAnlD1C,cAAc"}
1
+ {"version":3,"file":"Svedit.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Svedit.svelte.ts"],"names":[],"mappings":"AAyBA,OAAO,4BAA4B,CAAC;AACpC,OAAO,gCAAgC,CAAC;AAExC,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EASX,MAAM,YAAY,CAAC;AAGrB,iBAAS,QAAQ,CAAC,CAAC,SAAS,cAAc;WA8lDb,WAAW,CAAC,CAAC,CAAC;aAAwB;QAAE,YAAY,aAAqB;KAAE;;;;EAAuE;AAC/K,cAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc;IAC5C,KAAK,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAChD,MAAM,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClD,KAAK,IAAI,UAAU,CAAC,OAAO,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elte';
3
3
  import {
4
4
  char_slice,
@@ -9,12 +9,24 @@
9
9
  calculate_fragment_ranges
10
10
  } from './utils.js';
11
11
 
12
- /** @import { TextPropertyProps, Mark, Fragment, SelectionRange } from './types.d.ts'; */
13
-
14
- const svedit = getContext('svedit');
15
-
16
- /** @type {TextPropertyProps} */
17
- let { path, class: css_class, placeholder = '', tag = 'div', style = '', ...rest } = $props();
12
+ import type {
13
+ TextPropertyProps,
14
+ Mark,
15
+ Fragment,
16
+ SelectionRange,
17
+ SveditContext
18
+ } from './types.js';
19
+
20
+ const svedit = getContext<SveditContext>('svedit');
21
+
22
+ let {
23
+ path,
24
+ class: css_class,
25
+ placeholder = '',
26
+ tag = 'div',
27
+ style = '',
28
+ ...rest
29
+ }: TextPropertyProps = $props();
18
30
 
19
31
  let path_str = $derived(serialize_path(path));
20
32
 
@@ -30,9 +42,12 @@
30
42
  // re-runs for every text property on every document change).
31
43
  let is_empty = $derived(plain_text.length === 0 && !(svedit.is_composing && is_focused));
32
44
 
33
- let is_collapsed = $derived(
34
- is_focused && svedit.session.selection?.anchor_offset == svedit.session.selection?.focus_offset
35
- );
45
+ let is_collapsed = $derived.by(() => {
46
+ const selection = svedit.session.selection;
47
+ return (
48
+ is_focused && selection?.type === 'text' && selection.anchor_offset === selection.focus_offset
49
+ );
50
+ });
36
51
 
37
52
  // Get selection highlight range if it does not touch marks.
38
53
  // Only render selection highlight when canvas is NOT focused.
@@ -60,12 +75,12 @@
60
75
  /**
61
76
  * Converts text with marks into renderable fragments for display.
62
77
  * Annotations never fragment the text; they are data-only.
63
- * @param {string} text - The plain text content
64
- * @param {Array<Mark>} marks - Marks to render in-place
65
- * @param {SelectionRange} [selection_highlight_range] - Optional selection highlight range
66
- * @returns {Array<Fragment>} Array of fragments
67
78
  */
68
- function get_fragments(text, marks, selection_highlight_range) {
79
+ function get_fragments(
80
+ text: string,
81
+ marks: Array<Mark>,
82
+ selection_highlight_range?: SelectionRange | null
83
+ ): Array<Fragment> {
69
84
  // Fast path: no marks and no selection highlight means the whole text
70
85
  // is a single content fragment. This runs for EVERY text property on
71
86
  // EVERY document change, so skipping the two full Intl.Segmenter passes
@@ -79,8 +94,7 @@
79
94
  marks,
80
95
  selection_highlight_range
81
96
  );
82
- /** @type {Array<Fragment>} */
83
- let fragments = [];
97
+ const fragments: Array<Fragment> = [];
84
98
 
85
99
  for (const range of ranges) {
86
100
  const content = char_slice(text, range.start_offset, range.end_offset);
@@ -93,7 +107,7 @@
93
107
  type: 'mark',
94
108
  node,
95
109
  content,
96
- mark_index: range.mark_index
110
+ mark_index: range.mark_index!
97
111
  });
98
112
  } else if (range.type === 'selection_highlight') {
99
113
  fragments.push({
@@ -172,9 +186,9 @@
172
186
  display: inline-block;
173
187
  /* we use box-shadow to draw the caret shape, matching the native caret */
174
188
  box-shadow:
175
- 0 -0.4cap 0 0.65px var(--svedit-caret-color, AccentColor),
176
- 0 0 0 0.65px var(--svedit-caret-color, AccentColor),
177
- 0 0.4cap 0 0.65px var(--svedit-caret-color, AccentColor);
189
+ 0 -0.4cap 0 0.65px var(--editing, AccentColor),
190
+ 0 0 0 0.65px var(--editing, AccentColor),
191
+ 0 0.4cap 0 0.65px var(--editing, AccentColor);
178
192
  animation: var(
179
193
  --node-caret-animation,
180
194
  node-caret-blink var(--node-caret-blink-duration, 1.1s) ease-in-out infinite
@@ -193,12 +207,12 @@
193
207
 
194
208
  /* Dim the selection highlight when canvas loses native focus */
195
209
  :global(.svedit-canvas:not(:focus-within)) .selection-highlight {
196
- background: oklch(from var(--svedit-editing-fill) l 0 h / alpha);
210
+ background: oklch(from var(--editing-muted) l 0 h / alpha);
197
211
  }
198
212
 
199
213
  /* Make a collapsed caret visible */
200
214
  :global(.svedit-canvas:not(:focus-within)) .selection-highlight:empty {
201
215
  background: none;
202
- outline: 0.5px solid oklch(from var(--svedit-editing-stroke) l 0 h / alpha);
216
+ outline: 0.5px solid oklch(from var(--editing) l 0 h / alpha);
203
217
  }
204
218
  </style>
@@ -1,7 +1,5 @@
1
+ import type { TextPropertyProps } from './types.js';
2
+ declare const TextProperty: import("svelte").Component<TextPropertyProps, {}, "">;
3
+ type TextProperty = ReturnType<typeof TextProperty>;
1
4
  export default TextProperty;
2
- type TextProperty = {
3
- $on?(type: string, callback: (e: any) => void): () => void;
4
- $set?(props: Partial<TextPropertyProps>): void;
5
- };
6
- declare const TextProperty: import("svelte").Component<import("./types.d.ts").TextPropertyProps, {}, "">;
7
5
  //# sourceMappingURL=TextProperty.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TextProperty.svelte.d.ts","sourceRoot":"","sources":["../src/lib/TextProperty.svelte.js"],"names":[],"mappings":";;;;;AAyIA,yGAA2D"}
1
+ {"version":3,"file":"TextProperty.svelte.d.ts","sourceRoot":"","sources":["../src/lib/TextProperty.svelte.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,iBAAiB,EAKjB,MAAM,YAAY,CAAC;AAsIrB,QAAA,MAAM,YAAY,uDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
@@ -1,3 +1,5 @@
1
+ import type { SelectedAttachment } from './doc_utils.js';
2
+ import type { NodeId, NodeKind, Selection, Document, DocumentSchema, DocumentNode, DocumentPath, Mark, Annotation, DocumentOperation, DynamicRecord, Inspection, SessionConfig } from './types.js';
1
3
  /**
2
4
  * Transaction class for managing atomic document operations with undo/redo support.
3
5
  *
@@ -14,135 +16,81 @@
14
16
  * ```
15
17
  */
16
18
  export default class Transaction {
17
- /**
18
- * Creates a new Transaction with the given state.
19
- *
20
- * @param {DocumentSchema} schema - The document schema
21
- * @param {Document} doc - The document state {document_id, nodes}
22
- * @param {Selection | null} selection - The current selection
23
- * @param {object} config - The document config (including generate_id)
24
- */
25
- constructor(schema: DocumentSchema, doc: Document, selection: Selection | null, config: object);
26
19
  schema: DocumentSchema;
27
- /** @type {object} */
28
- doc: object;
29
- /** @type {Selection} */
20
+ doc: Document;
30
21
  selection: Selection;
31
- config: any;
32
- /** @type {Record<string, any>[]} */
33
- ops: Record<string, any>[];
34
- /** @type {Record<string, any>[]} */
35
- inverse_ops: Record<string, any>[];
36
- selection_before: Selection;
37
- /** @type {NodeId[]} */
22
+ config: SessionConfig;
23
+ ops: DocumentOperation[];
24
+ inverse_ops: DocumentOperation[];
25
+ selection_before: Selection | null;
38
26
  created_node_ids: NodeId[];
39
- /** @type {NodeId[]} */
40
27
  modified_node_ids: NodeId[];
41
- /** @type {NodeId[]} */
42
28
  deleted_node_ids: NodeId[];
43
29
  changed_node_types: boolean;
30
+ /**
31
+ * Creates a new Transaction with the given state.
32
+ *
33
+ * @param schema - The document schema
34
+ * @param doc - The document state {document_id, nodes}
35
+ * @param selection - The current selection
36
+ * @param config - The document config (including generate_id)
37
+ */
38
+ constructor(schema: DocumentSchema, doc: Document, selection: Selection | null, config: SessionConfig);
44
39
  /**
45
40
  * Gets a value from the document at the specified path.
46
41
  *
47
- * @param {DocumentPath|string} path - The path to the value in the document, or a string node ID
48
- * @returns {any} The value at the specified path
42
+ * @param path - The path to the value in the document, or a string node ID
43
+ * @returns The value at the specified path
49
44
  */
50
45
  get(path: DocumentPath | string): any;
51
46
  /**
52
47
  * Gets the type of a property from the schema.
53
- *
54
- * @param {string} type - The node type
55
- * @param {string} property - The property name
56
- * @returns {string} The property type
57
48
  */
58
49
  property_type(type: string, property: string): string;
59
50
  /**
60
- * Determines the kind of a node ('block', 'text', 'mark', or 'annotation').
61
- *
62
- * @param {any} node - The node to check
63
- * @returns {'block'|'text'|'mark'|'annotation'} The node kind
51
+ * Determines the kind of a node ('document', 'block', 'text', 'mark', or 'annotation').
64
52
  */
65
- kind(node: any): "block" | "text" | "mark" | "annotation";
53
+ kind(node: DocumentNode): NodeKind;
66
54
  /**
67
55
  * Inspects a path to get metadata about the value at that location.
68
- *
69
- * @param {DocumentPath} path - The path to inspect
70
- * @returns {{kind: 'property'|'node', [key: string]: any}} Metadata about the path
71
56
  */
72
- inspect(path: DocumentPath): {
73
- kind: "property" | "node";
74
- [key: string]: any;
75
- };
57
+ inspect(path: DocumentPath): Inspection;
76
58
  /**
77
59
  * Generates a new unique ID using the config's generate_id function.
78
- *
79
- * @returns {string} A new unique ID
80
60
  */
81
61
  generate_id(): string;
82
62
  /**
83
63
  * Validates a node against the document schema.
84
64
  *
85
- * @param {any} node - The node to validate
86
65
  * @throws {Error} Throws if the node is invalid
87
66
  */
88
- validate_node(node: any): void;
67
+ validate_node(node: DocumentNode): void;
89
68
  /**
90
69
  * Gets all nodes referenced by a given node (recursively).
91
- *
92
- * @param {NodeId} node_id - The node ID to get references for
93
- * @returns {NodeId[]} Array of referenced node IDs
94
70
  */
95
71
  get_referenced_nodes(node_id: NodeId): NodeId[];
96
72
  /**
97
73
  * Gets the available mark types for the current selection.
98
- *
99
- * @returns {string[]} Array of available mark type names
100
74
  */
101
75
  get available_mark_types(): string[];
102
76
  /**
103
77
  * Gets the available annotation types for the current selection.
104
- *
105
- * @returns {string[]} Array of available annotation type names
106
78
  */
107
79
  get available_annotation_types(): string[];
108
80
  /**
109
81
  * Returns marks touched by the current selection.
110
- *
111
- * @returns {Array<Mark & { index: number, node: any }>}
112
82
  */
113
- get selected_marks(): Array<Mark & {
114
- index: number;
115
- node: any;
116
- }>;
117
- get active_mark(): Attachment & {
118
- index: number;
119
- node: any;
120
- };
83
+ get selected_marks(): SelectedAttachment[];
84
+ get active_mark(): SelectedAttachment | null;
121
85
  /**
122
86
  * Returns annotations touched by the current selection.
123
- *
124
- * @returns {Array<Annotation & { index: number, node: any }>}
125
87
  */
126
- get selected_annotations(): Array<Annotation & {
127
- index: number;
128
- node: any;
129
- }>;
130
- get active_annotation(): Attachment & {
131
- index: number;
132
- node: any;
133
- };
88
+ get selected_annotations(): SelectedAttachment[];
89
+ get active_annotation(): SelectedAttachment | null;
134
90
  /**
135
91
  * Applies an operation to the document (internal).
136
- *
137
- * @param {Array} op - The operation to apply
138
- * @private
139
92
  */
140
93
  private _apply_op;
141
- /**
142
- * @param {NodeId[]} node_ids
143
- * @param {NodeId} node_id
144
- * @private
145
- */
146
94
  private _track_node_id;
147
95
  /**
148
96
  * Sets a property of a node to a new value.
@@ -150,9 +98,9 @@ export default class Transaction {
150
98
  * This is the core operation for modifying document properties. It records
151
99
  * both the forward operation and its inverse for undo support.
152
100
  *
153
- * @param {DocumentPath} path - Array path to the property (e.g., ["node_1", "title"])
154
- * @param {any} value - The new value to set
155
- * @returns {Transaction} This transaction instance for method chaining
101
+ * @param path - Array path to the property (e.g., ["node_1", "title"])
102
+ * @param value - The new value to set
103
+ * @returns This transaction instance for method chaining
156
104
  *
157
105
  * @example
158
106
  * ```js
@@ -160,16 +108,16 @@ export default class Transaction {
160
108
  * tr.set(["page_1", "body", "0", "description"], {content: "Hello world", marks: [], annotations: []});
161
109
  * ```
162
110
  */
163
- set(path: DocumentPath, value: any): Transaction;
164
- build(node_id: any, nodes: any): any;
111
+ set(path: DocumentPath, value: any): this;
112
+ build(node_id: NodeId, nodes: Record<string, DocumentNode>): NodeId;
165
113
  /**
166
114
  * Creates a new node in the document.
167
115
  *
168
116
  * The node must have a valid id and must not already exist in the document.
169
117
  * Omitted properties with schema defaults are filled before validation.
170
118
  *
171
- * @param {any} node - The node object to create (must include id, type, and required properties)
172
- * @returns {Transaction} This transaction instance for method chaining
119
+ * @param node - The node object to create (must include id, type, and required properties)
120
+ * @returns This transaction instance for method chaining
173
121
  * @throws {Error} If the node ID is invalid or if the node already exists
174
122
  *
175
123
  * @example
@@ -181,7 +129,7 @@ export default class Transaction {
181
129
  * });
182
130
  * ```
183
131
  */
184
- create(node: any): Transaction;
132
+ create(node: DocumentNode): this;
185
133
  /**
186
134
  * Deletes a node from the document by its ID.
187
135
  *
@@ -194,29 +142,27 @@ export default class Transaction {
194
142
  * For ref-count-aware cleanup, see how `set` calls
195
143
  * `_cascade_delete_unreferenced_nodes`.
196
144
  *
197
- * @param {any} id - The ID of the node to delete
198
- * @returns {Transaction} This transaction instance for method chaining
145
+ * @param id - The ID of the node to delete
146
+ * @returns This transaction instance for method chaining
199
147
  *
200
148
  * @example
201
149
  * ```js
202
150
  * tr.delete('node_123');
203
151
  * ```
204
152
  */
205
- delete(id: any): Transaction;
153
+ delete(id: NodeId): this;
206
154
  /**
207
155
  * Sets the document selection.
208
156
  *
209
- * @param {Selection} selection - The new selection object
210
- * @returns {Transaction} This transaction instance for method chaining
157
+ * @param selection - The new selection object
158
+ * @returns This transaction instance for method chaining
211
159
  * @throws {Error} Throws if the selection is invalid or out of bounds
212
160
  */
213
- set_selection(selection: Selection): Transaction;
161
+ set_selection(selection: Selection): this;
214
162
  /**
215
163
  * Validates a selection against the current document state.
216
164
  *
217
- * @param {Selection} selection - The selection to validate
218
165
  * @throws {Error} Throws if the selection is invalid
219
- * @private
220
166
  */
221
167
  private _validate_selection;
222
168
  /**
@@ -225,9 +171,9 @@ export default class Transaction {
225
171
  * Marks are mutually exclusive. Whole marks are toggled, removed, or
226
172
  * switched; ranges are never truncated or expanded by this command.
227
173
  *
228
- * @param {any} mark_type - The type of mark (e.g., 'link', 'strong', 'emphasis')
229
- * @param {any} mark_properties - Additional data for the mark (e.g., href for links)
230
- * @returns {Transaction} This transaction instance for method chaining
174
+ * @param mark_type - The type of mark (e.g., 'link', 'strong', 'emphasis')
175
+ * @param mark_properties - Additional data for the mark (e.g., href for links)
176
+ * @returns This transaction instance for method chaining
231
177
  *
232
178
  * @example
233
179
  * ```js
@@ -238,7 +184,7 @@ export default class Transaction {
238
184
  * tr.toggle_mark('emphasis', {});
239
185
  * ```
240
186
  */
241
- toggle_mark(mark_type: any, mark_properties: any): Transaction;
187
+ toggle_mark(mark_type: string, mark_properties?: DynamicRecord): this;
242
188
  /**
243
189
  * Toggles an annotation on the current text or node selection.
244
190
  *
@@ -248,9 +194,9 @@ export default class Transaction {
248
194
  * same-type annotations may still overlap when created through lower-level
249
195
  * APIs.
250
196
  *
251
- * @param {any} annotation_type - The type of annotation (e.g., 'comment', 'marker')
252
- * @param {any} annotation_properties - Additional data for the annotation
253
- * @returns {Transaction} This transaction instance for method chaining
197
+ * @param annotation_type - The type of annotation (e.g., 'comment', 'marker')
198
+ * @param annotation_properties - Additional data for the annotation
199
+ * @returns This transaction instance for method chaining
254
200
  *
255
201
  * @example
256
202
  * ```js
@@ -258,7 +204,7 @@ export default class Transaction {
258
204
  * tr.toggle_annotation('comment', { text: 'Please review' });
259
205
  * ```
260
206
  */
261
- toggle_annotation(annotation_type: any, annotation_properties: any): Transaction;
207
+ toggle_annotation(annotation_type: string, annotation_properties?: DynamicRecord): this;
262
208
  /**
263
209
  * Deletes the currently selected text, node, or property.
264
210
  *
@@ -268,23 +214,23 @@ export default class Transaction {
268
214
  * - For collapsed selections: Deletes the previous character/node (backward) or next character/node (forward)
269
215
  * - For property selections: Delegates to the config's handle_property_deletion hook
270
216
  *
271
- * @param {'backward' | 'forward'} [direction] - Direction of deletion for collapsed selections
272
- * @returns {Transaction} This transaction instance for method chaining
217
+ * @param direction - Direction of deletion for collapsed selections
218
+ * @returns This transaction instance for method chaining
273
219
  */
274
- delete_selection(direction?: "backward" | "forward"): Transaction;
220
+ delete_selection(direction?: 'backward' | 'forward'): this;
275
221
  /**
276
222
  * Inserts nodes at the current node selection position.
277
223
  *
278
224
  * If the selection is expanded (not collapsed), first deletes the selected nodes
279
225
  * before inserting the new ones.
280
226
  *
281
- * @param {NodeId[]} node_ids - Array of node IDs to insert
282
- * @param {Array<Mark>} [marks] - Selection-relative marks to restore
283
- * @param {Array<Annotation>} [annotations] - Selection-relative annotations to restore
284
- * @param {Record<NodeId, any>} [nodes] - Node graph for restored marks and annotations
285
- * @returns {Transaction} This transaction instance for method chaining
227
+ * @param node_ids - Array of node IDs to insert
228
+ * @param marks - Selection-relative marks to restore
229
+ * @param annotations - Selection-relative annotations to restore
230
+ * @param nodes - Node graph for restored marks and annotations
231
+ * @returns This transaction instance for method chaining
286
232
  */
287
- insert_nodes(node_ids: NodeId[], marks?: Array<Mark>, annotations?: Array<Annotation>, nodes?: Record<NodeId, any>): Transaction;
233
+ insert_nodes(node_ids: NodeId[], marks?: Array<Mark>, annotations?: Array<Annotation>, nodes?: Record<NodeId, DocumentNode>): this;
288
234
  /**
289
235
  * Inserts text at the current text selection position.
290
236
  *
@@ -293,13 +239,13 @@ export default class Transaction {
293
239
  * - Shifting ranges that come after the insertion point
294
240
  * - Optionally applying new marks and annotations to the inserted text
295
241
  *
296
- * @param {string} replaced_text - The text to insert
297
- * @param {Array<Mark>} [marks] - Optional marks to apply to the inserted text
298
- * @param {Array<Annotation>} [annotations] - Optional annotations to apply to the inserted text
299
- * @param {object} [nodes] - Optional node definitions for mark and annotation nodes
300
- * @returns {Transaction} This transaction instance for method chaining
242
+ * @param replaced_text - The text to insert
243
+ * @param marks - Optional marks to apply to the inserted text
244
+ * @param annotations - Optional annotations to apply to the inserted text
245
+ * @param nodes - Optional node definitions for mark and annotation nodes
246
+ * @returns This transaction instance for method chaining
301
247
  */
302
- insert_text(replaced_text: string, marks?: Array<Mark>, annotations?: Array<Annotation>, nodes?: object): Transaction;
248
+ insert_text(replaced_text: string, marks?: Array<Mark>, annotations?: Array<Annotation>, nodes?: Record<NodeId, DocumentNode>): this;
303
249
  /**
304
250
  * Recursively deletes nodes that are no longer referenced in the document.
305
251
  *
@@ -307,17 +253,8 @@ export default class Transaction {
307
253
  * references are removed. Uses reference counting to determine which
308
254
  * nodes are safe to delete.
309
255
  *
310
- * @param {NodeId[]} potentially_orphaned_nodes - Array of node IDs to check
311
- * @private
256
+ * @param potentially_orphaned_nodes - Array of node IDs to check
312
257
  */
313
258
  private _cascade_delete_unreferenced_nodes;
314
259
  }
315
- import type { DocumentSchema } from './types.d.js';
316
- import type { Selection } from './types.d.js';
317
- import type { NodeId } from './types.d.js';
318
- import type { DocumentPath } from './types.d.js';
319
- import type { Mark } from './types.d.js';
320
- import type { Attachment } from './types.d.js';
321
- import type { Annotation } from './types.d.js';
322
- import type { Document } from './types.d.js';
323
260
  //# sourceMappingURL=Transaction.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Transaction.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Transaction.svelte.js"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;GAcG;AACH;IACC;;;;;;;OAOG;IACH,oBALW,cAAc,OACd,QAAQ,aACR,SAAS,GAAG,IAAI,UAChB,MAAM,EA+BhB;IA5BA,uBAAoB;IAMpB,qBAAqB;IACrB,KADW,MAAM,CACoB;IACrC,wBAAwB;IACxB,WADW,SAAS,CACM;IAC1B,YAAoB;IAEpB,oCAAoC;IACpC,KADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CACnB;IACb,oCAAoC;IACpC,aADW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CACX;IAErB,4BAAiC;IAEjC,uBAAuB;IACvB,kBADW,MAAM,EAAE,CACO;IAC1B,uBAAuB;IACvB,mBADW,MAAM,EAAE,CACQ;IAC3B,uBAAuB;IACvB,kBADW,MAAM,EAAE,CACO;IAG1B,4BAA+B;IAGhC;;;;;OAKG;IACH,UAHW,YAAY,GAAC,MAAM,GACjB,GAAG,CAIf;IAED;;;;;;OAMG;IACH,oBAJW,MAAM,YACN,MAAM,GACJ,MAAM,CAIlB;IAED;;;;;OAKG;IACH,WAHW,GAAG,GACD,OAAO,GAAC,MAAM,GAAC,MAAM,GAAC,YAAY,CAI9C;IAED;;;;;OAKG;IACH,cAHW,YAAY,GACV;QAAC,IAAI,EAAE,UAAU,GAAC,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAIzD;IAED;;;;OAIG;IACH,eAFa,MAAM,CAUlB;IAED;;;;;OAKG;IACH,oBAHW,GAAG,QAKb;IAED;;;;;OAKG;IACH,8BAHW,MAAM,GACJ,MAAM,EAAE,CAIpB;IAED;;;;OAIG;IACH,4BAFa,MAAM,EAAE,CAMpB;IAED;;;;OAI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