@tiptap/extension-node-range 3.20.1 → 3.20.3
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/package.json +5 -5
- package/dist/index.cjs +0 -337
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -47
- package/dist/index.d.ts +0 -47
- package/dist/index.js +0 -306
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-node-range",
|
|
3
3
|
"description": "node range extension for tiptap",
|
|
4
|
-
"version": "3.20.
|
|
4
|
+
"version": "3.20.3",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tiptap/
|
|
40
|
-
"@tiptap/
|
|
39
|
+
"@tiptap/pm": "^3.20.3",
|
|
40
|
+
"@tiptap/core": "^3.20.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@tiptap/core": "^3.20.
|
|
44
|
-
"@tiptap/pm": "^3.20.
|
|
43
|
+
"@tiptap/core": "^3.20.3",
|
|
44
|
+
"@tiptap/pm": "^3.20.3"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsup",
|
package/dist/index.cjs
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
NodeRange: () => NodeRange2,
|
|
24
|
-
NodeRangeSelection: () => NodeRangeSelection,
|
|
25
|
-
default: () => index_default,
|
|
26
|
-
getNodeRangeDecorations: () => getNodeRangeDecorations,
|
|
27
|
-
getSelectionRanges: () => getSelectionRanges,
|
|
28
|
-
isNodeRangeSelection: () => isNodeRangeSelection
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(index_exports);
|
|
31
|
-
|
|
32
|
-
// src/node-range.ts
|
|
33
|
-
var import_core = require("@tiptap/core");
|
|
34
|
-
var import_state3 = require("@tiptap/pm/state");
|
|
35
|
-
|
|
36
|
-
// src/helpers/getNodeRangeDecorations.ts
|
|
37
|
-
var import_view = require("@tiptap/pm/view");
|
|
38
|
-
function getNodeRangeDecorations(ranges) {
|
|
39
|
-
if (!ranges.length) {
|
|
40
|
-
return import_view.DecorationSet.empty;
|
|
41
|
-
}
|
|
42
|
-
const decorations = [];
|
|
43
|
-
const doc = ranges[0].$from.node(0);
|
|
44
|
-
ranges.forEach((range) => {
|
|
45
|
-
const pos = range.$from.pos;
|
|
46
|
-
const node = range.$from.nodeAfter;
|
|
47
|
-
if (!node) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
decorations.push(
|
|
51
|
-
import_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
52
|
-
class: "ProseMirror-selectednoderange"
|
|
53
|
-
})
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
return import_view.DecorationSet.create(doc, decorations);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// src/helpers/getSelectionRanges.ts
|
|
60
|
-
var import_model = require("@tiptap/pm/model");
|
|
61
|
-
var import_state = require("@tiptap/pm/state");
|
|
62
|
-
function getSelectionRanges($from, $to, depth) {
|
|
63
|
-
const ranges = [];
|
|
64
|
-
const doc = $from.node(0);
|
|
65
|
-
if (typeof depth === "number" && depth >= 0) {
|
|
66
|
-
} else if ($from.sameParent($to)) {
|
|
67
|
-
depth = Math.max(0, $from.sharedDepth($to.pos) - 1);
|
|
68
|
-
} else {
|
|
69
|
-
depth = $from.sharedDepth($to.pos);
|
|
70
|
-
}
|
|
71
|
-
const nodeRange = new import_model.NodeRange($from, $to, depth);
|
|
72
|
-
const offset = nodeRange.depth === 0 ? 0 : doc.resolve(nodeRange.start).posAtIndex(0);
|
|
73
|
-
nodeRange.parent.forEach((node, pos) => {
|
|
74
|
-
const from = offset + pos;
|
|
75
|
-
const to = from + node.nodeSize;
|
|
76
|
-
if (from < nodeRange.start || from >= nodeRange.end) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const selectionRange = new import_state.SelectionRange(doc.resolve(from), doc.resolve(to));
|
|
80
|
-
ranges.push(selectionRange);
|
|
81
|
-
});
|
|
82
|
-
return ranges;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// src/helpers/NodeRangeSelection.ts
|
|
86
|
-
var import_state2 = require("@tiptap/pm/state");
|
|
87
|
-
|
|
88
|
-
// src/helpers/NodeRangeBookmark.ts
|
|
89
|
-
var NodeRangeBookmark = class _NodeRangeBookmark {
|
|
90
|
-
constructor(anchor, head) {
|
|
91
|
-
this.anchor = anchor;
|
|
92
|
-
this.head = head;
|
|
93
|
-
}
|
|
94
|
-
map(mapping) {
|
|
95
|
-
return new _NodeRangeBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
96
|
-
}
|
|
97
|
-
resolve(doc) {
|
|
98
|
-
const $anchor = doc.resolve(this.anchor);
|
|
99
|
-
const $head = doc.resolve(this.head);
|
|
100
|
-
return new NodeRangeSelection($anchor, $head);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/helpers/NodeRangeSelection.ts
|
|
105
|
-
var NodeRangeSelection = class _NodeRangeSelection extends import_state2.Selection {
|
|
106
|
-
constructor($anchor, $head, depth, bias = 1) {
|
|
107
|
-
const { doc } = $anchor;
|
|
108
|
-
const isCursor = $anchor === $head;
|
|
109
|
-
const isCursorAtEnd = $anchor.pos === doc.content.size && $head.pos === doc.content.size;
|
|
110
|
-
const $correctedHead = isCursor && !isCursorAtEnd ? doc.resolve($head.pos + (bias > 0 ? 1 : -1)) : $head;
|
|
111
|
-
const $correctedAnchor = isCursor && isCursorAtEnd ? doc.resolve($anchor.pos - (bias > 0 ? 1 : -1)) : $anchor;
|
|
112
|
-
const ranges = getSelectionRanges($correctedAnchor.min($correctedHead), $correctedAnchor.max($correctedHead), depth);
|
|
113
|
-
const $rangeFrom = $correctedHead.pos >= $anchor.pos ? ranges[0].$from : ranges[ranges.length - 1].$to;
|
|
114
|
-
const $rangeTo = $correctedHead.pos >= $anchor.pos ? ranges[ranges.length - 1].$to : ranges[0].$from;
|
|
115
|
-
super($rangeFrom, $rangeTo, ranges);
|
|
116
|
-
this.depth = depth;
|
|
117
|
-
}
|
|
118
|
-
// we can safely ignore this TypeScript error: https://github.com/Microsoft/TypeScript/issues/338
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
get $to() {
|
|
121
|
-
return this.ranges[this.ranges.length - 1].$to;
|
|
122
|
-
}
|
|
123
|
-
eq(other) {
|
|
124
|
-
return other instanceof _NodeRangeSelection && other.$from.pos === this.$from.pos && other.$to.pos === this.$to.pos;
|
|
125
|
-
}
|
|
126
|
-
map(doc, mapping) {
|
|
127
|
-
const $anchor = doc.resolve(mapping.map(this.anchor));
|
|
128
|
-
const $head = doc.resolve(mapping.map(this.head));
|
|
129
|
-
return new _NodeRangeSelection($anchor, $head);
|
|
130
|
-
}
|
|
131
|
-
toJSON() {
|
|
132
|
-
return {
|
|
133
|
-
type: "nodeRange",
|
|
134
|
-
anchor: this.anchor,
|
|
135
|
-
head: this.head
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
get isForwards() {
|
|
139
|
-
return this.head >= this.anchor;
|
|
140
|
-
}
|
|
141
|
-
get isBackwards() {
|
|
142
|
-
return !this.isForwards;
|
|
143
|
-
}
|
|
144
|
-
extendBackwards() {
|
|
145
|
-
const { doc } = this.$from;
|
|
146
|
-
if (this.isForwards && this.ranges.length > 1) {
|
|
147
|
-
const ranges = this.ranges.slice(0, -1);
|
|
148
|
-
const $from2 = ranges[0].$from;
|
|
149
|
-
const $to = ranges[ranges.length - 1].$to;
|
|
150
|
-
return new _NodeRangeSelection($from2, $to, this.depth);
|
|
151
|
-
}
|
|
152
|
-
const firstRange = this.ranges[0];
|
|
153
|
-
const $from = doc.resolve(Math.max(0, firstRange.$from.pos - 1));
|
|
154
|
-
return new _NodeRangeSelection(this.$anchor, $from, this.depth);
|
|
155
|
-
}
|
|
156
|
-
extendForwards() {
|
|
157
|
-
const { doc } = this.$from;
|
|
158
|
-
if (this.isBackwards && this.ranges.length > 1) {
|
|
159
|
-
const ranges = this.ranges.slice(1);
|
|
160
|
-
const $from = ranges[0].$from;
|
|
161
|
-
const $to2 = ranges[ranges.length - 1].$to;
|
|
162
|
-
return new _NodeRangeSelection($to2, $from, this.depth);
|
|
163
|
-
}
|
|
164
|
-
const lastRange = this.ranges[this.ranges.length - 1];
|
|
165
|
-
const $to = doc.resolve(Math.min(doc.content.size, lastRange.$to.pos + 1));
|
|
166
|
-
return new _NodeRangeSelection(this.$anchor, $to, this.depth);
|
|
167
|
-
}
|
|
168
|
-
static fromJSON(doc, json) {
|
|
169
|
-
return new _NodeRangeSelection(doc.resolve(json.anchor), doc.resolve(json.head));
|
|
170
|
-
}
|
|
171
|
-
static create(doc, anchor, head, depth, bias = 1) {
|
|
172
|
-
return new this(doc.resolve(anchor), doc.resolve(head), depth, bias);
|
|
173
|
-
}
|
|
174
|
-
getBookmark() {
|
|
175
|
-
return new NodeRangeBookmark(this.anchor, this.head);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
NodeRangeSelection.prototype.visible = false;
|
|
179
|
-
|
|
180
|
-
// src/helpers/isNodeRangeSelection.ts
|
|
181
|
-
function isNodeRangeSelection(value) {
|
|
182
|
-
return value instanceof NodeRangeSelection;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// src/node-range.ts
|
|
186
|
-
var NodeRange2 = import_core.Extension.create({
|
|
187
|
-
name: "nodeRange",
|
|
188
|
-
addOptions() {
|
|
189
|
-
return {
|
|
190
|
-
depth: void 0,
|
|
191
|
-
key: "Mod"
|
|
192
|
-
};
|
|
193
|
-
},
|
|
194
|
-
addKeyboardShortcuts() {
|
|
195
|
-
return {
|
|
196
|
-
// extend NodeRangeSelection upwards
|
|
197
|
-
"Shift-ArrowUp": ({ editor }) => {
|
|
198
|
-
const { depth } = this.options;
|
|
199
|
-
const { view, state } = editor;
|
|
200
|
-
const { doc, selection, tr } = state;
|
|
201
|
-
const { anchor, head } = selection;
|
|
202
|
-
if (!isNodeRangeSelection(selection)) {
|
|
203
|
-
const nodeRangeSelection2 = NodeRangeSelection.create(doc, anchor, head, depth, -1);
|
|
204
|
-
tr.setSelection(nodeRangeSelection2);
|
|
205
|
-
view.dispatch(tr);
|
|
206
|
-
return true;
|
|
207
|
-
}
|
|
208
|
-
const nodeRangeSelection = selection.extendBackwards();
|
|
209
|
-
tr.setSelection(nodeRangeSelection);
|
|
210
|
-
view.dispatch(tr);
|
|
211
|
-
return true;
|
|
212
|
-
},
|
|
213
|
-
// extend NodeRangeSelection downwards
|
|
214
|
-
"Shift-ArrowDown": ({ editor }) => {
|
|
215
|
-
const { depth } = this.options;
|
|
216
|
-
const { view, state } = editor;
|
|
217
|
-
const { doc, selection, tr } = state;
|
|
218
|
-
const { anchor, head } = selection;
|
|
219
|
-
if (!isNodeRangeSelection(selection)) {
|
|
220
|
-
const nodeRangeSelection2 = NodeRangeSelection.create(doc, anchor, head, depth);
|
|
221
|
-
tr.setSelection(nodeRangeSelection2);
|
|
222
|
-
view.dispatch(tr);
|
|
223
|
-
return true;
|
|
224
|
-
}
|
|
225
|
-
const nodeRangeSelection = selection.extendForwards();
|
|
226
|
-
tr.setSelection(nodeRangeSelection);
|
|
227
|
-
view.dispatch(tr);
|
|
228
|
-
return true;
|
|
229
|
-
},
|
|
230
|
-
// add `NodeRangeSelection` to all nodes
|
|
231
|
-
"Mod-a": ({ editor }) => {
|
|
232
|
-
const { depth } = this.options;
|
|
233
|
-
const { view, state } = editor;
|
|
234
|
-
const { doc, tr } = state;
|
|
235
|
-
const nodeRangeSelection = NodeRangeSelection.create(doc, 0, doc.content.size, depth);
|
|
236
|
-
tr.setSelection(nodeRangeSelection);
|
|
237
|
-
view.dispatch(tr);
|
|
238
|
-
return true;
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
},
|
|
242
|
-
onSelectionUpdate() {
|
|
243
|
-
const { selection } = this.editor.state;
|
|
244
|
-
if (isNodeRangeSelection(selection)) {
|
|
245
|
-
this.editor.view.dom.classList.add("ProseMirror-noderangeselection");
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
addProseMirrorPlugins() {
|
|
249
|
-
let hideTextSelection = false;
|
|
250
|
-
let activeMouseSelection = false;
|
|
251
|
-
return [
|
|
252
|
-
new import_state3.Plugin({
|
|
253
|
-
key: new import_state3.PluginKey("nodeRange"),
|
|
254
|
-
props: {
|
|
255
|
-
attributes: () => {
|
|
256
|
-
if (hideTextSelection) {
|
|
257
|
-
return {
|
|
258
|
-
class: "ProseMirror-noderangeselection"
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
return { class: "" };
|
|
262
|
-
},
|
|
263
|
-
handleDOMEvents: {
|
|
264
|
-
mousedown: (view, event) => {
|
|
265
|
-
const { key } = this.options;
|
|
266
|
-
const isMac = /Mac/.test(navigator.platform);
|
|
267
|
-
const isShift = !!event.shiftKey;
|
|
268
|
-
const isControl = !!event.ctrlKey;
|
|
269
|
-
const isAlt = !!event.altKey;
|
|
270
|
-
const isMeta = !!event.metaKey;
|
|
271
|
-
const isMod = isMac ? isMeta : isControl;
|
|
272
|
-
if (key === null || key === void 0 || key === "Shift" && isShift || key === "Control" && isControl || key === "Alt" && isAlt || key === "Meta" && isMeta || key === "Mod" && isMod) {
|
|
273
|
-
activeMouseSelection = true;
|
|
274
|
-
}
|
|
275
|
-
if (!activeMouseSelection) {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
document.addEventListener(
|
|
279
|
-
"mouseup",
|
|
280
|
-
() => {
|
|
281
|
-
activeMouseSelection = false;
|
|
282
|
-
const { state } = view;
|
|
283
|
-
const { doc, selection, tr } = state;
|
|
284
|
-
const { $anchor, $head } = selection;
|
|
285
|
-
if ($anchor.sameParent($head)) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const nodeRangeSelection = NodeRangeSelection.create(doc, $anchor.pos, $head.pos, this.options.depth);
|
|
289
|
-
tr.setSelection(nodeRangeSelection);
|
|
290
|
-
view.dispatch(tr);
|
|
291
|
-
},
|
|
292
|
-
{ once: true }
|
|
293
|
-
);
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
// when selecting some text we want to render some decorations
|
|
298
|
-
// to preview a `NodeRangeSelection`
|
|
299
|
-
decorations: (state) => {
|
|
300
|
-
const { selection } = state;
|
|
301
|
-
const isNodeRange = isNodeRangeSelection(selection);
|
|
302
|
-
hideTextSelection = false;
|
|
303
|
-
if (!activeMouseSelection) {
|
|
304
|
-
if (!isNodeRange) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
hideTextSelection = true;
|
|
308
|
-
return getNodeRangeDecorations(selection.ranges);
|
|
309
|
-
}
|
|
310
|
-
const { $from, $to } = selection;
|
|
311
|
-
if (!isNodeRange && $from.sameParent($to)) {
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
const nodeRanges = getSelectionRanges($from, $to, this.options.depth);
|
|
315
|
-
if (!nodeRanges.length) {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
hideTextSelection = true;
|
|
319
|
-
return getNodeRangeDecorations(nodeRanges);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
})
|
|
323
|
-
];
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
// src/index.ts
|
|
328
|
-
var index_default = NodeRange2;
|
|
329
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
330
|
-
0 && (module.exports = {
|
|
331
|
-
NodeRange,
|
|
332
|
-
NodeRangeSelection,
|
|
333
|
-
getNodeRangeDecorations,
|
|
334
|
-
getSelectionRanges,
|
|
335
|
-
isNodeRangeSelection
|
|
336
|
-
});
|
|
337
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/node-range.ts","../src/helpers/getNodeRangeDecorations.ts","../src/helpers/getSelectionRanges.ts","../src/helpers/NodeRangeSelection.ts","../src/helpers/NodeRangeBookmark.ts","../src/helpers/isNodeRangeSelection.ts"],"sourcesContent":["import { NodeRange } from './node-range.js'\n\nexport * from './helpers/getNodeRangeDecorations.js'\nexport * from './helpers/getSelectionRanges.js'\nexport * from './helpers/isNodeRangeSelection.js'\nexport * from './helpers/NodeRangeSelection.js'\nexport * from './node-range.js'\n\nexport default NodeRange\n","import { Extension } from '@tiptap/core'\nimport type { SelectionRange } from '@tiptap/pm/state'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { getNodeRangeDecorations } from './helpers/getNodeRangeDecorations.js'\nimport { getSelectionRanges } from './helpers/getSelectionRanges.js'\nimport { isNodeRangeSelection } from './helpers/isNodeRangeSelection.js'\nimport { NodeRangeSelection } from './helpers/NodeRangeSelection.js'\n\nexport interface NodeRangeOptions {\n depth: number | undefined\n key: 'Shift' | 'Control' | 'Alt' | 'Meta' | 'Mod' | null | undefined\n}\n\nexport const NodeRange = Extension.create<NodeRangeOptions>({\n name: 'nodeRange',\n\n addOptions() {\n return {\n depth: undefined,\n key: 'Mod',\n }\n },\n\n addKeyboardShortcuts() {\n return {\n // extend NodeRangeSelection upwards\n 'Shift-ArrowUp': ({ editor }) => {\n const { depth } = this.options\n const { view, state } = editor\n const { doc, selection, tr } = state\n const { anchor, head } = selection\n\n if (!isNodeRangeSelection(selection)) {\n const nodeRangeSelection = NodeRangeSelection.create(doc, anchor, head, depth, -1)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n }\n\n const nodeRangeSelection = selection.extendBackwards()\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n },\n\n // extend NodeRangeSelection downwards\n 'Shift-ArrowDown': ({ editor }) => {\n const { depth } = this.options\n const { view, state } = editor\n const { doc, selection, tr } = state\n const { anchor, head } = selection\n\n if (!isNodeRangeSelection(selection)) {\n const nodeRangeSelection = NodeRangeSelection.create(doc, anchor, head, depth)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n }\n\n const nodeRangeSelection = selection.extendForwards()\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n },\n\n // add `NodeRangeSelection` to all nodes\n 'Mod-a': ({ editor }) => {\n const { depth } = this.options\n const { view, state } = editor\n const { doc, tr } = state\n const nodeRangeSelection = NodeRangeSelection.create(doc, 0, doc.content.size, depth)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n },\n }\n },\n\n onSelectionUpdate() {\n const { selection } = this.editor.state\n\n if (isNodeRangeSelection(selection)) {\n this.editor.view.dom.classList.add('ProseMirror-noderangeselection')\n }\n },\n\n addProseMirrorPlugins() {\n let hideTextSelection = false\n let activeMouseSelection = false\n\n return [\n new Plugin({\n key: new PluginKey('nodeRange'),\n\n props: {\n attributes: () => {\n if (hideTextSelection) {\n return {\n class: 'ProseMirror-noderangeselection',\n }\n }\n\n return { class: '' }\n },\n\n handleDOMEvents: {\n mousedown: (view, event) => {\n const { key } = this.options\n const isMac = /Mac/.test(navigator.platform)\n const isShift = !!event.shiftKey\n const isControl = !!event.ctrlKey\n const isAlt = !!event.altKey\n const isMeta = !!event.metaKey\n const isMod = isMac ? isMeta : isControl\n\n if (\n key === null ||\n key === undefined ||\n (key === 'Shift' && isShift) ||\n (key === 'Control' && isControl) ||\n (key === 'Alt' && isAlt) ||\n (key === 'Meta' && isMeta) ||\n (key === 'Mod' && isMod)\n ) {\n activeMouseSelection = true\n }\n\n if (!activeMouseSelection) {\n return false\n }\n\n document.addEventListener(\n 'mouseup',\n () => {\n activeMouseSelection = false\n\n const { state } = view\n const { doc, selection, tr } = state\n const { $anchor, $head } = selection\n\n if ($anchor.sameParent($head)) {\n return\n }\n\n const nodeRangeSelection = NodeRangeSelection.create(doc, $anchor.pos, $head.pos, this.options.depth)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n },\n { once: true },\n )\n\n return false\n },\n },\n\n // when selecting some text we want to render some decorations\n // to preview a `NodeRangeSelection`\n decorations: state => {\n const { selection } = state\n const isNodeRange = isNodeRangeSelection(selection)\n\n hideTextSelection = false\n\n if (!activeMouseSelection) {\n if (!isNodeRange) {\n return null\n }\n\n hideTextSelection = true\n\n return getNodeRangeDecorations(selection.ranges as SelectionRange[])\n }\n\n const { $from, $to } = selection\n\n // selection is probably in the same node like a paragraph\n // so we don’t render decorations and show\n // a simple text selection instead\n if (!isNodeRange && $from.sameParent($to)) {\n return null\n }\n\n // try to calculate some node ranges\n const nodeRanges = getSelectionRanges($from, $to, this.options.depth)\n\n if (!nodeRanges.length) {\n return null\n }\n\n hideTextSelection = true\n\n return getNodeRangeDecorations(nodeRanges)\n },\n },\n }),\n ]\n },\n})\n","import type { SelectionRange } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport function getNodeRangeDecorations(ranges: SelectionRange[]): DecorationSet {\n if (!ranges.length) {\n return DecorationSet.empty\n }\n\n const decorations: Decoration[] = []\n const doc = ranges[0].$from.node(0)\n\n ranges.forEach(range => {\n const pos = range.$from.pos\n const node = range.$from.nodeAfter\n\n if (!node) {\n return\n }\n\n decorations.push(\n Decoration.node(pos, pos + node.nodeSize, {\n class: 'ProseMirror-selectednoderange',\n }),\n )\n })\n\n return DecorationSet.create(doc, decorations)\n}\n","import { type ResolvedPos, NodeRange } from '@tiptap/pm/model'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nexport function getSelectionRanges($from: ResolvedPos, $to: ResolvedPos, depth?: number): SelectionRange[] {\n const ranges: SelectionRange[] = []\n const doc = $from.node(0)\n\n // Determine the appropriate depth\n if (typeof depth === 'number' && depth >= 0) {\n // Use the provided depth\n } else if ($from.sameParent($to)) {\n depth = Math.max(0, $from.sharedDepth($to.pos) - 1)\n } else {\n depth = $from.sharedDepth($to.pos)\n }\n\n const nodeRange = new NodeRange($from, $to, depth)\n const offset = nodeRange.depth === 0 ? 0 : doc.resolve(nodeRange.start).posAtIndex(0)\n\n nodeRange.parent.forEach((node, pos) => {\n const from = offset + pos\n const to = from + node.nodeSize\n\n if (from < nodeRange.start || from >= nodeRange.end) {\n return\n }\n\n const selectionRange = new SelectionRange(doc.resolve(from), doc.resolve(to))\n\n ranges.push(selectionRange)\n })\n\n return ranges\n}\n","import type { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'\nimport { Selection } from '@tiptap/pm/state'\nimport type { Mapping } from '@tiptap/pm/transform'\n\nimport { getSelectionRanges } from './getSelectionRanges.js'\nimport { NodeRangeBookmark } from './NodeRangeBookmark.js'\n\nexport class NodeRangeSelection extends Selection {\n depth: number | undefined\n\n constructor($anchor: ResolvedPos, $head: ResolvedPos, depth?: number, bias = 1) {\n // if there is only a cursor we can’t calculate a direction of the selection\n // that’s why we adjust the head position by 1 in the desired direction\n const { doc } = $anchor\n const isCursor = $anchor === $head\n const isCursorAtEnd = $anchor.pos === doc.content.size && $head.pos === doc.content.size\n const $correctedHead = isCursor && !isCursorAtEnd ? doc.resolve($head.pos + (bias > 0 ? 1 : -1)) : $head\n const $correctedAnchor = isCursor && isCursorAtEnd ? doc.resolve($anchor.pos - (bias > 0 ? 1 : -1)) : $anchor\n\n const ranges = getSelectionRanges($correctedAnchor.min($correctedHead), $correctedAnchor.max($correctedHead), depth)\n\n // get the smallest range start position\n // this will become the $anchor\n const $rangeFrom = $correctedHead.pos >= $anchor.pos ? ranges[0].$from : ranges[ranges.length - 1].$to\n\n // get the biggest range end position\n // this will become the $head\n const $rangeTo = $correctedHead.pos >= $anchor.pos ? ranges[ranges.length - 1].$to : ranges[0].$from\n\n super($rangeFrom, $rangeTo, ranges)\n\n this.depth = depth\n }\n\n // we can safely ignore this TypeScript error: https://github.com/Microsoft/TypeScript/issues/338\n // @ts-ignore\n get $to() {\n return this.ranges[this.ranges.length - 1].$to\n }\n\n eq(other: Selection): boolean {\n return other instanceof NodeRangeSelection && other.$from.pos === this.$from.pos && other.$to.pos === this.$to.pos\n }\n\n map(doc: ProseMirrorNode, mapping: Mapping): NodeRangeSelection {\n const $anchor = doc.resolve(mapping.map(this.anchor))\n const $head = doc.resolve(mapping.map(this.head))\n\n return new NodeRangeSelection($anchor, $head)\n }\n\n toJSON() {\n return {\n type: 'nodeRange',\n anchor: this.anchor,\n head: this.head,\n }\n }\n\n get isForwards(): boolean {\n return this.head >= this.anchor\n }\n\n get isBackwards(): boolean {\n return !this.isForwards\n }\n\n extendBackwards(): NodeRangeSelection {\n const { doc } = this.$from\n\n if (this.isForwards && this.ranges.length > 1) {\n const ranges = this.ranges.slice(0, -1)\n const $from = ranges[0].$from\n const $to = ranges[ranges.length - 1].$to\n\n return new NodeRangeSelection($from, $to, this.depth)\n }\n\n const firstRange = this.ranges[0]\n const $from = doc.resolve(Math.max(0, firstRange.$from.pos - 1))\n\n return new NodeRangeSelection(this.$anchor, $from, this.depth)\n }\n\n extendForwards(): NodeRangeSelection {\n const { doc } = this.$from\n\n if (this.isBackwards && this.ranges.length > 1) {\n const ranges = this.ranges.slice(1)\n const $from = ranges[0].$from\n const $to = ranges[ranges.length - 1].$to\n\n return new NodeRangeSelection($to, $from, this.depth)\n }\n\n const lastRange = this.ranges[this.ranges.length - 1]\n const $to = doc.resolve(Math.min(doc.content.size, lastRange.$to.pos + 1))\n\n return new NodeRangeSelection(this.$anchor, $to, this.depth)\n }\n\n static fromJSON(doc: ProseMirrorNode, json: any): NodeRangeSelection {\n return new NodeRangeSelection(doc.resolve(json.anchor), doc.resolve(json.head))\n }\n\n static create(doc: ProseMirrorNode, anchor: number, head: number, depth?: number, bias = 1): NodeRangeSelection {\n return new this(doc.resolve(anchor), doc.resolve(head), depth, bias)\n }\n\n getBookmark(): NodeRangeBookmark {\n return new NodeRangeBookmark(this.anchor, this.head)\n }\n}\n\nNodeRangeSelection.prototype.visible = false\n","import type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { Mappable } from '@tiptap/pm/transform'\n\nimport { NodeRangeSelection } from './NodeRangeSelection.js'\n\nexport class NodeRangeBookmark {\n anchor!: number\n\n head!: number\n\n constructor(anchor: number, head: number) {\n this.anchor = anchor\n this.head = head\n }\n\n map(mapping: Mappable) {\n return new NodeRangeBookmark(mapping.map(this.anchor), mapping.map(this.head))\n }\n\n resolve(doc: ProseMirrorNode) {\n const $anchor = doc.resolve(this.anchor)\n const $head = doc.resolve(this.head)\n\n return new NodeRangeSelection($anchor, $head)\n }\n}\n","import { NodeRangeSelection } from './NodeRangeSelection.js'\n\nexport function isNodeRangeSelection(value: unknown): value is NodeRangeSelection {\n return value instanceof Node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vB,wBAAM,EAAE,MAAM,IAAI;AAClB,wBAAM,EAAE,KAAK,WAAW,GAAG,IAAI;AAC/B,wBAAM,EAAE,SAAS,MAAM,IAAI;AAE3B,sBAAI,QAAQ,WAAW,KAAK,GAAG;AAC7B;AAAA,kBACF;AAEA,wBAAM,qBAAqB,mBAAmB,OAAO,KAAK,QAAQ,KAAK,MAAM,KAAK,KAAK,QAAQ,KAAK;AAEpG,qBAAG,aAAa,kBAAkB;AAClC,uBAAK,SAAS,EAAE;AAAA,gBAClB;AAAA,gBACA,EAAE,MAAM,KAAK;AAAA,cACf;AAEA,qBAAO;AAAA,YACT;AAAA,UACF;AAAA;AAAA;AAAA,UAIA,aAAa,WAAS;AACpB,kBAAM,EAAE,UAAU,IAAI;AACtB,kBAAM,cAAc,qBAAqB,SAAS;AAElD,gCAAoB;AAEpB,gBAAI,CAAC,sBAAsB;AACzB,kBAAI,CAAC,aAAa;AAChB,uBAAO;AAAA,cACT;AAEA,kCAAoB;AAEpB,qBAAO,wBAAwB,UAAU,MAA0B;AAAA,YACrE;AAEA,kBAAM,EAAE,OAAO,IAAI,IAAI;AAKvB,gBAAI,CAAC,eAAe,MAAM,WAAW,GAAG,GAAG;AACzC,qBAAO;AAAA,YACT;AAGA,kBAAM,aAAa,mBAAmB,OAAO,KAAK,KAAK,QAAQ,KAAK;AAEpE,gBAAI,CAAC,WAAW,QAAQ;AACtB,qBAAO;AAAA,YACT;AAEA,gCAAoB;AAEpB,mBAAO,wBAAwB,UAAU;AAAA,UAC3C;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;ADzMD,IAAO,gBAAQC;","names":["NodeRange","import_state","import_state","$from","$to","NodeRange","nodeRangeSelection","NodeRange"]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { SelectionRange, Selection } from '@tiptap/pm/state';
|
|
3
|
-
import { DecorationSet } from '@tiptap/pm/view';
|
|
4
|
-
import { ResolvedPos, Node } from '@tiptap/pm/model';
|
|
5
|
-
import { Mappable, Mapping } from '@tiptap/pm/transform';
|
|
6
|
-
|
|
7
|
-
interface NodeRangeOptions {
|
|
8
|
-
depth: number | undefined;
|
|
9
|
-
key: 'Shift' | 'Control' | 'Alt' | 'Meta' | 'Mod' | null | undefined;
|
|
10
|
-
}
|
|
11
|
-
declare const NodeRange: Extension<NodeRangeOptions, any>;
|
|
12
|
-
|
|
13
|
-
declare function getNodeRangeDecorations(ranges: SelectionRange[]): DecorationSet;
|
|
14
|
-
|
|
15
|
-
declare function getSelectionRanges($from: ResolvedPos, $to: ResolvedPos, depth?: number): SelectionRange[];
|
|
16
|
-
|
|
17
|
-
declare class NodeRangeBookmark {
|
|
18
|
-
anchor: number;
|
|
19
|
-
head: number;
|
|
20
|
-
constructor(anchor: number, head: number);
|
|
21
|
-
map(mapping: Mappable): NodeRangeBookmark;
|
|
22
|
-
resolve(doc: Node): NodeRangeSelection;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
declare class NodeRangeSelection extends Selection {
|
|
26
|
-
depth: number | undefined;
|
|
27
|
-
constructor($anchor: ResolvedPos, $head: ResolvedPos, depth?: number, bias?: number);
|
|
28
|
-
get $to(): ResolvedPos;
|
|
29
|
-
eq(other: Selection): boolean;
|
|
30
|
-
map(doc: Node, mapping: Mapping): NodeRangeSelection;
|
|
31
|
-
toJSON(): {
|
|
32
|
-
type: string;
|
|
33
|
-
anchor: number;
|
|
34
|
-
head: number;
|
|
35
|
-
};
|
|
36
|
-
get isForwards(): boolean;
|
|
37
|
-
get isBackwards(): boolean;
|
|
38
|
-
extendBackwards(): NodeRangeSelection;
|
|
39
|
-
extendForwards(): NodeRangeSelection;
|
|
40
|
-
static fromJSON(doc: Node, json: any): NodeRangeSelection;
|
|
41
|
-
static create(doc: Node, anchor: number, head: number, depth?: number, bias?: number): NodeRangeSelection;
|
|
42
|
-
getBookmark(): NodeRangeBookmark;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
declare function isNodeRangeSelection(value: unknown): value is NodeRangeSelection;
|
|
46
|
-
|
|
47
|
-
export { NodeRange, type NodeRangeOptions, NodeRangeSelection, NodeRange as default, getNodeRangeDecorations, getSelectionRanges, isNodeRangeSelection };
|
package/dist/index.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { SelectionRange, Selection } from '@tiptap/pm/state';
|
|
3
|
-
import { DecorationSet } from '@tiptap/pm/view';
|
|
4
|
-
import { ResolvedPos, Node } from '@tiptap/pm/model';
|
|
5
|
-
import { Mappable, Mapping } from '@tiptap/pm/transform';
|
|
6
|
-
|
|
7
|
-
interface NodeRangeOptions {
|
|
8
|
-
depth: number | undefined;
|
|
9
|
-
key: 'Shift' | 'Control' | 'Alt' | 'Meta' | 'Mod' | null | undefined;
|
|
10
|
-
}
|
|
11
|
-
declare const NodeRange: Extension<NodeRangeOptions, any>;
|
|
12
|
-
|
|
13
|
-
declare function getNodeRangeDecorations(ranges: SelectionRange[]): DecorationSet;
|
|
14
|
-
|
|
15
|
-
declare function getSelectionRanges($from: ResolvedPos, $to: ResolvedPos, depth?: number): SelectionRange[];
|
|
16
|
-
|
|
17
|
-
declare class NodeRangeBookmark {
|
|
18
|
-
anchor: number;
|
|
19
|
-
head: number;
|
|
20
|
-
constructor(anchor: number, head: number);
|
|
21
|
-
map(mapping: Mappable): NodeRangeBookmark;
|
|
22
|
-
resolve(doc: Node): NodeRangeSelection;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
declare class NodeRangeSelection extends Selection {
|
|
26
|
-
depth: number | undefined;
|
|
27
|
-
constructor($anchor: ResolvedPos, $head: ResolvedPos, depth?: number, bias?: number);
|
|
28
|
-
get $to(): ResolvedPos;
|
|
29
|
-
eq(other: Selection): boolean;
|
|
30
|
-
map(doc: Node, mapping: Mapping): NodeRangeSelection;
|
|
31
|
-
toJSON(): {
|
|
32
|
-
type: string;
|
|
33
|
-
anchor: number;
|
|
34
|
-
head: number;
|
|
35
|
-
};
|
|
36
|
-
get isForwards(): boolean;
|
|
37
|
-
get isBackwards(): boolean;
|
|
38
|
-
extendBackwards(): NodeRangeSelection;
|
|
39
|
-
extendForwards(): NodeRangeSelection;
|
|
40
|
-
static fromJSON(doc: Node, json: any): NodeRangeSelection;
|
|
41
|
-
static create(doc: Node, anchor: number, head: number, depth?: number, bias?: number): NodeRangeSelection;
|
|
42
|
-
getBookmark(): NodeRangeBookmark;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
declare function isNodeRangeSelection(value: unknown): value is NodeRangeSelection;
|
|
46
|
-
|
|
47
|
-
export { NodeRange, type NodeRangeOptions, NodeRangeSelection, NodeRange as default, getNodeRangeDecorations, getSelectionRanges, isNodeRangeSelection };
|
package/dist/index.js
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
// src/node-range.ts
|
|
2
|
-
import { Extension } from "@tiptap/core";
|
|
3
|
-
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
4
|
-
|
|
5
|
-
// src/helpers/getNodeRangeDecorations.ts
|
|
6
|
-
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
7
|
-
function getNodeRangeDecorations(ranges) {
|
|
8
|
-
if (!ranges.length) {
|
|
9
|
-
return DecorationSet.empty;
|
|
10
|
-
}
|
|
11
|
-
const decorations = [];
|
|
12
|
-
const doc = ranges[0].$from.node(0);
|
|
13
|
-
ranges.forEach((range) => {
|
|
14
|
-
const pos = range.$from.pos;
|
|
15
|
-
const node = range.$from.nodeAfter;
|
|
16
|
-
if (!node) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
decorations.push(
|
|
20
|
-
Decoration.node(pos, pos + node.nodeSize, {
|
|
21
|
-
class: "ProseMirror-selectednoderange"
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
return DecorationSet.create(doc, decorations);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/helpers/getSelectionRanges.ts
|
|
29
|
-
import { NodeRange } from "@tiptap/pm/model";
|
|
30
|
-
import { SelectionRange } from "@tiptap/pm/state";
|
|
31
|
-
function getSelectionRanges($from, $to, depth) {
|
|
32
|
-
const ranges = [];
|
|
33
|
-
const doc = $from.node(0);
|
|
34
|
-
if (typeof depth === "number" && depth >= 0) {
|
|
35
|
-
} else if ($from.sameParent($to)) {
|
|
36
|
-
depth = Math.max(0, $from.sharedDepth($to.pos) - 1);
|
|
37
|
-
} else {
|
|
38
|
-
depth = $from.sharedDepth($to.pos);
|
|
39
|
-
}
|
|
40
|
-
const nodeRange = new NodeRange($from, $to, depth);
|
|
41
|
-
const offset = nodeRange.depth === 0 ? 0 : doc.resolve(nodeRange.start).posAtIndex(0);
|
|
42
|
-
nodeRange.parent.forEach((node, pos) => {
|
|
43
|
-
const from = offset + pos;
|
|
44
|
-
const to = from + node.nodeSize;
|
|
45
|
-
if (from < nodeRange.start || from >= nodeRange.end) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const selectionRange = new SelectionRange(doc.resolve(from), doc.resolve(to));
|
|
49
|
-
ranges.push(selectionRange);
|
|
50
|
-
});
|
|
51
|
-
return ranges;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// src/helpers/NodeRangeSelection.ts
|
|
55
|
-
import { Selection } from "@tiptap/pm/state";
|
|
56
|
-
|
|
57
|
-
// src/helpers/NodeRangeBookmark.ts
|
|
58
|
-
var NodeRangeBookmark = class _NodeRangeBookmark {
|
|
59
|
-
constructor(anchor, head) {
|
|
60
|
-
this.anchor = anchor;
|
|
61
|
-
this.head = head;
|
|
62
|
-
}
|
|
63
|
-
map(mapping) {
|
|
64
|
-
return new _NodeRangeBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
65
|
-
}
|
|
66
|
-
resolve(doc) {
|
|
67
|
-
const $anchor = doc.resolve(this.anchor);
|
|
68
|
-
const $head = doc.resolve(this.head);
|
|
69
|
-
return new NodeRangeSelection($anchor, $head);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// src/helpers/NodeRangeSelection.ts
|
|
74
|
-
var NodeRangeSelection = class _NodeRangeSelection extends Selection {
|
|
75
|
-
constructor($anchor, $head, depth, bias = 1) {
|
|
76
|
-
const { doc } = $anchor;
|
|
77
|
-
const isCursor = $anchor === $head;
|
|
78
|
-
const isCursorAtEnd = $anchor.pos === doc.content.size && $head.pos === doc.content.size;
|
|
79
|
-
const $correctedHead = isCursor && !isCursorAtEnd ? doc.resolve($head.pos + (bias > 0 ? 1 : -1)) : $head;
|
|
80
|
-
const $correctedAnchor = isCursor && isCursorAtEnd ? doc.resolve($anchor.pos - (bias > 0 ? 1 : -1)) : $anchor;
|
|
81
|
-
const ranges = getSelectionRanges($correctedAnchor.min($correctedHead), $correctedAnchor.max($correctedHead), depth);
|
|
82
|
-
const $rangeFrom = $correctedHead.pos >= $anchor.pos ? ranges[0].$from : ranges[ranges.length - 1].$to;
|
|
83
|
-
const $rangeTo = $correctedHead.pos >= $anchor.pos ? ranges[ranges.length - 1].$to : ranges[0].$from;
|
|
84
|
-
super($rangeFrom, $rangeTo, ranges);
|
|
85
|
-
this.depth = depth;
|
|
86
|
-
}
|
|
87
|
-
// we can safely ignore this TypeScript error: https://github.com/Microsoft/TypeScript/issues/338
|
|
88
|
-
// @ts-ignore
|
|
89
|
-
get $to() {
|
|
90
|
-
return this.ranges[this.ranges.length - 1].$to;
|
|
91
|
-
}
|
|
92
|
-
eq(other) {
|
|
93
|
-
return other instanceof _NodeRangeSelection && other.$from.pos === this.$from.pos && other.$to.pos === this.$to.pos;
|
|
94
|
-
}
|
|
95
|
-
map(doc, mapping) {
|
|
96
|
-
const $anchor = doc.resolve(mapping.map(this.anchor));
|
|
97
|
-
const $head = doc.resolve(mapping.map(this.head));
|
|
98
|
-
return new _NodeRangeSelection($anchor, $head);
|
|
99
|
-
}
|
|
100
|
-
toJSON() {
|
|
101
|
-
return {
|
|
102
|
-
type: "nodeRange",
|
|
103
|
-
anchor: this.anchor,
|
|
104
|
-
head: this.head
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
get isForwards() {
|
|
108
|
-
return this.head >= this.anchor;
|
|
109
|
-
}
|
|
110
|
-
get isBackwards() {
|
|
111
|
-
return !this.isForwards;
|
|
112
|
-
}
|
|
113
|
-
extendBackwards() {
|
|
114
|
-
const { doc } = this.$from;
|
|
115
|
-
if (this.isForwards && this.ranges.length > 1) {
|
|
116
|
-
const ranges = this.ranges.slice(0, -1);
|
|
117
|
-
const $from2 = ranges[0].$from;
|
|
118
|
-
const $to = ranges[ranges.length - 1].$to;
|
|
119
|
-
return new _NodeRangeSelection($from2, $to, this.depth);
|
|
120
|
-
}
|
|
121
|
-
const firstRange = this.ranges[0];
|
|
122
|
-
const $from = doc.resolve(Math.max(0, firstRange.$from.pos - 1));
|
|
123
|
-
return new _NodeRangeSelection(this.$anchor, $from, this.depth);
|
|
124
|
-
}
|
|
125
|
-
extendForwards() {
|
|
126
|
-
const { doc } = this.$from;
|
|
127
|
-
if (this.isBackwards && this.ranges.length > 1) {
|
|
128
|
-
const ranges = this.ranges.slice(1);
|
|
129
|
-
const $from = ranges[0].$from;
|
|
130
|
-
const $to2 = ranges[ranges.length - 1].$to;
|
|
131
|
-
return new _NodeRangeSelection($to2, $from, this.depth);
|
|
132
|
-
}
|
|
133
|
-
const lastRange = this.ranges[this.ranges.length - 1];
|
|
134
|
-
const $to = doc.resolve(Math.min(doc.content.size, lastRange.$to.pos + 1));
|
|
135
|
-
return new _NodeRangeSelection(this.$anchor, $to, this.depth);
|
|
136
|
-
}
|
|
137
|
-
static fromJSON(doc, json) {
|
|
138
|
-
return new _NodeRangeSelection(doc.resolve(json.anchor), doc.resolve(json.head));
|
|
139
|
-
}
|
|
140
|
-
static create(doc, anchor, head, depth, bias = 1) {
|
|
141
|
-
return new this(doc.resolve(anchor), doc.resolve(head), depth, bias);
|
|
142
|
-
}
|
|
143
|
-
getBookmark() {
|
|
144
|
-
return new NodeRangeBookmark(this.anchor, this.head);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
NodeRangeSelection.prototype.visible = false;
|
|
148
|
-
|
|
149
|
-
// src/helpers/isNodeRangeSelection.ts
|
|
150
|
-
function isNodeRangeSelection(value) {
|
|
151
|
-
return value instanceof NodeRangeSelection;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// src/node-range.ts
|
|
155
|
-
var NodeRange2 = Extension.create({
|
|
156
|
-
name: "nodeRange",
|
|
157
|
-
addOptions() {
|
|
158
|
-
return {
|
|
159
|
-
depth: void 0,
|
|
160
|
-
key: "Mod"
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
addKeyboardShortcuts() {
|
|
164
|
-
return {
|
|
165
|
-
// extend NodeRangeSelection upwards
|
|
166
|
-
"Shift-ArrowUp": ({ editor }) => {
|
|
167
|
-
const { depth } = this.options;
|
|
168
|
-
const { view, state } = editor;
|
|
169
|
-
const { doc, selection, tr } = state;
|
|
170
|
-
const { anchor, head } = selection;
|
|
171
|
-
if (!isNodeRangeSelection(selection)) {
|
|
172
|
-
const nodeRangeSelection2 = NodeRangeSelection.create(doc, anchor, head, depth, -1);
|
|
173
|
-
tr.setSelection(nodeRangeSelection2);
|
|
174
|
-
view.dispatch(tr);
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
const nodeRangeSelection = selection.extendBackwards();
|
|
178
|
-
tr.setSelection(nodeRangeSelection);
|
|
179
|
-
view.dispatch(tr);
|
|
180
|
-
return true;
|
|
181
|
-
},
|
|
182
|
-
// extend NodeRangeSelection downwards
|
|
183
|
-
"Shift-ArrowDown": ({ editor }) => {
|
|
184
|
-
const { depth } = this.options;
|
|
185
|
-
const { view, state } = editor;
|
|
186
|
-
const { doc, selection, tr } = state;
|
|
187
|
-
const { anchor, head } = selection;
|
|
188
|
-
if (!isNodeRangeSelection(selection)) {
|
|
189
|
-
const nodeRangeSelection2 = NodeRangeSelection.create(doc, anchor, head, depth);
|
|
190
|
-
tr.setSelection(nodeRangeSelection2);
|
|
191
|
-
view.dispatch(tr);
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
const nodeRangeSelection = selection.extendForwards();
|
|
195
|
-
tr.setSelection(nodeRangeSelection);
|
|
196
|
-
view.dispatch(tr);
|
|
197
|
-
return true;
|
|
198
|
-
},
|
|
199
|
-
// add `NodeRangeSelection` to all nodes
|
|
200
|
-
"Mod-a": ({ editor }) => {
|
|
201
|
-
const { depth } = this.options;
|
|
202
|
-
const { view, state } = editor;
|
|
203
|
-
const { doc, tr } = state;
|
|
204
|
-
const nodeRangeSelection = NodeRangeSelection.create(doc, 0, doc.content.size, depth);
|
|
205
|
-
tr.setSelection(nodeRangeSelection);
|
|
206
|
-
view.dispatch(tr);
|
|
207
|
-
return true;
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
},
|
|
211
|
-
onSelectionUpdate() {
|
|
212
|
-
const { selection } = this.editor.state;
|
|
213
|
-
if (isNodeRangeSelection(selection)) {
|
|
214
|
-
this.editor.view.dom.classList.add("ProseMirror-noderangeselection");
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
addProseMirrorPlugins() {
|
|
218
|
-
let hideTextSelection = false;
|
|
219
|
-
let activeMouseSelection = false;
|
|
220
|
-
return [
|
|
221
|
-
new Plugin({
|
|
222
|
-
key: new PluginKey("nodeRange"),
|
|
223
|
-
props: {
|
|
224
|
-
attributes: () => {
|
|
225
|
-
if (hideTextSelection) {
|
|
226
|
-
return {
|
|
227
|
-
class: "ProseMirror-noderangeselection"
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
return { class: "" };
|
|
231
|
-
},
|
|
232
|
-
handleDOMEvents: {
|
|
233
|
-
mousedown: (view, event) => {
|
|
234
|
-
const { key } = this.options;
|
|
235
|
-
const isMac = /Mac/.test(navigator.platform);
|
|
236
|
-
const isShift = !!event.shiftKey;
|
|
237
|
-
const isControl = !!event.ctrlKey;
|
|
238
|
-
const isAlt = !!event.altKey;
|
|
239
|
-
const isMeta = !!event.metaKey;
|
|
240
|
-
const isMod = isMac ? isMeta : isControl;
|
|
241
|
-
if (key === null || key === void 0 || key === "Shift" && isShift || key === "Control" && isControl || key === "Alt" && isAlt || key === "Meta" && isMeta || key === "Mod" && isMod) {
|
|
242
|
-
activeMouseSelection = true;
|
|
243
|
-
}
|
|
244
|
-
if (!activeMouseSelection) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
document.addEventListener(
|
|
248
|
-
"mouseup",
|
|
249
|
-
() => {
|
|
250
|
-
activeMouseSelection = false;
|
|
251
|
-
const { state } = view;
|
|
252
|
-
const { doc, selection, tr } = state;
|
|
253
|
-
const { $anchor, $head } = selection;
|
|
254
|
-
if ($anchor.sameParent($head)) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
const nodeRangeSelection = NodeRangeSelection.create(doc, $anchor.pos, $head.pos, this.options.depth);
|
|
258
|
-
tr.setSelection(nodeRangeSelection);
|
|
259
|
-
view.dispatch(tr);
|
|
260
|
-
},
|
|
261
|
-
{ once: true }
|
|
262
|
-
);
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
// when selecting some text we want to render some decorations
|
|
267
|
-
// to preview a `NodeRangeSelection`
|
|
268
|
-
decorations: (state) => {
|
|
269
|
-
const { selection } = state;
|
|
270
|
-
const isNodeRange = isNodeRangeSelection(selection);
|
|
271
|
-
hideTextSelection = false;
|
|
272
|
-
if (!activeMouseSelection) {
|
|
273
|
-
if (!isNodeRange) {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
hideTextSelection = true;
|
|
277
|
-
return getNodeRangeDecorations(selection.ranges);
|
|
278
|
-
}
|
|
279
|
-
const { $from, $to } = selection;
|
|
280
|
-
if (!isNodeRange && $from.sameParent($to)) {
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
const nodeRanges = getSelectionRanges($from, $to, this.options.depth);
|
|
284
|
-
if (!nodeRanges.length) {
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
hideTextSelection = true;
|
|
288
|
-
return getNodeRangeDecorations(nodeRanges);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
})
|
|
292
|
-
];
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
// src/index.ts
|
|
297
|
-
var index_default = NodeRange2;
|
|
298
|
-
export {
|
|
299
|
-
NodeRange2 as NodeRange,
|
|
300
|
-
NodeRangeSelection,
|
|
301
|
-
index_default as default,
|
|
302
|
-
getNodeRangeDecorations,
|
|
303
|
-
getSelectionRanges,
|
|
304
|
-
isNodeRangeSelection
|
|
305
|
-
};
|
|
306
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/node-range.ts","../src/helpers/getNodeRangeDecorations.ts","../src/helpers/getSelectionRanges.ts","../src/helpers/NodeRangeSelection.ts","../src/helpers/NodeRangeBookmark.ts","../src/helpers/isNodeRangeSelection.ts","../src/index.ts"],"sourcesContent":["import { Extension } from '@tiptap/core'\nimport type { SelectionRange } from '@tiptap/pm/state'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { getNodeRangeDecorations } from './helpers/getNodeRangeDecorations.js'\nimport { getSelectionRanges } from './helpers/getSelectionRanges.js'\nimport { isNodeRangeSelection } from './helpers/isNodeRangeSelection.js'\nimport { NodeRangeSelection } from './helpers/NodeRangeSelection.js'\n\nexport interface NodeRangeOptions {\n depth: number | undefined\n key: 'Shift' | 'Control' | 'Alt' | 'Meta' | 'Mod' | null | undefined\n}\n\nexport const NodeRange = Extension.create<NodeRangeOptions>({\n name: 'nodeRange',\n\n addOptions() {\n return {\n depth: undefined,\n key: 'Mod',\n }\n },\n\n addKeyboardShortcuts() {\n return {\n // extend NodeRangeSelection upwards\n 'Shift-ArrowUp': ({ editor }) => {\n const { depth } = this.options\n const { view, state } = editor\n const { doc, selection, tr } = state\n const { anchor, head } = selection\n\n if (!isNodeRangeSelection(selection)) {\n const nodeRangeSelection = NodeRangeSelection.create(doc, anchor, head, depth, -1)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n }\n\n const nodeRangeSelection = selection.extendBackwards()\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n },\n\n // extend NodeRangeSelection downwards\n 'Shift-ArrowDown': ({ editor }) => {\n const { depth } = this.options\n const { view, state } = editor\n const { doc, selection, tr } = state\n const { anchor, head } = selection\n\n if (!isNodeRangeSelection(selection)) {\n const nodeRangeSelection = NodeRangeSelection.create(doc, anchor, head, depth)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n }\n\n const nodeRangeSelection = selection.extendForwards()\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n },\n\n // add `NodeRangeSelection` to all nodes\n 'Mod-a': ({ editor }) => {\n const { depth } = this.options\n const { view, state } = editor\n const { doc, tr } = state\n const nodeRangeSelection = NodeRangeSelection.create(doc, 0, doc.content.size, depth)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n\n return true\n },\n }\n },\n\n onSelectionUpdate() {\n const { selection } = this.editor.state\n\n if (isNodeRangeSelection(selection)) {\n this.editor.view.dom.classList.add('ProseMirror-noderangeselection')\n }\n },\n\n addProseMirrorPlugins() {\n let hideTextSelection = false\n let activeMouseSelection = false\n\n return [\n new Plugin({\n key: new PluginKey('nodeRange'),\n\n props: {\n attributes: () => {\n if (hideTextSelection) {\n return {\n class: 'ProseMirror-noderangeselection',\n }\n }\n\n return { class: '' }\n },\n\n handleDOMEvents: {\n mousedown: (view, event) => {\n const { key } = this.options\n const isMac = /Mac/.test(navigator.platform)\n const isShift = !!event.shiftKey\n const isControl = !!event.ctrlKey\n const isAlt = !!event.altKey\n const isMeta = !!event.metaKey\n const isMod = isMac ? isMeta : isControl\n\n if (\n key === null ||\n key === undefined ||\n (key === 'Shift' && isShift) ||\n (key === 'Control' && isControl) ||\n (key === 'Alt' && isAlt) ||\n (key === 'Meta' && isMeta) ||\n (key === 'Mod' && isMod)\n ) {\n activeMouseSelection = true\n }\n\n if (!activeMouseSelection) {\n return false\n }\n\n document.addEventListener(\n 'mouseup',\n () => {\n activeMouseSelection = false\n\n const { state } = view\n const { doc, selection, tr } = state\n const { $anchor, $head } = selection\n\n if ($anchor.sameParent($head)) {\n return\n }\n\n const nodeRangeSelection = NodeRangeSelection.create(doc, $anchor.pos, $head.pos, this.options.depth)\n\n tr.setSelection(nodeRangeSelection)\n view.dispatch(tr)\n },\n { once: true },\n )\n\n return false\n },\n },\n\n // when selecting some text we want to render some decorations\n // to preview a `NodeRangeSelection`\n decorations: state => {\n const { selection } = state\n const isNodeRange = isNodeRangeSelection(selection)\n\n hideTextSelection = false\n\n if (!activeMouseSelection) {\n if (!isNodeRange) {\n return null\n }\n\n hideTextSelection = true\n\n return getNodeRangeDecorations(selection.ranges as SelectionRange[])\n }\n\n const { $from, $to } = selection\n\n // selection is probably in the same node like a paragraph\n // so we don’t render decorations and show\n // a simple text selection instead\n if (!isNodeRange && $from.sameParent($to)) {\n return null\n }\n\n // try to calculate some node ranges\n const nodeRanges = getSelectionRanges($from, $to, this.options.depth)\n\n if (!nodeRanges.length) {\n return null\n }\n\n hideTextSelection = true\n\n return getNodeRangeDecorations(nodeRanges)\n },\n },\n }),\n ]\n },\n})\n","import type { SelectionRange } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\n\nexport function getNodeRangeDecorations(ranges: SelectionRange[]): DecorationSet {\n if (!ranges.length) {\n return DecorationSet.empty\n }\n\n const decorations: Decoration[] = []\n const doc = ranges[0].$from.node(0)\n\n ranges.forEach(range => {\n const pos = range.$from.pos\n const node = range.$from.nodeAfter\n\n if (!node) {\n return\n }\n\n decorations.push(\n Decoration.node(pos, pos + node.nodeSize, {\n class: 'ProseMirror-selectednoderange',\n }),\n )\n })\n\n return DecorationSet.create(doc, decorations)\n}\n","import { type ResolvedPos, NodeRange } from '@tiptap/pm/model'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nexport function getSelectionRanges($from: ResolvedPos, $to: ResolvedPos, depth?: number): SelectionRange[] {\n const ranges: SelectionRange[] = []\n const doc = $from.node(0)\n\n // Determine the appropriate depth\n if (typeof depth === 'number' && depth >= 0) {\n // Use the provided depth\n } else if ($from.sameParent($to)) {\n depth = Math.max(0, $from.sharedDepth($to.pos) - 1)\n } else {\n depth = $from.sharedDepth($to.pos)\n }\n\n const nodeRange = new NodeRange($from, $to, depth)\n const offset = nodeRange.depth === 0 ? 0 : doc.resolve(nodeRange.start).posAtIndex(0)\n\n nodeRange.parent.forEach((node, pos) => {\n const from = offset + pos\n const to = from + node.nodeSize\n\n if (from < nodeRange.start || from >= nodeRange.end) {\n return\n }\n\n const selectionRange = new SelectionRange(doc.resolve(from), doc.resolve(to))\n\n ranges.push(selectionRange)\n })\n\n return ranges\n}\n","import type { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'\nimport { Selection } from '@tiptap/pm/state'\nimport type { Mapping } from '@tiptap/pm/transform'\n\nimport { getSelectionRanges } from './getSelectionRanges.js'\nimport { NodeRangeBookmark } from './NodeRangeBookmark.js'\n\nexport class NodeRangeSelection extends Selection {\n depth: number | undefined\n\n constructor($anchor: ResolvedPos, $head: ResolvedPos, depth?: number, bias = 1) {\n // if there is only a cursor we can’t calculate a direction of the selection\n // that’s why we adjust the head position by 1 in the desired direction\n const { doc } = $anchor\n const isCursor = $anchor === $head\n const isCursorAtEnd = $anchor.pos === doc.content.size && $head.pos === doc.content.size\n const $correctedHead = isCursor && !isCursorAtEnd ? doc.resolve($head.pos + (bias > 0 ? 1 : -1)) : $head\n const $correctedAnchor = isCursor && isCursorAtEnd ? doc.resolve($anchor.pos - (bias > 0 ? 1 : -1)) : $anchor\n\n const ranges = getSelectionRanges($correctedAnchor.min($correctedHead), $correctedAnchor.max($correctedHead), depth)\n\n // get the smallest range start position\n // this will become the $anchor\n const $rangeFrom = $correctedHead.pos >= $anchor.pos ? ranges[0].$from : ranges[ranges.length - 1].$to\n\n // get the biggest range end position\n // this will become the $head\n const $rangeTo = $correctedHead.pos >= $anchor.pos ? ranges[ranges.length - 1].$to : ranges[0].$from\n\n super($rangeFrom, $rangeTo, ranges)\n\n this.depth = depth\n }\n\n // we can safely ignore this TypeScript error: https://github.com/Microsoft/TypeScript/issues/338\n // @ts-ignore\n get $to() {\n return this.ranges[this.ranges.length - 1].$to\n }\n\n eq(other: Selection): boolean {\n return other instanceof NodeRangeSelection && other.$from.pos === this.$from.pos && other.$to.pos === this.$to.pos\n }\n\n map(doc: ProseMirrorNode, mapping: Mapping): NodeRangeSelection {\n const $anchor = doc.resolve(mapping.map(this.anchor))\n const $head = doc.resolve(mapping.map(this.head))\n\n return new NodeRangeSelection($anchor, $head)\n }\n\n toJSON() {\n return {\n type: 'nodeRange',\n anchor: this.anchor,\n head: this.head,\n }\n }\n\n get isForwards(): boolean {\n return this.head >= this.anchor\n }\n\n get isBackwards(): boolean {\n return !this.isForwards\n }\n\n extendBackwards(): NodeRangeSelection {\n const { doc } = this.$from\n\n if (this.isForwards && this.ranges.length > 1) {\n const ranges = this.ranges.slice(0, -1)\n const $from = ranges[0].$from\n const $to = ranges[ranges.length - 1].$to\n\n return new NodeRangeSelection($from, $to, this.depth)\n }\n\n const firstRange = this.ranges[0]\n const $from = doc.resolve(Math.max(0, firstRange.$from.pos - 1))\n\n return new NodeRangeSelection(this.$anchor, $from, this.depth)\n }\n\n extendForwards(): NodeRangeSelection {\n const { doc } = this.$from\n\n if (this.isBackwards && this.ranges.length > 1) {\n const ranges = this.ranges.slice(1)\n const $from = ranges[0].$from\n const $to = ranges[ranges.length - 1].$to\n\n return new NodeRangeSelection($to, $from, this.depth)\n }\n\n const lastRange = this.ranges[this.ranges.length - 1]\n const $to = doc.resolve(Math.min(doc.content.size, lastRange.$to.pos + 1))\n\n return new NodeRangeSelection(this.$anchor, $to, this.depth)\n }\n\n static fromJSON(doc: ProseMirrorNode, json: any): NodeRangeSelection {\n return new NodeRangeSelection(doc.resolve(json.anchor), doc.resolve(json.head))\n }\n\n static create(doc: ProseMirrorNode, anchor: number, head: number, depth?: number, bias = 1): NodeRangeSelection {\n return new this(doc.resolve(anchor), doc.resolve(head), depth, bias)\n }\n\n getBookmark(): NodeRangeBookmark {\n return new NodeRangeBookmark(this.anchor, this.head)\n }\n}\n\nNodeRangeSelection.prototype.visible = false\n","import type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { Mappable } from '@tiptap/pm/transform'\n\nimport { NodeRangeSelection } from './NodeRangeSelection.js'\n\nexport class NodeRangeBookmark {\n anchor!: number\n\n head!: number\n\n constructor(anchor: number, head: number) {\n this.anchor = anchor\n this.head = head\n }\n\n map(mapping: Mappable) {\n return new NodeRangeBookmark(mapping.map(this.anchor), mapping.map(this.head))\n }\n\n resolve(doc: ProseMirrorNode) {\n const $anchor = doc.resolve(this.anchor)\n const $head = doc.resolve(this.head)\n\n return new NodeRangeSelection($anchor, $head)\n }\n}\n","import { NodeRangeSelection } from './NodeRangeSelection.js'\n\nexport function isNodeRangeSelection(value: unknown): value is NodeRangeSelection {\n return value instanceof NodeRangeSelection\n}\n","import { NodeRange } from './node-range.js'\n\nexport * from './helpers/getNodeRangeDecorations.js'\nexport * from './helpers/getSelectionRanges.js'\nexport * from './helpers/isNodeRangeSelection.js'\nexport * from './helpers/NodeRangeSelection.js'\nexport * from './node-range.js'\n\nexport default NodeRange\n"],"mappings":";AAAA,SAAS,iBAAiB;AAE1B,SAAS,QAAQ,iBAAiB;;;ACDlC,SAAS,YAAY,qBAAqB;AAEnC,SAAS,wBAAwB,QAAyC;AAC/E,MAAI,CAAC,OAAO,QAAQ;AAClB,WAAO,cAAc;AAAA,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