svedit 0.11.1 → 0.12.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.
- package/README.md +230 -64
- package/dist/Command.svelte.d.ts +21 -4
- package/dist/Command.svelte.d.ts.map +1 -1
- package/dist/Command.svelte.js +85 -27
- package/dist/Node.svelte +29 -1
- package/dist/Node.svelte.d.ts.map +1 -1
- package/dist/NodeArrayProperty.svelte +119 -12
- package/dist/NodeArrayProperty.svelte.d.ts.map +1 -1
- package/dist/NodeGap.svelte +48 -6
- package/dist/NodeGap.svelte.d.ts.map +1 -1
- package/dist/Session.svelte.d.ts +31 -14
- package/dist/Session.svelte.d.ts.map +1 -1
- package/dist/Session.svelte.js +155 -77
- package/dist/Svedit.svelte +110 -89
- package/dist/Svedit.svelte.d.ts.map +1 -1
- package/dist/{AnnotatedTextProperty.svelte → TextProperty.svelte} +45 -44
- package/dist/TextProperty.svelte.d.ts +7 -0
- package/dist/TextProperty.svelte.d.ts.map +1 -0
- package/dist/Transaction.svelte.d.ts +78 -40
- package/dist/Transaction.svelte.d.ts.map +1 -1
- package/dist/Transaction.svelte.js +412 -234
- package/dist/doc_utils.d.ts +96 -21
- package/dist/doc_utils.d.ts.map +1 -1
- package/dist/doc_utils.js +440 -168
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node_visibility.svelte.d.ts +30 -4
- package/dist/node_visibility.svelte.d.ts.map +1 -1
- package/dist/node_visibility.svelte.js +327 -363
- package/dist/paste_utils.d.ts +3 -2
- package/dist/paste_utils.d.ts.map +1 -1
- package/dist/paste_utils.js +16 -13
- package/dist/transforms.svelte.d.ts.map +1 -1
- package/dist/transforms.svelte.js +5 -6
- package/dist/types.d.ts +112 -42
- package/dist/utils.d.ts +75 -12
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +292 -78
- package/package.json +4 -1
- package/src/lib/Command.svelte.js +85 -27
- package/src/lib/Node.svelte +29 -1
- package/src/lib/NodeArrayProperty.svelte +119 -12
- package/src/lib/NodeGap.svelte +48 -6
- package/src/lib/Session.svelte.js +155 -77
- package/src/lib/Svedit.svelte +110 -89
- package/src/lib/{AnnotatedTextProperty.svelte → TextProperty.svelte} +45 -44
- package/src/lib/Transaction.svelte.js +412 -234
- package/src/lib/doc_utils.js +440 -168
- package/src/lib/index.js +1 -1
- package/src/lib/node_visibility.svelte.js +327 -363
- package/src/lib/paste_utils.js +16 -13
- package/src/lib/transforms.svelte.js +5 -6
- package/src/lib/types.d.ts +112 -42
- package/src/lib/utils.js +292 -78
- package/dist/AnnotatedTextProperty.svelte.d.ts +0 -7
- package/dist/AnnotatedTextProperty.svelte.d.ts.map +0 -1
package/dist/doc_utils.d.ts
CHANGED
|
@@ -55,6 +55,17 @@ export function fill_document_defaults(doc: Document, schema: DocumentSchema): D
|
|
|
55
55
|
* @throws {Error} Throws if the document schema is invalid
|
|
56
56
|
*/
|
|
57
57
|
export function validate_document_schema(document_schema: DocumentSchema): void;
|
|
58
|
+
/**
|
|
59
|
+
* Validate that no annotation node type has a registered component.
|
|
60
|
+
*
|
|
61
|
+
* Marks render in-place via components; annotations are data-only overlay
|
|
62
|
+
* ranges that must be interpreted by the app (via CSS classes or props).
|
|
63
|
+
*
|
|
64
|
+
* @param {DocumentSchema} schema - The document schema
|
|
65
|
+
* @param {any} config - The Svedit config
|
|
66
|
+
* @throws {Error} Throws if a kind 'annotation' type has a registered component
|
|
67
|
+
*/
|
|
68
|
+
export function validate_config_components(schema: DocumentSchema, config: any): void;
|
|
58
69
|
/**
|
|
59
70
|
* @param {string} id
|
|
60
71
|
* @returns {boolean}
|
|
@@ -98,23 +109,13 @@ export function get(schema: DocumentSchema, doc: Document, path: DocumentPath |
|
|
|
98
109
|
*/
|
|
99
110
|
export function property_type(schema: object, type: string, property: string): string;
|
|
100
111
|
/**
|
|
101
|
-
* Determines the kind of a node ('block', 'text', or 'annotation').
|
|
112
|
+
* Determines the kind of a node ('block', 'text', 'mark', or 'annotation').
|
|
102
113
|
*
|
|
103
114
|
* @param {object} schema - The document schema
|
|
104
115
|
* @param {any} node - The node to check
|
|
105
|
-
* @returns {'block'|'text'|'annotation'} The node kind
|
|
116
|
+
* @returns {'block'|'text'|'mark'|'annotation'} The node kind
|
|
106
117
|
*/
|
|
107
|
-
export function kind(schema: object, node: any): "block" | "text" | "annotation";
|
|
108
|
-
/**
|
|
109
|
-
* Checks whether an annotation node can be switched to another annotation type
|
|
110
|
-
* without losing data.
|
|
111
|
-
*
|
|
112
|
-
* @param {DocumentSchema} schema - The document schema
|
|
113
|
-
* @param {any} annotation_node - The annotation node to switch
|
|
114
|
-
* @param {string} target_annotation_type - The target annotation type
|
|
115
|
-
* @returns {boolean} True if the annotation can be switched safely
|
|
116
|
-
*/
|
|
117
|
-
export function can_switch_annotation_type(schema: DocumentSchema, annotation_node: any, target_annotation_type: string): boolean;
|
|
118
|
+
export function kind(schema: object, node: any): "block" | "text" | "mark" | "annotation";
|
|
118
119
|
/**
|
|
119
120
|
* Inspects a path to get metadata about the value at that location.
|
|
120
121
|
*
|
|
@@ -127,6 +128,32 @@ export function inspect(schema: DocumentSchema, doc: Document, path: DocumentPat
|
|
|
127
128
|
kind: "property" | "node";
|
|
128
129
|
[key: string]: any;
|
|
129
130
|
};
|
|
131
|
+
/**
|
|
132
|
+
* Creates a mutable draft of a document: a new document object with a new
|
|
133
|
+
* nodes map, sharing the (immutable) node objects with the original.
|
|
134
|
+
*
|
|
135
|
+
* apply_op_to_draft mutates the draft's nodes map but copies node objects
|
|
136
|
+
* before changing them, so node identity is preserved for unchanged nodes
|
|
137
|
+
* (fine-grained rendering relies on this) and the original document is
|
|
138
|
+
* never touched.
|
|
139
|
+
*
|
|
140
|
+
* @param {Document} doc - The document to create a draft of
|
|
141
|
+
* @returns {Document} A draft document safe to mutate via apply_op_to_draft
|
|
142
|
+
*/
|
|
143
|
+
export function create_document_draft(doc: Document): Document;
|
|
144
|
+
/**
|
|
145
|
+
* Applies an operation to a document draft in place.
|
|
146
|
+
*
|
|
147
|
+
* The draft's nodes map is mutated, but node objects are copied on write —
|
|
148
|
+
* one nodes-map copy per draft (see create_document_draft) replaces the
|
|
149
|
+
* previous one-copy-per-op behavior, which made transactions with many ops
|
|
150
|
+
* (paste, cascade delete) O(N·ops).
|
|
151
|
+
*
|
|
152
|
+
* @param {Document} draft - A draft created via create_document_draft
|
|
153
|
+
* @param {Array} op - The operation to apply [type, ...args]
|
|
154
|
+
* @returns {Document} The same draft, for convenience
|
|
155
|
+
*/
|
|
156
|
+
export function apply_op_to_draft(draft: Document, op: any[]): Document;
|
|
130
157
|
/**
|
|
131
158
|
* Applies an operation to a document and returns the new document.
|
|
132
159
|
* Uses copy-on-write semantics.
|
|
@@ -146,20 +173,44 @@ export function apply_op(doc: Document, op: any[]): Document;
|
|
|
146
173
|
*/
|
|
147
174
|
export function count_references(schema: DocumentSchema, doc: Document, node_id: NodeId): number;
|
|
148
175
|
/**
|
|
149
|
-
*
|
|
176
|
+
* @param {DocumentSchema} schema - The document schema
|
|
177
|
+
* @param {string} from_type - Current mark type
|
|
178
|
+
* @param {string} to_type - Target mark type
|
|
179
|
+
* @returns {boolean} Whether a mark can be switched between these types
|
|
180
|
+
*/
|
|
181
|
+
export function can_switch_mark_type(schema: DocumentSchema, from_type: string, to_type: string): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Gets marks touched by the current selection.
|
|
150
184
|
*
|
|
151
|
-
*
|
|
152
|
-
* -
|
|
153
|
-
* -
|
|
154
|
-
*
|
|
185
|
+
* @param {DocumentSchema} schema - The document schema
|
|
186
|
+
* @param {Document} doc - The document containing nodes
|
|
187
|
+
* @param {Selection} [selection] - The current selection
|
|
188
|
+
* @returns {(Mark & { index: number, node: any })[]} Selected mark records
|
|
189
|
+
*/
|
|
190
|
+
export function get_selected_marks(schema: DocumentSchema, doc: Document, selection?: Selection): (Mark & {
|
|
191
|
+
index: number;
|
|
192
|
+
node: any;
|
|
193
|
+
})[];
|
|
194
|
+
/**
|
|
195
|
+
* Gets annotations touched by the current selection.
|
|
155
196
|
*
|
|
156
197
|
* @param {DocumentSchema} schema - The document schema
|
|
157
198
|
* @param {Document} doc - The document containing nodes
|
|
158
199
|
* @param {Selection} [selection] - The current selection
|
|
159
|
-
* @
|
|
160
|
-
|
|
200
|
+
* @returns {(Annotation & { index: number, node: any })[]} Selected annotation records
|
|
201
|
+
*/
|
|
202
|
+
export function get_selected_annotations(schema: DocumentSchema, doc: Document, selection?: Selection): (Annotation & {
|
|
203
|
+
index: number;
|
|
204
|
+
node: any;
|
|
205
|
+
})[];
|
|
206
|
+
/**
|
|
207
|
+
* @param {(Attachment & { index: number, node: any })[]} selected_ranges
|
|
208
|
+
* @returns {Set<string>} Node types represented in the selected ranges
|
|
161
209
|
*/
|
|
162
|
-
export function
|
|
210
|
+
export function get_selected_range_types(selected_ranges: (Attachment & {
|
|
211
|
+
index: number;
|
|
212
|
+
node: any;
|
|
213
|
+
})[]): Set<string>;
|
|
163
214
|
/**
|
|
164
215
|
* Counts references to a node, excluding nodes marked for deletion.
|
|
165
216
|
*
|
|
@@ -170,6 +221,28 @@ export function get_active_annotation(schema: DocumentSchema, doc: Document, sel
|
|
|
170
221
|
* @returns {number} The number of references excluding deleted nodes
|
|
171
222
|
*/
|
|
172
223
|
export function count_references_excluding_deleted(schema: DocumentSchema, doc: Document, target_node_id: NodeId, nodes_to_delete: Record<NodeId, boolean>): number;
|
|
224
|
+
/**
|
|
225
|
+
* Iterates all node references going out of a node, invoking the visitor
|
|
226
|
+
* once per occurrence (multiplicity matters for reference counting).
|
|
227
|
+
* Covers the same reference kinds as count_references_excluding_deleted:
|
|
228
|
+
* a `node` property, `node_array` .nodes ids, and the mark/annotation
|
|
229
|
+
* node_ids carried on `text` and `node_array` properties.
|
|
230
|
+
*
|
|
231
|
+
* @param {DocumentSchema} schema - The document schema
|
|
232
|
+
* @param {any} node - The node whose outgoing references to visit
|
|
233
|
+
* @param {(referenced_id: NodeId) => void} visit - Called per reference occurrence
|
|
234
|
+
*/
|
|
235
|
+
export function visit_node_references(schema: DocumentSchema, node: any, visit: (referenced_id: NodeId) => void): void;
|
|
236
|
+
/**
|
|
237
|
+
* Builds reference counts for every referenced node in one full-document
|
|
238
|
+
* scan. Used by cascade deletion so the fixpoint can decrement counts
|
|
239
|
+
* incrementally instead of re-scanning the document per candidate node.
|
|
240
|
+
*
|
|
241
|
+
* @param {DocumentSchema} schema - The document schema
|
|
242
|
+
* @param {Document} doc - The document containing nodes
|
|
243
|
+
* @returns {Map<NodeId, number>} Reference count per referenced node id
|
|
244
|
+
*/
|
|
245
|
+
export function build_reference_counts(schema: DocumentSchema, doc: Document): Map<NodeId, number>;
|
|
173
246
|
/**
|
|
174
247
|
* Gets ids of nodes that reference any of the target nodes.
|
|
175
248
|
*
|
|
@@ -201,5 +274,7 @@ import type { Document } from './types';
|
|
|
201
274
|
import type { DocumentPath } from './types';
|
|
202
275
|
import type { NodeId } from './types';
|
|
203
276
|
import type { Selection } from './types';
|
|
277
|
+
import type { Mark } from './types';
|
|
204
278
|
import type { Annotation } from './types';
|
|
279
|
+
import type { Attachment } from './types';
|
|
205
280
|
//# sourceMappingURL=doc_utils.d.ts.map
|
package/dist/doc_utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc_utils.d.ts","sourceRoot":"","sources":["../src/lib/doc_utils.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doc_utils.d.ts","sourceRoot":"","sources":["../src/lib/doc_utils.js"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,uCAJ0C,CAAC,SAA7B,MAAM,CAAC,MAAM,EAAE,UAAU,CAAE,UAC9B,CAAC,GAAG,uBAAuB,CAAC,CAAC,GAC3B,CAAC,CAIb;AAED;;;;GAIG;AACH,wCAHW,MAAM,GACJ,IAAI,IAAI,aAAa,CAejC;AAED;;;;GAIG;AACH,2DAHW,YAAY,GAAG,iBAAiB,GAC9B,MAAM,GAAG,IAAI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