svedit 0.12.0 → 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 +33 -21
- package/dist/Command.svelte.d.ts +38 -30
- package/dist/Command.svelte.d.ts.map +1 -1
- package/dist/Command.svelte.js +271 -326
- 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 +16 -13
- package/dist/Node.svelte.d.ts +3 -5
- package/dist/Node.svelte.d.ts.map +1 -1
- package/dist/NodeArrayProperty.svelte +39 -22
- 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 +12 -6
- 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 +81 -129
- package/dist/Session.svelte.d.ts.map +1 -1
- package/dist/Session.svelte.js +542 -648
- package/dist/Svedit.svelte +144 -138
- package/dist/Svedit.svelte.d.ts +30 -10
- package/dist/Svedit.svelte.d.ts.map +1 -1
- package/dist/TextProperty.svelte +32 -18
- package/dist/TextProperty.svelte.d.ts +3 -5
- package/dist/TextProperty.svelte.d.ts.map +1 -1
- package/dist/Transaction.svelte.d.ts +64 -127
- package/dist/Transaction.svelte.d.ts.map +1 -1
- package/dist/Transaction.svelte.js +839 -1001
- 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 +67 -155
- package/dist/doc_utils.d.ts.map +1 -1
- package/dist/doc_utils.js +619 -863
- package/dist/index.d.ts +20 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -17
- package/dist/node_visibility.svelte.d.ts +110 -9
- package/dist/node_visibility.svelte.d.ts.map +1 -1
- package/dist/node_visibility.svelte.js +473 -544
- package/dist/paste_utils.d.ts +11 -44
- package/dist/paste_utils.d.ts.map +1 -1
- package/dist/paste_utils.js +111 -152
- package/dist/transforms.svelte.d.ts +9 -7
- package/dist/transforms.svelte.d.ts.map +1 -1
- package/dist/transforms.svelte.js +125 -150
- package/dist/types.d.ts +277 -309
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +40 -119
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +346 -473
- package/package.json +69 -70
- package/src/lib/{Command.svelte.js → Command.svelte.ts} +29 -17
- package/src/lib/CustomProperty.svelte +3 -5
- package/src/lib/{KeyMapper.svelte.js → KeyMapper.svelte.ts} +28 -11
- package/src/lib/Node.svelte +16 -13
- package/src/lib/NodeArrayProperty.svelte +39 -22
- package/src/lib/NodeCaret.svelte +1 -1
- package/src/lib/NodeGap.svelte +12 -6
- package/src/lib/NodeGapMarkers.svelte +19 -10
- package/src/lib/NodeSelectionMarkers.svelte +20 -6
- package/src/lib/{Session.svelte.js → Session.svelte.ts} +130 -127
- package/src/lib/Svedit.svelte +144 -138
- package/src/lib/TextProperty.svelte +32 -18
- package/src/lib/{Transaction.svelte.js → Transaction.svelte.ts} +139 -143
- package/src/lib/UnknownNode.svelte +4 -3
- package/src/lib/{doc_utils.js → doc_utils.ts} +247 -206
- package/src/lib/{index.js → index.ts} +47 -0
- package/src/lib/{node_visibility.svelte.js → node_visibility.svelte.ts} +68 -92
- package/src/lib/{paste_utils.js → paste_utils.ts} +47 -58
- package/src/lib/{transforms.svelte.js → transforms.svelte.ts} +39 -21
- package/src/lib/{types.d.ts → types.ts} +143 -66
- package/src/lib/{utils.js → utils.ts} +110 -129
package/dist/TextProperty.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
3
|
import {
|
|
4
4
|
char_slice,
|
|
@@ -9,12 +9,24 @@
|
|
|
9
9
|
calculate_fragment_ranges
|
|
10
10
|
} from './utils.js';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
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({
|
|
@@ -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.
|
|
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
|
-
|
|
28
|
-
doc: object;
|
|
29
|
-
/** @type {Selection} */
|
|
20
|
+
doc: Document;
|
|
30
21
|
selection: Selection;
|
|
31
|
-
config:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
48
|
-
* @returns
|
|
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:
|
|
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:
|
|
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():
|
|
114
|
-
|
|
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():
|
|
127
|
-
|
|
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
|
|
154
|
-
* @param
|
|
155
|
-
* @returns
|
|
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):
|
|
164
|
-
build(node_id:
|
|
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
|
|
172
|
-
* @returns
|
|
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:
|
|
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
|
|
198
|
-
* @returns
|
|
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:
|
|
153
|
+
delete(id: NodeId): this;
|
|
206
154
|
/**
|
|
207
155
|
* Sets the document selection.
|
|
208
156
|
*
|
|
209
|
-
* @param
|
|
210
|
-
* @returns
|
|
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):
|
|
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
|
|
229
|
-
* @param
|
|
230
|
-
* @returns
|
|
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:
|
|
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
|
|
252
|
-
* @param
|
|
253
|
-
* @returns
|
|
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:
|
|
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
|
|
272
|
-
* @returns
|
|
217
|
+
* @param direction - Direction of deletion for collapsed selections
|
|
218
|
+
* @returns This transaction instance for method chaining
|
|
273
219
|
*/
|
|
274
|
-
delete_selection(direction?:
|
|
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
|
|
282
|
-
* @param
|
|
283
|
-
* @param
|
|
284
|
-
* @param
|
|
285
|
-
* @returns
|
|
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,
|
|
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
|
|
297
|
-
* @param
|
|
298
|
-
* @param
|
|
299
|
-
* @param
|
|
300
|
-
* @returns
|
|
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?:
|
|
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
|
|
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.
|
|
1
|
+
{"version":3,"file":"Transaction.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Transaction.svelte.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,KAAK,EACX,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,YAAY,EAEZ,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,aAAa,EACb,MAAM,YAAY,CAAC;AAepB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,GAAG,EAAE,QAAQ,CAAC;IAId,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,EAAE,iBAAiB,EAAE,CAAC;IACzB,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAC;IACnC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,k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