svedit 0.11.1 → 0.13.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 +260 -82
- package/dist/Command.svelte.d.ts +54 -29
- package/dist/Command.svelte.d.ts.map +1 -1
- package/dist/Command.svelte.js +286 -283
- package/dist/CustomProperty.svelte +3 -5
- package/dist/CustomProperty.svelte.d.ts +3 -6
- package/dist/CustomProperty.svelte.d.ts.map +1 -1
- package/dist/KeyMapper.svelte.d.ts +19 -6
- package/dist/KeyMapper.svelte.d.ts.map +1 -1
- package/dist/KeyMapper.svelte.js +95 -112
- package/dist/Node.svelte +40 -9
- package/dist/Node.svelte.d.ts +3 -5
- package/dist/Node.svelte.d.ts.map +1 -1
- package/dist/NodeArrayProperty.svelte +142 -18
- package/dist/NodeArrayProperty.svelte.d.ts +3 -5
- package/dist/NodeArrayProperty.svelte.d.ts.map +1 -1
- package/dist/NodeCaret.svelte +1 -1
- package/dist/NodeCaret.svelte.d.ts +6 -14
- package/dist/NodeCaret.svelte.d.ts.map +1 -1
- package/dist/NodeGap.svelte +60 -12
- package/dist/NodeGap.svelte.d.ts +7 -14
- package/dist/NodeGap.svelte.d.ts.map +1 -1
- package/dist/NodeGapMarkers.svelte +19 -10
- package/dist/NodeGapMarkers.svelte.d.ts +6 -11
- package/dist/NodeGapMarkers.svelte.d.ts.map +1 -1
- package/dist/NodeSelectionMarkers.svelte +20 -6
- package/dist/NodeSelectionMarkers.svelte.d.ts +2 -5
- package/dist/NodeSelectionMarkers.svelte.d.ts.map +1 -1
- package/dist/Session.svelte.d.ts +85 -116
- package/dist/Session.svelte.d.ts.map +1 -1
- package/dist/Session.svelte.js +543 -571
- package/dist/Svedit.svelte +243 -216
- package/dist/Svedit.svelte.d.ts +30 -10
- package/dist/Svedit.svelte.d.ts.map +1 -1
- package/dist/{AnnotatedTextProperty.svelte → TextProperty.svelte} +71 -56
- package/dist/TextProperty.svelte.d.ts +5 -0
- package/dist/TextProperty.svelte.d.ts.map +1 -0
- package/dist/Transaction.svelte.d.ts +101 -126
- package/dist/Transaction.svelte.d.ts.map +1 -1
- package/dist/Transaction.svelte.js +843 -827
- package/dist/UnknownNode.svelte +4 -3
- package/dist/UnknownNode.svelte.d.ts +5 -9
- package/dist/UnknownNode.svelte.d.ts.map +1 -1
- package/dist/doc_utils.d.ts +109 -122
- package/dist/doc_utils.d.ts.map +1 -1
- package/dist/doc_utils.js +726 -698
- package/dist/index.d.ts +20 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -18
- package/dist/node_visibility.svelte.d.ts +132 -5
- package/dist/node_visibility.svelte.d.ts.map +1 -1
- package/dist/node_visibility.svelte.js +535 -642
- package/dist/paste_utils.d.ts +11 -43
- package/dist/paste_utils.d.ts.map +1 -1
- package/dist/paste_utils.js +111 -149
- package/dist/transforms.svelte.d.ts +9 -7
- package/dist/transforms.svelte.d.ts.map +1 -1
- package/dist/transforms.svelte.js +126 -152
- package/dist/types.d.ts +329 -291
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +79 -95
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +392 -305
- package/package.json +69 -67
- package/src/lib/{Command.svelte.js → Command.svelte.ts} +111 -41
- package/src/lib/CustomProperty.svelte +3 -5
- package/src/lib/{KeyMapper.svelte.js → KeyMapper.svelte.ts} +28 -11
- package/src/lib/Node.svelte +40 -9
- package/src/lib/NodeArrayProperty.svelte +142 -18
- package/src/lib/NodeCaret.svelte +1 -1
- package/src/lib/NodeGap.svelte +60 -12
- package/src/lib/NodeGapMarkers.svelte +19 -10
- package/src/lib/NodeSelectionMarkers.svelte +20 -6
- package/src/lib/Session.svelte.ts +656 -0
- package/src/lib/Svedit.svelte +243 -216
- package/src/lib/{AnnotatedTextProperty.svelte → TextProperty.svelte} +71 -56
- package/src/lib/Transaction.svelte.ts +1020 -0
- package/src/lib/UnknownNode.svelte +4 -3
- package/src/lib/doc_utils.ts +1120 -0
- package/src/lib/{index.js → index.ts} +48 -1
- package/src/lib/node_visibility.svelte.ts +658 -0
- package/src/lib/{paste_utils.js → paste_utils.ts} +51 -59
- package/src/lib/{transforms.svelte.js → transforms.svelte.ts} +44 -27
- package/src/lib/{types.d.ts → types.ts} +250 -103
- package/src/lib/utils.ts +660 -0
- package/dist/AnnotatedTextProperty.svelte.d.ts +0 -7
- package/dist/AnnotatedTextProperty.svelte.d.ts.map +0 -1
- package/src/lib/Session.svelte.js +0 -575
- package/src/lib/Transaction.svelte.js +0 -846
- package/src/lib/doc_utils.js +0 -807
- package/src/lib/node_visibility.svelte.js +0 -718
- package/src/lib/utils.js +0 -465
package/dist/UnknownNode.svelte
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
3
|
import Node from './Node.svelte';
|
|
4
|
+
import type { DocumentPath, SveditContext } from './types.js';
|
|
4
5
|
|
|
5
|
-
const svedit = getContext('svedit');
|
|
6
|
-
let { path } = $props();
|
|
6
|
+
const svedit = getContext<SveditContext>('svedit');
|
|
7
|
+
let { path }: { path: DocumentPath } = $props();
|
|
7
8
|
let node = $derived(svedit.session.get(path));
|
|
8
9
|
</script>
|
|
9
10
|
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
type UnknownNode = {
|
|
3
|
-
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
-
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
-
};
|
|
6
|
-
declare const UnknownNode: import("svelte").Component<{
|
|
7
|
-
path: any;
|
|
8
|
-
}, {}, "">;
|
|
1
|
+
import type { DocumentPath } from './types.js';
|
|
9
2
|
type $$ComponentProps = {
|
|
10
|
-
path:
|
|
3
|
+
path: DocumentPath;
|
|
11
4
|
};
|
|
5
|
+
declare const UnknownNode: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type UnknownNode = ReturnType<typeof UnknownNode>;
|
|
7
|
+
export default UnknownNode;
|
|
12
8
|
//# sourceMappingURL=UnknownNode.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnknownNode.svelte.d.ts","sourceRoot":"","sources":["../src/lib/UnknownNode.svelte.
|
|
1
|
+
{"version":3,"file":"UnknownNode.svelte.d.ts","sourceRoot":"","sources":["../src/lib/UnknownNode.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,YAAY,CAAC;AAE7D,KAAK,gBAAgB,GAAI;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC;AAiBjD,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
package/dist/doc_utils.d.ts
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared document utilities used by both Session and Transaction.
|
|
3
|
+
*
|
|
4
|
+
* These functions operate on the core document state (schema, doc, selection, config)
|
|
5
|
+
* without any history management or transaction tracking.
|
|
6
|
+
*/
|
|
7
|
+
import type { NodeId, DocumentPath, PrimitiveType, PropertyDefinition, NodeProperty, NodeArrayProperty, NodeSchema, NodeKind, DocumentSchema, Selection, Attachment, Document, DocumentNode, ValidateDocumentSchema, Inspection, DocumentOperation, SessionConfig } from './types.js';
|
|
1
8
|
/**
|
|
2
9
|
* Identity function — keeps schema at runtime & makes IDE infer types.
|
|
3
10
|
* Similar to your define_schema pattern but for document schemas.
|
|
4
|
-
*
|
|
5
|
-
* @template {Record<string, NodeSchema>} S
|
|
6
|
-
* @param {S & ValidateDocumentSchema<S>} schema - The document schema to validate
|
|
7
|
-
* @returns {S} The same schema, but with type information preserved
|
|
8
11
|
*/
|
|
9
|
-
export function define_document_schema<S extends Record<string, NodeSchema>>(schema: S & ValidateDocumentSchema<S>): S;
|
|
12
|
+
export declare function define_document_schema<S extends Record<string, NodeSchema>>(schema: S & ValidateDocumentSchema<S>): S;
|
|
10
13
|
/**
|
|
11
14
|
* Check if a string represents a valid primitive type.
|
|
12
|
-
* @param {string} type - The type string to check
|
|
13
|
-
* @returns {type is PrimitiveType} True if it's a valid primitive type
|
|
14
15
|
*/
|
|
15
|
-
export function is_primitive_type(type: string): type is PrimitiveType;
|
|
16
|
+
export declare function is_primitive_type(type: string): type is PrimitiveType;
|
|
16
17
|
/**
|
|
17
18
|
* Get the default node type for a property that references nodes.
|
|
18
|
-
*
|
|
19
|
-
* @returns {string | null} The default node type, or null if none specified
|
|
19
|
+
* Returns null if none specified.
|
|
20
20
|
*/
|
|
21
|
-
export function get_default_node_type(property_definition: NodeProperty | NodeArrayProperty): string | null;
|
|
22
|
-
|
|
23
|
-
* @param {import('./types').PropertyDefinition} property_definition
|
|
24
|
-
* @returns {any}
|
|
25
|
-
*/
|
|
26
|
-
export function get_property_default(property_definition: import("./types").PropertyDefinition): any;
|
|
21
|
+
export declare function get_default_node_type(property_definition: NodeProperty | NodeArrayProperty): string | null;
|
|
22
|
+
export declare function get_property_default(property_definition: PropertyDefinition): any;
|
|
27
23
|
/**
|
|
28
24
|
* Fill omitted properties with schema defaults and Svedit's built-in type defaults.
|
|
29
25
|
*
|
|
@@ -32,11 +28,9 @@ export function get_property_default(property_definition: import("./types").Prop
|
|
|
32
28
|
* schema changes cannot be represented by defaults, such as property renames or
|
|
33
29
|
* data transformations.
|
|
34
30
|
*
|
|
35
|
-
* @
|
|
36
|
-
* @param {DocumentSchema} schema - The document schema
|
|
37
|
-
* @returns {any} A shallow copy of the node with cloned default values filled in
|
|
31
|
+
* @returns A shallow copy of the node with cloned default values filled in
|
|
38
32
|
*/
|
|
39
|
-
export function fill_node_defaults(node:
|
|
33
|
+
export declare function fill_node_defaults(node: DocumentNode, schema: DocumentSchema): DocumentNode;
|
|
40
34
|
/**
|
|
41
35
|
* Fill omitted properties with schema defaults and Svedit's built-in type defaults across a document.
|
|
42
36
|
*
|
|
@@ -44,162 +38,155 @@ export function fill_node_defaults(node: any, schema: DocumentSchema): any;
|
|
|
44
38
|
* by itself. Call this as one step in an explicit document migration when it is
|
|
45
39
|
* appropriate.
|
|
46
40
|
*
|
|
47
|
-
* @
|
|
48
|
-
* @param {DocumentSchema} schema - The document schema
|
|
49
|
-
* @returns {Document} A document copy with cloned default values filled in
|
|
41
|
+
* @returns A document copy with cloned default values filled in
|
|
50
42
|
*/
|
|
51
|
-
export function fill_document_defaults(doc: Document, schema: DocumentSchema): Document;
|
|
43
|
+
export declare function fill_document_defaults(doc: Document, schema: DocumentSchema): Document;
|
|
52
44
|
/**
|
|
53
45
|
* Validate a document schema to ensure all referenced node types exist.
|
|
54
|
-
* @param {DocumentSchema} document_schema - The document schema to validate
|
|
55
46
|
* @throws {Error} Throws if the document schema is invalid
|
|
56
47
|
*/
|
|
57
|
-
export function validate_document_schema(document_schema: DocumentSchema): void;
|
|
48
|
+
export declare function validate_document_schema(document_schema: DocumentSchema): void;
|
|
58
49
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
50
|
+
* Validate that no annotation node type has a registered component.
|
|
51
|
+
*
|
|
52
|
+
* Marks render in-place via components; annotations are data-only overlay
|
|
53
|
+
* ranges that must be interpreted by the app (via CSS classes or props).
|
|
54
|
+
*
|
|
55
|
+
* @throws {Error} Throws if a kind 'annotation' type has a registered component
|
|
61
56
|
*/
|
|
62
|
-
export function
|
|
57
|
+
export declare function validate_config_components(schema: DocumentSchema, config: SessionConfig): void;
|
|
58
|
+
export declare function is_id_valid(id: string): boolean;
|
|
63
59
|
/**
|
|
64
60
|
* Validate a node against its schema.
|
|
65
|
-
*
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
61
|
+
*
|
|
62
|
+
* @param node - The node to validate
|
|
63
|
+
* @param schema - The document schema
|
|
64
|
+
* @param all_nodes - All nodes in the document to check references
|
|
65
|
+
* @param options - Validation options
|
|
69
66
|
* @throws {Error} Throws if the node is invalid
|
|
70
67
|
*/
|
|
71
|
-
export function validate_node(node:
|
|
68
|
+
export declare function validate_node(node: DocumentNode, schema: DocumentSchema, all_nodes?: Record<string, DocumentNode>, options?: {
|
|
72
69
|
require_references?: boolean;
|
|
73
70
|
}): void;
|
|
74
71
|
/**
|
|
75
72
|
* Validate a document against its schema.
|
|
76
73
|
*
|
|
77
|
-
* @param {Document} doc - The document to validate
|
|
78
|
-
* @param {DocumentSchema} schema - The document schema
|
|
79
74
|
* @throws {Error} Throws if the document is invalid
|
|
80
75
|
*/
|
|
81
|
-
export function validate_document(doc: Document, schema: DocumentSchema): void;
|
|
76
|
+
export declare function validate_document(doc: Document, schema: DocumentSchema): void;
|
|
82
77
|
/**
|
|
83
78
|
* Gets a value from the document at the specified path.
|
|
84
79
|
*
|
|
85
|
-
* @param
|
|
86
|
-
* @param
|
|
87
|
-
* @param
|
|
88
|
-
* @returns
|
|
80
|
+
* @param schema - The document schema
|
|
81
|
+
* @param doc - The document containing nodes
|
|
82
|
+
* @param path - Array path to the value, or a string node ID
|
|
83
|
+
* @returns The value at the specified path
|
|
89
84
|
*/
|
|
90
|
-
export function get(schema: DocumentSchema, doc: Document, path: DocumentPath | string): any;
|
|
85
|
+
export declare function get(schema: DocumentSchema, doc: Document, path: DocumentPath | string): any;
|
|
91
86
|
/**
|
|
92
87
|
* Gets the type of a property from the schema.
|
|
93
|
-
*
|
|
94
|
-
* @param {object} schema - The document schema
|
|
95
|
-
* @param {string} type - The node type
|
|
96
|
-
* @param {string} property - The property name
|
|
97
|
-
* @returns {string} The property type
|
|
98
88
|
*/
|
|
99
|
-
export function property_type(schema:
|
|
89
|
+
export declare function property_type(schema: DocumentSchema, type: string, property: string): string;
|
|
100
90
|
/**
|
|
101
|
-
* Determines the kind of a node ('block', 'text', or 'annotation').
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
91
|
+
* Determines the kind of a node ('document', 'block', 'text', 'mark', or 'annotation').
|
|
92
|
+
*/
|
|
93
|
+
export declare function kind(schema: DocumentSchema, node: DocumentNode): NodeKind;
|
|
94
|
+
/**
|
|
95
|
+
* Inspects a path to get metadata about the value at that location.
|
|
106
96
|
*/
|
|
107
|
-
export function
|
|
97
|
+
export declare function inspect(schema: DocumentSchema, doc: Document, path: DocumentPath): Inspection;
|
|
108
98
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
99
|
+
* Creates a mutable draft of a document: a new document object with a new
|
|
100
|
+
* nodes map, sharing the (immutable) node objects with the original.
|
|
111
101
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
102
|
+
* apply_op_to_draft mutates the draft's nodes map but copies node objects
|
|
103
|
+
* before changing them, so node identity is preserved for unchanged nodes
|
|
104
|
+
* (fine-grained rendering relies on this) and the original document is
|
|
105
|
+
* never touched.
|
|
106
|
+
*
|
|
107
|
+
* @returns A draft document safe to mutate via apply_op_to_draft
|
|
116
108
|
*/
|
|
117
|
-
export function
|
|
109
|
+
export declare function create_document_draft(doc: Document): Document;
|
|
118
110
|
/**
|
|
119
|
-
*
|
|
111
|
+
* Applies an operation to a document draft in place.
|
|
120
112
|
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
113
|
+
* The draft's nodes map is mutated, but node objects are copied on write —
|
|
114
|
+
* one nodes-map copy per draft (see create_document_draft) replaces the
|
|
115
|
+
* previous one-copy-per-op behavior, which made transactions with many ops
|
|
116
|
+
* (paste, cascade delete) O(N·ops).
|
|
117
|
+
*
|
|
118
|
+
* @param draft - A draft created via create_document_draft
|
|
119
|
+
* @param op - The operation to apply [type, ...args]
|
|
120
|
+
* @returns The same draft, for convenience
|
|
125
121
|
*/
|
|
126
|
-
export function
|
|
127
|
-
kind: "property" | "node";
|
|
128
|
-
[key: string]: any;
|
|
129
|
-
};
|
|
122
|
+
export declare function apply_op_to_draft(draft: Document, op: DocumentOperation): Document;
|
|
130
123
|
/**
|
|
131
124
|
* Applies an operation to a document and returns the new document.
|
|
132
125
|
* Uses copy-on-write semantics.
|
|
133
126
|
*
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
136
|
-
* @returns
|
|
127
|
+
* @param doc - The document to apply the operation to
|
|
128
|
+
* @param op - The operation to apply [type, ...args]
|
|
129
|
+
* @returns The new document with the operation applied
|
|
137
130
|
*/
|
|
138
|
-
export function apply_op(doc: Document, op:
|
|
131
|
+
export declare function apply_op(doc: Document, op: DocumentOperation): Document;
|
|
139
132
|
/**
|
|
140
133
|
* Counts how many times a node is referenced in the document.
|
|
141
|
-
*
|
|
142
|
-
* @param {DocumentSchema} schema - The document schema
|
|
143
|
-
* @param {Document} doc - The document containing nodes
|
|
144
|
-
* @param {NodeId} node_id - The node ID to count references for
|
|
145
|
-
* @returns {number} The number of references
|
|
146
134
|
*/
|
|
147
|
-
export function count_references(schema: DocumentSchema, doc: Document, node_id: NodeId): number;
|
|
135
|
+
export declare function count_references(schema: DocumentSchema, doc: Document, node_id: NodeId): number;
|
|
148
136
|
/**
|
|
149
|
-
*
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
137
|
+
* Whether a mark can be switched between these types.
|
|
138
|
+
*/
|
|
139
|
+
export declare function can_switch_mark_type(schema: DocumentSchema, from_type: string, to_type: string): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* An attachment (mark or annotation) enriched with its index in the parent
|
|
142
|
+
* attachment array and the resolved payload node.
|
|
143
|
+
*/
|
|
144
|
+
export type SelectedAttachment = Attachment & {
|
|
145
|
+
index: number;
|
|
146
|
+
node: DocumentNode;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Gets marks touched by the current selection.
|
|
150
|
+
*/
|
|
151
|
+
export declare function get_selected_marks(schema: DocumentSchema, doc: Document, selection?: Selection | null): SelectedAttachment[];
|
|
152
|
+
/**
|
|
153
|
+
* Gets annotations touched by the current selection.
|
|
154
|
+
*/
|
|
155
|
+
export declare function get_selected_annotations(schema: DocumentSchema, doc: Document, selection?: Selection | null): SelectedAttachment[];
|
|
156
|
+
/**
|
|
157
|
+
* Node types represented in the selected ranges.
|
|
161
158
|
*/
|
|
162
|
-
export function
|
|
159
|
+
export declare function get_selected_range_types(selected_ranges: SelectedAttachment[]): Set<string>;
|
|
163
160
|
/**
|
|
164
161
|
* Counts references to a node, excluding nodes marked for deletion.
|
|
165
|
-
*
|
|
166
|
-
* @param {DocumentSchema} schema - The document schema
|
|
167
|
-
* @param {Document} doc - The document containing nodes
|
|
168
|
-
* @param {NodeId} target_node_id - The node ID to count references for
|
|
169
|
-
* @param {Record<NodeId, boolean>} nodes_to_delete - Nodes marked for deletion
|
|
170
|
-
* @returns {number} The number of references excluding deleted nodes
|
|
171
162
|
*/
|
|
172
|
-
export function count_references_excluding_deleted(schema: DocumentSchema, doc: Document, target_node_id: NodeId, nodes_to_delete: Record<NodeId, boolean>): number;
|
|
163
|
+
export declare function count_references_excluding_deleted(schema: DocumentSchema, doc: Document, target_node_id: NodeId, nodes_to_delete: Record<NodeId, boolean>): number;
|
|
164
|
+
/**
|
|
165
|
+
* Iterates all node references going out of a node, invoking the visitor
|
|
166
|
+
* once per occurrence (multiplicity matters for reference counting).
|
|
167
|
+
* Covers the same reference kinds as count_references_excluding_deleted:
|
|
168
|
+
* a `node` property, `node_array` .nodes ids, and the mark/annotation
|
|
169
|
+
* node_ids carried on `text` and `node_array` properties.
|
|
170
|
+
*/
|
|
171
|
+
export declare function visit_node_references(schema: DocumentSchema, node: DocumentNode, visit: (referenced_id: NodeId) => void): void;
|
|
172
|
+
/**
|
|
173
|
+
* Builds reference counts for every referenced node in one full-document
|
|
174
|
+
* scan. Used by cascade deletion so the fixpoint can decrement counts
|
|
175
|
+
* incrementally instead of re-scanning the document per candidate node.
|
|
176
|
+
*/
|
|
177
|
+
export declare function build_reference_counts(schema: DocumentSchema, doc: Document): Map<NodeId, number>;
|
|
173
178
|
/**
|
|
174
179
|
* Gets ids of nodes that reference any of the target nodes.
|
|
175
|
-
*
|
|
176
|
-
* @param {DocumentSchema} schema - The document schema
|
|
177
|
-
* @param {Document} doc - The document containing nodes
|
|
178
|
-
* @param {Iterable<NodeId>} target_node_ids - Node IDs to find referrers for
|
|
179
|
-
* @returns {NodeId[]} IDs of nodes with references to any target node
|
|
180
180
|
*/
|
|
181
|
-
export function get_referencing_node_ids(schema: DocumentSchema, doc: Document, target_node_ids: Iterable<NodeId>): NodeId[];
|
|
181
|
+
export declare function get_referencing_node_ids(schema: DocumentSchema, doc: Document, target_node_ids: Iterable<NodeId>): NodeId[];
|
|
182
182
|
/**
|
|
183
183
|
* Validates a selection against the current document state.
|
|
184
184
|
* Works with any object that implements get() and inspect() (Session or Transaction).
|
|
185
185
|
*
|
|
186
|
-
* @param {Selection} selection - The selection to validate
|
|
187
|
-
* @param {{ get: Function, inspect: Function }} session_or_transaction - A Session or Transaction instance
|
|
188
186
|
* @throws {Error} Throws if the selection is invalid
|
|
189
187
|
*/
|
|
190
|
-
export function validate_selection(selection: Selection, session_or_transaction: {
|
|
191
|
-
get:
|
|
192
|
-
inspect:
|
|
188
|
+
export declare function validate_selection(selection: Selection | null | undefined, session_or_transaction: {
|
|
189
|
+
get: (path: DocumentPath) => any;
|
|
190
|
+
inspect: (path: DocumentPath) => Inspection;
|
|
193
191
|
}): void;
|
|
194
|
-
import type { NodeSchema } from './types';
|
|
195
|
-
import type { ValidateDocumentSchema } from './types';
|
|
196
|
-
import type { PrimitiveType } from './types';
|
|
197
|
-
import type { NodeProperty } from './types';
|
|
198
|
-
import type { NodeArrayProperty } from './types';
|
|
199
|
-
import type { DocumentSchema } from './types';
|
|
200
|
-
import type { Document } from './types';
|
|
201
|
-
import type { DocumentPath } from './types';
|
|
202
|
-
import type { NodeId } from './types';
|
|
203
|
-
import type { Selection } from './types';
|
|
204
|
-
import type { Annotation } from './types';
|
|
205
192
|
//# 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.
|
|
1
|
+
{"version":3,"file":"doc_utils.d.ts","sourceRoot":"","sources":["../src/lib/doc_utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EACX,MAAM,EACN,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,SAAS,EACT,UAAU,EAGV,QAAQ,EACR,YAAY,EAGZ,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EAC1E,MAAM,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,GACnC,CAAC,CAEH;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,aAAa,CAarE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACpC,mBAAmB,EAAE,YAAY,GAAG,iBAAiB,GACnD,MAAM,GAAG,IAAI,CASf;AAGD,wBAAgB,oBAAoB,CAAC,mBAAmB,EAAE,kBAAkB,GAAG,GAAG,CAmBjF;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAG,YAAY,CAc3F;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,GAAG,QAAQ,CAWtF;AAED;;;GAGG;AACH,w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