@openeditor/react 0.0.29 → 0.0.30
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 +2 -0
- package/dist/index.d.ts +47 -8
- package/dist/index.js +2845 -675
- package/dist/index.js.map +1 -1
- package/package.json +7 -8
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { DEFAULT_CALLOUT_EMOJI, normalizeEmoji, DEFAULT_PAGE_EMOJI, normalizeDocument, toProseMirrorDocument, createDocument as createDocument$1, openEditorPublicUrlPolicy, isOpenEditorBlockEnabled, createBlockRegistry, OPENEDITOR_BLOCK_ID_ATTR, createBlockId, fromProseMirrorDocument, findBlockSpecForNode } from '@openeditor/core';
|
|
2
2
|
export { openEditorPublicUrlPolicy, openEditorUnsafeUrlPolicy } from '@openeditor/core';
|
|
3
3
|
import { Checkbox } from '@base-ui/react/checkbox';
|
|
4
|
-
import { shift as shift$1,
|
|
4
|
+
import { shift as shift$1, flip, offset, arrow as arrow$1, size, autoPlacement, hide, inline, computePosition, autoUpdate } from '@floating-ui/dom';
|
|
5
5
|
import { OpenEditorEmojiPicker } from '@openeditor/emoji';
|
|
6
|
-
import React, { createContext, forwardRef, useContext, useMemo, createRef, memo, createElement, version,
|
|
6
|
+
import React, { createContext, forwardRef, useRef, useState, useEffect, useContext, useMemo, useLayoutEffect, createRef, memo, createElement, version, useSyncExternalStore as useSyncExternalStore$1, useCallback, use, useDebugValue } from 'react';
|
|
7
7
|
import { jsxs, Fragment as Fragment$1, jsx } from 'react/jsx-runtime';
|
|
8
8
|
import { renderMermaidSVG } from 'beautiful-mermaid';
|
|
9
9
|
import { exportDocumentUnsafe, exportDocument } from '@openeditor/exporters';
|
|
10
10
|
import { openEditorInsertPresets, resolveOpenEditorInsertBlock, defaultBlockRegistry } from '@openeditor/extensions';
|
|
11
11
|
export { seedDocument } from '@openeditor/extensions';
|
|
12
|
-
import ReactDOM, {
|
|
12
|
+
import ReactDOM, { createPortal, flushSync } from 'react-dom';
|
|
13
13
|
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
14
14
|
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js';
|
|
15
15
|
|
|
@@ -166,10 +166,10 @@ function findDiffEnd(a, b, posA, posB) {
|
|
|
166
166
|
for (let iA = a.childCount, iB = b.childCount; ; ) {
|
|
167
167
|
if (iA == 0 || iB == 0)
|
|
168
168
|
return iA == iB ? null : { a: posA, b: posB };
|
|
169
|
-
let childA = a.child(--iA), childB = b.child(--iB),
|
|
169
|
+
let childA = a.child(--iA), childB = b.child(--iB), size3 = childA.nodeSize;
|
|
170
170
|
if (childA == childB) {
|
|
171
|
-
posA -=
|
|
172
|
-
posB -=
|
|
171
|
+
posA -= size3;
|
|
172
|
+
posB -= size3;
|
|
173
173
|
continue;
|
|
174
174
|
}
|
|
175
175
|
if (!childA.sameMarkup(childB))
|
|
@@ -193,8 +193,8 @@ function findDiffEnd(a, b, posA, posB) {
|
|
|
193
193
|
if (inner)
|
|
194
194
|
return inner;
|
|
195
195
|
}
|
|
196
|
-
posA -=
|
|
197
|
-
posB -=
|
|
196
|
+
posA -= size3;
|
|
197
|
+
posB -= size3;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
function surrogateLow(ch) {
|
|
@@ -207,10 +207,10 @@ var Fragment = class _Fragment2 {
|
|
|
207
207
|
/**
|
|
208
208
|
@internal
|
|
209
209
|
*/
|
|
210
|
-
constructor(content,
|
|
210
|
+
constructor(content, size3) {
|
|
211
211
|
this.content = content;
|
|
212
|
-
this.size =
|
|
213
|
-
if (
|
|
212
|
+
this.size = size3 || 0;
|
|
213
|
+
if (size3 == null)
|
|
214
214
|
for (let i = 0; i < content.length; i++)
|
|
215
215
|
this.size += content[i].nodeSize;
|
|
216
216
|
}
|
|
@@ -279,7 +279,7 @@ var Fragment = class _Fragment2 {
|
|
|
279
279
|
cut(from2, to = this.size) {
|
|
280
280
|
if (from2 == 0 && to == this.size)
|
|
281
281
|
return this;
|
|
282
|
-
let result = [],
|
|
282
|
+
let result = [], size3 = 0;
|
|
283
283
|
if (to > from2)
|
|
284
284
|
for (let i = 0, pos = 0; pos < to; i++) {
|
|
285
285
|
let child = this.content[i], end = pos + child.nodeSize;
|
|
@@ -291,11 +291,11 @@ var Fragment = class _Fragment2 {
|
|
|
291
291
|
child = child.cut(Math.max(0, from2 - pos - 1), Math.min(child.content.size, to - pos - 1));
|
|
292
292
|
}
|
|
293
293
|
result.push(child);
|
|
294
|
-
|
|
294
|
+
size3 += child.nodeSize;
|
|
295
295
|
}
|
|
296
296
|
pos = end;
|
|
297
297
|
}
|
|
298
|
-
return new _Fragment2(result,
|
|
298
|
+
return new _Fragment2(result, size3);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
301
|
@internal
|
|
@@ -316,9 +316,9 @@ var Fragment = class _Fragment2 {
|
|
|
316
316
|
if (current == node)
|
|
317
317
|
return this;
|
|
318
318
|
let copy2 = this.content.slice();
|
|
319
|
-
let
|
|
319
|
+
let size3 = this.size + node.nodeSize - current.nodeSize;
|
|
320
320
|
copy2[index] = node;
|
|
321
|
-
return new _Fragment2(copy2,
|
|
321
|
+
return new _Fragment2(copy2, size3);
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
324
|
Create a new fragment by prepending the given node to this
|
|
@@ -463,10 +463,10 @@ var Fragment = class _Fragment2 {
|
|
|
463
463
|
static fromArray(array) {
|
|
464
464
|
if (!array.length)
|
|
465
465
|
return _Fragment2.empty;
|
|
466
|
-
let joined,
|
|
466
|
+
let joined, size3 = 0;
|
|
467
467
|
for (let i = 0; i < array.length; i++) {
|
|
468
468
|
let node = array[i];
|
|
469
|
-
|
|
469
|
+
size3 += node.nodeSize;
|
|
470
470
|
if (i && node.isText && array[i - 1].sameMarkup(node)) {
|
|
471
471
|
if (!joined)
|
|
472
472
|
joined = array.slice(0, i);
|
|
@@ -475,7 +475,7 @@ var Fragment = class _Fragment2 {
|
|
|
475
475
|
joined.push(node);
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
-
return new _Fragment2(joined || array,
|
|
478
|
+
return new _Fragment2(joined || array, size3);
|
|
479
479
|
}
|
|
480
480
|
/**
|
|
481
481
|
Create a fragment from something that can be interpreted as a
|
|
@@ -497,9 +497,9 @@ var Fragment = class _Fragment2 {
|
|
|
497
497
|
};
|
|
498
498
|
Fragment.empty = new Fragment([], 0);
|
|
499
499
|
var found = { index: 0, offset: 0 };
|
|
500
|
-
function retIndex(index,
|
|
500
|
+
function retIndex(index, offset3) {
|
|
501
501
|
found.index = index;
|
|
502
|
-
found.offset =
|
|
502
|
+
found.offset = offset3;
|
|
503
503
|
return found;
|
|
504
504
|
}
|
|
505
505
|
function compareDeep(a, b) {
|
|
@@ -737,25 +737,25 @@ var Slice = class _Slice2 {
|
|
|
737
737
|
};
|
|
738
738
|
Slice.empty = new Slice(Fragment.empty, 0, 0);
|
|
739
739
|
function removeRange(content, from2, to) {
|
|
740
|
-
let { index, offset } = content.findIndex(from2), child = content.maybeChild(index);
|
|
740
|
+
let { index, offset: offset3 } = content.findIndex(from2), child = content.maybeChild(index);
|
|
741
741
|
let { index: indexTo, offset: offsetTo } = content.findIndex(to);
|
|
742
|
-
if (
|
|
742
|
+
if (offset3 == from2 || child.isText) {
|
|
743
743
|
if (offsetTo != to && !content.child(indexTo).isText)
|
|
744
744
|
throw new RangeError("Removing non-flat range");
|
|
745
745
|
return content.cut(0, from2).append(content.cut(to));
|
|
746
746
|
}
|
|
747
747
|
if (index != indexTo)
|
|
748
748
|
throw new RangeError("Removing non-flat range");
|
|
749
|
-
return content.replaceChild(index, child.copy(removeRange(child.content, from2 -
|
|
749
|
+
return content.replaceChild(index, child.copy(removeRange(child.content, from2 - offset3 - 1, to - offset3 - 1)));
|
|
750
750
|
}
|
|
751
751
|
function insertInto(content, dist, insert, openStart, openEnd, parent) {
|
|
752
|
-
let { index, offset } = content.findIndex(dist), child = content.maybeChild(index);
|
|
753
|
-
if (
|
|
752
|
+
let { index, offset: offset3 } = content.findIndex(dist), child = content.maybeChild(index);
|
|
753
|
+
if (offset3 == dist || child.isText) {
|
|
754
754
|
if (parent && openStart <= 0 && openEnd <= 0 && !parent.canReplace(index, index, insert))
|
|
755
755
|
return null;
|
|
756
756
|
return content.cut(0, dist).append(insert).append(content.cut(dist));
|
|
757
757
|
}
|
|
758
|
-
let inner = insertInto(child.content, dist -
|
|
758
|
+
let inner = insertInto(child.content, dist - offset3 - 1, insert, index == 0 ? openStart - 1 : 0, index == content.childCount - 1 ? openEnd - 1 : 0, child);
|
|
759
759
|
return inner && content.replaceChild(index, child.copy(inner));
|
|
760
760
|
}
|
|
761
761
|
function replace($from, $to, slice2) {
|
|
@@ -1098,16 +1098,16 @@ var ResolvedPos = class _ResolvedPos2 {
|
|
|
1098
1098
|
let path = [];
|
|
1099
1099
|
let start = 0, parentOffset = pos;
|
|
1100
1100
|
for (let node = doc3; ; ) {
|
|
1101
|
-
let { index, offset } = node.content.findIndex(parentOffset);
|
|
1102
|
-
let rem = parentOffset -
|
|
1103
|
-
path.push(node, index, start +
|
|
1101
|
+
let { index, offset: offset3 } = node.content.findIndex(parentOffset);
|
|
1102
|
+
let rem = parentOffset - offset3;
|
|
1103
|
+
path.push(node, index, start + offset3);
|
|
1104
1104
|
if (!rem)
|
|
1105
1105
|
break;
|
|
1106
1106
|
node = node.child(index);
|
|
1107
1107
|
if (node.isText)
|
|
1108
1108
|
break;
|
|
1109
1109
|
parentOffset = rem - 1;
|
|
1110
|
-
start +=
|
|
1110
|
+
start += offset3 + 1;
|
|
1111
1111
|
}
|
|
1112
1112
|
return new _ResolvedPos2(pos, path, parentOffset);
|
|
1113
1113
|
}
|
|
@@ -1181,7 +1181,7 @@ var NodeRange = class {
|
|
|
1181
1181
|
}
|
|
1182
1182
|
};
|
|
1183
1183
|
var emptyAttrs = /* @__PURE__ */ Object.create(null);
|
|
1184
|
-
var
|
|
1184
|
+
var Node2 = class _Node3 {
|
|
1185
1185
|
/**
|
|
1186
1186
|
@internal
|
|
1187
1187
|
*/
|
|
@@ -1360,13 +1360,13 @@ var Node = class _Node3 {
|
|
|
1360
1360
|
*/
|
|
1361
1361
|
nodeAt(pos) {
|
|
1362
1362
|
for (let node = this; ; ) {
|
|
1363
|
-
let { index, offset } = node.content.findIndex(pos);
|
|
1363
|
+
let { index, offset: offset3 } = node.content.findIndex(pos);
|
|
1364
1364
|
node = node.maybeChild(index);
|
|
1365
1365
|
if (!node)
|
|
1366
1366
|
return null;
|
|
1367
|
-
if (
|
|
1367
|
+
if (offset3 == pos || node.isText)
|
|
1368
1368
|
return node;
|
|
1369
|
-
pos -=
|
|
1369
|
+
pos -= offset3 + 1;
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
1372
|
/**
|
|
@@ -1375,8 +1375,8 @@ var Node = class _Node3 {
|
|
|
1375
1375
|
node.
|
|
1376
1376
|
*/
|
|
1377
1377
|
childAfter(pos) {
|
|
1378
|
-
let { index, offset } = this.content.findIndex(pos);
|
|
1379
|
-
return { node: this.content.maybeChild(index), index, offset };
|
|
1378
|
+
let { index, offset: offset3 } = this.content.findIndex(pos);
|
|
1379
|
+
return { node: this.content.maybeChild(index), index, offset: offset3 };
|
|
1380
1380
|
}
|
|
1381
1381
|
/**
|
|
1382
1382
|
Find the (direct) child node before the given offset, if any,
|
|
@@ -1386,11 +1386,11 @@ var Node = class _Node3 {
|
|
|
1386
1386
|
childBefore(pos) {
|
|
1387
1387
|
if (pos == 0)
|
|
1388
1388
|
return { node: null, index: 0, offset: 0 };
|
|
1389
|
-
let { index, offset } = this.content.findIndex(pos);
|
|
1390
|
-
if (
|
|
1391
|
-
return { node: this.content.child(index), index, offset };
|
|
1389
|
+
let { index, offset: offset3 } = this.content.findIndex(pos);
|
|
1390
|
+
if (offset3 < pos)
|
|
1391
|
+
return { node: this.content.child(index), index, offset: offset3 };
|
|
1392
1392
|
let node = this.content.child(index - 1);
|
|
1393
|
-
return { node, index: index - 1, offset:
|
|
1393
|
+
return { node, index: index - 1, offset: offset3 - node.nodeSize };
|
|
1394
1394
|
}
|
|
1395
1395
|
/**
|
|
1396
1396
|
Resolve the given position in the document, returning an
|
|
@@ -1583,8 +1583,8 @@ var Node = class _Node3 {
|
|
|
1583
1583
|
return node;
|
|
1584
1584
|
}
|
|
1585
1585
|
};
|
|
1586
|
-
|
|
1587
|
-
var TextNode = class _TextNode extends
|
|
1586
|
+
Node2.prototype.text = void 0;
|
|
1587
|
+
var TextNode = class _TextNode extends Node2 {
|
|
1588
1588
|
/**
|
|
1589
1589
|
@internal
|
|
1590
1590
|
*/
|
|
@@ -2170,7 +2170,7 @@ var NodeType = class _NodeType {
|
|
|
2170
2170
|
create(attrs = null, content, marks) {
|
|
2171
2171
|
if (this.isText)
|
|
2172
2172
|
throw new Error("NodeType.create can't construct text nodes");
|
|
2173
|
-
return new
|
|
2173
|
+
return new Node2(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks));
|
|
2174
2174
|
}
|
|
2175
2175
|
/**
|
|
2176
2176
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but check the given content
|
|
@@ -2180,7 +2180,7 @@ var NodeType = class _NodeType {
|
|
|
2180
2180
|
createChecked(attrs = null, content, marks) {
|
|
2181
2181
|
content = Fragment.from(content);
|
|
2182
2182
|
this.checkContent(content);
|
|
2183
|
-
return new
|
|
2183
|
+
return new Node2(this, this.computeAttrs(attrs), content, Mark.setFrom(marks));
|
|
2184
2184
|
}
|
|
2185
2185
|
/**
|
|
2186
2186
|
Like [`create`](https://prosemirror.net/docs/ref/#model.NodeType.create), but see if it is
|
|
@@ -2203,7 +2203,7 @@ var NodeType = class _NodeType {
|
|
|
2203
2203
|
let after = matched && matched.fillBefore(Fragment.empty, true);
|
|
2204
2204
|
if (!after)
|
|
2205
2205
|
return null;
|
|
2206
|
-
return new
|
|
2206
|
+
return new Node2(this, attrs, content.append(after), Mark.setFrom(marks));
|
|
2207
2207
|
}
|
|
2208
2208
|
/**
|
|
2209
2209
|
Returns true if the given fragment is valid content for this node
|
|
@@ -2399,7 +2399,7 @@ var Schema = class {
|
|
|
2399
2399
|
let type = this.marks[prop], excl = type.spec.excludes;
|
|
2400
2400
|
type.excluded = excl == null ? [type] : excl == "" ? [] : gatherMarks(this, excl.split(" "));
|
|
2401
2401
|
}
|
|
2402
|
-
this.nodeFromJSON = (json) =>
|
|
2402
|
+
this.nodeFromJSON = (json) => Node2.fromJSON(this, json);
|
|
2403
2403
|
this.markFromJSON = (json) => Mark.fromJSON(this, json);
|
|
2404
2404
|
this.topNodeType = this.nodes[this.spec.topNode || "doc"];
|
|
2405
2405
|
this.cached.wrappings = /* @__PURE__ */ Object.create(null);
|
|
@@ -3018,10 +3018,10 @@ var ParseContext = class {
|
|
|
3018
3018
|
}
|
|
3019
3019
|
return pos;
|
|
3020
3020
|
}
|
|
3021
|
-
findAtPoint(parent,
|
|
3021
|
+
findAtPoint(parent, offset3) {
|
|
3022
3022
|
if (this.find)
|
|
3023
3023
|
for (let i = 0; i < this.find.length; i++) {
|
|
3024
|
-
if (this.find[i].node == parent && this.find[i].offset ==
|
|
3024
|
+
if (this.find[i].node == parent && this.find[i].offset == offset3)
|
|
3025
3025
|
this.find[i].pos = this.currentPos;
|
|
3026
3026
|
}
|
|
3027
3027
|
}
|
|
@@ -3224,9 +3224,9 @@ var DOMSerializer = class _DOMSerializer {
|
|
|
3224
3224
|
/**
|
|
3225
3225
|
@internal
|
|
3226
3226
|
*/
|
|
3227
|
-
serializeMark(mark,
|
|
3227
|
+
serializeMark(mark, inline3, options = {}) {
|
|
3228
3228
|
let toDOM = this.marks[mark.type.name];
|
|
3229
|
-
return toDOM && renderSpec(doc(options), toDOM(mark,
|
|
3229
|
+
return toDOM && renderSpec(doc(options), toDOM(mark, inline3), null, mark.attrs);
|
|
3230
3230
|
}
|
|
3231
3231
|
static renderSpec(doc3, structure, xmlNS = null, blockArraysIn) {
|
|
3232
3232
|
if (typeof structure == "string")
|
|
@@ -3353,8 +3353,8 @@ function renderSpec(doc3, structure, xmlNS, blockArraysIn) {
|
|
|
3353
3353
|
// ../../node_modules/.pnpm/prosemirror-transform@1.12.0/node_modules/prosemirror-transform/dist/index.js
|
|
3354
3354
|
var lower16 = 65535;
|
|
3355
3355
|
var factor16 = Math.pow(2, 16);
|
|
3356
|
-
function makeRecover(index,
|
|
3357
|
-
return index +
|
|
3356
|
+
function makeRecover(index, offset3) {
|
|
3357
|
+
return index + offset3 * factor16;
|
|
3358
3358
|
}
|
|
3359
3359
|
function recoverIndex(value) {
|
|
3360
3360
|
return value & lower16;
|
|
@@ -4283,20 +4283,20 @@ function setBlockType(tr2, from2, to, type, attrs) {
|
|
|
4283
4283
|
});
|
|
4284
4284
|
}
|
|
4285
4285
|
function replaceNewlines(tr2, node, pos, mapFrom) {
|
|
4286
|
-
node.forEach((child,
|
|
4286
|
+
node.forEach((child, offset3) => {
|
|
4287
4287
|
if (child.isText) {
|
|
4288
4288
|
let m, newline = /\r?\n|\r/g;
|
|
4289
4289
|
while (m = newline.exec(child.text)) {
|
|
4290
|
-
let start = tr2.mapping.slice(mapFrom).map(pos + 1 +
|
|
4290
|
+
let start = tr2.mapping.slice(mapFrom).map(pos + 1 + offset3 + m.index);
|
|
4291
4291
|
tr2.replaceWith(start, start + 1, node.type.schema.linebreakReplacement.create());
|
|
4292
4292
|
}
|
|
4293
4293
|
}
|
|
4294
4294
|
});
|
|
4295
4295
|
}
|
|
4296
4296
|
function replaceLinebreaks(tr2, node, pos, mapFrom) {
|
|
4297
|
-
node.forEach((child,
|
|
4297
|
+
node.forEach((child, offset3) => {
|
|
4298
4298
|
if (child.type == child.type.schema.linebreakReplacement) {
|
|
4299
|
-
let start = tr2.mapping.slice(mapFrom).map(pos + 1 +
|
|
4299
|
+
let start = tr2.mapping.slice(mapFrom).map(pos + 1 + offset3);
|
|
4300
4300
|
tr2.replaceWith(start, start + 1, node.type.schema.text("\n"));
|
|
4301
4301
|
}
|
|
4302
4302
|
});
|
|
@@ -6056,7 +6056,7 @@ var EditorState = class _EditorState {
|
|
|
6056
6056
|
let instance = new _EditorState($config);
|
|
6057
6057
|
$config.fields.forEach((field) => {
|
|
6058
6058
|
if (field.name == "doc") {
|
|
6059
|
-
instance.doc =
|
|
6059
|
+
instance.doc = Node2.fromJSON(config.schema, json.doc);
|
|
6060
6060
|
} else if (field.name == "selection") {
|
|
6061
6061
|
instance.selection = Selection.fromJSON(instance.doc, json.selection);
|
|
6062
6062
|
} else if (field.name == "storedMarks") {
|
|
@@ -6232,26 +6232,26 @@ var duplicateBlockByRef = (editor, block) => {
|
|
|
6232
6232
|
return false;
|
|
6233
6233
|
}
|
|
6234
6234
|
};
|
|
6235
|
-
var canMoveBlockByOffset = (editor, block,
|
|
6235
|
+
var canMoveBlockByOffset = (editor, block, offset3) => {
|
|
6236
6236
|
const position = findBlockPosition(editor, block);
|
|
6237
6237
|
if (position === null) return false;
|
|
6238
6238
|
const $position = editor.state.doc.resolve(position);
|
|
6239
6239
|
const index = $position.index();
|
|
6240
|
-
const siblingIndex = index +
|
|
6240
|
+
const siblingIndex = index + offset3;
|
|
6241
6241
|
return siblingIndex >= 0 && siblingIndex < $position.parent.childCount;
|
|
6242
6242
|
};
|
|
6243
|
-
var moveBlockByOffset = (editor, block,
|
|
6243
|
+
var moveBlockByOffset = (editor, block, offset3) => {
|
|
6244
6244
|
const position = findBlockPosition(editor, block);
|
|
6245
6245
|
if (position === null) return false;
|
|
6246
6246
|
const $position = editor.state.doc.resolve(position);
|
|
6247
6247
|
const index = $position.index();
|
|
6248
|
-
const siblingIndex = index +
|
|
6248
|
+
const siblingIndex = index + offset3;
|
|
6249
6249
|
if (siblingIndex < 0 || siblingIndex >= $position.parent.childCount) return false;
|
|
6250
6250
|
const node = $position.parent.child(index);
|
|
6251
6251
|
const sibling = $position.parent.child(siblingIndex);
|
|
6252
6252
|
try {
|
|
6253
6253
|
let tr2 = editor.state.tr.delete(position, position + node.nodeSize);
|
|
6254
|
-
const insertPosition =
|
|
6254
|
+
const insertPosition = offset3 < 0 ? position - sibling.nodeSize : position + sibling.nodeSize;
|
|
6255
6255
|
tr2 = tr2.insert(insertPosition, node);
|
|
6256
6256
|
tr2.setSelection(NodeSelection.create(tr2.doc, insertPosition));
|
|
6257
6257
|
editor.view.dispatch(tr2.scrollIntoView());
|
|
@@ -6995,42 +6995,42 @@ function scanFor(node, off, targetNode, targetOff, dir) {
|
|
|
6995
6995
|
function nodeSize(node) {
|
|
6996
6996
|
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
6997
6997
|
}
|
|
6998
|
-
function textNodeBefore$1(node,
|
|
6998
|
+
function textNodeBefore$1(node, offset3) {
|
|
6999
6999
|
for (; ; ) {
|
|
7000
|
-
if (node.nodeType == 3 &&
|
|
7000
|
+
if (node.nodeType == 3 && offset3)
|
|
7001
7001
|
return node;
|
|
7002
|
-
if (node.nodeType == 1 &&
|
|
7002
|
+
if (node.nodeType == 1 && offset3 > 0) {
|
|
7003
7003
|
if (node.contentEditable == "false")
|
|
7004
7004
|
return null;
|
|
7005
|
-
node = node.childNodes[
|
|
7006
|
-
|
|
7005
|
+
node = node.childNodes[offset3 - 1];
|
|
7006
|
+
offset3 = nodeSize(node);
|
|
7007
7007
|
} else if (node.parentNode && !hasBlockDesc(node)) {
|
|
7008
|
-
|
|
7008
|
+
offset3 = domIndex(node);
|
|
7009
7009
|
node = node.parentNode;
|
|
7010
7010
|
} else {
|
|
7011
7011
|
return null;
|
|
7012
7012
|
}
|
|
7013
7013
|
}
|
|
7014
7014
|
}
|
|
7015
|
-
function textNodeAfter$1(node,
|
|
7015
|
+
function textNodeAfter$1(node, offset3) {
|
|
7016
7016
|
for (; ; ) {
|
|
7017
|
-
if (node.nodeType == 3 &&
|
|
7017
|
+
if (node.nodeType == 3 && offset3 < node.nodeValue.length)
|
|
7018
7018
|
return node;
|
|
7019
|
-
if (node.nodeType == 1 &&
|
|
7019
|
+
if (node.nodeType == 1 && offset3 < node.childNodes.length) {
|
|
7020
7020
|
if (node.contentEditable == "false")
|
|
7021
7021
|
return null;
|
|
7022
|
-
node = node.childNodes[
|
|
7023
|
-
|
|
7022
|
+
node = node.childNodes[offset3];
|
|
7023
|
+
offset3 = 0;
|
|
7024
7024
|
} else if (node.parentNode && !hasBlockDesc(node)) {
|
|
7025
|
-
|
|
7025
|
+
offset3 = domIndex(node) + 1;
|
|
7026
7026
|
node = node.parentNode;
|
|
7027
7027
|
} else {
|
|
7028
7028
|
return null;
|
|
7029
7029
|
}
|
|
7030
7030
|
}
|
|
7031
7031
|
}
|
|
7032
|
-
function isOnEdge(node,
|
|
7033
|
-
for (let atStart =
|
|
7032
|
+
function isOnEdge(node, offset3, parent) {
|
|
7033
|
+
for (let atStart = offset3 == 0, atEnd = offset3 == nodeSize(node); atStart || atEnd; ) {
|
|
7034
7034
|
if (node == parent)
|
|
7035
7035
|
return true;
|
|
7036
7036
|
let index = domIndex(node);
|
|
@@ -7227,7 +7227,7 @@ function focusPreventScroll(dom) {
|
|
|
7227
7227
|
}
|
|
7228
7228
|
}
|
|
7229
7229
|
function findOffsetInNode(node, coords) {
|
|
7230
|
-
let closest, dxClosest = 2e8, coordsClosest,
|
|
7230
|
+
let closest, dxClosest = 2e8, coordsClosest, offset3 = 0;
|
|
7231
7231
|
let rowBot = coords.top, rowTop = coords.top;
|
|
7232
7232
|
let firstBelow, coordsBelow;
|
|
7233
7233
|
for (let child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {
|
|
@@ -7252,7 +7252,7 @@ function findOffsetInNode(node, coords) {
|
|
|
7252
7252
|
top: coords.top
|
|
7253
7253
|
} : coords;
|
|
7254
7254
|
if (child.nodeType == 1 && dx)
|
|
7255
|
-
|
|
7255
|
+
offset3 = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
|
|
7256
7256
|
continue;
|
|
7257
7257
|
}
|
|
7258
7258
|
} else if (rect.top > coords.top && !firstBelow && rect.left <= coords.left && rect.right >= coords.left) {
|
|
@@ -7260,7 +7260,7 @@ function findOffsetInNode(node, coords) {
|
|
|
7260
7260
|
coordsBelow = { left: Math.max(rect.left, Math.min(rect.right, coords.left)), top: rect.top };
|
|
7261
7261
|
}
|
|
7262
7262
|
if (!closest && (coords.left >= rect.right && coords.top >= rect.top || coords.left >= rect.left && coords.top >= rect.bottom))
|
|
7263
|
-
|
|
7263
|
+
offset3 = childIndex + 1;
|
|
7264
7264
|
}
|
|
7265
7265
|
}
|
|
7266
7266
|
if (!closest && firstBelow) {
|
|
@@ -7271,7 +7271,7 @@ function findOffsetInNode(node, coords) {
|
|
|
7271
7271
|
if (closest && closest.nodeType == 3)
|
|
7272
7272
|
return findOffsetInText(closest, coordsClosest);
|
|
7273
7273
|
if (!closest || dxClosest && closest.nodeType == 1)
|
|
7274
|
-
return { node, offset };
|
|
7274
|
+
return { node, offset: offset3 };
|
|
7275
7275
|
return findOffsetInNode(closest, coordsClosest);
|
|
7276
7276
|
}
|
|
7277
7277
|
function findOffsetInText(node, coords) {
|
|
@@ -7301,14 +7301,14 @@ function targetKludge(dom, coords) {
|
|
|
7301
7301
|
return dom;
|
|
7302
7302
|
}
|
|
7303
7303
|
function posFromElement(view, elt, coords) {
|
|
7304
|
-
let { node, offset } = findOffsetInNode(elt, coords), bias = -1;
|
|
7304
|
+
let { node, offset: offset3 } = findOffsetInNode(elt, coords), bias = -1;
|
|
7305
7305
|
if (node.nodeType == 1 && !node.firstChild) {
|
|
7306
7306
|
let rect = node.getBoundingClientRect();
|
|
7307
7307
|
bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
|
|
7308
7308
|
}
|
|
7309
|
-
return view.docView.posFromDOM(node,
|
|
7309
|
+
return view.docView.posFromDOM(node, offset3, bias);
|
|
7310
7310
|
}
|
|
7311
|
-
function posFromCaret(view, node,
|
|
7311
|
+
function posFromCaret(view, node, offset3, coords) {
|
|
7312
7312
|
let outsideBlock = -1;
|
|
7313
7313
|
for (let cur = node, sawBlock = false; ; ) {
|
|
7314
7314
|
if (cur == view.dom)
|
|
@@ -7332,7 +7332,7 @@ function posFromCaret(view, node, offset, coords) {
|
|
|
7332
7332
|
}
|
|
7333
7333
|
cur = desc.dom.parentNode;
|
|
7334
7334
|
}
|
|
7335
|
-
return outsideBlock > -1 ? outsideBlock : view.docView.posFromDOM(node,
|
|
7335
|
+
return outsideBlock > -1 ? outsideBlock : view.docView.posFromDOM(node, offset3, -1);
|
|
7336
7336
|
}
|
|
7337
7337
|
function elementFromPoint(element, coords, box) {
|
|
7338
7338
|
let len = element.childNodes.length;
|
|
@@ -7354,10 +7354,10 @@ function elementFromPoint(element, coords, box) {
|
|
|
7354
7354
|
return element;
|
|
7355
7355
|
}
|
|
7356
7356
|
function posAtCoords(view, coords) {
|
|
7357
|
-
let doc3 = view.dom.ownerDocument, node,
|
|
7357
|
+
let doc3 = view.dom.ownerDocument, node, offset3 = 0;
|
|
7358
7358
|
let caret = caretFromPoint(doc3, coords.left, coords.top);
|
|
7359
7359
|
if (caret)
|
|
7360
|
-
({ node, offset } = caret);
|
|
7360
|
+
({ node, offset: offset3 } = caret);
|
|
7361
7361
|
let elt = (view.root.elementFromPoint ? view.root : doc3).elementFromPoint(coords.left, coords.top);
|
|
7362
7362
|
let pos;
|
|
7363
7363
|
if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) {
|
|
@@ -7376,20 +7376,20 @@ function posAtCoords(view, coords) {
|
|
|
7376
7376
|
elt = targetKludge(elt, coords);
|
|
7377
7377
|
if (node) {
|
|
7378
7378
|
if (gecko && node.nodeType == 1) {
|
|
7379
|
-
|
|
7380
|
-
if (
|
|
7381
|
-
let next = node.childNodes[
|
|
7379
|
+
offset3 = Math.min(offset3, node.childNodes.length);
|
|
7380
|
+
if (offset3 < node.childNodes.length) {
|
|
7381
|
+
let next = node.childNodes[offset3], box;
|
|
7382
7382
|
if (next.nodeName == "IMG" && (box = next.getBoundingClientRect()).right <= coords.left && box.bottom > coords.top)
|
|
7383
|
-
|
|
7383
|
+
offset3++;
|
|
7384
7384
|
}
|
|
7385
7385
|
}
|
|
7386
7386
|
let prev;
|
|
7387
|
-
if (webkit &&
|
|
7388
|
-
|
|
7389
|
-
if (node == view.dom &&
|
|
7387
|
+
if (webkit && offset3 && node.nodeType == 1 && (prev = node.childNodes[offset3 - 1]).nodeType == 1 && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top)
|
|
7388
|
+
offset3--;
|
|
7389
|
+
if (node == view.dom && offset3 == node.childNodes.length - 1 && node.lastChild.nodeType == 1 && coords.top > node.lastChild.getBoundingClientRect().bottom)
|
|
7390
7390
|
pos = view.state.doc.content.size;
|
|
7391
|
-
else if (
|
|
7392
|
-
pos = posFromCaret(view, node,
|
|
7391
|
+
else if (offset3 == 0 || node.nodeType != 1 || node.childNodes[offset3 - 1].nodeName != "BR")
|
|
7392
|
+
pos = posFromCaret(view, node, offset3, coords);
|
|
7393
7393
|
}
|
|
7394
7394
|
if (pos == null)
|
|
7395
7395
|
pos = posFromElement(view, elt, coords);
|
|
@@ -7410,26 +7410,26 @@ function singleRect(target, bias) {
|
|
|
7410
7410
|
}
|
|
7411
7411
|
var BIDI = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
|
7412
7412
|
function coordsAtPos(view, pos, side) {
|
|
7413
|
-
let { node, offset, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
|
|
7413
|
+
let { node, offset: offset3, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
|
|
7414
7414
|
let supportEmptyRange = webkit || gecko;
|
|
7415
7415
|
if (node.nodeType == 3) {
|
|
7416
|
-
if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !
|
|
7417
|
-
let rect = singleRect(textRange(node,
|
|
7418
|
-
if (gecko &&
|
|
7419
|
-
let rectBefore = singleRect(textRange(node,
|
|
7416
|
+
if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset3 : offset3 == node.nodeValue.length))) {
|
|
7417
|
+
let rect = singleRect(textRange(node, offset3, offset3), side);
|
|
7418
|
+
if (gecko && offset3 && /\s/.test(node.nodeValue[offset3 - 1]) && offset3 < node.nodeValue.length) {
|
|
7419
|
+
let rectBefore = singleRect(textRange(node, offset3 - 1, offset3 - 1), -1);
|
|
7420
7420
|
if (rectBefore.top == rect.top) {
|
|
7421
|
-
let rectAfter = singleRect(textRange(node,
|
|
7421
|
+
let rectAfter = singleRect(textRange(node, offset3, offset3 + 1), -1);
|
|
7422
7422
|
if (rectAfter.top != rect.top)
|
|
7423
7423
|
return flattenV(rectAfter, rectAfter.left < rectBefore.left);
|
|
7424
7424
|
}
|
|
7425
7425
|
}
|
|
7426
7426
|
return rect;
|
|
7427
7427
|
} else {
|
|
7428
|
-
let from2 =
|
|
7429
|
-
if (side < 0 && !
|
|
7428
|
+
let from2 = offset3, to = offset3, takeSide = side < 0 ? 1 : -1;
|
|
7429
|
+
if (side < 0 && !offset3) {
|
|
7430
7430
|
to++;
|
|
7431
7431
|
takeSide = -1;
|
|
7432
|
-
} else if (side >= 0 &&
|
|
7432
|
+
} else if (side >= 0 && offset3 == node.nodeValue.length) {
|
|
7433
7433
|
from2--;
|
|
7434
7434
|
takeSide = 1;
|
|
7435
7435
|
} else if (side < 0) {
|
|
@@ -7442,26 +7442,26 @@ function coordsAtPos(view, pos, side) {
|
|
|
7442
7442
|
}
|
|
7443
7443
|
let $dom = view.state.doc.resolve(pos - (atom || 0));
|
|
7444
7444
|
if (!$dom.parent.inlineContent) {
|
|
7445
|
-
if (atom == null &&
|
|
7446
|
-
let before = node.childNodes[
|
|
7445
|
+
if (atom == null && offset3 && (side < 0 || offset3 == nodeSize(node))) {
|
|
7446
|
+
let before = node.childNodes[offset3 - 1];
|
|
7447
7447
|
if (before.nodeType == 1)
|
|
7448
7448
|
return flattenH(before.getBoundingClientRect(), false);
|
|
7449
7449
|
}
|
|
7450
|
-
if (atom == null &&
|
|
7451
|
-
let after = node.childNodes[
|
|
7450
|
+
if (atom == null && offset3 < nodeSize(node)) {
|
|
7451
|
+
let after = node.childNodes[offset3];
|
|
7452
7452
|
if (after.nodeType == 1)
|
|
7453
7453
|
return flattenH(after.getBoundingClientRect(), true);
|
|
7454
7454
|
}
|
|
7455
7455
|
return flattenH(node.getBoundingClientRect(), side >= 0);
|
|
7456
7456
|
}
|
|
7457
|
-
if (atom == null &&
|
|
7458
|
-
let before = node.childNodes[
|
|
7457
|
+
if (atom == null && offset3 && (side < 0 || offset3 == nodeSize(node))) {
|
|
7458
|
+
let before = node.childNodes[offset3 - 1];
|
|
7459
7459
|
let target = before.nodeType == 3 ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1)) : before.nodeType == 1 && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
|
|
7460
7460
|
if (target)
|
|
7461
7461
|
return flattenV(singleRect(target, 1), false);
|
|
7462
7462
|
}
|
|
7463
|
-
if (atom == null &&
|
|
7464
|
-
let after = node.childNodes[
|
|
7463
|
+
if (atom == null && offset3 < nodeSize(node)) {
|
|
7464
|
+
let after = node.childNodes[offset3];
|
|
7465
7465
|
while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords)
|
|
7466
7466
|
after = after.nextSibling;
|
|
7467
7467
|
let target = !after ? null : after.nodeType == 3 ? textRange(after, 0, supportEmptyRange ? 0 : 1) : after.nodeType == 1 ? after : null;
|
|
@@ -7535,7 +7535,7 @@ function endOfTextblockHorizontal(view, state, dir) {
|
|
|
7535
7535
|
let { $head } = state.selection;
|
|
7536
7536
|
if (!$head.parent.isTextblock)
|
|
7537
7537
|
return false;
|
|
7538
|
-
let
|
|
7538
|
+
let offset3 = $head.parentOffset, atStart = !offset3, atEnd = offset3 == $head.parent.content.size;
|
|
7539
7539
|
let sel = view.domSelection();
|
|
7540
7540
|
if (!sel)
|
|
7541
7541
|
return $head.pos == $head.start() || $head.pos == $head.end();
|
|
@@ -7609,10 +7609,10 @@ var ViewDesc = class {
|
|
|
7609
7609
|
}
|
|
7610
7610
|
// The size of the content represented by this desc.
|
|
7611
7611
|
get size() {
|
|
7612
|
-
let
|
|
7612
|
+
let size3 = 0;
|
|
7613
7613
|
for (let i = 0; i < this.children.length; i++)
|
|
7614
|
-
|
|
7615
|
-
return
|
|
7614
|
+
size3 += this.children[i].size;
|
|
7615
|
+
return size3;
|
|
7616
7616
|
}
|
|
7617
7617
|
// For block nodes, this represents the space taken up by their
|
|
7618
7618
|
// start/end tokens.
|
|
@@ -7646,12 +7646,12 @@ var ViewDesc = class {
|
|
|
7646
7646
|
get posAtEnd() {
|
|
7647
7647
|
return this.posAtStart + this.size - 2 * this.border;
|
|
7648
7648
|
}
|
|
7649
|
-
localPosFromDOM(dom,
|
|
7649
|
+
localPosFromDOM(dom, offset3, bias) {
|
|
7650
7650
|
if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) {
|
|
7651
7651
|
if (bias < 0) {
|
|
7652
7652
|
let domBefore, desc;
|
|
7653
7653
|
if (dom == this.contentDOM) {
|
|
7654
|
-
domBefore = dom.childNodes[
|
|
7654
|
+
domBefore = dom.childNodes[offset3 - 1];
|
|
7655
7655
|
} else {
|
|
7656
7656
|
while (dom.parentNode != this.contentDOM)
|
|
7657
7657
|
dom = dom.parentNode;
|
|
@@ -7663,7 +7663,7 @@ var ViewDesc = class {
|
|
|
7663
7663
|
} else {
|
|
7664
7664
|
let domAfter, desc;
|
|
7665
7665
|
if (dom == this.contentDOM) {
|
|
7666
|
-
domAfter = dom.childNodes[
|
|
7666
|
+
domAfter = dom.childNodes[offset3];
|
|
7667
7667
|
} else {
|
|
7668
7668
|
while (dom.parentNode != this.contentDOM)
|
|
7669
7669
|
dom = dom.parentNode;
|
|
@@ -7676,11 +7676,11 @@ var ViewDesc = class {
|
|
|
7676
7676
|
}
|
|
7677
7677
|
let atEnd;
|
|
7678
7678
|
if (dom == this.dom && this.contentDOM) {
|
|
7679
|
-
atEnd =
|
|
7679
|
+
atEnd = offset3 > domIndex(this.contentDOM);
|
|
7680
7680
|
} else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {
|
|
7681
7681
|
atEnd = dom.compareDocumentPosition(this.contentDOM) & 2;
|
|
7682
7682
|
} else if (this.dom.firstChild) {
|
|
7683
|
-
if (
|
|
7683
|
+
if (offset3 == 0)
|
|
7684
7684
|
for (let search = dom; ; search = search.parentNode) {
|
|
7685
7685
|
if (search == this.dom) {
|
|
7686
7686
|
atEnd = false;
|
|
@@ -7689,7 +7689,7 @@ var ViewDesc = class {
|
|
|
7689
7689
|
if (search.previousSibling)
|
|
7690
7690
|
break;
|
|
7691
7691
|
}
|
|
7692
|
-
if (atEnd == null &&
|
|
7692
|
+
if (atEnd == null && offset3 == dom.childNodes.length)
|
|
7693
7693
|
for (let search = dom; ; search = search.parentNode) {
|
|
7694
7694
|
if (search == this.dom) {
|
|
7695
7695
|
atEnd = true;
|
|
@@ -7718,20 +7718,20 @@ var ViewDesc = class {
|
|
|
7718
7718
|
if (cur == this)
|
|
7719
7719
|
return desc;
|
|
7720
7720
|
}
|
|
7721
|
-
posFromDOM(dom,
|
|
7721
|
+
posFromDOM(dom, offset3, bias) {
|
|
7722
7722
|
for (let scan = dom; scan; scan = scan.parentNode) {
|
|
7723
7723
|
let desc = this.getDesc(scan);
|
|
7724
7724
|
if (desc)
|
|
7725
|
-
return desc.localPosFromDOM(dom,
|
|
7725
|
+
return desc.localPosFromDOM(dom, offset3, bias);
|
|
7726
7726
|
}
|
|
7727
7727
|
return -1;
|
|
7728
7728
|
}
|
|
7729
7729
|
// Find the desc for the node after the given pos, if any. (When a
|
|
7730
7730
|
// parent node overrode rendering, there might not be one.)
|
|
7731
7731
|
descAt(pos) {
|
|
7732
|
-
for (let i = 0,
|
|
7733
|
-
let child = this.children[i], end =
|
|
7734
|
-
if (
|
|
7732
|
+
for (let i = 0, offset3 = 0; i < this.children.length; i++) {
|
|
7733
|
+
let child = this.children[i], end = offset3 + child.size;
|
|
7734
|
+
if (offset3 == pos && end != offset3) {
|
|
7735
7735
|
while (!child.border && child.children.length) {
|
|
7736
7736
|
for (let i2 = 0; i2 < child.children.length; i2++) {
|
|
7737
7737
|
let inner = child.children[i2];
|
|
@@ -7744,24 +7744,24 @@ var ViewDesc = class {
|
|
|
7744
7744
|
return child;
|
|
7745
7745
|
}
|
|
7746
7746
|
if (pos < end)
|
|
7747
|
-
return child.descAt(pos -
|
|
7748
|
-
|
|
7747
|
+
return child.descAt(pos - offset3 - child.border);
|
|
7748
|
+
offset3 = end;
|
|
7749
7749
|
}
|
|
7750
7750
|
}
|
|
7751
7751
|
domFromPos(pos, side) {
|
|
7752
7752
|
if (!this.contentDOM)
|
|
7753
7753
|
return { node: this.dom, offset: 0, atom: pos + 1 };
|
|
7754
|
-
let i = 0,
|
|
7754
|
+
let i = 0, offset3 = 0;
|
|
7755
7755
|
for (let curPos = 0; i < this.children.length; i++) {
|
|
7756
7756
|
let child = this.children[i], end = curPos + child.size;
|
|
7757
7757
|
if (end > pos || child instanceof TrailingHackViewDesc) {
|
|
7758
|
-
|
|
7758
|
+
offset3 = pos - curPos;
|
|
7759
7759
|
break;
|
|
7760
7760
|
}
|
|
7761
7761
|
curPos = end;
|
|
7762
7762
|
}
|
|
7763
|
-
if (
|
|
7764
|
-
return this.children[i].domFromPos(
|
|
7763
|
+
if (offset3)
|
|
7764
|
+
return this.children[i].domFromPos(offset3 - this.children[i].border, side);
|
|
7765
7765
|
for (let prev; i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.side >= 0; i--) {
|
|
7766
7766
|
}
|
|
7767
7767
|
if (side <= 0) {
|
|
@@ -7792,13 +7792,13 @@ var ViewDesc = class {
|
|
|
7792
7792
|
if (this.children.length == 0)
|
|
7793
7793
|
return { node: this.contentDOM, from: from2, to, fromOffset: 0, toOffset: this.contentDOM.childNodes.length };
|
|
7794
7794
|
let fromOffset = -1, toOffset = -1;
|
|
7795
|
-
for (let
|
|
7796
|
-
let child = this.children[i], end =
|
|
7795
|
+
for (let offset3 = base2, i = 0; ; i++) {
|
|
7796
|
+
let child = this.children[i], end = offset3 + child.size;
|
|
7797
7797
|
if (fromOffset == -1 && from2 <= end) {
|
|
7798
|
-
let childBase =
|
|
7798
|
+
let childBase = offset3 + child.border;
|
|
7799
7799
|
if (from2 >= childBase && to <= end - child.border && child.node && child.contentDOM && this.contentDOM.contains(child.contentDOM))
|
|
7800
7800
|
return child.parseRange(from2, to, childBase);
|
|
7801
|
-
from2 =
|
|
7801
|
+
from2 = offset3;
|
|
7802
7802
|
for (let j = i; j > 0; j--) {
|
|
7803
7803
|
let prev = this.children[j - 1];
|
|
7804
7804
|
if (prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1)) {
|
|
@@ -7824,7 +7824,7 @@ var ViewDesc = class {
|
|
|
7824
7824
|
toOffset = this.contentDOM.childNodes.length;
|
|
7825
7825
|
break;
|
|
7826
7826
|
}
|
|
7827
|
-
|
|
7827
|
+
offset3 = end;
|
|
7828
7828
|
}
|
|
7829
7829
|
return { node: this.contentDOM, from: from2, to, fromOffset, toOffset };
|
|
7830
7830
|
}
|
|
@@ -7835,10 +7835,10 @@ var ViewDesc = class {
|
|
|
7835
7835
|
return child.size == 0 || child.emptyChildAt(side);
|
|
7836
7836
|
}
|
|
7837
7837
|
domAfterPos(pos) {
|
|
7838
|
-
let { node, offset } = this.domFromPos(pos, 0);
|
|
7839
|
-
if (node.nodeType != 1 ||
|
|
7838
|
+
let { node, offset: offset3 } = this.domFromPos(pos, 0);
|
|
7839
|
+
if (node.nodeType != 1 || offset3 == node.childNodes.length)
|
|
7840
7840
|
throw new RangeError("No node after pos " + pos);
|
|
7841
|
-
return node.childNodes[
|
|
7841
|
+
return node.childNodes[offset3];
|
|
7842
7842
|
}
|
|
7843
7843
|
// View descs are responsible for setting any selection that falls
|
|
7844
7844
|
// entirely inside of them, so that custom implementations can do
|
|
@@ -7847,11 +7847,11 @@ var ViewDesc = class {
|
|
|
7847
7847
|
// case we just use whatever domFromPos produces as a best effort.
|
|
7848
7848
|
setSelection(anchor, head, view, force = false) {
|
|
7849
7849
|
let from2 = Math.min(anchor, head), to = Math.max(anchor, head);
|
|
7850
|
-
for (let i = 0,
|
|
7851
|
-
let child = this.children[i], end =
|
|
7852
|
-
if (from2 >
|
|
7853
|
-
return child.setSelection(anchor -
|
|
7854
|
-
|
|
7850
|
+
for (let i = 0, offset3 = 0; i < this.children.length; i++) {
|
|
7851
|
+
let child = this.children[i], end = offset3 + child.size;
|
|
7852
|
+
if (from2 > offset3 && to < end)
|
|
7853
|
+
return child.setSelection(anchor - offset3 - child.border, head - offset3 - child.border, view, force);
|
|
7854
|
+
offset3 = end;
|
|
7855
7855
|
}
|
|
7856
7856
|
let anchorDOM = this.domFromPos(anchor, anchor ? -1 : 1);
|
|
7857
7857
|
let headDOM = head == anchor ? anchorDOM : this.domFromPos(head, head ? -1 : 1);
|
|
@@ -7859,10 +7859,10 @@ var ViewDesc = class {
|
|
|
7859
7859
|
let selRange = view.domSelectionRange();
|
|
7860
7860
|
let brKludge = false;
|
|
7861
7861
|
if ((gecko || safari) && anchor == head) {
|
|
7862
|
-
let { node, offset } = anchorDOM;
|
|
7862
|
+
let { node, offset: offset3 } = anchorDOM;
|
|
7863
7863
|
if (node.nodeType == 3) {
|
|
7864
|
-
brKludge = !!(
|
|
7865
|
-
if (brKludge &&
|
|
7864
|
+
brKludge = !!(offset3 && node.nodeValue[offset3 - 1] == "\n");
|
|
7865
|
+
if (brKludge && offset3 == node.nodeValue.length) {
|
|
7866
7866
|
for (let scan = node, after; scan; scan = scan.parentNode) {
|
|
7867
7867
|
if (after = scan.nextSibling) {
|
|
7868
7868
|
if (after.nodeName == "BR")
|
|
@@ -7875,7 +7875,7 @@ var ViewDesc = class {
|
|
|
7875
7875
|
}
|
|
7876
7876
|
}
|
|
7877
7877
|
} else {
|
|
7878
|
-
let prev = node.childNodes[
|
|
7878
|
+
let prev = node.childNodes[offset3 - 1];
|
|
7879
7879
|
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
|
|
7880
7880
|
}
|
|
7881
7881
|
}
|
|
@@ -7918,12 +7918,12 @@ var ViewDesc = class {
|
|
|
7918
7918
|
// Remove a subtree of the element tree that has been touched
|
|
7919
7919
|
// by a DOM change, so that the next update will redraw it.
|
|
7920
7920
|
markDirty(from2, to) {
|
|
7921
|
-
for (let
|
|
7922
|
-
let child = this.children[i], end =
|
|
7923
|
-
if (
|
|
7924
|
-
let startInside =
|
|
7921
|
+
for (let offset3 = 0, i = 0; i < this.children.length; i++) {
|
|
7922
|
+
let child = this.children[i], end = offset3 + child.size;
|
|
7923
|
+
if (offset3 == end ? from2 <= end && to >= offset3 : from2 < end && to > offset3) {
|
|
7924
|
+
let startInside = offset3 + child.border, endInside = end - child.border;
|
|
7925
7925
|
if (from2 >= startInside && to <= endInside) {
|
|
7926
|
-
this.dirty = from2 ==
|
|
7926
|
+
this.dirty = from2 == offset3 || to == end ? CONTENT_DIRTY : CHILD_DIRTY;
|
|
7927
7927
|
if (from2 == startInside && to == endInside && (child.contentLost || child.dom.parentNode != this.contentDOM))
|
|
7928
7928
|
child.dirty = NODE_DIRTY;
|
|
7929
7929
|
else
|
|
@@ -7933,7 +7933,7 @@ var ViewDesc = class {
|
|
|
7933
7933
|
child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM && !child.children.length ? CONTENT_DIRTY : NODE_DIRTY;
|
|
7934
7934
|
}
|
|
7935
7935
|
}
|
|
7936
|
-
|
|
7936
|
+
offset3 = end;
|
|
7937
7937
|
}
|
|
7938
7938
|
this.dirty = CONTENT_DIRTY;
|
|
7939
7939
|
}
|
|
@@ -8018,10 +8018,10 @@ var CompositionViewDesc = class extends ViewDesc {
|
|
|
8018
8018
|
get size() {
|
|
8019
8019
|
return this.text.length;
|
|
8020
8020
|
}
|
|
8021
|
-
localPosFromDOM(dom,
|
|
8021
|
+
localPosFromDOM(dom, offset3) {
|
|
8022
8022
|
if (dom != this.textDOM)
|
|
8023
|
-
return this.posAtStart + (
|
|
8024
|
-
return this.posAtStart +
|
|
8023
|
+
return this.posAtStart + (offset3 ? this.size : 0);
|
|
8024
|
+
return this.posAtStart + offset3;
|
|
8025
8025
|
}
|
|
8026
8026
|
domFromPos(pos) {
|
|
8027
8027
|
return { node: this.textDOM, offset: pos };
|
|
@@ -8036,11 +8036,11 @@ var MarkViewDesc = class _MarkViewDesc extends ViewDesc {
|
|
|
8036
8036
|
this.mark = mark;
|
|
8037
8037
|
this.spec = spec;
|
|
8038
8038
|
}
|
|
8039
|
-
static create(parent, mark,
|
|
8039
|
+
static create(parent, mark, inline3, view) {
|
|
8040
8040
|
let custom = view.nodeViews[mark.type.name];
|
|
8041
|
-
let spec = custom && custom(mark, view,
|
|
8041
|
+
let spec = custom && custom(mark, view, inline3);
|
|
8042
8042
|
if (!spec || !spec.dom)
|
|
8043
|
-
spec = DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark,
|
|
8043
|
+
spec = DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark, inline3), null, mark.attrs);
|
|
8044
8044
|
return new _MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom, spec);
|
|
8045
8045
|
}
|
|
8046
8046
|
parseRule() {
|
|
@@ -8064,9 +8064,9 @@ var MarkViewDesc = class _MarkViewDesc extends ViewDesc {
|
|
|
8064
8064
|
}
|
|
8065
8065
|
slice(from2, to, view) {
|
|
8066
8066
|
let copy2 = _MarkViewDesc.create(this.parent, this.mark, true, view);
|
|
8067
|
-
let nodes = this.children,
|
|
8068
|
-
if (to <
|
|
8069
|
-
nodes = replaceNodes(nodes, to,
|
|
8067
|
+
let nodes = this.children, size3 = this.size;
|
|
8068
|
+
if (to < size3)
|
|
8069
|
+
nodes = replaceNodes(nodes, to, size3, view);
|
|
8070
8070
|
if (from2 > 0)
|
|
8071
8071
|
nodes = replaceNodes(nodes, 0, from2, view);
|
|
8072
8072
|
for (let i = 0; i < nodes.length; i++)
|
|
@@ -8170,19 +8170,19 @@ var NodeViewDesc = class _NodeViewDesc extends ViewDesc {
|
|
|
8170
8170
|
// separate step, syncs the DOM inside `this.contentDOM` to
|
|
8171
8171
|
// `this.children`.
|
|
8172
8172
|
updateChildren(view, pos) {
|
|
8173
|
-
let
|
|
8173
|
+
let inline3 = this.node.inlineContent, off = pos;
|
|
8174
8174
|
let composition = view.composing ? this.localCompositionInfo(view, pos) : null;
|
|
8175
8175
|
let localComposition = composition && composition.pos > -1 ? composition : null;
|
|
8176
8176
|
let compositionInChild = composition && composition.pos < 0;
|
|
8177
8177
|
let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
|
|
8178
8178
|
iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
|
|
8179
8179
|
if (widget.spec.marks)
|
|
8180
|
-
updater.syncToMarks(widget.spec.marks,
|
|
8180
|
+
updater.syncToMarks(widget.spec.marks, inline3, view, i);
|
|
8181
8181
|
else if (widget.type.side >= 0 && !insideNode)
|
|
8182
|
-
updater.syncToMarks(i == this.node.childCount ? Mark.none : this.node.child(i).marks,
|
|
8182
|
+
updater.syncToMarks(i == this.node.childCount ? Mark.none : this.node.child(i).marks, inline3, view, i);
|
|
8183
8183
|
updater.placeWidget(widget, view, off);
|
|
8184
8184
|
}, (child, outerDeco, innerDeco, i) => {
|
|
8185
|
-
updater.syncToMarks(child.marks,
|
|
8185
|
+
updater.syncToMarks(child.marks, inline3, view, i);
|
|
8186
8186
|
let compIndex;
|
|
8187
8187
|
if (updater.findNodeMatch(child, outerDeco, innerDeco, i)) ;
|
|
8188
8188
|
else if (compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild(composition.node)) > -1 && updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view)) ;
|
|
@@ -8192,7 +8192,7 @@ var NodeViewDesc = class _NodeViewDesc extends ViewDesc {
|
|
|
8192
8192
|
}
|
|
8193
8193
|
off += child.nodeSize;
|
|
8194
8194
|
});
|
|
8195
|
-
updater.syncToMarks([],
|
|
8195
|
+
updater.syncToMarks([], inline3, view, 0);
|
|
8196
8196
|
if (this.node.isTextblock)
|
|
8197
8197
|
updater.addTextblockHacks();
|
|
8198
8198
|
updater.destroyRest();
|
|
@@ -8325,10 +8325,10 @@ var TextViewDesc = class _TextViewDesc extends NodeViewDesc {
|
|
|
8325
8325
|
domFromPos(pos) {
|
|
8326
8326
|
return { node: this.nodeDOM, offset: pos };
|
|
8327
8327
|
}
|
|
8328
|
-
localPosFromDOM(dom,
|
|
8328
|
+
localPosFromDOM(dom, offset3, bias) {
|
|
8329
8329
|
if (dom == this.nodeDOM)
|
|
8330
|
-
return this.posAtStart + Math.min(
|
|
8331
|
-
return super.localPosFromDOM(dom,
|
|
8330
|
+
return this.posAtStart + Math.min(offset3, this.node.text.length);
|
|
8331
|
+
return super.localPosFromDOM(dom, offset3, bias);
|
|
8332
8332
|
}
|
|
8333
8333
|
ignoreMutation(mutation) {
|
|
8334
8334
|
return mutation.type != "characterData" && mutation.type != "selection";
|
|
@@ -8558,7 +8558,7 @@ var ViewTreeUpdater = class {
|
|
|
8558
8558
|
}
|
|
8559
8559
|
// Sync the current stack of mark descs with the given array of
|
|
8560
8560
|
// marks, reusing existing mark descs when possible.
|
|
8561
|
-
syncToMarks(marks,
|
|
8561
|
+
syncToMarks(marks, inline3, view, parentIndex) {
|
|
8562
8562
|
let keep = 0, depth = this.stack.length >> 1;
|
|
8563
8563
|
let maxKeep = Math.min(depth, marks.length);
|
|
8564
8564
|
while (keep < maxKeep && (keep == depth - 1 ? this.top : this.stack[keep + 1 << 1]).matchesMark(marks[keep]) && marks[keep].type.spec.spanning !== false)
|
|
@@ -8589,7 +8589,7 @@ var ViewTreeUpdater = class {
|
|
|
8589
8589
|
}
|
|
8590
8590
|
this.top = this.top.children[this.index];
|
|
8591
8591
|
} else {
|
|
8592
|
-
let markDesc = MarkViewDesc.create(this.top, marks[depth],
|
|
8592
|
+
let markDesc = MarkViewDesc.create(this.top, marks[depth], inline3, view);
|
|
8593
8593
|
this.top.children.splice(this.index, 0, markDesc);
|
|
8594
8594
|
this.top = markDesc;
|
|
8595
8595
|
this.changed = true;
|
|
@@ -8789,19 +8789,19 @@ function compareSide(a, b) {
|
|
|
8789
8789
|
return a.type.side - b.type.side;
|
|
8790
8790
|
}
|
|
8791
8791
|
function iterDeco(parent, deco, onWidget, onNode) {
|
|
8792
|
-
let locals = deco.locals(parent),
|
|
8792
|
+
let locals = deco.locals(parent), offset3 = 0;
|
|
8793
8793
|
if (locals.length == 0) {
|
|
8794
8794
|
for (let i = 0; i < parent.childCount; i++) {
|
|
8795
8795
|
let child = parent.child(i);
|
|
8796
|
-
onNode(child, locals, deco.forChild(
|
|
8797
|
-
|
|
8796
|
+
onNode(child, locals, deco.forChild(offset3, child), i);
|
|
8797
|
+
offset3 += child.nodeSize;
|
|
8798
8798
|
}
|
|
8799
8799
|
return;
|
|
8800
8800
|
}
|
|
8801
8801
|
let decoIndex = 0, active = [], restNode = null;
|
|
8802
8802
|
for (let parentIndex = 0; ; ) {
|
|
8803
8803
|
let widget, widgets;
|
|
8804
|
-
while (decoIndex < locals.length && locals[decoIndex].to ==
|
|
8804
|
+
while (decoIndex < locals.length && locals[decoIndex].to == offset3) {
|
|
8805
8805
|
let next = locals[decoIndex++];
|
|
8806
8806
|
if (next.widget) {
|
|
8807
8807
|
if (!widget)
|
|
@@ -8831,11 +8831,11 @@ function iterDeco(parent, deco, onWidget, onNode) {
|
|
|
8831
8831
|
break;
|
|
8832
8832
|
}
|
|
8833
8833
|
for (let i = 0; i < active.length; i++)
|
|
8834
|
-
if (active[i].to <=
|
|
8834
|
+
if (active[i].to <= offset3)
|
|
8835
8835
|
active.splice(i--, 1);
|
|
8836
|
-
while (decoIndex < locals.length && locals[decoIndex].from <=
|
|
8836
|
+
while (decoIndex < locals.length && locals[decoIndex].from <= offset3 && locals[decoIndex].to > offset3)
|
|
8837
8837
|
active.push(locals[decoIndex++]);
|
|
8838
|
-
let end =
|
|
8838
|
+
let end = offset3 + child.nodeSize;
|
|
8839
8839
|
if (child.isText) {
|
|
8840
8840
|
let cutAt = end;
|
|
8841
8841
|
if (decoIndex < locals.length && locals[decoIndex].from < cutAt)
|
|
@@ -8844,8 +8844,8 @@ function iterDeco(parent, deco, onWidget, onNode) {
|
|
|
8844
8844
|
if (active[i].to < cutAt)
|
|
8845
8845
|
cutAt = active[i].to;
|
|
8846
8846
|
if (cutAt < end) {
|
|
8847
|
-
restNode = child.cut(cutAt -
|
|
8848
|
-
child = child.cut(0, cutAt -
|
|
8847
|
+
restNode = child.cut(cutAt - offset3);
|
|
8848
|
+
child = child.cut(0, cutAt - offset3);
|
|
8849
8849
|
end = cutAt;
|
|
8850
8850
|
index = -1;
|
|
8851
8851
|
}
|
|
@@ -8854,8 +8854,8 @@ function iterDeco(parent, deco, onWidget, onNode) {
|
|
|
8854
8854
|
decoIndex++;
|
|
8855
8855
|
}
|
|
8856
8856
|
let outerDeco = child.isInline && !child.isLeaf ? active.filter((d) => !d.inline) : active.slice();
|
|
8857
|
-
onNode(child, outerDeco, deco.forChild(
|
|
8858
|
-
|
|
8857
|
+
onNode(child, outerDeco, deco.forChild(offset3, child), index);
|
|
8858
|
+
offset3 = end;
|
|
8859
8859
|
}
|
|
8860
8860
|
}
|
|
8861
8861
|
function iosHacks(dom) {
|
|
@@ -9001,9 +9001,9 @@ function selectionToDOM(view, force = false) {
|
|
|
9001
9001
|
}
|
|
9002
9002
|
var brokenSelectBetweenUneditable = safari || chrome && chrome_version < 63;
|
|
9003
9003
|
function temporarilyEditableNear(view, pos) {
|
|
9004
|
-
let { node, offset } = view.docView.domFromPos(pos, 0);
|
|
9005
|
-
let after =
|
|
9006
|
-
let before =
|
|
9004
|
+
let { node, offset: offset3 } = view.docView.domFromPos(pos, 0);
|
|
9005
|
+
let after = offset3 < node.childNodes.length ? node.childNodes[offset3] : null;
|
|
9006
|
+
let before = offset3 ? node.childNodes[offset3 - 1] : null;
|
|
9007
9007
|
if (safari && after && after.contentEditable == "false")
|
|
9008
9008
|
return setEditable(after);
|
|
9009
9009
|
if ((!after || after.contentEditable == "false") && (!before || before.contentEditable == "false")) {
|
|
@@ -9032,9 +9032,9 @@ function removeClassOnSelectionChange(view) {
|
|
|
9032
9032
|
let doc3 = view.dom.ownerDocument;
|
|
9033
9033
|
doc3.removeEventListener("selectionchange", view.input.hideSelectionGuard);
|
|
9034
9034
|
let domSel = view.domSelectionRange();
|
|
9035
|
-
let node = domSel.anchorNode,
|
|
9035
|
+
let node = domSel.anchorNode, offset3 = domSel.anchorOffset;
|
|
9036
9036
|
doc3.addEventListener("selectionchange", view.input.hideSelectionGuard = () => {
|
|
9037
|
-
if (domSel.anchorNode != node || domSel.anchorOffset !=
|
|
9037
|
+
if (domSel.anchorNode != node || domSel.anchorOffset != offset3) {
|
|
9038
9038
|
doc3.removeEventListener("selectionchange", view.input.hideSelectionGuard);
|
|
9039
9039
|
setTimeout(() => {
|
|
9040
9040
|
if (!editorOwnsSelection(view) || view.state.selection.visible)
|
|
@@ -9162,24 +9162,24 @@ function skipIgnoredNodes(view, dir) {
|
|
|
9162
9162
|
}
|
|
9163
9163
|
function skipIgnoredNodesBefore(view) {
|
|
9164
9164
|
let sel = view.domSelectionRange();
|
|
9165
|
-
let node = sel.focusNode,
|
|
9165
|
+
let node = sel.focusNode, offset3 = sel.focusOffset;
|
|
9166
9166
|
if (!node)
|
|
9167
9167
|
return;
|
|
9168
9168
|
let moveNode, moveOffset, force = false;
|
|
9169
|
-
if (gecko && node.nodeType == 1 &&
|
|
9169
|
+
if (gecko && node.nodeType == 1 && offset3 < nodeLen(node) && isIgnorable(node.childNodes[offset3], -1))
|
|
9170
9170
|
force = true;
|
|
9171
9171
|
for (; ; ) {
|
|
9172
|
-
if (
|
|
9172
|
+
if (offset3 > 0) {
|
|
9173
9173
|
if (node.nodeType != 1) {
|
|
9174
9174
|
break;
|
|
9175
9175
|
} else {
|
|
9176
|
-
let before = node.childNodes[
|
|
9176
|
+
let before = node.childNodes[offset3 - 1];
|
|
9177
9177
|
if (isIgnorable(before, -1)) {
|
|
9178
9178
|
moveNode = node;
|
|
9179
|
-
moveOffset = --
|
|
9179
|
+
moveOffset = --offset3;
|
|
9180
9180
|
} else if (before.nodeType == 3) {
|
|
9181
9181
|
node = before;
|
|
9182
|
-
|
|
9182
|
+
offset3 = node.nodeValue.length;
|
|
9183
9183
|
} else
|
|
9184
9184
|
break;
|
|
9185
9185
|
}
|
|
@@ -9196,33 +9196,33 @@ function skipIgnoredNodesBefore(view) {
|
|
|
9196
9196
|
node = node.parentNode;
|
|
9197
9197
|
if (node == view.dom)
|
|
9198
9198
|
break;
|
|
9199
|
-
|
|
9199
|
+
offset3 = 0;
|
|
9200
9200
|
} else {
|
|
9201
9201
|
node = prev;
|
|
9202
|
-
|
|
9202
|
+
offset3 = nodeLen(node);
|
|
9203
9203
|
}
|
|
9204
9204
|
}
|
|
9205
9205
|
}
|
|
9206
9206
|
if (force)
|
|
9207
|
-
setSelFocus(view, node,
|
|
9207
|
+
setSelFocus(view, node, offset3);
|
|
9208
9208
|
else if (moveNode)
|
|
9209
9209
|
setSelFocus(view, moveNode, moveOffset);
|
|
9210
9210
|
}
|
|
9211
9211
|
function skipIgnoredNodesAfter(view) {
|
|
9212
9212
|
let sel = view.domSelectionRange();
|
|
9213
|
-
let node = sel.focusNode,
|
|
9213
|
+
let node = sel.focusNode, offset3 = sel.focusOffset;
|
|
9214
9214
|
if (!node)
|
|
9215
9215
|
return;
|
|
9216
9216
|
let len = nodeLen(node);
|
|
9217
9217
|
let moveNode, moveOffset;
|
|
9218
9218
|
for (; ; ) {
|
|
9219
|
-
if (
|
|
9219
|
+
if (offset3 < len) {
|
|
9220
9220
|
if (node.nodeType != 1)
|
|
9221
9221
|
break;
|
|
9222
|
-
let after = node.childNodes[
|
|
9222
|
+
let after = node.childNodes[offset3];
|
|
9223
9223
|
if (isIgnorable(after, 1)) {
|
|
9224
9224
|
moveNode = node;
|
|
9225
|
-
moveOffset = ++
|
|
9225
|
+
moveOffset = ++offset3;
|
|
9226
9226
|
} else
|
|
9227
9227
|
break;
|
|
9228
9228
|
} else if (isBlockNode(node)) {
|
|
@@ -9238,10 +9238,10 @@ function skipIgnoredNodesAfter(view) {
|
|
|
9238
9238
|
node = node.parentNode;
|
|
9239
9239
|
if (node == view.dom)
|
|
9240
9240
|
break;
|
|
9241
|
-
|
|
9241
|
+
offset3 = len = 0;
|
|
9242
9242
|
} else {
|
|
9243
9243
|
node = next;
|
|
9244
|
-
|
|
9244
|
+
offset3 = 0;
|
|
9245
9245
|
len = nodeLen(node);
|
|
9246
9246
|
}
|
|
9247
9247
|
}
|
|
@@ -9253,45 +9253,45 @@ function isBlockNode(dom) {
|
|
|
9253
9253
|
let desc = dom.pmViewDesc;
|
|
9254
9254
|
return desc && desc.node && desc.node.isBlock;
|
|
9255
9255
|
}
|
|
9256
|
-
function textNodeAfter(node,
|
|
9257
|
-
while (node &&
|
|
9258
|
-
|
|
9256
|
+
function textNodeAfter(node, offset3) {
|
|
9257
|
+
while (node && offset3 == node.childNodes.length && !hasBlockDesc(node)) {
|
|
9258
|
+
offset3 = domIndex(node) + 1;
|
|
9259
9259
|
node = node.parentNode;
|
|
9260
9260
|
}
|
|
9261
|
-
while (node &&
|
|
9262
|
-
let next = node.childNodes[
|
|
9261
|
+
while (node && offset3 < node.childNodes.length) {
|
|
9262
|
+
let next = node.childNodes[offset3];
|
|
9263
9263
|
if (next.nodeType == 3)
|
|
9264
9264
|
return next;
|
|
9265
9265
|
if (next.nodeType == 1 && next.contentEditable == "false")
|
|
9266
9266
|
break;
|
|
9267
9267
|
node = next;
|
|
9268
|
-
|
|
9268
|
+
offset3 = 0;
|
|
9269
9269
|
}
|
|
9270
9270
|
}
|
|
9271
|
-
function textNodeBefore(node,
|
|
9272
|
-
while (node && !
|
|
9273
|
-
|
|
9271
|
+
function textNodeBefore(node, offset3) {
|
|
9272
|
+
while (node && !offset3 && !hasBlockDesc(node)) {
|
|
9273
|
+
offset3 = domIndex(node);
|
|
9274
9274
|
node = node.parentNode;
|
|
9275
9275
|
}
|
|
9276
|
-
while (node &&
|
|
9277
|
-
let next = node.childNodes[
|
|
9276
|
+
while (node && offset3) {
|
|
9277
|
+
let next = node.childNodes[offset3 - 1];
|
|
9278
9278
|
if (next.nodeType == 3)
|
|
9279
9279
|
return next;
|
|
9280
9280
|
if (next.nodeType == 1 && next.contentEditable == "false")
|
|
9281
9281
|
break;
|
|
9282
9282
|
node = next;
|
|
9283
|
-
|
|
9283
|
+
offset3 = node.childNodes.length;
|
|
9284
9284
|
}
|
|
9285
9285
|
}
|
|
9286
|
-
function setSelFocus(view, node,
|
|
9286
|
+
function setSelFocus(view, node, offset3) {
|
|
9287
9287
|
if (node.nodeType != 3) {
|
|
9288
9288
|
let before, after;
|
|
9289
|
-
if (after = textNodeAfter(node,
|
|
9289
|
+
if (after = textNodeAfter(node, offset3)) {
|
|
9290
9290
|
node = after;
|
|
9291
|
-
|
|
9292
|
-
} else if (before = textNodeBefore(node,
|
|
9291
|
+
offset3 = 0;
|
|
9292
|
+
} else if (before = textNodeBefore(node, offset3)) {
|
|
9293
9293
|
node = before;
|
|
9294
|
-
|
|
9294
|
+
offset3 = before.nodeValue.length;
|
|
9295
9295
|
}
|
|
9296
9296
|
}
|
|
9297
9297
|
let sel = view.domSelection();
|
|
@@ -9299,12 +9299,12 @@ function setSelFocus(view, node, offset) {
|
|
|
9299
9299
|
return;
|
|
9300
9300
|
if (selectionCollapsed(sel)) {
|
|
9301
9301
|
let range = document.createRange();
|
|
9302
|
-
range.setEnd(node,
|
|
9303
|
-
range.setStart(node,
|
|
9302
|
+
range.setEnd(node, offset3);
|
|
9303
|
+
range.setStart(node, offset3);
|
|
9304
9304
|
sel.removeAllRanges();
|
|
9305
9305
|
sel.addRange(range);
|
|
9306
9306
|
} else if (sel.extend) {
|
|
9307
|
-
sel.extend(node,
|
|
9307
|
+
sel.extend(node, offset3);
|
|
9308
9308
|
}
|
|
9309
9309
|
view.domObserver.setCurSelection();
|
|
9310
9310
|
let { state } = view;
|
|
@@ -10103,8 +10103,8 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
10103
10103
|
endComposition(view, !state.selection.empty);
|
|
10104
10104
|
if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
|
|
10105
10105
|
let sel = view.domSelectionRange();
|
|
10106
|
-
for (let node = sel.focusNode,
|
|
10107
|
-
let before =
|
|
10106
|
+
for (let node = sel.focusNode, offset3 = sel.focusOffset; node && node.nodeType == 1 && offset3 != 0; ) {
|
|
10107
|
+
let before = offset3 < 0 ? node.lastChild : node.childNodes[offset3 - 1];
|
|
10108
10108
|
if (!before)
|
|
10109
10109
|
break;
|
|
10110
10110
|
if (before.nodeType == 3) {
|
|
@@ -10114,7 +10114,7 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
10114
10114
|
break;
|
|
10115
10115
|
} else {
|
|
10116
10116
|
node = before;
|
|
10117
|
-
|
|
10117
|
+
offset3 = -1;
|
|
10118
10118
|
}
|
|
10119
10119
|
}
|
|
10120
10120
|
}
|
|
@@ -10455,9 +10455,9 @@ var WidgetType = class _WidgetType {
|
|
|
10455
10455
|
this.spec = spec || noSpec;
|
|
10456
10456
|
this.side = this.spec.side || 0;
|
|
10457
10457
|
}
|
|
10458
|
-
map(mapping, span,
|
|
10458
|
+
map(mapping, span, offset3, oldOffset) {
|
|
10459
10459
|
let { pos, deleted } = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
|
|
10460
|
-
return deleted ? null : new Decoration(pos -
|
|
10460
|
+
return deleted ? null : new Decoration(pos - offset3, pos - offset3, this);
|
|
10461
10461
|
}
|
|
10462
10462
|
valid() {
|
|
10463
10463
|
return true;
|
|
@@ -10475,9 +10475,9 @@ var InlineType = class _InlineType {
|
|
|
10475
10475
|
this.attrs = attrs;
|
|
10476
10476
|
this.spec = spec || noSpec;
|
|
10477
10477
|
}
|
|
10478
|
-
map(mapping, span,
|
|
10479
|
-
let from2 = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) -
|
|
10480
|
-
let to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) -
|
|
10478
|
+
map(mapping, span, offset3, oldOffset) {
|
|
10479
|
+
let from2 = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset3;
|
|
10480
|
+
let to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) - offset3;
|
|
10481
10481
|
return from2 >= to ? null : new Decoration(from2, to, this);
|
|
10482
10482
|
}
|
|
10483
10483
|
valid(_, span) {
|
|
@@ -10497,18 +10497,18 @@ var NodeType2 = class _NodeType {
|
|
|
10497
10497
|
this.attrs = attrs;
|
|
10498
10498
|
this.spec = spec || noSpec;
|
|
10499
10499
|
}
|
|
10500
|
-
map(mapping, span,
|
|
10500
|
+
map(mapping, span, offset3, oldOffset) {
|
|
10501
10501
|
let from2 = mapping.mapResult(span.from + oldOffset, 1);
|
|
10502
10502
|
if (from2.deleted)
|
|
10503
10503
|
return null;
|
|
10504
10504
|
let to = mapping.mapResult(span.to + oldOffset, -1);
|
|
10505
10505
|
if (to.deleted || to.pos <= from2.pos)
|
|
10506
10506
|
return null;
|
|
10507
|
-
return new Decoration(from2.pos -
|
|
10507
|
+
return new Decoration(from2.pos - offset3, to.pos - offset3, this);
|
|
10508
10508
|
}
|
|
10509
10509
|
valid(node, span) {
|
|
10510
|
-
let { index, offset } = node.content.findIndex(span.from), child;
|
|
10511
|
-
return
|
|
10510
|
+
let { index, offset: offset3 } = node.content.findIndex(span.from), child;
|
|
10511
|
+
return offset3 == span.from && !(child = node.child(index)).isText && offset3 + child.nodeSize == span.to;
|
|
10512
10512
|
}
|
|
10513
10513
|
eq(other) {
|
|
10514
10514
|
return this == other || other instanceof _NodeType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);
|
|
@@ -10534,14 +10534,14 @@ var Decoration = class _Decoration {
|
|
|
10534
10534
|
/**
|
|
10535
10535
|
@internal
|
|
10536
10536
|
*/
|
|
10537
|
-
eq(other,
|
|
10538
|
-
return this.type.eq(other.type) && this.from +
|
|
10537
|
+
eq(other, offset3 = 0) {
|
|
10538
|
+
return this.type.eq(other.type) && this.from + offset3 == other.from && this.to + offset3 == other.to;
|
|
10539
10539
|
}
|
|
10540
10540
|
/**
|
|
10541
10541
|
@internal
|
|
10542
10542
|
*/
|
|
10543
|
-
map(mapping,
|
|
10544
|
-
return this.type.map(mapping, this,
|
|
10543
|
+
map(mapping, offset3, oldOffset) {
|
|
10544
|
+
return this.type.map(mapping, this, offset3, oldOffset);
|
|
10545
10545
|
}
|
|
10546
10546
|
/**
|
|
10547
10547
|
Creates a widget decoration, which is a DOM node that's shown in
|
|
@@ -10620,16 +10620,16 @@ var DecorationSet = class _DecorationSet {
|
|
|
10620
10620
|
this.findInner(start == null ? 0 : start, end == null ? 1e9 : end, result, 0, predicate);
|
|
10621
10621
|
return result;
|
|
10622
10622
|
}
|
|
10623
|
-
findInner(start, end, result,
|
|
10623
|
+
findInner(start, end, result, offset3, predicate) {
|
|
10624
10624
|
for (let i = 0; i < this.local.length; i++) {
|
|
10625
10625
|
let span = this.local[i];
|
|
10626
10626
|
if (span.from <= end && span.to >= start && (!predicate || predicate(span.spec)))
|
|
10627
|
-
result.push(span.copy(span.from +
|
|
10627
|
+
result.push(span.copy(span.from + offset3, span.to + offset3));
|
|
10628
10628
|
}
|
|
10629
10629
|
for (let i = 0; i < this.children.length; i += 3) {
|
|
10630
10630
|
if (this.children[i] < end && this.children[i + 1] > start) {
|
|
10631
10631
|
let childOff = this.children[i] + 1;
|
|
10632
|
-
this.children[i + 2].findInner(start - childOff, end - childOff, result,
|
|
10632
|
+
this.children[i + 2].findInner(start - childOff, end - childOff, result, offset3 + childOff, predicate);
|
|
10633
10633
|
}
|
|
10634
10634
|
}
|
|
10635
10635
|
}
|
|
@@ -10645,17 +10645,17 @@ var DecorationSet = class _DecorationSet {
|
|
|
10645
10645
|
/**
|
|
10646
10646
|
@internal
|
|
10647
10647
|
*/
|
|
10648
|
-
mapInner(mapping, node,
|
|
10648
|
+
mapInner(mapping, node, offset3, oldOffset, options) {
|
|
10649
10649
|
let newLocal;
|
|
10650
10650
|
for (let i = 0; i < this.local.length; i++) {
|
|
10651
|
-
let mapped = this.local[i].map(mapping,
|
|
10651
|
+
let mapped = this.local[i].map(mapping, offset3, oldOffset);
|
|
10652
10652
|
if (mapped && mapped.type.valid(node, mapped))
|
|
10653
10653
|
(newLocal || (newLocal = [])).push(mapped);
|
|
10654
10654
|
else if (options.onRemove)
|
|
10655
10655
|
options.onRemove(this.local[i].spec);
|
|
10656
10656
|
}
|
|
10657
10657
|
if (this.children.length)
|
|
10658
|
-
return mapChildren(this.children, newLocal || [], mapping, node,
|
|
10658
|
+
return mapChildren(this.children, newLocal || [], mapping, node, offset3, oldOffset, options);
|
|
10659
10659
|
else
|
|
10660
10660
|
return newLocal ? new _DecorationSet(newLocal.sort(byPos), none) : empty;
|
|
10661
10661
|
}
|
|
@@ -10672,10 +10672,10 @@ var DecorationSet = class _DecorationSet {
|
|
|
10672
10672
|
return _DecorationSet.create(doc3, decorations);
|
|
10673
10673
|
return this.addInner(doc3, decorations, 0);
|
|
10674
10674
|
}
|
|
10675
|
-
addInner(doc3, decorations,
|
|
10675
|
+
addInner(doc3, decorations, offset3) {
|
|
10676
10676
|
let children, childIndex = 0;
|
|
10677
10677
|
doc3.forEach((childNode, childOffset) => {
|
|
10678
|
-
let baseOffset = childOffset +
|
|
10678
|
+
let baseOffset = childOffset + offset3, found3;
|
|
10679
10679
|
if (!(found3 = takeSpansForNode(decorations, childNode, baseOffset)))
|
|
10680
10680
|
return;
|
|
10681
10681
|
if (!children)
|
|
@@ -10688,7 +10688,7 @@ var DecorationSet = class _DecorationSet {
|
|
|
10688
10688
|
children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found3, childNode, baseOffset + 1, noSpec));
|
|
10689
10689
|
childIndex += 3;
|
|
10690
10690
|
});
|
|
10691
|
-
let local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -
|
|
10691
|
+
let local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset3);
|
|
10692
10692
|
for (let i = 0; i < local.length; i++)
|
|
10693
10693
|
if (!local[i].type.valid(doc3, local[i]))
|
|
10694
10694
|
local.splice(i--, 1);
|
|
@@ -10703,11 +10703,11 @@ var DecorationSet = class _DecorationSet {
|
|
|
10703
10703
|
return this;
|
|
10704
10704
|
return this.removeInner(decorations, 0);
|
|
10705
10705
|
}
|
|
10706
|
-
removeInner(decorations,
|
|
10706
|
+
removeInner(decorations, offset3) {
|
|
10707
10707
|
let children = this.children, local = this.local;
|
|
10708
10708
|
for (let i = 0; i < children.length; i += 3) {
|
|
10709
10709
|
let found3;
|
|
10710
|
-
let from2 = children[i] +
|
|
10710
|
+
let from2 = children[i] + offset3, to = children[i + 1] + offset3;
|
|
10711
10711
|
for (let j = 0, span; j < decorations.length; j++)
|
|
10712
10712
|
if (span = decorations[j]) {
|
|
10713
10713
|
if (span.from > from2 && span.to < to) {
|
|
@@ -10731,7 +10731,7 @@ var DecorationSet = class _DecorationSet {
|
|
|
10731
10731
|
for (let i = 0, span; i < decorations.length; i++)
|
|
10732
10732
|
if (span = decorations[i]) {
|
|
10733
10733
|
for (let j = 0; j < local.length; j++)
|
|
10734
|
-
if (local[j].eq(span,
|
|
10734
|
+
if (local[j].eq(span, offset3)) {
|
|
10735
10735
|
if (local == this.local)
|
|
10736
10736
|
local = this.local.slice();
|
|
10737
10737
|
local.splice(j--, 1);
|
|
@@ -10742,19 +10742,19 @@ var DecorationSet = class _DecorationSet {
|
|
|
10742
10742
|
return this;
|
|
10743
10743
|
return local.length || children.length ? new _DecorationSet(local, children) : empty;
|
|
10744
10744
|
}
|
|
10745
|
-
forChild(
|
|
10745
|
+
forChild(offset3, node) {
|
|
10746
10746
|
if (this == empty)
|
|
10747
10747
|
return this;
|
|
10748
10748
|
if (node.isLeaf)
|
|
10749
10749
|
return _DecorationSet.empty;
|
|
10750
10750
|
let child, local;
|
|
10751
10751
|
for (let i = 0; i < this.children.length; i += 3)
|
|
10752
|
-
if (this.children[i] >=
|
|
10753
|
-
if (this.children[i] ==
|
|
10752
|
+
if (this.children[i] >= offset3) {
|
|
10753
|
+
if (this.children[i] == offset3)
|
|
10754
10754
|
child = this.children[i + 2];
|
|
10755
10755
|
break;
|
|
10756
10756
|
}
|
|
10757
|
-
let start =
|
|
10757
|
+
let start = offset3 + 1, end = start + node.content.size;
|
|
10758
10758
|
for (let i = 0; i < this.local.length; i++) {
|
|
10759
10759
|
let dec = this.local[i];
|
|
10760
10760
|
if (dec.from < end && dec.to > start && dec.type instanceof InlineType) {
|
|
@@ -10821,12 +10821,12 @@ var DecorationGroup = class _DecorationGroup {
|
|
|
10821
10821
|
const mappedDecos = this.members.map((member) => member.map(mapping, doc3, noSpec));
|
|
10822
10822
|
return _DecorationGroup.from(mappedDecos);
|
|
10823
10823
|
}
|
|
10824
|
-
forChild(
|
|
10824
|
+
forChild(offset3, child) {
|
|
10825
10825
|
if (child.isLeaf)
|
|
10826
10826
|
return DecorationSet.empty;
|
|
10827
10827
|
let found3 = [];
|
|
10828
10828
|
for (let i = 0; i < this.members.length; i++) {
|
|
10829
|
-
let result = this.members[i].forChild(
|
|
10829
|
+
let result = this.members[i].forChild(offset3, child);
|
|
10830
10830
|
if (result == empty)
|
|
10831
10831
|
continue;
|
|
10832
10832
|
if (result instanceof _DecorationGroup)
|
|
@@ -10880,7 +10880,7 @@ var DecorationGroup = class _DecorationGroup {
|
|
|
10880
10880
|
this.members[i].forEachSet(f);
|
|
10881
10881
|
}
|
|
10882
10882
|
};
|
|
10883
|
-
function mapChildren(oldChildren, newLocal, mapping, node,
|
|
10883
|
+
function mapChildren(oldChildren, newLocal, mapping, node, offset3, oldOffset, options) {
|
|
10884
10884
|
let children = oldChildren.slice();
|
|
10885
10885
|
for (let i = 0, baseOffset = oldOffset; i < mapping.maps.length; i++) {
|
|
10886
10886
|
let moved = 0;
|
|
@@ -10910,12 +10910,12 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
10910
10910
|
children[i + 1] = -1;
|
|
10911
10911
|
continue;
|
|
10912
10912
|
}
|
|
10913
|
-
let from2 = mapping.map(oldChildren[i] + oldOffset), fromLocal = from2 -
|
|
10913
|
+
let from2 = mapping.map(oldChildren[i] + oldOffset), fromLocal = from2 - offset3;
|
|
10914
10914
|
if (fromLocal < 0 || fromLocal >= node.content.size) {
|
|
10915
10915
|
mustRebuild = true;
|
|
10916
10916
|
continue;
|
|
10917
10917
|
}
|
|
10918
|
-
let to = mapping.map(oldChildren[i + 1] + oldOffset, -1), toLocal = to -
|
|
10918
|
+
let to = mapping.map(oldChildren[i + 1] + oldOffset, -1), toLocal = to - offset3;
|
|
10919
10919
|
let { index, offset: childOffset } = node.content.findIndex(fromLocal);
|
|
10920
10920
|
let childNode = node.maybeChild(index);
|
|
10921
10921
|
if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) {
|
|
@@ -10933,7 +10933,7 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
10933
10933
|
}
|
|
10934
10934
|
}
|
|
10935
10935
|
if (mustRebuild) {
|
|
10936
|
-
let decorations = mapAndGatherRemainingDecorations(children, oldChildren, newLocal, mapping,
|
|
10936
|
+
let decorations = mapAndGatherRemainingDecorations(children, oldChildren, newLocal, mapping, offset3, oldOffset, options);
|
|
10937
10937
|
let built = buildTree(decorations, node, 0, options);
|
|
10938
10938
|
newLocal = built.local;
|
|
10939
10939
|
for (let i = 0; i < children.length; i += 3)
|
|
@@ -10950,20 +10950,20 @@ function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, op
|
|
|
10950
10950
|
}
|
|
10951
10951
|
return new DecorationSet(newLocal.sort(byPos), children);
|
|
10952
10952
|
}
|
|
10953
|
-
function moveSpans(spans,
|
|
10954
|
-
if (!
|
|
10953
|
+
function moveSpans(spans, offset3) {
|
|
10954
|
+
if (!offset3 || !spans.length)
|
|
10955
10955
|
return spans;
|
|
10956
10956
|
let result = [];
|
|
10957
10957
|
for (let i = 0; i < spans.length; i++) {
|
|
10958
10958
|
let span = spans[i];
|
|
10959
|
-
result.push(new Decoration(span.from +
|
|
10959
|
+
result.push(new Decoration(span.from + offset3, span.to + offset3, span.type));
|
|
10960
10960
|
}
|
|
10961
10961
|
return result;
|
|
10962
10962
|
}
|
|
10963
|
-
function mapAndGatherRemainingDecorations(children, oldChildren, decorations, mapping,
|
|
10963
|
+
function mapAndGatherRemainingDecorations(children, oldChildren, decorations, mapping, offset3, oldOffset, options) {
|
|
10964
10964
|
function gather(set, oldOffset2) {
|
|
10965
10965
|
for (let i = 0; i < set.local.length; i++) {
|
|
10966
|
-
let mapped = set.local[i].map(mapping,
|
|
10966
|
+
let mapped = set.local[i].map(mapping, offset3, oldOffset2);
|
|
10967
10967
|
if (mapped)
|
|
10968
10968
|
decorations.push(mapped);
|
|
10969
10969
|
else if (options.onRemove)
|
|
@@ -10977,12 +10977,12 @@ function mapAndGatherRemainingDecorations(children, oldChildren, decorations, ma
|
|
|
10977
10977
|
gather(children[i + 2], oldChildren[i] + oldOffset + 1);
|
|
10978
10978
|
return decorations;
|
|
10979
10979
|
}
|
|
10980
|
-
function takeSpansForNode(spans, node,
|
|
10980
|
+
function takeSpansForNode(spans, node, offset3) {
|
|
10981
10981
|
if (node.isLeaf)
|
|
10982
10982
|
return null;
|
|
10983
|
-
let end =
|
|
10983
|
+
let end = offset3 + node.nodeSize, found3 = null;
|
|
10984
10984
|
for (let i = 0, span; i < spans.length; i++) {
|
|
10985
|
-
if ((span = spans[i]) && span.from >
|
|
10985
|
+
if ((span = spans[i]) && span.from > offset3 && span.to < end) {
|
|
10986
10986
|
(found3 || (found3 = [])).push(span);
|
|
10987
10987
|
spans[i] = null;
|
|
10988
10988
|
}
|
|
@@ -10996,18 +10996,18 @@ function withoutNulls(array) {
|
|
|
10996
10996
|
result.push(array[i]);
|
|
10997
10997
|
return result;
|
|
10998
10998
|
}
|
|
10999
|
-
function buildTree(spans, node,
|
|
10999
|
+
function buildTree(spans, node, offset3, options) {
|
|
11000
11000
|
let children = [], hasNulls = false;
|
|
11001
11001
|
node.forEach((childNode, localStart) => {
|
|
11002
|
-
let found3 = takeSpansForNode(spans, childNode, localStart +
|
|
11002
|
+
let found3 = takeSpansForNode(spans, childNode, localStart + offset3);
|
|
11003
11003
|
if (found3) {
|
|
11004
11004
|
hasNulls = true;
|
|
11005
|
-
let subtree = buildTree(found3, childNode,
|
|
11005
|
+
let subtree = buildTree(found3, childNode, offset3 + localStart + 1, options);
|
|
11006
11006
|
if (subtree != empty)
|
|
11007
11007
|
children.push(localStart, localStart + childNode.nodeSize, subtree);
|
|
11008
11008
|
}
|
|
11009
11009
|
});
|
|
11010
|
-
let locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -
|
|
11010
|
+
let locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset3).sort(byPos);
|
|
11011
11011
|
for (let i = 0; i < locals.length; i++)
|
|
11012
11012
|
if (!locals[i].type.valid(node, locals[i])) {
|
|
11013
11013
|
if (options.onRemove)
|
|
@@ -12043,8 +12043,8 @@ var EditorView = class {
|
|
|
12043
12043
|
The `bias` parameter can be used to influence which side of a DOM
|
|
12044
12044
|
node to use when the position is inside a leaf node.
|
|
12045
12045
|
*/
|
|
12046
|
-
posAtDOM(node,
|
|
12047
|
-
let pos = this.docView.posFromDOM(node,
|
|
12046
|
+
posAtDOM(node, offset3, bias = -1) {
|
|
12047
|
+
let pos = this.docView.posFromDOM(node, offset3, bias);
|
|
12048
12048
|
if (pos == null)
|
|
12049
12049
|
throw new RangeError("DOM position not inside the editor");
|
|
12050
12050
|
return pos;
|
|
@@ -12320,7 +12320,7 @@ function normalizeKeyName(name) {
|
|
|
12320
12320
|
let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
|
|
12321
12321
|
if (result == "Space")
|
|
12322
12322
|
result = " ";
|
|
12323
|
-
let alt, ctrl,
|
|
12323
|
+
let alt, ctrl, shift5, meta;
|
|
12324
12324
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
12325
12325
|
let mod = parts[i];
|
|
12326
12326
|
if (/^(cmd|meta|m)$/i.test(mod))
|
|
@@ -12330,7 +12330,7 @@ function normalizeKeyName(name) {
|
|
|
12330
12330
|
else if (/^(c|ctrl|control)$/i.test(mod))
|
|
12331
12331
|
ctrl = true;
|
|
12332
12332
|
else if (/^s(hift)?$/i.test(mod))
|
|
12333
|
-
|
|
12333
|
+
shift5 = true;
|
|
12334
12334
|
else if (/^mod$/i.test(mod)) {
|
|
12335
12335
|
if (mac4)
|
|
12336
12336
|
meta = true;
|
|
@@ -12345,7 +12345,7 @@ function normalizeKeyName(name) {
|
|
|
12345
12345
|
result = "Ctrl-" + result;
|
|
12346
12346
|
if (meta)
|
|
12347
12347
|
result = "Meta-" + result;
|
|
12348
|
-
if (
|
|
12348
|
+
if (shift5)
|
|
12349
12349
|
result = "Shift-" + result;
|
|
12350
12350
|
return result;
|
|
12351
12351
|
}
|
|
@@ -12355,14 +12355,14 @@ function normalize(map2) {
|
|
|
12355
12355
|
copy2[normalizeKeyName(prop)] = map2[prop];
|
|
12356
12356
|
return copy2;
|
|
12357
12357
|
}
|
|
12358
|
-
function modifiers(name, event,
|
|
12358
|
+
function modifiers(name, event, shift5 = true) {
|
|
12359
12359
|
if (event.altKey)
|
|
12360
12360
|
name = "Alt-" + name;
|
|
12361
12361
|
if (event.ctrlKey)
|
|
12362
12362
|
name = "Ctrl-" + name;
|
|
12363
12363
|
if (event.metaKey)
|
|
12364
12364
|
name = "Meta-" + name;
|
|
12365
|
-
if (
|
|
12365
|
+
if (shift5 && event.shiftKey)
|
|
12366
12366
|
name = "Shift-" + name;
|
|
12367
12367
|
return name;
|
|
12368
12368
|
}
|
|
@@ -12974,7 +12974,7 @@ function elementFromString(value) {
|
|
|
12974
12974
|
return removeWhitespaces(html);
|
|
12975
12975
|
}
|
|
12976
12976
|
function createNodeFromContent(content, schema, options) {
|
|
12977
|
-
if (content instanceof
|
|
12977
|
+
if (content instanceof Node2 || content instanceof Fragment) {
|
|
12978
12978
|
return content;
|
|
12979
12979
|
}
|
|
12980
12980
|
options = {
|
|
@@ -13238,7 +13238,7 @@ function normalizeKeyName2(name) {
|
|
|
13238
13238
|
}
|
|
13239
13239
|
let alt;
|
|
13240
13240
|
let ctrl;
|
|
13241
|
-
let
|
|
13241
|
+
let shift5;
|
|
13242
13242
|
let meta;
|
|
13243
13243
|
for (let i = 0; i < parts.length - 1; i += 1) {
|
|
13244
13244
|
const mod = parts[i];
|
|
@@ -13249,7 +13249,7 @@ function normalizeKeyName2(name) {
|
|
|
13249
13249
|
} else if (/^(c|ctrl|control)$/i.test(mod)) {
|
|
13250
13250
|
ctrl = true;
|
|
13251
13251
|
} else if (/^s(hift)?$/i.test(mod)) {
|
|
13252
|
-
|
|
13252
|
+
shift5 = true;
|
|
13253
13253
|
} else if (/^mod$/i.test(mod)) {
|
|
13254
13254
|
if (isiOS() || isMacOS()) {
|
|
13255
13255
|
meta = true;
|
|
@@ -13269,7 +13269,7 @@ function normalizeKeyName2(name) {
|
|
|
13269
13269
|
if (meta) {
|
|
13270
13270
|
result = `Meta-${result}`;
|
|
13271
13271
|
}
|
|
13272
|
-
if (
|
|
13272
|
+
if (shift5) {
|
|
13273
13273
|
result = `Shift-${result}`;
|
|
13274
13274
|
}
|
|
13275
13275
|
return result;
|
|
@@ -14435,6 +14435,36 @@ function getUpdatedPosition(position, transaction) {
|
|
|
14435
14435
|
function createMappablePosition(position) {
|
|
14436
14436
|
return new MappablePosition(position);
|
|
14437
14437
|
}
|
|
14438
|
+
function posToDOMRect(view, from2, to) {
|
|
14439
|
+
const minPos = 0;
|
|
14440
|
+
const maxPos = view.state.doc.content.size;
|
|
14441
|
+
const resolvedFrom = minMax(from2, minPos, maxPos);
|
|
14442
|
+
const resolvedEnd = minMax(to, minPos, maxPos);
|
|
14443
|
+
const start = view.coordsAtPos(resolvedFrom);
|
|
14444
|
+
const end = view.coordsAtPos(resolvedEnd, -1);
|
|
14445
|
+
const top = Math.min(start.top, end.top);
|
|
14446
|
+
const bottom = Math.max(start.bottom, end.bottom);
|
|
14447
|
+
const left = Math.min(start.left, end.left);
|
|
14448
|
+
const right = Math.max(start.right, end.right);
|
|
14449
|
+
const width = right - left;
|
|
14450
|
+
const height = bottom - top;
|
|
14451
|
+
const x = left;
|
|
14452
|
+
const y = top;
|
|
14453
|
+
const data = {
|
|
14454
|
+
top,
|
|
14455
|
+
bottom,
|
|
14456
|
+
left,
|
|
14457
|
+
right,
|
|
14458
|
+
width,
|
|
14459
|
+
height,
|
|
14460
|
+
x,
|
|
14461
|
+
y
|
|
14462
|
+
};
|
|
14463
|
+
return {
|
|
14464
|
+
...data,
|
|
14465
|
+
toJSON: () => data
|
|
14466
|
+
};
|
|
14467
|
+
}
|
|
14438
14468
|
function canSetMark(state, tr2, newMarkType) {
|
|
14439
14469
|
var _a;
|
|
14440
14470
|
const { selection } = tr2;
|
|
@@ -15163,6 +15193,9 @@ function createStyleTag(style2, nonce, suffix) {
|
|
|
15163
15193
|
document.getElementsByTagName("head")[0].appendChild(styleNode);
|
|
15164
15194
|
return styleNode;
|
|
15165
15195
|
}
|
|
15196
|
+
function escapeForRegEx(string) {
|
|
15197
|
+
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
15198
|
+
}
|
|
15166
15199
|
function isNumber(value) {
|
|
15167
15200
|
return typeof value === "number";
|
|
15168
15201
|
}
|
|
@@ -16466,13 +16499,13 @@ var ExtensionManager = class {
|
|
|
16466
16499
|
if (!addMarkView) {
|
|
16467
16500
|
return [];
|
|
16468
16501
|
}
|
|
16469
|
-
const markView = (mark, view,
|
|
16502
|
+
const markView = (mark, view, inline3) => {
|
|
16470
16503
|
const HTMLAttributes = getRenderedAttributes(mark, extensionAttributes);
|
|
16471
16504
|
return addMarkView()({
|
|
16472
16505
|
// pass-through
|
|
16473
16506
|
mark,
|
|
16474
16507
|
view,
|
|
16475
|
-
inline,
|
|
16508
|
+
inline: inline3,
|
|
16476
16509
|
// tiptap-specific
|
|
16477
16510
|
editor,
|
|
16478
16511
|
extension,
|
|
@@ -17118,11 +17151,11 @@ var NodePos = class _NodePos {
|
|
|
17118
17151
|
}
|
|
17119
17152
|
get children() {
|
|
17120
17153
|
const children = [];
|
|
17121
|
-
this.node.content.forEach((node,
|
|
17154
|
+
this.node.content.forEach((node, offset3) => {
|
|
17122
17155
|
const isBlock = node.isBlock && !node.isTextblock;
|
|
17123
17156
|
const isNonTextAtom = node.isAtom && !node.isText;
|
|
17124
17157
|
const isInline2 = node.isInline;
|
|
17125
|
-
const targetPos = this.pos +
|
|
17158
|
+
const targetPos = this.pos + offset3 + (isNonTextAtom ? 0 : 1);
|
|
17126
17159
|
if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {
|
|
17127
17160
|
return;
|
|
17128
17161
|
}
|
|
@@ -17905,8 +17938,8 @@ function nodeInputRule(config) {
|
|
|
17905
17938
|
let end = range.to;
|
|
17906
17939
|
const newNode = config.type.create(attributes);
|
|
17907
17940
|
if (match[1]) {
|
|
17908
|
-
const
|
|
17909
|
-
let matchStart = start +
|
|
17941
|
+
const offset3 = match[0].lastIndexOf(match[1]);
|
|
17942
|
+
let matchStart = start + offset3;
|
|
17910
17943
|
if (matchStart > end) {
|
|
17911
17944
|
matchStart = end;
|
|
17912
17945
|
} else {
|
|
@@ -18952,7 +18985,7 @@ var createOpenEditorBlockHandlePlugin = ({
|
|
|
18952
18985
|
targetPos: target?.pos ?? null
|
|
18953
18986
|
}));
|
|
18954
18987
|
};
|
|
18955
|
-
const
|
|
18988
|
+
const hide3 = () => {
|
|
18956
18989
|
if (state().locked || pressed || dragging) return;
|
|
18957
18990
|
setTarget(null);
|
|
18958
18991
|
};
|
|
@@ -18961,7 +18994,7 @@ var createOpenEditorBlockHandlePlugin = ({
|
|
|
18961
18994
|
clearHideTimer();
|
|
18962
18995
|
hideTimer = window.setTimeout(() => {
|
|
18963
18996
|
hideTimer = null;
|
|
18964
|
-
|
|
18997
|
+
hide3();
|
|
18965
18998
|
}, HIDE_DELAY_MS);
|
|
18966
18999
|
};
|
|
18967
19000
|
const onMouseMove = (event) => {
|
|
@@ -19050,7 +19083,7 @@ var createOpenEditorBlockHandlePlugin = ({
|
|
|
19050
19083
|
props: {
|
|
19051
19084
|
handleDOMEvents: {
|
|
19052
19085
|
keydown() {
|
|
19053
|
-
|
|
19086
|
+
hide3();
|
|
19054
19087
|
return false;
|
|
19055
19088
|
}
|
|
19056
19089
|
}
|
|
@@ -22968,19 +23001,19 @@ function normalizeSelection(state, tr2, allowTableNodeSelection) {
|
|
|
22968
23001
|
return tr2;
|
|
22969
23002
|
}
|
|
22970
23003
|
var fixTablesKey = new PluginKey("fix-tables");
|
|
22971
|
-
function changedDescendants(old, cur,
|
|
23004
|
+
function changedDescendants(old, cur, offset3, f) {
|
|
22972
23005
|
const oldSize = old.childCount, curSize = cur.childCount;
|
|
22973
23006
|
outer: for (let i = 0, j = 0; i < curSize; i++) {
|
|
22974
23007
|
const child = cur.child(i);
|
|
22975
23008
|
for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) if (old.child(scan) == child) {
|
|
22976
23009
|
j = scan + 1;
|
|
22977
|
-
|
|
23010
|
+
offset3 += child.nodeSize;
|
|
22978
23011
|
continue outer;
|
|
22979
23012
|
}
|
|
22980
|
-
f(child,
|
|
22981
|
-
if (j < oldSize && old.child(j).sameMarkup(child)) changedDescendants(old.child(j), child,
|
|
22982
|
-
else child.nodesBetween(0, child.content.size, f,
|
|
22983
|
-
|
|
23013
|
+
f(child, offset3);
|
|
23014
|
+
if (j < oldSize && old.child(j).sameMarkup(child)) changedDescendants(old.child(j), child, offset3 + 1, f);
|
|
23015
|
+
else child.nodesBetween(0, child.content.size, f, offset3 + 1);
|
|
23016
|
+
offset3 += child.nodeSize;
|
|
22984
23017
|
}
|
|
22985
23018
|
}
|
|
22986
23019
|
function fixTables(state, oldState) {
|
|
@@ -24042,9 +24075,9 @@ function domCellAround(target) {
|
|
|
24042
24075
|
return target;
|
|
24043
24076
|
}
|
|
24044
24077
|
function edgeCell(view, event, side, handleWidth) {
|
|
24045
|
-
const
|
|
24078
|
+
const offset3 = side == "right" ? -handleWidth : handleWidth;
|
|
24046
24079
|
const found3 = view.posAtCoords({
|
|
24047
|
-
left: event.clientX +
|
|
24080
|
+
left: event.clientX + offset3,
|
|
24048
24081
|
top: event.clientY
|
|
24049
24082
|
});
|
|
24050
24083
|
if (!found3) return -1;
|
|
@@ -24057,8 +24090,8 @@ function edgeCell(view, event, side, handleWidth) {
|
|
|
24057
24090
|
return index % map2.width == 0 ? -1 : start + map2.map[index - 1];
|
|
24058
24091
|
}
|
|
24059
24092
|
function draggedWidth(dragging, event, resizeMinWidth) {
|
|
24060
|
-
const
|
|
24061
|
-
return Math.max(resizeMinWidth, dragging.startWidth +
|
|
24093
|
+
const offset3 = event.clientX - dragging.startX;
|
|
24094
|
+
return Math.max(resizeMinWidth, dragging.startWidth + offset3);
|
|
24062
24095
|
}
|
|
24063
24096
|
function updateHandle(view, value) {
|
|
24064
24097
|
view.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));
|
|
@@ -24639,8 +24672,8 @@ var Table = Node3.create({
|
|
|
24639
24672
|
insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr: tr2, dispatch, editor }) => {
|
|
24640
24673
|
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
24641
24674
|
if (dispatch) {
|
|
24642
|
-
const
|
|
24643
|
-
tr2.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr2.doc.resolve(
|
|
24675
|
+
const offset3 = tr2.selection.from + 1;
|
|
24676
|
+
tr2.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr2.doc.resolve(offset3)));
|
|
24644
24677
|
}
|
|
24645
24678
|
return true;
|
|
24646
24679
|
},
|
|
@@ -24767,7 +24800,7 @@ var Table = Node3.create({
|
|
|
24767
24800
|
};
|
|
24768
24801
|
}
|
|
24769
24802
|
});
|
|
24770
|
-
Extension.create({
|
|
24803
|
+
var TableKit = Extension.create({
|
|
24771
24804
|
name: "tableKit",
|
|
24772
24805
|
addExtensions() {
|
|
24773
24806
|
const extensions = [];
|
|
@@ -24787,15 +24820,6 @@ Extension.create({
|
|
|
24787
24820
|
}
|
|
24788
24821
|
});
|
|
24789
24822
|
|
|
24790
|
-
// ../../node_modules/.pnpm/@tiptap+extension-table-cell@3.27.1_@tiptap+extension-table@3.27.1_@tiptap+core@3.27.1__d0f7e78f5b75941668b2166cd5a344d7/node_modules/@tiptap/extension-table-cell/dist/index.js
|
|
24791
|
-
var index_default5 = TableCell;
|
|
24792
|
-
|
|
24793
|
-
// ../../node_modules/.pnpm/@tiptap+extension-table-header@3.27.1_@tiptap+extension-table@3.27.1_@tiptap+core@3.27._3c7a9f88f0681aa37114b8584057ef25/node_modules/@tiptap/extension-table-header/dist/index.js
|
|
24794
|
-
var index_default6 = TableHeader;
|
|
24795
|
-
|
|
24796
|
-
// ../../node_modules/.pnpm/@tiptap+extension-table-row@3.27.1_@tiptap+extension-table@3.27.1_@tiptap+core@3.27.1_@_9035de50f10413a8b79147293faad1a6/node_modules/@tiptap/extension-table-row/dist/index.js
|
|
24797
|
-
var index_default7 = TableRow;
|
|
24798
|
-
|
|
24799
24823
|
// ../../node_modules/.pnpm/@tiptap+extension-list@3.27.1_@tiptap+core@3.27.1_@tiptap+pm@3.27.1__@tiptap+pm@3.27.1/node_modules/@tiptap/extension-list/dist/index.js
|
|
24800
24824
|
var __defProp2 = Object.defineProperty;
|
|
24801
24825
|
var __export2 = (target, all) => {
|
|
@@ -26334,10 +26358,10 @@ Extension.create({
|
|
|
26334
26358
|
});
|
|
26335
26359
|
|
|
26336
26360
|
// ../../node_modules/.pnpm/@tiptap+extension-task-item@3.27.1_@tiptap+extension-list@3.27.1_@tiptap+core@3.27.1_@t_dc3cbb692c609e2ee87b89a29eb021e5/node_modules/@tiptap/extension-task-item/dist/index.js
|
|
26337
|
-
var
|
|
26361
|
+
var index_default5 = TaskItem;
|
|
26338
26362
|
|
|
26339
26363
|
// ../../node_modules/.pnpm/@tiptap+extension-task-list@3.27.1_@tiptap+extension-list@3.27.1_@tiptap+core@3.27.1_@t_4f7bde92718bc86efe94a5b45c31dca2/node_modules/@tiptap/extension-task-list/dist/index.js
|
|
26340
|
-
var
|
|
26364
|
+
var index_default6 = TaskList;
|
|
26341
26365
|
|
|
26342
26366
|
// ../../node_modules/.pnpm/@tiptap+extension-text-align@3.27.1_@tiptap+core@3.27.1_@tiptap+pm@3.27.1_/node_modules/@tiptap/extension-text-align/dist/index.js
|
|
26343
26367
|
var TextAlign = Extension.create({
|
|
@@ -26402,7 +26426,7 @@ var TextAlign = Extension.create({
|
|
|
26402
26426
|
};
|
|
26403
26427
|
}
|
|
26404
26428
|
});
|
|
26405
|
-
var
|
|
26429
|
+
var index_default7 = TextAlign;
|
|
26406
26430
|
|
|
26407
26431
|
// ../../node_modules/.pnpm/@tiptap+extension-underline@3.27.1_@tiptap+core@3.27.1_@tiptap+pm@3.27.1_/node_modules/@tiptap/extension-underline/dist/index.js
|
|
26408
26432
|
var Underline = Mark2.create({
|
|
@@ -26474,15 +26498,15 @@ var Underline = Mark2.create({
|
|
|
26474
26498
|
};
|
|
26475
26499
|
}
|
|
26476
26500
|
});
|
|
26477
|
-
var
|
|
26501
|
+
var index_default8 = Underline;
|
|
26478
26502
|
|
|
26479
26503
|
// ../../node_modules/.pnpm/uuid@14.0.1/node_modules/uuid/dist-node/stringify.js
|
|
26480
26504
|
var byteToHex = [];
|
|
26481
26505
|
for (let i = 0; i < 256; ++i) {
|
|
26482
26506
|
byteToHex.push((i + 256).toString(16).slice(1));
|
|
26483
26507
|
}
|
|
26484
|
-
function unsafeStringify(arr,
|
|
26485
|
-
return (byteToHex[arr[
|
|
26508
|
+
function unsafeStringify(arr, offset3 = 0) {
|
|
26509
|
+
return (byteToHex[arr[offset3 + 0]] + byteToHex[arr[offset3 + 1]] + byteToHex[arr[offset3 + 2]] + byteToHex[arr[offset3 + 3]] + "-" + byteToHex[arr[offset3 + 4]] + byteToHex[arr[offset3 + 5]] + "-" + byteToHex[arr[offset3 + 6]] + byteToHex[arr[offset3 + 7]] + "-" + byteToHex[arr[offset3 + 8]] + byteToHex[arr[offset3 + 9]] + "-" + byteToHex[arr[offset3 + 10]] + byteToHex[arr[offset3 + 11]] + byteToHex[arr[offset3 + 12]] + byteToHex[arr[offset3 + 13]] + byteToHex[arr[offset3 + 14]] + byteToHex[arr[offset3 + 15]]).toLowerCase();
|
|
26486
26510
|
}
|
|
26487
26511
|
|
|
26488
26512
|
// ../../node_modules/.pnpm/uuid@14.0.1/node_modules/uuid/dist-node/rng.js
|
|
@@ -26492,13 +26516,13 @@ function rng() {
|
|
|
26492
26516
|
}
|
|
26493
26517
|
|
|
26494
26518
|
// ../../node_modules/.pnpm/uuid@14.0.1/node_modules/uuid/dist-node/v4.js
|
|
26495
|
-
function v4(options, buf,
|
|
26519
|
+
function v4(options, buf, offset3) {
|
|
26496
26520
|
if (!buf && !options && crypto.randomUUID) {
|
|
26497
26521
|
return crypto.randomUUID();
|
|
26498
26522
|
}
|
|
26499
|
-
return _v4(options, buf,
|
|
26523
|
+
return _v4(options, buf, offset3);
|
|
26500
26524
|
}
|
|
26501
|
-
function _v4(options, buf,
|
|
26525
|
+
function _v4(options, buf, offset3) {
|
|
26502
26526
|
options = options || {};
|
|
26503
26527
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
26504
26528
|
if (rnds.length < 16) {
|
|
@@ -26507,12 +26531,12 @@ function _v4(options, buf, offset) {
|
|
|
26507
26531
|
rnds[6] = rnds[6] & 15 | 64;
|
|
26508
26532
|
rnds[8] = rnds[8] & 63 | 128;
|
|
26509
26533
|
if (buf) {
|
|
26510
|
-
|
|
26511
|
-
if (
|
|
26512
|
-
throw new RangeError(`UUID byte range ${
|
|
26534
|
+
offset3 = offset3 || 0;
|
|
26535
|
+
if (offset3 < 0 || offset3 + 16 > buf.length) {
|
|
26536
|
+
throw new RangeError(`UUID byte range ${offset3}:${offset3 + 15} is out of buffer bounds`);
|
|
26513
26537
|
}
|
|
26514
26538
|
for (let i = 0; i < 16; ++i) {
|
|
26515
|
-
buf[
|
|
26539
|
+
buf[offset3 + i] = rnds[i];
|
|
26516
26540
|
}
|
|
26517
26541
|
return buf;
|
|
26518
26542
|
}
|
|
@@ -26830,7 +26854,7 @@ var UniqueID = Extension.create({
|
|
|
26830
26854
|
];
|
|
26831
26855
|
}
|
|
26832
26856
|
});
|
|
26833
|
-
var
|
|
26857
|
+
var index_default9 = UniqueID;
|
|
26834
26858
|
|
|
26835
26859
|
// ../../node_modules/.pnpm/fast-equals@5.4.0/node_modules/fast-equals/dist/es/index.mjs
|
|
26836
26860
|
var { getOwnPropertyNames, getOwnPropertySymbols } = Object;
|
|
@@ -26904,14 +26928,14 @@ function areFunctionsEqual(a, b) {
|
|
|
26904
26928
|
return a === b;
|
|
26905
26929
|
}
|
|
26906
26930
|
function areMapsEqual(a, b, state) {
|
|
26907
|
-
const
|
|
26908
|
-
if (
|
|
26931
|
+
const size3 = a.size;
|
|
26932
|
+
if (size3 !== b.size) {
|
|
26909
26933
|
return false;
|
|
26910
26934
|
}
|
|
26911
|
-
if (!
|
|
26935
|
+
if (!size3) {
|
|
26912
26936
|
return true;
|
|
26913
26937
|
}
|
|
26914
|
-
const matchedIndices = new Array(
|
|
26938
|
+
const matchedIndices = new Array(size3);
|
|
26915
26939
|
const aIterable = a.entries();
|
|
26916
26940
|
let aResult;
|
|
26917
26941
|
let bResult;
|
|
@@ -26989,14 +27013,14 @@ function areRegExpsEqual(a, b) {
|
|
|
26989
27013
|
return a.source === b.source && a.flags === b.flags;
|
|
26990
27014
|
}
|
|
26991
27015
|
function areSetsEqual(a, b, state) {
|
|
26992
|
-
const
|
|
26993
|
-
if (
|
|
27016
|
+
const size3 = a.size;
|
|
27017
|
+
if (size3 !== b.size) {
|
|
26994
27018
|
return false;
|
|
26995
27019
|
}
|
|
26996
|
-
if (!
|
|
27020
|
+
if (!size3) {
|
|
26997
27021
|
return true;
|
|
26998
27022
|
}
|
|
26999
|
-
const matchedIndices = new Array(
|
|
27023
|
+
const matchedIndices = new Array(size3);
|
|
27000
27024
|
const aIterable = a.values();
|
|
27001
27025
|
let aResult;
|
|
27002
27026
|
let bResult;
|
|
@@ -27737,6 +27761,7 @@ var EditorContext = createContext({
|
|
|
27737
27761
|
editor: null
|
|
27738
27762
|
});
|
|
27739
27763
|
EditorContext.Consumer;
|
|
27764
|
+
var useCurrentEditor = () => useContext(EditorContext);
|
|
27740
27765
|
var ReactNodeViewContext = createContext({
|
|
27741
27766
|
onDragStart: () => {
|
|
27742
27767
|
},
|
|
@@ -28301,10 +28326,10 @@ function findDiffEnd2(a, b, posA, posB) {
|
|
|
28301
28326
|
for (let iA = a.childCount, iB = b.childCount; ; ) {
|
|
28302
28327
|
if (iA == 0 || iB == 0)
|
|
28303
28328
|
return iA == iB ? null : { a: posA, b: posB };
|
|
28304
|
-
let childA = a.child(--iA), childB = b.child(--iB),
|
|
28329
|
+
let childA = a.child(--iA), childB = b.child(--iB), size3 = childA.nodeSize;
|
|
28305
28330
|
if (childA == childB) {
|
|
28306
|
-
posA -=
|
|
28307
|
-
posB -=
|
|
28331
|
+
posA -= size3;
|
|
28332
|
+
posB -= size3;
|
|
28308
28333
|
continue;
|
|
28309
28334
|
}
|
|
28310
28335
|
if (!childA.sameMarkup(childB))
|
|
@@ -28323,18 +28348,18 @@ function findDiffEnd2(a, b, posA, posB) {
|
|
|
28323
28348
|
if (inner)
|
|
28324
28349
|
return inner;
|
|
28325
28350
|
}
|
|
28326
|
-
posA -=
|
|
28327
|
-
posB -=
|
|
28351
|
+
posA -= size3;
|
|
28352
|
+
posB -= size3;
|
|
28328
28353
|
}
|
|
28329
28354
|
}
|
|
28330
28355
|
var Fragment3 = class _Fragment {
|
|
28331
28356
|
/**
|
|
28332
28357
|
@internal
|
|
28333
28358
|
*/
|
|
28334
|
-
constructor(content,
|
|
28359
|
+
constructor(content, size3) {
|
|
28335
28360
|
this.content = content;
|
|
28336
|
-
this.size =
|
|
28337
|
-
if (
|
|
28361
|
+
this.size = size3 || 0;
|
|
28362
|
+
if (size3 == null)
|
|
28338
28363
|
for (let i = 0; i < content.length; i++)
|
|
28339
28364
|
this.size += content[i].nodeSize;
|
|
28340
28365
|
}
|
|
@@ -28403,7 +28428,7 @@ var Fragment3 = class _Fragment {
|
|
|
28403
28428
|
cut(from2, to = this.size) {
|
|
28404
28429
|
if (from2 == 0 && to == this.size)
|
|
28405
28430
|
return this;
|
|
28406
|
-
let result = [],
|
|
28431
|
+
let result = [], size3 = 0;
|
|
28407
28432
|
if (to > from2)
|
|
28408
28433
|
for (let i = 0, pos = 0; pos < to; i++) {
|
|
28409
28434
|
let child = this.content[i], end = pos + child.nodeSize;
|
|
@@ -28415,11 +28440,11 @@ var Fragment3 = class _Fragment {
|
|
|
28415
28440
|
child = child.cut(Math.max(0, from2 - pos - 1), Math.min(child.content.size, to - pos - 1));
|
|
28416
28441
|
}
|
|
28417
28442
|
result.push(child);
|
|
28418
|
-
|
|
28443
|
+
size3 += child.nodeSize;
|
|
28419
28444
|
}
|
|
28420
28445
|
pos = end;
|
|
28421
28446
|
}
|
|
28422
|
-
return new _Fragment(result,
|
|
28447
|
+
return new _Fragment(result, size3);
|
|
28423
28448
|
}
|
|
28424
28449
|
/**
|
|
28425
28450
|
@internal
|
|
@@ -28440,9 +28465,9 @@ var Fragment3 = class _Fragment {
|
|
|
28440
28465
|
if (current == node)
|
|
28441
28466
|
return this;
|
|
28442
28467
|
let copy2 = this.content.slice();
|
|
28443
|
-
let
|
|
28468
|
+
let size3 = this.size + node.nodeSize - current.nodeSize;
|
|
28444
28469
|
copy2[index] = node;
|
|
28445
|
-
return new _Fragment(copy2,
|
|
28470
|
+
return new _Fragment(copy2, size3);
|
|
28446
28471
|
}
|
|
28447
28472
|
/**
|
|
28448
28473
|
Create a new fragment by prepending the given node to this
|
|
@@ -28587,10 +28612,10 @@ var Fragment3 = class _Fragment {
|
|
|
28587
28612
|
static fromArray(array) {
|
|
28588
28613
|
if (!array.length)
|
|
28589
28614
|
return _Fragment.empty;
|
|
28590
|
-
let joined,
|
|
28615
|
+
let joined, size3 = 0;
|
|
28591
28616
|
for (let i = 0; i < array.length; i++) {
|
|
28592
28617
|
let node = array[i];
|
|
28593
|
-
|
|
28618
|
+
size3 += node.nodeSize;
|
|
28594
28619
|
if (i && node.isText && array[i - 1].sameMarkup(node)) {
|
|
28595
28620
|
if (!joined)
|
|
28596
28621
|
joined = array.slice(0, i);
|
|
@@ -28599,7 +28624,7 @@ var Fragment3 = class _Fragment {
|
|
|
28599
28624
|
joined.push(node);
|
|
28600
28625
|
}
|
|
28601
28626
|
}
|
|
28602
|
-
return new _Fragment(joined || array,
|
|
28627
|
+
return new _Fragment(joined || array, size3);
|
|
28603
28628
|
}
|
|
28604
28629
|
/**
|
|
28605
28630
|
Create a fragment from something that can be interpreted as a
|
|
@@ -28621,9 +28646,9 @@ var Fragment3 = class _Fragment {
|
|
|
28621
28646
|
};
|
|
28622
28647
|
Fragment3.empty = new Fragment3([], 0);
|
|
28623
28648
|
var found2 = { index: 0, offset: 0 };
|
|
28624
|
-
function retIndex2(index,
|
|
28649
|
+
function retIndex2(index, offset3) {
|
|
28625
28650
|
found2.index = index;
|
|
28626
|
-
found2.offset =
|
|
28651
|
+
found2.offset = offset3;
|
|
28627
28652
|
return found2;
|
|
28628
28653
|
}
|
|
28629
28654
|
var ReplaceError2 = class extends Error {
|
|
@@ -28716,31 +28741,31 @@ var Slice2 = class _Slice {
|
|
|
28716
28741
|
};
|
|
28717
28742
|
Slice2.empty = new Slice2(Fragment3.empty, 0, 0);
|
|
28718
28743
|
function removeRange2(content, from2, to) {
|
|
28719
|
-
let { index, offset } = content.findIndex(from2), child = content.maybeChild(index);
|
|
28744
|
+
let { index, offset: offset3 } = content.findIndex(from2), child = content.maybeChild(index);
|
|
28720
28745
|
let { index: indexTo, offset: offsetTo } = content.findIndex(to);
|
|
28721
|
-
if (
|
|
28746
|
+
if (offset3 == from2 || child.isText) {
|
|
28722
28747
|
if (offsetTo != to && !content.child(indexTo).isText)
|
|
28723
28748
|
throw new RangeError("Removing non-flat range");
|
|
28724
28749
|
return content.cut(0, from2).append(content.cut(to));
|
|
28725
28750
|
}
|
|
28726
28751
|
if (index != indexTo)
|
|
28727
28752
|
throw new RangeError("Removing non-flat range");
|
|
28728
|
-
return content.replaceChild(index, child.copy(removeRange2(child.content, from2 -
|
|
28753
|
+
return content.replaceChild(index, child.copy(removeRange2(child.content, from2 - offset3 - 1, to - offset3 - 1)));
|
|
28729
28754
|
}
|
|
28730
28755
|
function insertInto2(content, dist, insert, openStart, openEnd, parent) {
|
|
28731
|
-
let { index, offset } = content.findIndex(dist), child = content.maybeChild(index);
|
|
28732
|
-
if (
|
|
28756
|
+
let { index, offset: offset3 } = content.findIndex(dist), child = content.maybeChild(index);
|
|
28757
|
+
if (offset3 == dist || child.isText) {
|
|
28733
28758
|
if (parent && openStart <= 0 && openEnd <= 0 && !parent.canReplace(index, index, insert))
|
|
28734
28759
|
return null;
|
|
28735
28760
|
return content.cut(0, dist).append(insert).append(content.cut(dist));
|
|
28736
28761
|
}
|
|
28737
|
-
let inner = insertInto2(child.content, dist -
|
|
28762
|
+
let inner = insertInto2(child.content, dist - offset3 - 1, insert, index == 0 ? openStart - 1 : 0, index == content.childCount - 1 ? openEnd - 1 : 0, child);
|
|
28738
28763
|
return inner && content.replaceChild(index, child.copy(inner));
|
|
28739
28764
|
}
|
|
28740
28765
|
var lower162 = 65535;
|
|
28741
28766
|
var factor162 = Math.pow(2, 16);
|
|
28742
|
-
function makeRecover2(index,
|
|
28743
|
-
return index +
|
|
28767
|
+
function makeRecover2(index, offset3) {
|
|
28768
|
+
return index + offset3 * factor162;
|
|
28744
28769
|
}
|
|
28745
28770
|
function recoverIndex2(value) {
|
|
28746
28771
|
return value & lower162;
|
|
@@ -30974,182 +30999,2274 @@ var StarterKit = Extension.create({
|
|
|
30974
30999
|
return extensions;
|
|
30975
31000
|
}
|
|
30976
31001
|
});
|
|
30977
|
-
var
|
|
30978
|
-
|
|
30979
|
-
var
|
|
30980
|
-
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
30989
|
-
|
|
30990
|
-
|
|
30991
|
-
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
|
|
30995
|
-
|
|
30996
|
-
|
|
30997
|
-
|
|
30998
|
-
|
|
30999
|
-
|
|
31000
|
-
|
|
31001
|
-
|
|
31002
|
-
|
|
31003
|
-
|
|
31004
|
-
|
|
31005
|
-
|
|
31006
|
-
|
|
31007
|
-
|
|
31008
|
-
|
|
31009
|
-
|
|
31010
|
-
|
|
31002
|
+
var index_default10 = StarterKit;
|
|
31003
|
+
function findSuggestionMatch(config) {
|
|
31004
|
+
var _a;
|
|
31005
|
+
const {
|
|
31006
|
+
char,
|
|
31007
|
+
allowSpaces: allowSpacesOption,
|
|
31008
|
+
allowToIncludeChar,
|
|
31009
|
+
allowedPrefixes,
|
|
31010
|
+
startOfLine,
|
|
31011
|
+
$position
|
|
31012
|
+
} = config;
|
|
31013
|
+
const allowSpaces = allowSpacesOption && !allowToIncludeChar;
|
|
31014
|
+
const escapedChar = escapeForRegEx(char);
|
|
31015
|
+
const suffix = new RegExp(`\\s${escapedChar}$`);
|
|
31016
|
+
const prefix = startOfLine ? "^" : "";
|
|
31017
|
+
const finalEscapedChar = allowToIncludeChar ? "" : escapedChar;
|
|
31018
|
+
const regexp = allowSpaces ? new RegExp(`${prefix}${escapedChar}.*?(?=\\s${finalEscapedChar}|$)`, "gm") : new RegExp(`${prefix}(?:^)?${escapedChar}[^\\s${finalEscapedChar}]*`, "gm");
|
|
31019
|
+
const text = ((_a = $position.nodeBefore) == null ? void 0 : _a.isText) && $position.nodeBefore.text;
|
|
31020
|
+
if (!text) {
|
|
31021
|
+
return null;
|
|
31022
|
+
}
|
|
31023
|
+
const textFrom = $position.pos - text.length;
|
|
31024
|
+
const match = Array.from(text.matchAll(regexp)).pop();
|
|
31025
|
+
if (!match || match.input === void 0 || match.index === void 0) {
|
|
31026
|
+
return null;
|
|
31027
|
+
}
|
|
31028
|
+
const matchPrefix = match.input.slice(Math.max(0, match.index - 1), match.index);
|
|
31029
|
+
const matchPrefixIsAllowed = new RegExp(`^[${allowedPrefixes == null ? void 0 : allowedPrefixes.join("")}\0]?$`).test(matchPrefix);
|
|
31030
|
+
if (allowedPrefixes !== null && !matchPrefixIsAllowed) {
|
|
31031
|
+
return null;
|
|
31032
|
+
}
|
|
31033
|
+
const from2 = textFrom + match.index;
|
|
31034
|
+
let to = from2 + match[0].length;
|
|
31035
|
+
if (allowSpaces && suffix.test(text.slice(to - 1, to + 1))) {
|
|
31036
|
+
match[0] += " ";
|
|
31037
|
+
to += 1;
|
|
31038
|
+
}
|
|
31039
|
+
if (from2 < $position.pos && to >= $position.pos) {
|
|
31040
|
+
return {
|
|
31041
|
+
range: {
|
|
31042
|
+
from: from2,
|
|
31043
|
+
to
|
|
31044
|
+
},
|
|
31045
|
+
query: match[0].slice(char.length),
|
|
31046
|
+
text: match[0]
|
|
31047
|
+
};
|
|
31048
|
+
}
|
|
31049
|
+
return null;
|
|
31050
|
+
}
|
|
31051
|
+
function hasInsertedWhitespace(transaction) {
|
|
31052
|
+
if (!transaction.docChanged) {
|
|
31053
|
+
return false;
|
|
31054
|
+
}
|
|
31055
|
+
return transaction.steps.some((step) => {
|
|
31056
|
+
const slice2 = step.slice;
|
|
31057
|
+
if (!(slice2 == null ? void 0 : slice2.content)) {
|
|
31058
|
+
return false;
|
|
31011
31059
|
}
|
|
31012
|
-
|
|
31013
|
-
);
|
|
31014
|
-
|
|
31015
|
-
|
|
31016
|
-
|
|
31017
|
-
|
|
31018
|
-
|
|
31019
|
-
|
|
31020
|
-
|
|
31021
|
-
|
|
31022
|
-
|
|
31023
|
-
|
|
31024
|
-
|
|
31025
|
-
"*": ["id"]
|
|
31026
|
-
};
|
|
31027
|
-
for (const tag of FORBIDDEN_PASTE_TAGS) {
|
|
31028
|
-
for (const element of Array.from(parsed.body.getElementsByTagName(tag))) {
|
|
31029
|
-
element.remove();
|
|
31060
|
+
const inserted = slice2.content.textBetween(0, slice2.content.size, "\n");
|
|
31061
|
+
return /\s/.test(inserted);
|
|
31062
|
+
});
|
|
31063
|
+
}
|
|
31064
|
+
function getAnchorClientRect(editor) {
|
|
31065
|
+
return () => {
|
|
31066
|
+
const pos = editor.state.selection.$anchor.pos;
|
|
31067
|
+
const coords = editor.view.coordsAtPos(pos);
|
|
31068
|
+
const { top, right, bottom, left } = coords;
|
|
31069
|
+
try {
|
|
31070
|
+
return new DOMRect(left, top, right - left, bottom - top);
|
|
31071
|
+
} catch {
|
|
31072
|
+
return null;
|
|
31030
31073
|
}
|
|
31074
|
+
};
|
|
31075
|
+
}
|
|
31076
|
+
function clientRectFor(editor, view, decorationNode, pluginKey) {
|
|
31077
|
+
if (!decorationNode) {
|
|
31078
|
+
return getAnchorClientRect(editor);
|
|
31031
31079
|
}
|
|
31032
|
-
|
|
31033
|
-
const
|
|
31034
|
-
|
|
31035
|
-
|
|
31036
|
-
|
|
31037
|
-
|
|
31038
|
-
|
|
31039
|
-
|
|
31040
|
-
|
|
31080
|
+
return () => {
|
|
31081
|
+
const state = pluginKey.getState(editor.state);
|
|
31082
|
+
const decorationId = state == null ? void 0 : state.decorationId;
|
|
31083
|
+
const currentDecorationNode = view.dom.querySelector(`[data-decoration-id="${decorationId}"]`);
|
|
31084
|
+
return (currentDecorationNode == null ? void 0 : currentDecorationNode.getBoundingClientRect()) || null;
|
|
31085
|
+
};
|
|
31086
|
+
}
|
|
31087
|
+
function shouldKeepDismissed({
|
|
31088
|
+
match,
|
|
31089
|
+
dismissedRange,
|
|
31090
|
+
state,
|
|
31091
|
+
transaction,
|
|
31092
|
+
editor,
|
|
31093
|
+
shouldResetDismissed,
|
|
31094
|
+
effectiveAllowSpaces
|
|
31095
|
+
}) {
|
|
31096
|
+
if (shouldResetDismissed == null ? void 0 : shouldResetDismissed({
|
|
31097
|
+
editor,
|
|
31098
|
+
state,
|
|
31099
|
+
range: dismissedRange,
|
|
31100
|
+
match,
|
|
31101
|
+
transaction,
|
|
31102
|
+
allowSpaces: effectiveAllowSpaces
|
|
31103
|
+
})) {
|
|
31104
|
+
return false;
|
|
31041
31105
|
}
|
|
31042
|
-
if (
|
|
31043
|
-
return
|
|
31106
|
+
if (effectiveAllowSpaces) {
|
|
31107
|
+
return match.range.from === dismissedRange.from;
|
|
31044
31108
|
}
|
|
31045
|
-
|
|
31046
|
-
|
|
31047
|
-
|
|
31048
|
-
|
|
31049
|
-
|
|
31050
|
-
|
|
31051
|
-
|
|
31052
|
-
|
|
31053
|
-
|
|
31109
|
+
return match.range.from === dismissedRange.from && !hasInsertedWhitespace(transaction);
|
|
31110
|
+
}
|
|
31111
|
+
function dispatchExit({
|
|
31112
|
+
view,
|
|
31113
|
+
pluginKeyRef
|
|
31114
|
+
}) {
|
|
31115
|
+
const tr2 = view.state.tr.setMeta(pluginKeyRef, { exit: true });
|
|
31116
|
+
view.dispatch(tr2);
|
|
31117
|
+
}
|
|
31118
|
+
function createSuggestionProps({
|
|
31119
|
+
pluginKey,
|
|
31120
|
+
decorationTag,
|
|
31121
|
+
decorationClass,
|
|
31122
|
+
decorationContent,
|
|
31123
|
+
decorationEmptyClass,
|
|
31124
|
+
renderer,
|
|
31125
|
+
dispatchExit: dispatchExit2
|
|
31126
|
+
}) {
|
|
31127
|
+
return {
|
|
31128
|
+
/**
|
|
31129
|
+
* Call the keydown hook if suggestion is active.
|
|
31130
|
+
*/
|
|
31131
|
+
handleKeyDown(view, event) {
|
|
31132
|
+
var _a, _b;
|
|
31133
|
+
const state = pluginKey.getState(view.state);
|
|
31134
|
+
if (!state.active) {
|
|
31135
|
+
return false;
|
|
31054
31136
|
}
|
|
31055
|
-
|
|
31056
|
-
|
|
31057
|
-
|
|
31137
|
+
if (event.key === "Escape" || event.key === "Esc") {
|
|
31138
|
+
(_a = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _a.call(renderer, { view, event, range: state.range });
|
|
31139
|
+
dispatchExit2(view);
|
|
31140
|
+
return true;
|
|
31141
|
+
}
|
|
31142
|
+
const handled = ((_b = renderer == null ? void 0 : renderer.onKeyDown) == null ? void 0 : _b.call(renderer, { view, event, range: state.range })) || false;
|
|
31143
|
+
return handled;
|
|
31144
|
+
},
|
|
31145
|
+
/**
|
|
31146
|
+
* Setup decorator on the currently active suggestion.
|
|
31147
|
+
*/
|
|
31148
|
+
decorations(state) {
|
|
31149
|
+
const pluginState = pluginKey.getState(state);
|
|
31150
|
+
const { active, range, decorationId, query } = pluginState;
|
|
31151
|
+
if (!active) {
|
|
31152
|
+
return null;
|
|
31153
|
+
}
|
|
31154
|
+
const isEmpty2 = !(query == null ? void 0 : query.length);
|
|
31155
|
+
const classNames = [decorationClass];
|
|
31156
|
+
if (isEmpty2) {
|
|
31157
|
+
classNames.push(decorationEmptyClass);
|
|
31158
|
+
}
|
|
31159
|
+
return DecorationSet.create(state.doc, [
|
|
31160
|
+
Decoration.inline(range.from, range.to, {
|
|
31161
|
+
nodeName: decorationTag,
|
|
31162
|
+
class: classNames.join(" "),
|
|
31163
|
+
"data-decoration-id": decorationId || void 0,
|
|
31164
|
+
"data-decoration-content": decorationContent
|
|
31165
|
+
})
|
|
31166
|
+
]);
|
|
31058
31167
|
}
|
|
31059
31168
|
};
|
|
31060
|
-
|
|
31061
|
-
|
|
31062
|
-
|
|
31063
|
-
|
|
31064
|
-
|
|
31065
|
-
|
|
31066
|
-
|
|
31067
|
-
|
|
31068
|
-
|
|
31069
|
-
|
|
31070
|
-
|
|
31071
|
-
|
|
31072
|
-
|
|
31073
|
-
|
|
31074
|
-
|
|
31075
|
-
|
|
31076
|
-
|
|
31077
|
-
|
|
31078
|
-
|
|
31079
|
-
|
|
31080
|
-
|
|
31081
|
-
|
|
31082
|
-
|
|
31083
|
-
|
|
31084
|
-
|
|
31085
|
-
|
|
31086
|
-
|
|
31087
|
-
|
|
31088
|
-
|
|
31089
|
-
|
|
31090
|
-
|
|
31091
|
-
|
|
31092
|
-
|
|
31093
|
-
|
|
31094
|
-
|
|
31095
|
-
|
|
31096
|
-
|
|
31097
|
-
|
|
31098
|
-
|
|
31099
|
-
|
|
31100
|
-
|
|
31101
|
-
|
|
31102
|
-
|
|
31103
|
-
|
|
31104
|
-
|
|
31105
|
-
|
|
31106
|
-
|
|
31107
|
-
|
|
31108
|
-
|
|
31109
|
-
|
|
31110
|
-
|
|
31111
|
-
|
|
31169
|
+
}
|
|
31170
|
+
function createSuggestionState({
|
|
31171
|
+
editor,
|
|
31172
|
+
char,
|
|
31173
|
+
effectiveAllowSpaces,
|
|
31174
|
+
allowToIncludeChar,
|
|
31175
|
+
allowedPrefixes,
|
|
31176
|
+
startOfLine,
|
|
31177
|
+
findSuggestionMatch: findSuggestionMatch2,
|
|
31178
|
+
allow,
|
|
31179
|
+
shouldShow,
|
|
31180
|
+
shouldKeepDismissed: shouldKeepDismissed2,
|
|
31181
|
+
pluginKey
|
|
31182
|
+
}) {
|
|
31183
|
+
return {
|
|
31184
|
+
/**
|
|
31185
|
+
* Initialize the plugin's internal state.
|
|
31186
|
+
*/
|
|
31187
|
+
init() {
|
|
31188
|
+
return {
|
|
31189
|
+
active: false,
|
|
31190
|
+
range: { from: 0, to: 0 },
|
|
31191
|
+
query: null,
|
|
31192
|
+
text: null,
|
|
31193
|
+
composing: false,
|
|
31194
|
+
dismissedRange: null
|
|
31195
|
+
};
|
|
31196
|
+
},
|
|
31197
|
+
/**
|
|
31198
|
+
* Apply changes to the plugin state from a view transaction.
|
|
31199
|
+
*/
|
|
31200
|
+
apply(transaction, prev, _oldState, state) {
|
|
31201
|
+
const { isEditable } = editor;
|
|
31202
|
+
const { composing } = editor.view;
|
|
31203
|
+
const { selection } = transaction;
|
|
31204
|
+
const { empty: empty2, from: from2 } = selection;
|
|
31205
|
+
const next = { ...prev };
|
|
31206
|
+
const meta = transaction.getMeta(pluginKey);
|
|
31207
|
+
if (meta && meta.exit) {
|
|
31208
|
+
next.active = false;
|
|
31209
|
+
next.decorationId = null;
|
|
31210
|
+
next.range = { from: 0, to: 0 };
|
|
31211
|
+
next.query = null;
|
|
31212
|
+
next.text = null;
|
|
31213
|
+
next.dismissedRange = prev.active ? { ...prev.range } : prev.dismissedRange;
|
|
31214
|
+
return next;
|
|
31215
|
+
}
|
|
31216
|
+
next.composing = composing;
|
|
31217
|
+
if (transaction.docChanged && next.dismissedRange !== null) {
|
|
31218
|
+
next.dismissedRange = {
|
|
31219
|
+
from: transaction.mapping.map(next.dismissedRange.from),
|
|
31220
|
+
to: transaction.mapping.map(next.dismissedRange.to)
|
|
31221
|
+
};
|
|
31222
|
+
}
|
|
31223
|
+
if (isEditable && (empty2 || editor.view.composing)) {
|
|
31224
|
+
if ((from2 < prev.range.from || from2 > prev.range.to) && !composing && !prev.composing) {
|
|
31225
|
+
next.active = false;
|
|
31112
31226
|
}
|
|
31113
|
-
const
|
|
31114
|
-
|
|
31115
|
-
|
|
31116
|
-
|
|
31117
|
-
|
|
31118
|
-
|
|
31119
|
-
|
|
31120
|
-
|
|
31227
|
+
const match = findSuggestionMatch2({
|
|
31228
|
+
char,
|
|
31229
|
+
allowSpaces: effectiveAllowSpaces,
|
|
31230
|
+
allowToIncludeChar,
|
|
31231
|
+
allowedPrefixes,
|
|
31232
|
+
startOfLine,
|
|
31233
|
+
$position: selection.$from
|
|
31234
|
+
});
|
|
31235
|
+
const decorationId = `id_${Math.floor(Math.random() * 4294967295)}`;
|
|
31236
|
+
if (match && allow({
|
|
31237
|
+
editor,
|
|
31238
|
+
state,
|
|
31239
|
+
range: match.range,
|
|
31240
|
+
isActive: prev.active
|
|
31241
|
+
}) && (!shouldShow || shouldShow({
|
|
31242
|
+
editor,
|
|
31243
|
+
range: match.range,
|
|
31244
|
+
query: match.query,
|
|
31245
|
+
text: match.text,
|
|
31246
|
+
transaction
|
|
31247
|
+
}))) {
|
|
31248
|
+
if (next.dismissedRange !== null && !shouldKeepDismissed2({
|
|
31249
|
+
match,
|
|
31250
|
+
dismissedRange: next.dismissedRange,
|
|
31251
|
+
state,
|
|
31252
|
+
transaction
|
|
31253
|
+
})) {
|
|
31254
|
+
next.dismissedRange = null;
|
|
31255
|
+
}
|
|
31256
|
+
if (next.dismissedRange === null) {
|
|
31257
|
+
next.active = true;
|
|
31258
|
+
next.decorationId = prev.decorationId || decorationId;
|
|
31259
|
+
next.range = match.range;
|
|
31260
|
+
next.query = match.query;
|
|
31261
|
+
next.text = match.text;
|
|
31262
|
+
} else {
|
|
31263
|
+
next.active = false;
|
|
31264
|
+
}
|
|
31265
|
+
} else {
|
|
31266
|
+
if (!match) {
|
|
31267
|
+
next.dismissedRange = null;
|
|
31268
|
+
}
|
|
31269
|
+
next.active = false;
|
|
31121
31270
|
}
|
|
31122
|
-
|
|
31123
|
-
|
|
31124
|
-
);
|
|
31125
|
-
return true;
|
|
31271
|
+
} else {
|
|
31272
|
+
next.active = false;
|
|
31126
31273
|
}
|
|
31127
|
-
|
|
31128
|
-
|
|
31129
|
-
}
|
|
31130
|
-
|
|
31131
|
-
|
|
31132
|
-
content: "block+",
|
|
31133
|
-
isolating: true,
|
|
31134
|
-
defining: true,
|
|
31135
|
-
addAttributes() {
|
|
31136
|
-
return createStandardAttributes([...COMMON_HTML_ATTRIBUTES, ...LAYOUT_ATTRIBUTES]);
|
|
31137
|
-
},
|
|
31138
|
-
parseHTML() {
|
|
31139
|
-
return [{ tag: "div[data-openeditor-column]" }];
|
|
31140
|
-
},
|
|
31141
|
-
renderHTML({ HTMLAttributes }) {
|
|
31142
|
-
return ["div", mergeAttributes({ "data-openeditor-column": "", class: "oe-column" }, HTMLAttributes), 0];
|
|
31143
|
-
}
|
|
31144
|
-
});
|
|
31145
|
-
var Divider = index_default.extend({
|
|
31146
|
-
addAttributes() {
|
|
31147
|
-
return {
|
|
31148
|
-
...createStandardAttributes(["class", "style"]),
|
|
31149
|
-
class: {
|
|
31150
|
-
default: "oe-divider"
|
|
31274
|
+
if (!next.active) {
|
|
31275
|
+
next.decorationId = null;
|
|
31276
|
+
next.range = { from: 0, to: 0 };
|
|
31277
|
+
next.query = null;
|
|
31278
|
+
next.text = null;
|
|
31151
31279
|
}
|
|
31152
|
-
|
|
31280
|
+
return next;
|
|
31281
|
+
}
|
|
31282
|
+
};
|
|
31283
|
+
}
|
|
31284
|
+
function createSuggestionAsyncRequestManager({
|
|
31285
|
+
editor,
|
|
31286
|
+
items
|
|
31287
|
+
}) {
|
|
31288
|
+
let abortController = null;
|
|
31289
|
+
let debounceTimer = null;
|
|
31290
|
+
let debounceResolve = null;
|
|
31291
|
+
const clearDebounceTimer = () => {
|
|
31292
|
+
if (debounceTimer !== null) {
|
|
31293
|
+
clearTimeout(debounceTimer);
|
|
31294
|
+
debounceTimer = null;
|
|
31295
|
+
}
|
|
31296
|
+
debounceResolve == null ? void 0 : debounceResolve();
|
|
31297
|
+
debounceResolve = null;
|
|
31298
|
+
};
|
|
31299
|
+
const waitForDebounce = (delay) => {
|
|
31300
|
+
return new Promise((resolve) => {
|
|
31301
|
+
debounceResolve = resolve;
|
|
31302
|
+
debounceTimer = setTimeout(() => {
|
|
31303
|
+
debounceTimer = null;
|
|
31304
|
+
const pendingResolve = debounceResolve;
|
|
31305
|
+
debounceResolve = null;
|
|
31306
|
+
pendingResolve == null ? void 0 : pendingResolve();
|
|
31307
|
+
}, delay);
|
|
31308
|
+
});
|
|
31309
|
+
};
|
|
31310
|
+
const abort = () => {
|
|
31311
|
+
abortController == null ? void 0 : abortController.abort();
|
|
31312
|
+
clearDebounceTimer();
|
|
31313
|
+
abortController = null;
|
|
31314
|
+
};
|
|
31315
|
+
const fetch = async (query, debounce) => {
|
|
31316
|
+
abort();
|
|
31317
|
+
abortController = new AbortController();
|
|
31318
|
+
const controller = abortController;
|
|
31319
|
+
if (debounce > 0) {
|
|
31320
|
+
await waitForDebounce(debounce);
|
|
31321
|
+
}
|
|
31322
|
+
if (abortController !== controller || controller.signal.aborted) {
|
|
31323
|
+
return { status: "aborted" };
|
|
31324
|
+
}
|
|
31325
|
+
try {
|
|
31326
|
+
const result = await items({
|
|
31327
|
+
editor,
|
|
31328
|
+
query,
|
|
31329
|
+
signal: controller.signal
|
|
31330
|
+
});
|
|
31331
|
+
if (abortController !== controller || controller.signal.aborted) {
|
|
31332
|
+
return { status: "aborted" };
|
|
31333
|
+
}
|
|
31334
|
+
return { status: "resolved", items: result };
|
|
31335
|
+
} catch {
|
|
31336
|
+
if (abortController !== controller || controller.signal.aborted) {
|
|
31337
|
+
return { status: "aborted" };
|
|
31338
|
+
}
|
|
31339
|
+
return { status: "error" };
|
|
31340
|
+
}
|
|
31341
|
+
};
|
|
31342
|
+
return {
|
|
31343
|
+
abort,
|
|
31344
|
+
fetch
|
|
31345
|
+
};
|
|
31346
|
+
}
|
|
31347
|
+
function createSuggestionFloatingUiConfig({
|
|
31348
|
+
placement,
|
|
31349
|
+
offset: offset3,
|
|
31350
|
+
flip: flip3,
|
|
31351
|
+
floatingUi
|
|
31352
|
+
}) {
|
|
31353
|
+
var _a, _b, _c, _d;
|
|
31354
|
+
const middleware = [
|
|
31355
|
+
offset({
|
|
31356
|
+
mainAxis: (_a = offset3.mainAxis) != null ? _a : 4,
|
|
31357
|
+
crossAxis: (_b = offset3.crossAxis) != null ? _b : 0
|
|
31358
|
+
})
|
|
31359
|
+
];
|
|
31360
|
+
if (flip3) {
|
|
31361
|
+
middleware.push(flip());
|
|
31362
|
+
}
|
|
31363
|
+
if ((_c = floatingUi == null ? void 0 : floatingUi.middleware) == null ? void 0 : _c.length) {
|
|
31364
|
+
middleware.push(...floatingUi.middleware);
|
|
31365
|
+
}
|
|
31366
|
+
return {
|
|
31367
|
+
placement,
|
|
31368
|
+
strategy: (_d = floatingUi == null ? void 0 : floatingUi.strategy) != null ? _d : "absolute",
|
|
31369
|
+
middleware
|
|
31370
|
+
};
|
|
31371
|
+
}
|
|
31372
|
+
function resolveContainer(container) {
|
|
31373
|
+
if (container instanceof HTMLElement) {
|
|
31374
|
+
return container;
|
|
31375
|
+
}
|
|
31376
|
+
if (typeof container === "string") {
|
|
31377
|
+
try {
|
|
31378
|
+
const found3 = document.querySelector(container);
|
|
31379
|
+
if (found3) {
|
|
31380
|
+
return found3;
|
|
31381
|
+
}
|
|
31382
|
+
} catch {
|
|
31383
|
+
return document.body;
|
|
31384
|
+
}
|
|
31385
|
+
}
|
|
31386
|
+
return document.body;
|
|
31387
|
+
}
|
|
31388
|
+
function createMount({
|
|
31389
|
+
getReferenceRect,
|
|
31390
|
+
contextElement,
|
|
31391
|
+
config,
|
|
31392
|
+
container,
|
|
31393
|
+
dismissOnOutsideClick,
|
|
31394
|
+
dismiss
|
|
31395
|
+
}) {
|
|
31396
|
+
return (element, options = {}) => {
|
|
31397
|
+
const reference = {
|
|
31398
|
+
getBoundingClientRect: () => {
|
|
31399
|
+
var _a;
|
|
31400
|
+
return (_a = getReferenceRect()) != null ? _a : new DOMRect();
|
|
31401
|
+
},
|
|
31402
|
+
contextElement
|
|
31403
|
+
};
|
|
31404
|
+
let positioned = false;
|
|
31405
|
+
const mountedByUs = !element.isConnected;
|
|
31406
|
+
if (mountedByUs) {
|
|
31407
|
+
resolveContainer(container).appendChild(element);
|
|
31408
|
+
}
|
|
31409
|
+
if (!options.onPosition) {
|
|
31410
|
+
element.style.visibility = "hidden";
|
|
31411
|
+
element.style.width = "max-content";
|
|
31412
|
+
}
|
|
31413
|
+
const update = () => {
|
|
31414
|
+
computePosition(reference, element, {
|
|
31415
|
+
placement: config.placement,
|
|
31416
|
+
strategy: config.strategy,
|
|
31417
|
+
middleware: config.middleware
|
|
31418
|
+
}).then(({ x, y, placement, strategy }) => {
|
|
31419
|
+
if (options.onPosition) {
|
|
31420
|
+
options.onPosition({ x, y, placement, strategy });
|
|
31421
|
+
return;
|
|
31422
|
+
}
|
|
31423
|
+
Object.assign(element.style, {
|
|
31424
|
+
position: strategy,
|
|
31425
|
+
left: `${x}px`,
|
|
31426
|
+
top: `${y}px`
|
|
31427
|
+
});
|
|
31428
|
+
if (!positioned) {
|
|
31429
|
+
positioned = true;
|
|
31430
|
+
element.style.visibility = "";
|
|
31431
|
+
}
|
|
31432
|
+
});
|
|
31433
|
+
};
|
|
31434
|
+
const cleanupAutoUpdate = autoUpdate(reference, element, update, options.autoUpdate);
|
|
31435
|
+
let onOutsidePointerDown;
|
|
31436
|
+
if (dismissOnOutsideClick) {
|
|
31437
|
+
onOutsidePointerDown = (event) => {
|
|
31438
|
+
const target = event.target;
|
|
31439
|
+
if (!(target instanceof Node) || element.contains(target) || contextElement.contains(target)) {
|
|
31440
|
+
return;
|
|
31441
|
+
}
|
|
31442
|
+
dismiss();
|
|
31443
|
+
};
|
|
31444
|
+
document.addEventListener("pointerdown", onOutsidePointerDown, true);
|
|
31445
|
+
}
|
|
31446
|
+
return () => {
|
|
31447
|
+
cleanupAutoUpdate();
|
|
31448
|
+
if (onOutsidePointerDown) {
|
|
31449
|
+
document.removeEventListener("pointerdown", onOutsidePointerDown, true);
|
|
31450
|
+
}
|
|
31451
|
+
if (mountedByUs) {
|
|
31452
|
+
element.remove();
|
|
31453
|
+
}
|
|
31454
|
+
};
|
|
31455
|
+
};
|
|
31456
|
+
}
|
|
31457
|
+
function createSuggestionView({
|
|
31458
|
+
editor,
|
|
31459
|
+
pluginKey,
|
|
31460
|
+
items,
|
|
31461
|
+
renderer,
|
|
31462
|
+
minQueryLength,
|
|
31463
|
+
debounce,
|
|
31464
|
+
initialItems,
|
|
31465
|
+
placement,
|
|
31466
|
+
offset: offsetOption,
|
|
31467
|
+
container,
|
|
31468
|
+
flip: flip3,
|
|
31469
|
+
floatingUi,
|
|
31470
|
+
dismissOnOutsideClick,
|
|
31471
|
+
command: command2,
|
|
31472
|
+
clientRectFor: clientRectFor2,
|
|
31473
|
+
dispatchExit: dispatchExit2
|
|
31474
|
+
}) {
|
|
31475
|
+
let props;
|
|
31476
|
+
const asyncRequest = createSuggestionAsyncRequestManager({
|
|
31477
|
+
editor,
|
|
31478
|
+
items
|
|
31479
|
+
});
|
|
31480
|
+
const floatingUiConfig = createSuggestionFloatingUiConfig({
|
|
31481
|
+
placement,
|
|
31482
|
+
offset: offsetOption,
|
|
31483
|
+
flip: flip3,
|
|
31484
|
+
floatingUi
|
|
31485
|
+
});
|
|
31486
|
+
function dispatchStateUpdate(state, dispatchProps) {
|
|
31487
|
+
var _a, _b, _c;
|
|
31488
|
+
switch (state) {
|
|
31489
|
+
case "started":
|
|
31490
|
+
(_a = renderer == null ? void 0 : renderer.onStart) == null ? void 0 : _a.call(renderer, dispatchProps);
|
|
31491
|
+
break;
|
|
31492
|
+
case "updated":
|
|
31493
|
+
(_b = renderer == null ? void 0 : renderer.onUpdate) == null ? void 0 : _b.call(renderer, dispatchProps);
|
|
31494
|
+
break;
|
|
31495
|
+
case "stopped":
|
|
31496
|
+
(_c = renderer == null ? void 0 : renderer.onExit) == null ? void 0 : _c.call(renderer, dispatchProps);
|
|
31497
|
+
break;
|
|
31498
|
+
}
|
|
31499
|
+
}
|
|
31500
|
+
return {
|
|
31501
|
+
update: async (view, prevState) => {
|
|
31502
|
+
var _a, _b, _c, _d;
|
|
31503
|
+
const prev = pluginKey.getState(prevState);
|
|
31504
|
+
const next = pluginKey.getState(view.state);
|
|
31505
|
+
if (!prev || !next) {
|
|
31506
|
+
return;
|
|
31507
|
+
}
|
|
31508
|
+
let currentState = null;
|
|
31509
|
+
const queryChanged = prev.query !== next.query;
|
|
31510
|
+
const textChanged = prev.text !== next.text;
|
|
31511
|
+
const rangeChanged = prev.range.from !== next.range.from || prev.range.to !== next.range.to;
|
|
31512
|
+
const effectiveQueryChanged = queryChanged || textChanged || rangeChanged;
|
|
31513
|
+
if (!prev.active && next.active) {
|
|
31514
|
+
currentState = "started";
|
|
31515
|
+
} else if (prev.active && !next.active) {
|
|
31516
|
+
currentState = "stopped";
|
|
31517
|
+
} else if (next.active && effectiveQueryChanged) {
|
|
31518
|
+
currentState = "updated";
|
|
31519
|
+
} else {
|
|
31520
|
+
return;
|
|
31521
|
+
}
|
|
31522
|
+
const state = currentState === "stopped" ? prev : next;
|
|
31523
|
+
const decorationNode = view.dom.querySelector(`[data-decoration-id="${state.decorationId}"]`);
|
|
31524
|
+
const clientRect2 = clientRectFor2(view, decorationNode);
|
|
31525
|
+
const exceedsMinQueryLength = minQueryLength === 0 || (state.query ? state.query.length >= minQueryLength : false);
|
|
31526
|
+
const willFetch = (currentState === "started" || currentState === "updated") && exceedsMinQueryLength;
|
|
31527
|
+
props = {
|
|
31528
|
+
editor,
|
|
31529
|
+
range: state.range,
|
|
31530
|
+
query: state.query || "",
|
|
31531
|
+
text: state.text || "",
|
|
31532
|
+
items: initialItems != null ? initialItems : [],
|
|
31533
|
+
command: (commandProps) => {
|
|
31534
|
+
return command2({
|
|
31535
|
+
editor,
|
|
31536
|
+
range: state.range,
|
|
31537
|
+
props: commandProps
|
|
31538
|
+
});
|
|
31539
|
+
},
|
|
31540
|
+
decorationNode,
|
|
31541
|
+
clientRect: clientRect2,
|
|
31542
|
+
loading: willFetch,
|
|
31543
|
+
placement,
|
|
31544
|
+
offset: { mainAxis: (_a = offsetOption.mainAxis) != null ? _a : 4, crossAxis: (_b = offsetOption.crossAxis) != null ? _b : 0 },
|
|
31545
|
+
container,
|
|
31546
|
+
flip: flip3,
|
|
31547
|
+
floatingUi: floatingUiConfig,
|
|
31548
|
+
mount: createMount({
|
|
31549
|
+
getReferenceRect: clientRect2,
|
|
31550
|
+
contextElement: view.dom,
|
|
31551
|
+
config: floatingUiConfig,
|
|
31552
|
+
container,
|
|
31553
|
+
dismissOnOutsideClick,
|
|
31554
|
+
dismiss: () => dispatchExit2(editor.view)
|
|
31555
|
+
})
|
|
31556
|
+
};
|
|
31557
|
+
if (currentState === "started") {
|
|
31558
|
+
(_c = renderer == null ? void 0 : renderer.onBeforeStart) == null ? void 0 : _c.call(renderer, props);
|
|
31559
|
+
}
|
|
31560
|
+
if (currentState === "updated") {
|
|
31561
|
+
(_d = renderer == null ? void 0 : renderer.onBeforeUpdate) == null ? void 0 : _d.call(renderer, props);
|
|
31562
|
+
}
|
|
31563
|
+
if (currentState === "started") {
|
|
31564
|
+
dispatchStateUpdate(currentState, props);
|
|
31565
|
+
}
|
|
31566
|
+
if (currentState === "started" || currentState === "updated") {
|
|
31567
|
+
if (!willFetch) {
|
|
31568
|
+
asyncRequest.abort();
|
|
31569
|
+
props = { ...props, items: initialItems != null ? initialItems : [], loading: false };
|
|
31570
|
+
} else {
|
|
31571
|
+
props = { ...props, items: initialItems != null ? initialItems : [], loading: true };
|
|
31572
|
+
currentState = "updated";
|
|
31573
|
+
dispatchStateUpdate(currentState, props);
|
|
31574
|
+
const result = await asyncRequest.fetch(state.query || "", debounce);
|
|
31575
|
+
if (result.status === "aborted") {
|
|
31576
|
+
return;
|
|
31577
|
+
}
|
|
31578
|
+
const currentPluginState = pluginKey.getState(view.state);
|
|
31579
|
+
if (!(currentPluginState == null ? void 0 : currentPluginState.active)) {
|
|
31580
|
+
asyncRequest.abort();
|
|
31581
|
+
return;
|
|
31582
|
+
}
|
|
31583
|
+
props = result.status === "resolved" ? {
|
|
31584
|
+
...props,
|
|
31585
|
+
items: result.items,
|
|
31586
|
+
loading: false
|
|
31587
|
+
} : {
|
|
31588
|
+
...props,
|
|
31589
|
+
loading: false
|
|
31590
|
+
};
|
|
31591
|
+
}
|
|
31592
|
+
}
|
|
31593
|
+
if (currentState === "stopped") {
|
|
31594
|
+
asyncRequest.abort();
|
|
31595
|
+
dispatchStateUpdate(currentState, props);
|
|
31596
|
+
props = void 0;
|
|
31597
|
+
return;
|
|
31598
|
+
}
|
|
31599
|
+
if (currentState === "updated") {
|
|
31600
|
+
dispatchStateUpdate(currentState, props);
|
|
31601
|
+
}
|
|
31602
|
+
},
|
|
31603
|
+
destroy: () => {
|
|
31604
|
+
var _a;
|
|
31605
|
+
asyncRequest.abort();
|
|
31606
|
+
if (!props) {
|
|
31607
|
+
return;
|
|
31608
|
+
}
|
|
31609
|
+
(_a = renderer == null ? void 0 : renderer.onExit) == null ? void 0 : _a.call(renderer, props);
|
|
31610
|
+
}
|
|
31611
|
+
};
|
|
31612
|
+
}
|
|
31613
|
+
var SuggestionPluginKey = new PluginKey("suggestion");
|
|
31614
|
+
function Suggestion({
|
|
31615
|
+
pluginKey = SuggestionPluginKey,
|
|
31616
|
+
editor,
|
|
31617
|
+
char = "@",
|
|
31618
|
+
allowSpaces = false,
|
|
31619
|
+
allowToIncludeChar = false,
|
|
31620
|
+
allowedPrefixes = [" "],
|
|
31621
|
+
startOfLine = false,
|
|
31622
|
+
decorationTag = "span",
|
|
31623
|
+
decorationClass = "suggestion",
|
|
31624
|
+
decorationContent = "",
|
|
31625
|
+
decorationEmptyClass = "is-empty",
|
|
31626
|
+
command: command2 = () => null,
|
|
31627
|
+
items = () => [],
|
|
31628
|
+
minQueryLength = 0,
|
|
31629
|
+
debounce = 0,
|
|
31630
|
+
initialItems,
|
|
31631
|
+
placement = "bottom-start",
|
|
31632
|
+
offset: offsetOption = {},
|
|
31633
|
+
container,
|
|
31634
|
+
flip: flip3 = true,
|
|
31635
|
+
floatingUi,
|
|
31636
|
+
dismissOnOutsideClick = true,
|
|
31637
|
+
render = () => ({}),
|
|
31638
|
+
allow = () => true,
|
|
31639
|
+
findSuggestionMatch: findSuggestionMatch2 = findSuggestionMatch,
|
|
31640
|
+
shouldShow,
|
|
31641
|
+
shouldResetDismissed
|
|
31642
|
+
}) {
|
|
31643
|
+
const renderer = render == null ? void 0 : render();
|
|
31644
|
+
const effectiveAllowSpaces = allowSpaces && !allowToIncludeChar;
|
|
31645
|
+
const clientRectFor2 = (view, decorationNode) => clientRectFor(editor, view, decorationNode, pluginKey);
|
|
31646
|
+
function shouldKeepDismissed2(props) {
|
|
31647
|
+
return shouldKeepDismissed({
|
|
31648
|
+
...props,
|
|
31649
|
+
editor,
|
|
31650
|
+
shouldResetDismissed,
|
|
31651
|
+
effectiveAllowSpaces
|
|
31652
|
+
});
|
|
31653
|
+
}
|
|
31654
|
+
const dispatchExit2 = (view) => dispatchExit({
|
|
31655
|
+
view,
|
|
31656
|
+
pluginKeyRef: pluginKey
|
|
31657
|
+
});
|
|
31658
|
+
return new Plugin({
|
|
31659
|
+
key: pluginKey,
|
|
31660
|
+
view: () => createSuggestionView({
|
|
31661
|
+
editor,
|
|
31662
|
+
pluginKey,
|
|
31663
|
+
items,
|
|
31664
|
+
renderer,
|
|
31665
|
+
minQueryLength,
|
|
31666
|
+
debounce,
|
|
31667
|
+
initialItems,
|
|
31668
|
+
placement,
|
|
31669
|
+
offset: offsetOption,
|
|
31670
|
+
container,
|
|
31671
|
+
flip: flip3,
|
|
31672
|
+
floatingUi,
|
|
31673
|
+
dismissOnOutsideClick,
|
|
31674
|
+
command: command2,
|
|
31675
|
+
clientRectFor: clientRectFor2,
|
|
31676
|
+
dispatchExit: dispatchExit2
|
|
31677
|
+
}),
|
|
31678
|
+
state: createSuggestionState({
|
|
31679
|
+
editor,
|
|
31680
|
+
char,
|
|
31681
|
+
effectiveAllowSpaces,
|
|
31682
|
+
allowToIncludeChar,
|
|
31683
|
+
allowedPrefixes,
|
|
31684
|
+
startOfLine,
|
|
31685
|
+
findSuggestionMatch: findSuggestionMatch2,
|
|
31686
|
+
allow,
|
|
31687
|
+
shouldShow,
|
|
31688
|
+
shouldKeepDismissed: shouldKeepDismissed2,
|
|
31689
|
+
pluginKey
|
|
31690
|
+
}),
|
|
31691
|
+
props: createSuggestionProps({
|
|
31692
|
+
pluginKey,
|
|
31693
|
+
decorationTag,
|
|
31694
|
+
decorationClass,
|
|
31695
|
+
decorationContent,
|
|
31696
|
+
decorationEmptyClass,
|
|
31697
|
+
renderer,
|
|
31698
|
+
dispatchExit: dispatchExit2
|
|
31699
|
+
})
|
|
31700
|
+
});
|
|
31701
|
+
}
|
|
31702
|
+
function exitSuggestion(view, pluginKeyRef = SuggestionPluginKey) {
|
|
31703
|
+
const tr2 = view.state.tr.setMeta(pluginKeyRef, { exit: true });
|
|
31704
|
+
view.dispatch(tr2);
|
|
31705
|
+
}
|
|
31706
|
+
function combineDOMRects(rect1, rect2) {
|
|
31707
|
+
const top = Math.min(rect1.top, rect2.top);
|
|
31708
|
+
const bottom = Math.max(rect1.bottom, rect2.bottom);
|
|
31709
|
+
const left = Math.min(rect1.left, rect2.left);
|
|
31710
|
+
const right = Math.max(rect1.right, rect2.right);
|
|
31711
|
+
const width = right - left;
|
|
31712
|
+
const height = bottom - top;
|
|
31713
|
+
const x = left;
|
|
31714
|
+
const y = top;
|
|
31715
|
+
return new DOMRect(x, y, width, height);
|
|
31716
|
+
}
|
|
31717
|
+
var BubbleMenuView = class {
|
|
31718
|
+
constructor({
|
|
31719
|
+
editor,
|
|
31720
|
+
element,
|
|
31721
|
+
view,
|
|
31722
|
+
pluginKey = "bubbleMenu",
|
|
31723
|
+
updateDelay = 250,
|
|
31724
|
+
resizeDelay = 60,
|
|
31725
|
+
shouldShow,
|
|
31726
|
+
appendTo,
|
|
31727
|
+
getReferencedVirtualElement,
|
|
31728
|
+
options
|
|
31729
|
+
}) {
|
|
31730
|
+
this.preventHide = false;
|
|
31731
|
+
this.isVisible = false;
|
|
31732
|
+
this.scrollTarget = window;
|
|
31733
|
+
this.floatingUIOptions = {
|
|
31734
|
+
strategy: "absolute",
|
|
31735
|
+
placement: "top",
|
|
31736
|
+
offset: 8,
|
|
31737
|
+
flip: {},
|
|
31738
|
+
shift: {},
|
|
31739
|
+
arrow: false,
|
|
31740
|
+
size: false,
|
|
31741
|
+
autoPlacement: false,
|
|
31742
|
+
hide: false,
|
|
31743
|
+
inline: false,
|
|
31744
|
+
onShow: void 0,
|
|
31745
|
+
onHide: void 0,
|
|
31746
|
+
onUpdate: void 0,
|
|
31747
|
+
onDestroy: void 0
|
|
31748
|
+
};
|
|
31749
|
+
this.shouldShow = ({
|
|
31750
|
+
view: view2,
|
|
31751
|
+
state,
|
|
31752
|
+
from: from2,
|
|
31753
|
+
to
|
|
31754
|
+
}) => {
|
|
31755
|
+
const { doc: doc3, selection } = state;
|
|
31756
|
+
const { empty: empty2 } = selection;
|
|
31757
|
+
const isEmptyTextBlock = !doc3.textBetween(from2, to).length && isTextSelection(state.selection);
|
|
31758
|
+
const isChildOfMenu = this.element.contains(document.activeElement);
|
|
31759
|
+
const hasEditorFocus = view2.hasFocus() || isChildOfMenu;
|
|
31760
|
+
if (!hasEditorFocus || empty2 || isEmptyTextBlock || !this.editor.isEditable) {
|
|
31761
|
+
return false;
|
|
31762
|
+
}
|
|
31763
|
+
return true;
|
|
31764
|
+
};
|
|
31765
|
+
this.mousedownHandler = () => {
|
|
31766
|
+
this.preventHide = true;
|
|
31767
|
+
};
|
|
31768
|
+
this.dragstartHandler = () => {
|
|
31769
|
+
this.hide();
|
|
31770
|
+
};
|
|
31771
|
+
this.resizeHandler = () => {
|
|
31772
|
+
if (this.resizeDebounceTimer) {
|
|
31773
|
+
clearTimeout(this.resizeDebounceTimer);
|
|
31774
|
+
}
|
|
31775
|
+
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
31776
|
+
this.updatePosition();
|
|
31777
|
+
}, this.resizeDelay);
|
|
31778
|
+
};
|
|
31779
|
+
this.focusHandler = () => {
|
|
31780
|
+
setTimeout(() => this.update(this.editor.view));
|
|
31781
|
+
};
|
|
31782
|
+
this.blurHandler = ({ event }) => {
|
|
31783
|
+
var _a2;
|
|
31784
|
+
if (this.editor.isDestroyed) {
|
|
31785
|
+
this.destroy();
|
|
31786
|
+
return;
|
|
31787
|
+
}
|
|
31788
|
+
if (this.preventHide) {
|
|
31789
|
+
this.preventHide = false;
|
|
31790
|
+
return;
|
|
31791
|
+
}
|
|
31792
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a2 = this.element.parentNode) == null ? void 0 : _a2.contains(event.relatedTarget))) {
|
|
31793
|
+
return;
|
|
31794
|
+
}
|
|
31795
|
+
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
31796
|
+
return;
|
|
31797
|
+
}
|
|
31798
|
+
this.hide();
|
|
31799
|
+
};
|
|
31800
|
+
this.handleDebouncedUpdate = (view2, oldState) => {
|
|
31801
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view2.state.selection));
|
|
31802
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view2.state.doc));
|
|
31803
|
+
if (!selectionChanged && !docChanged) {
|
|
31804
|
+
return;
|
|
31805
|
+
}
|
|
31806
|
+
if (this.updateDebounceTimer) {
|
|
31807
|
+
clearTimeout(this.updateDebounceTimer);
|
|
31808
|
+
}
|
|
31809
|
+
this.updateDebounceTimer = window.setTimeout(() => {
|
|
31810
|
+
this.updateHandler(view2, selectionChanged, docChanged, oldState);
|
|
31811
|
+
}, this.updateDelay);
|
|
31812
|
+
};
|
|
31813
|
+
this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
31814
|
+
const { composing } = view2;
|
|
31815
|
+
const isSame = !selectionChanged && !docChanged;
|
|
31816
|
+
if (composing || isSame) {
|
|
31817
|
+
return;
|
|
31818
|
+
}
|
|
31819
|
+
const shouldShow2 = this.getShouldShow(oldState);
|
|
31820
|
+
if (!shouldShow2) {
|
|
31821
|
+
this.hide();
|
|
31822
|
+
return;
|
|
31823
|
+
}
|
|
31824
|
+
this.show();
|
|
31825
|
+
this.updatePosition();
|
|
31826
|
+
};
|
|
31827
|
+
this.transactionHandler = ({ transaction: tr2 }) => {
|
|
31828
|
+
const meta = tr2.getMeta(this.pluginKey);
|
|
31829
|
+
if (meta === "updatePosition") {
|
|
31830
|
+
this.updatePosition();
|
|
31831
|
+
} else if (meta && typeof meta === "object" && meta.type === "updateOptions") {
|
|
31832
|
+
this.updateOptions(meta.options);
|
|
31833
|
+
} else if (meta === "hide") {
|
|
31834
|
+
this.hide();
|
|
31835
|
+
} else if (meta === "show") {
|
|
31836
|
+
this.updatePosition();
|
|
31837
|
+
this.show();
|
|
31838
|
+
}
|
|
31839
|
+
};
|
|
31840
|
+
var _a;
|
|
31841
|
+
this.editor = editor;
|
|
31842
|
+
this.element = element;
|
|
31843
|
+
this.view = view;
|
|
31844
|
+
this.pluginKey = pluginKey;
|
|
31845
|
+
this.updateDelay = updateDelay;
|
|
31846
|
+
this.resizeDelay = resizeDelay;
|
|
31847
|
+
this.appendTo = appendTo;
|
|
31848
|
+
this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
|
|
31849
|
+
this.getReferencedVirtualElement = getReferencedVirtualElement;
|
|
31850
|
+
this.floatingUIOptions = {
|
|
31851
|
+
...this.floatingUIOptions,
|
|
31852
|
+
...options
|
|
31853
|
+
};
|
|
31854
|
+
this.element.tabIndex = 0;
|
|
31855
|
+
if (shouldShow) {
|
|
31856
|
+
this.shouldShow = shouldShow;
|
|
31857
|
+
}
|
|
31858
|
+
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
31859
|
+
this.view.dom.addEventListener("dragstart", this.dragstartHandler);
|
|
31860
|
+
this.editor.on("focus", this.focusHandler);
|
|
31861
|
+
this.editor.on("blur", this.blurHandler);
|
|
31862
|
+
this.editor.on("transaction", this.transactionHandler);
|
|
31863
|
+
window.addEventListener("resize", this.resizeHandler);
|
|
31864
|
+
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
|
|
31865
|
+
this.update(view, view.state);
|
|
31866
|
+
if (this.getShouldShow()) {
|
|
31867
|
+
this.show();
|
|
31868
|
+
this.updatePosition();
|
|
31869
|
+
}
|
|
31870
|
+
}
|
|
31871
|
+
get middlewares() {
|
|
31872
|
+
const middlewares = [];
|
|
31873
|
+
if (this.floatingUIOptions.flip) {
|
|
31874
|
+
middlewares.push(
|
|
31875
|
+
flip(
|
|
31876
|
+
typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0
|
|
31877
|
+
)
|
|
31878
|
+
);
|
|
31879
|
+
}
|
|
31880
|
+
if (this.floatingUIOptions.shift) {
|
|
31881
|
+
middlewares.push(
|
|
31882
|
+
shift$1(
|
|
31883
|
+
typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0
|
|
31884
|
+
)
|
|
31885
|
+
);
|
|
31886
|
+
}
|
|
31887
|
+
if (this.floatingUIOptions.offset) {
|
|
31888
|
+
middlewares.push(
|
|
31889
|
+
offset(
|
|
31890
|
+
typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0
|
|
31891
|
+
)
|
|
31892
|
+
);
|
|
31893
|
+
}
|
|
31894
|
+
if (this.floatingUIOptions.arrow) {
|
|
31895
|
+
middlewares.push(arrow$1(this.floatingUIOptions.arrow));
|
|
31896
|
+
}
|
|
31897
|
+
if (this.floatingUIOptions.size) {
|
|
31898
|
+
middlewares.push(
|
|
31899
|
+
size(
|
|
31900
|
+
typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0
|
|
31901
|
+
)
|
|
31902
|
+
);
|
|
31903
|
+
}
|
|
31904
|
+
if (this.floatingUIOptions.autoPlacement) {
|
|
31905
|
+
middlewares.push(
|
|
31906
|
+
autoPlacement(
|
|
31907
|
+
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
31908
|
+
)
|
|
31909
|
+
);
|
|
31910
|
+
}
|
|
31911
|
+
if (this.floatingUIOptions.hide) {
|
|
31912
|
+
middlewares.push(
|
|
31913
|
+
hide(
|
|
31914
|
+
typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0
|
|
31915
|
+
)
|
|
31916
|
+
);
|
|
31917
|
+
}
|
|
31918
|
+
if (this.floatingUIOptions.inline) {
|
|
31919
|
+
middlewares.push(
|
|
31920
|
+
inline(
|
|
31921
|
+
typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0
|
|
31922
|
+
)
|
|
31923
|
+
);
|
|
31924
|
+
}
|
|
31925
|
+
return middlewares;
|
|
31926
|
+
}
|
|
31927
|
+
get virtualElement() {
|
|
31928
|
+
var _a, _b, _c;
|
|
31929
|
+
const { selection } = this.editor.state;
|
|
31930
|
+
const referencedVirtualElement = (_a = this.getReferencedVirtualElement) == null ? void 0 : _a.call(this);
|
|
31931
|
+
if (referencedVirtualElement) {
|
|
31932
|
+
return referencedVirtualElement;
|
|
31933
|
+
}
|
|
31934
|
+
if (!((_c = (_b = this.view) == null ? void 0 : _b.dom) == null ? void 0 : _c.parentNode)) {
|
|
31935
|
+
return;
|
|
31936
|
+
}
|
|
31937
|
+
const domRect = posToDOMRect(this.view, selection.from, selection.to);
|
|
31938
|
+
let virtualElement = {
|
|
31939
|
+
getBoundingClientRect: () => domRect,
|
|
31940
|
+
getClientRects: () => [domRect]
|
|
31941
|
+
};
|
|
31942
|
+
if (selection instanceof NodeSelection) {
|
|
31943
|
+
let node = this.view.nodeDOM(selection.from);
|
|
31944
|
+
const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector("[data-node-view-wrapper]");
|
|
31945
|
+
if (nodeViewWrapper) {
|
|
31946
|
+
node = nodeViewWrapper;
|
|
31947
|
+
}
|
|
31948
|
+
if (node) {
|
|
31949
|
+
virtualElement = {
|
|
31950
|
+
getBoundingClientRect: () => node.getBoundingClientRect(),
|
|
31951
|
+
getClientRects: () => [node.getBoundingClientRect()]
|
|
31952
|
+
};
|
|
31953
|
+
}
|
|
31954
|
+
}
|
|
31955
|
+
if (selection instanceof CellSelection) {
|
|
31956
|
+
const { $anchorCell, $headCell } = selection;
|
|
31957
|
+
const from2 = $anchorCell ? $anchorCell.pos : $headCell.pos;
|
|
31958
|
+
const to = $headCell ? $headCell.pos : $anchorCell.pos;
|
|
31959
|
+
const fromDOM = this.view.nodeDOM(from2);
|
|
31960
|
+
const toDOM = this.view.nodeDOM(to);
|
|
31961
|
+
if (!fromDOM || !toDOM) {
|
|
31962
|
+
return;
|
|
31963
|
+
}
|
|
31964
|
+
const clientRect2 = fromDOM === toDOM ? fromDOM.getBoundingClientRect() : combineDOMRects(
|
|
31965
|
+
fromDOM.getBoundingClientRect(),
|
|
31966
|
+
toDOM.getBoundingClientRect()
|
|
31967
|
+
);
|
|
31968
|
+
virtualElement = {
|
|
31969
|
+
getBoundingClientRect: () => clientRect2,
|
|
31970
|
+
getClientRects: () => [clientRect2]
|
|
31971
|
+
};
|
|
31972
|
+
}
|
|
31973
|
+
return virtualElement;
|
|
31974
|
+
}
|
|
31975
|
+
updatePosition() {
|
|
31976
|
+
if (!this.isVisible) {
|
|
31977
|
+
return;
|
|
31978
|
+
}
|
|
31979
|
+
const virtualElement = this.virtualElement;
|
|
31980
|
+
if (!virtualElement) {
|
|
31981
|
+
return;
|
|
31982
|
+
}
|
|
31983
|
+
computePosition(virtualElement, this.element, {
|
|
31984
|
+
placement: this.floatingUIOptions.placement,
|
|
31985
|
+
strategy: this.floatingUIOptions.strategy,
|
|
31986
|
+
middleware: this.middlewares
|
|
31987
|
+
}).then(({ x, y, strategy, middlewareData }) => {
|
|
31988
|
+
var _a, _b;
|
|
31989
|
+
if (!this.isVisible || this.editor.isDestroyed || !this.element.isConnected) {
|
|
31990
|
+
return;
|
|
31991
|
+
}
|
|
31992
|
+
if (((_a = middlewareData.hide) == null ? void 0 : _a.referenceHidden) || ((_b = middlewareData.hide) == null ? void 0 : _b.escaped)) {
|
|
31993
|
+
this.element.style.visibility = "hidden";
|
|
31994
|
+
return;
|
|
31995
|
+
}
|
|
31996
|
+
this.element.style.visibility = "visible";
|
|
31997
|
+
this.element.style.width = "max-content";
|
|
31998
|
+
this.element.style.position = strategy;
|
|
31999
|
+
this.element.style.left = `${x}px`;
|
|
32000
|
+
this.element.style.top = `${y}px`;
|
|
32001
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
32002
|
+
this.floatingUIOptions.onUpdate();
|
|
32003
|
+
}
|
|
32004
|
+
});
|
|
32005
|
+
}
|
|
32006
|
+
update(view, oldState) {
|
|
32007
|
+
const { state } = view;
|
|
32008
|
+
const hasValidSelection = state.selection.from !== state.selection.to;
|
|
32009
|
+
if (this.updateDelay > 0 && hasValidSelection) {
|
|
32010
|
+
this.handleDebouncedUpdate(view, oldState);
|
|
32011
|
+
return;
|
|
32012
|
+
}
|
|
32013
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
32014
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
32015
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
32016
|
+
}
|
|
32017
|
+
getShouldShow(oldState) {
|
|
32018
|
+
var _a;
|
|
32019
|
+
const { state } = this.view;
|
|
32020
|
+
const { selection } = state;
|
|
32021
|
+
const { ranges } = selection;
|
|
32022
|
+
const from2 = Math.min(...ranges.map((range) => range.$from.pos));
|
|
32023
|
+
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
32024
|
+
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
|
|
32025
|
+
editor: this.editor,
|
|
32026
|
+
element: this.element,
|
|
32027
|
+
view: this.view,
|
|
32028
|
+
state,
|
|
32029
|
+
oldState,
|
|
32030
|
+
from: from2,
|
|
32031
|
+
to
|
|
32032
|
+
});
|
|
32033
|
+
return shouldShow || false;
|
|
32034
|
+
}
|
|
32035
|
+
show() {
|
|
32036
|
+
var _a;
|
|
32037
|
+
if (this.isVisible) {
|
|
32038
|
+
return;
|
|
32039
|
+
}
|
|
32040
|
+
this.element.style.visibility = "visible";
|
|
32041
|
+
this.element.style.opacity = "1";
|
|
32042
|
+
const appendToElement = typeof this.appendTo === "function" ? this.appendTo() : this.appendTo;
|
|
32043
|
+
(_a = appendToElement != null ? appendToElement : this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
32044
|
+
if (this.floatingUIOptions.onShow) {
|
|
32045
|
+
this.floatingUIOptions.onShow();
|
|
32046
|
+
}
|
|
32047
|
+
this.isVisible = true;
|
|
32048
|
+
}
|
|
32049
|
+
hide() {
|
|
32050
|
+
if (!this.isVisible) {
|
|
32051
|
+
return;
|
|
32052
|
+
}
|
|
32053
|
+
this.element.style.visibility = "hidden";
|
|
32054
|
+
this.element.style.opacity = "0";
|
|
32055
|
+
this.element.remove();
|
|
32056
|
+
if (this.floatingUIOptions.onHide) {
|
|
32057
|
+
this.floatingUIOptions.onHide();
|
|
32058
|
+
}
|
|
32059
|
+
this.isVisible = false;
|
|
32060
|
+
}
|
|
32061
|
+
updateOptions(newProps) {
|
|
32062
|
+
var _a;
|
|
32063
|
+
if (newProps.updateDelay !== void 0) {
|
|
32064
|
+
this.updateDelay = newProps.updateDelay;
|
|
32065
|
+
}
|
|
32066
|
+
if (newProps.resizeDelay !== void 0) {
|
|
32067
|
+
this.resizeDelay = newProps.resizeDelay;
|
|
32068
|
+
}
|
|
32069
|
+
if (newProps.appendTo !== void 0) {
|
|
32070
|
+
this.appendTo = newProps.appendTo;
|
|
32071
|
+
}
|
|
32072
|
+
if (newProps.getReferencedVirtualElement !== void 0) {
|
|
32073
|
+
this.getReferencedVirtualElement = newProps.getReferencedVirtualElement;
|
|
32074
|
+
}
|
|
32075
|
+
if (newProps.shouldShow !== void 0) {
|
|
32076
|
+
if (newProps.shouldShow) {
|
|
32077
|
+
this.shouldShow = newProps.shouldShow;
|
|
32078
|
+
}
|
|
32079
|
+
}
|
|
32080
|
+
if (newProps.options !== void 0) {
|
|
32081
|
+
const newScrollTarget = (_a = newProps.options.scrollTarget) != null ? _a : window;
|
|
32082
|
+
if (newScrollTarget !== this.scrollTarget) {
|
|
32083
|
+
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
|
|
32084
|
+
this.scrollTarget = newScrollTarget;
|
|
32085
|
+
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
|
|
32086
|
+
}
|
|
32087
|
+
this.floatingUIOptions = {
|
|
32088
|
+
...this.floatingUIOptions,
|
|
32089
|
+
...newProps.options
|
|
32090
|
+
};
|
|
32091
|
+
}
|
|
32092
|
+
}
|
|
32093
|
+
destroy() {
|
|
32094
|
+
this.hide();
|
|
32095
|
+
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
32096
|
+
this.view.dom.removeEventListener("dragstart", this.dragstartHandler);
|
|
32097
|
+
window.removeEventListener("resize", this.resizeHandler);
|
|
32098
|
+
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
|
|
32099
|
+
this.editor.off("focus", this.focusHandler);
|
|
32100
|
+
this.editor.off("blur", this.blurHandler);
|
|
32101
|
+
this.editor.off("transaction", this.transactionHandler);
|
|
32102
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
32103
|
+
this.floatingUIOptions.onDestroy();
|
|
32104
|
+
}
|
|
32105
|
+
}
|
|
32106
|
+
};
|
|
32107
|
+
var BubbleMenuPlugin = (options) => {
|
|
32108
|
+
return new Plugin({
|
|
32109
|
+
key: typeof options.pluginKey === "string" ? new PluginKey(options.pluginKey) : options.pluginKey,
|
|
32110
|
+
view: (view) => new BubbleMenuView({ view, ...options })
|
|
32111
|
+
});
|
|
32112
|
+
};
|
|
32113
|
+
Extension.create({
|
|
32114
|
+
name: "bubbleMenu",
|
|
32115
|
+
addOptions() {
|
|
32116
|
+
return {
|
|
32117
|
+
element: null,
|
|
32118
|
+
pluginKey: "bubbleMenu",
|
|
32119
|
+
updateDelay: void 0,
|
|
32120
|
+
appendTo: void 0,
|
|
32121
|
+
shouldShow: null
|
|
32122
|
+
};
|
|
32123
|
+
},
|
|
32124
|
+
addProseMirrorPlugins() {
|
|
32125
|
+
if (!this.options.element) {
|
|
32126
|
+
return [];
|
|
32127
|
+
}
|
|
32128
|
+
return [
|
|
32129
|
+
BubbleMenuPlugin({
|
|
32130
|
+
pluginKey: this.options.pluginKey,
|
|
32131
|
+
editor: this.editor,
|
|
32132
|
+
element: this.options.element,
|
|
32133
|
+
updateDelay: this.options.updateDelay,
|
|
32134
|
+
options: this.options.options,
|
|
32135
|
+
appendTo: this.options.appendTo,
|
|
32136
|
+
getReferencedVirtualElement: this.options.getReferencedVirtualElement,
|
|
32137
|
+
shouldShow: this.options.shouldShow
|
|
32138
|
+
})
|
|
32139
|
+
];
|
|
32140
|
+
}
|
|
32141
|
+
});
|
|
32142
|
+
var FloatingMenuView = class {
|
|
32143
|
+
constructor({
|
|
32144
|
+
editor,
|
|
32145
|
+
element,
|
|
32146
|
+
view,
|
|
32147
|
+
pluginKey = "floatingMenu",
|
|
32148
|
+
updateDelay = 250,
|
|
32149
|
+
resizeDelay = 60,
|
|
32150
|
+
options,
|
|
32151
|
+
appendTo,
|
|
32152
|
+
shouldShow
|
|
32153
|
+
}) {
|
|
32154
|
+
this.preventHide = false;
|
|
32155
|
+
this.isVisible = false;
|
|
32156
|
+
this.scrollTarget = window;
|
|
32157
|
+
this.shouldShow = ({ view: view2, state }) => {
|
|
32158
|
+
const { selection } = state;
|
|
32159
|
+
const { $anchor, empty: empty2 } = selection;
|
|
32160
|
+
const isRootDepth = $anchor.depth === 1;
|
|
32161
|
+
const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
|
|
32162
|
+
if (!view2.hasFocus() || !empty2 || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
|
|
32163
|
+
return false;
|
|
32164
|
+
}
|
|
32165
|
+
return true;
|
|
32166
|
+
};
|
|
32167
|
+
this.floatingUIOptions = {
|
|
32168
|
+
strategy: "absolute",
|
|
32169
|
+
placement: "right",
|
|
32170
|
+
offset: 8,
|
|
32171
|
+
flip: {},
|
|
32172
|
+
shift: {},
|
|
32173
|
+
arrow: false,
|
|
32174
|
+
size: false,
|
|
32175
|
+
autoPlacement: false,
|
|
32176
|
+
hide: false,
|
|
32177
|
+
inline: false
|
|
32178
|
+
};
|
|
32179
|
+
this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
|
|
32180
|
+
const { composing } = view2;
|
|
32181
|
+
const isSame = !selectionChanged && !docChanged;
|
|
32182
|
+
if (composing || isSame) {
|
|
32183
|
+
return;
|
|
32184
|
+
}
|
|
32185
|
+
const shouldShow2 = this.getShouldShow(oldState);
|
|
32186
|
+
if (!shouldShow2) {
|
|
32187
|
+
this.hide();
|
|
32188
|
+
return;
|
|
32189
|
+
}
|
|
32190
|
+
this.updatePosition();
|
|
32191
|
+
this.show();
|
|
32192
|
+
};
|
|
32193
|
+
this.mousedownHandler = () => {
|
|
32194
|
+
this.preventHide = true;
|
|
32195
|
+
};
|
|
32196
|
+
this.focusHandler = () => {
|
|
32197
|
+
setTimeout(() => this.update(this.editor.view));
|
|
32198
|
+
};
|
|
32199
|
+
this.blurHandler = ({ event }) => {
|
|
32200
|
+
var _a2;
|
|
32201
|
+
if (this.preventHide) {
|
|
32202
|
+
this.preventHide = false;
|
|
32203
|
+
return;
|
|
32204
|
+
}
|
|
32205
|
+
if ((event == null ? void 0 : event.relatedTarget) && ((_a2 = this.element.parentNode) == null ? void 0 : _a2.contains(event.relatedTarget))) {
|
|
32206
|
+
return;
|
|
32207
|
+
}
|
|
32208
|
+
if ((event == null ? void 0 : event.relatedTarget) === this.editor.view.dom) {
|
|
32209
|
+
return;
|
|
32210
|
+
}
|
|
32211
|
+
this.hide();
|
|
32212
|
+
};
|
|
32213
|
+
this.transactionHandler = ({ transaction: tr2 }) => {
|
|
32214
|
+
const meta = tr2.getMeta(this.pluginKey);
|
|
32215
|
+
if (meta === "updatePosition") {
|
|
32216
|
+
this.updatePosition();
|
|
32217
|
+
} else if (meta && typeof meta === "object" && meta.type === "updateOptions") {
|
|
32218
|
+
this.updateOptions(meta.options);
|
|
32219
|
+
} else if (meta === "hide") {
|
|
32220
|
+
this.hide();
|
|
32221
|
+
} else if (meta === "show") {
|
|
32222
|
+
this.updatePosition();
|
|
32223
|
+
this.show();
|
|
32224
|
+
}
|
|
32225
|
+
};
|
|
32226
|
+
this.resizeHandler = () => {
|
|
32227
|
+
if (this.resizeDebounceTimer) {
|
|
32228
|
+
clearTimeout(this.resizeDebounceTimer);
|
|
32229
|
+
}
|
|
32230
|
+
this.resizeDebounceTimer = window.setTimeout(() => {
|
|
32231
|
+
this.updatePosition();
|
|
32232
|
+
}, this.resizeDelay);
|
|
32233
|
+
};
|
|
32234
|
+
var _a;
|
|
32235
|
+
this.editor = editor;
|
|
32236
|
+
this.element = element;
|
|
32237
|
+
this.view = view;
|
|
32238
|
+
this.pluginKey = pluginKey;
|
|
32239
|
+
this.updateDelay = updateDelay;
|
|
32240
|
+
this.resizeDelay = resizeDelay;
|
|
32241
|
+
this.appendTo = appendTo;
|
|
32242
|
+
this.scrollTarget = (_a = options == null ? void 0 : options.scrollTarget) != null ? _a : window;
|
|
32243
|
+
this.floatingUIOptions = {
|
|
32244
|
+
...this.floatingUIOptions,
|
|
32245
|
+
...options
|
|
32246
|
+
};
|
|
32247
|
+
this.element.tabIndex = 0;
|
|
32248
|
+
if (shouldShow) {
|
|
32249
|
+
this.shouldShow = shouldShow;
|
|
32250
|
+
}
|
|
32251
|
+
this.element.addEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
32252
|
+
this.editor.on("focus", this.focusHandler);
|
|
32253
|
+
this.editor.on("blur", this.blurHandler);
|
|
32254
|
+
this.editor.on("transaction", this.transactionHandler);
|
|
32255
|
+
window.addEventListener("resize", this.resizeHandler);
|
|
32256
|
+
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
|
|
32257
|
+
this.update(view, view.state);
|
|
32258
|
+
if (this.getShouldShow()) {
|
|
32259
|
+
this.show();
|
|
32260
|
+
this.updatePosition();
|
|
32261
|
+
}
|
|
32262
|
+
}
|
|
32263
|
+
getTextContent(node) {
|
|
32264
|
+
return getText2(node, { textSerializers: getTextSerializersFromSchema(this.editor.schema) });
|
|
32265
|
+
}
|
|
32266
|
+
get middlewares() {
|
|
32267
|
+
const middlewares = [];
|
|
32268
|
+
if (this.floatingUIOptions.flip) {
|
|
32269
|
+
middlewares.push(
|
|
32270
|
+
flip(
|
|
32271
|
+
typeof this.floatingUIOptions.flip !== "boolean" ? this.floatingUIOptions.flip : void 0
|
|
32272
|
+
)
|
|
32273
|
+
);
|
|
32274
|
+
}
|
|
32275
|
+
if (this.floatingUIOptions.shift) {
|
|
32276
|
+
middlewares.push(
|
|
32277
|
+
shift$1(
|
|
32278
|
+
typeof this.floatingUIOptions.shift !== "boolean" ? this.floatingUIOptions.shift : void 0
|
|
32279
|
+
)
|
|
32280
|
+
);
|
|
32281
|
+
}
|
|
32282
|
+
if (this.floatingUIOptions.offset) {
|
|
32283
|
+
middlewares.push(
|
|
32284
|
+
offset(
|
|
32285
|
+
typeof this.floatingUIOptions.offset !== "boolean" ? this.floatingUIOptions.offset : void 0
|
|
32286
|
+
)
|
|
32287
|
+
);
|
|
32288
|
+
}
|
|
32289
|
+
if (this.floatingUIOptions.arrow) {
|
|
32290
|
+
middlewares.push(arrow$1(this.floatingUIOptions.arrow));
|
|
32291
|
+
}
|
|
32292
|
+
if (this.floatingUIOptions.size) {
|
|
32293
|
+
middlewares.push(
|
|
32294
|
+
size(
|
|
32295
|
+
typeof this.floatingUIOptions.size !== "boolean" ? this.floatingUIOptions.size : void 0
|
|
32296
|
+
)
|
|
32297
|
+
);
|
|
32298
|
+
}
|
|
32299
|
+
if (this.floatingUIOptions.autoPlacement) {
|
|
32300
|
+
middlewares.push(
|
|
32301
|
+
autoPlacement(
|
|
32302
|
+
typeof this.floatingUIOptions.autoPlacement !== "boolean" ? this.floatingUIOptions.autoPlacement : void 0
|
|
32303
|
+
)
|
|
32304
|
+
);
|
|
32305
|
+
}
|
|
32306
|
+
if (this.floatingUIOptions.hide) {
|
|
32307
|
+
middlewares.push(
|
|
32308
|
+
hide(
|
|
32309
|
+
typeof this.floatingUIOptions.hide !== "boolean" ? this.floatingUIOptions.hide : void 0
|
|
32310
|
+
)
|
|
32311
|
+
);
|
|
32312
|
+
}
|
|
32313
|
+
if (this.floatingUIOptions.inline) {
|
|
32314
|
+
middlewares.push(
|
|
32315
|
+
inline(
|
|
32316
|
+
typeof this.floatingUIOptions.inline !== "boolean" ? this.floatingUIOptions.inline : void 0
|
|
32317
|
+
)
|
|
32318
|
+
);
|
|
32319
|
+
}
|
|
32320
|
+
return middlewares;
|
|
32321
|
+
}
|
|
32322
|
+
getShouldShow(oldState) {
|
|
32323
|
+
var _a;
|
|
32324
|
+
const { state } = this.view;
|
|
32325
|
+
const { selection } = state;
|
|
32326
|
+
const { ranges } = selection;
|
|
32327
|
+
const from2 = Math.min(...ranges.map((range) => range.$from.pos));
|
|
32328
|
+
const to = Math.max(...ranges.map((range) => range.$to.pos));
|
|
32329
|
+
const shouldShow = (_a = this.shouldShow) == null ? void 0 : _a.call(this, {
|
|
32330
|
+
editor: this.editor,
|
|
32331
|
+
view: this.view,
|
|
32332
|
+
state,
|
|
32333
|
+
oldState,
|
|
32334
|
+
from: from2,
|
|
32335
|
+
to
|
|
32336
|
+
});
|
|
32337
|
+
return shouldShow;
|
|
32338
|
+
}
|
|
32339
|
+
updateOptions(newProps) {
|
|
32340
|
+
var _a;
|
|
32341
|
+
if (newProps.updateDelay !== void 0) {
|
|
32342
|
+
this.updateDelay = newProps.updateDelay;
|
|
32343
|
+
}
|
|
32344
|
+
if (newProps.resizeDelay !== void 0) {
|
|
32345
|
+
this.resizeDelay = newProps.resizeDelay;
|
|
32346
|
+
}
|
|
32347
|
+
if (newProps.appendTo !== void 0) {
|
|
32348
|
+
this.appendTo = newProps.appendTo;
|
|
32349
|
+
}
|
|
32350
|
+
if (newProps.shouldShow !== void 0) {
|
|
32351
|
+
if (newProps.shouldShow) {
|
|
32352
|
+
this.shouldShow = newProps.shouldShow;
|
|
32353
|
+
}
|
|
32354
|
+
}
|
|
32355
|
+
if (newProps.options !== void 0) {
|
|
32356
|
+
const newScrollTarget = (_a = newProps.options.scrollTarget) != null ? _a : window;
|
|
32357
|
+
if (newScrollTarget !== this.scrollTarget) {
|
|
32358
|
+
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
|
|
32359
|
+
this.scrollTarget = newScrollTarget;
|
|
32360
|
+
this.scrollTarget.addEventListener("scroll", this.resizeHandler);
|
|
32361
|
+
}
|
|
32362
|
+
this.floatingUIOptions = {
|
|
32363
|
+
...this.floatingUIOptions,
|
|
32364
|
+
...newProps.options
|
|
32365
|
+
};
|
|
32366
|
+
}
|
|
32367
|
+
}
|
|
32368
|
+
updatePosition() {
|
|
32369
|
+
var _a, _b;
|
|
32370
|
+
if (!((_b = (_a = this.view) == null ? void 0 : _a.dom) == null ? void 0 : _b.parentNode)) {
|
|
32371
|
+
return;
|
|
32372
|
+
}
|
|
32373
|
+
const { selection } = this.editor.state;
|
|
32374
|
+
const domRect = posToDOMRect(this.view, selection.from, selection.to);
|
|
32375
|
+
const virtualElement = {
|
|
32376
|
+
getBoundingClientRect: () => domRect,
|
|
32377
|
+
getClientRects: () => [domRect]
|
|
32378
|
+
};
|
|
32379
|
+
computePosition(virtualElement, this.element, {
|
|
32380
|
+
placement: this.floatingUIOptions.placement,
|
|
32381
|
+
strategy: this.floatingUIOptions.strategy,
|
|
32382
|
+
middleware: this.middlewares
|
|
32383
|
+
}).then(({ x, y, strategy, middlewareData }) => {
|
|
32384
|
+
var _a2, _b2;
|
|
32385
|
+
if (((_a2 = middlewareData.hide) == null ? void 0 : _a2.referenceHidden) || ((_b2 = middlewareData.hide) == null ? void 0 : _b2.escaped)) {
|
|
32386
|
+
this.element.style.visibility = "hidden";
|
|
32387
|
+
return;
|
|
32388
|
+
}
|
|
32389
|
+
this.element.style.visibility = "visible";
|
|
32390
|
+
this.element.style.width = "max-content";
|
|
32391
|
+
this.element.style.position = strategy;
|
|
32392
|
+
this.element.style.left = `${x}px`;
|
|
32393
|
+
this.element.style.top = `${y}px`;
|
|
32394
|
+
if (this.isVisible && this.floatingUIOptions.onUpdate) {
|
|
32395
|
+
this.floatingUIOptions.onUpdate();
|
|
32396
|
+
}
|
|
32397
|
+
});
|
|
32398
|
+
}
|
|
32399
|
+
update(view, oldState) {
|
|
32400
|
+
const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
|
|
32401
|
+
const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
|
|
32402
|
+
this.updateHandler(view, selectionChanged, docChanged, oldState);
|
|
32403
|
+
}
|
|
32404
|
+
show() {
|
|
32405
|
+
var _a;
|
|
32406
|
+
if (this.isVisible) {
|
|
32407
|
+
return;
|
|
32408
|
+
}
|
|
32409
|
+
this.element.style.visibility = "visible";
|
|
32410
|
+
this.element.style.opacity = "1";
|
|
32411
|
+
const appendToElement = typeof this.appendTo === "function" ? this.appendTo() : this.appendTo;
|
|
32412
|
+
(_a = appendToElement != null ? appendToElement : this.view.dom.parentElement) == null ? void 0 : _a.appendChild(this.element);
|
|
32413
|
+
if (this.floatingUIOptions.onShow) {
|
|
32414
|
+
this.floatingUIOptions.onShow();
|
|
32415
|
+
}
|
|
32416
|
+
this.isVisible = true;
|
|
32417
|
+
}
|
|
32418
|
+
hide() {
|
|
32419
|
+
if (!this.isVisible) {
|
|
32420
|
+
return;
|
|
32421
|
+
}
|
|
32422
|
+
this.element.style.visibility = "hidden";
|
|
32423
|
+
this.element.style.opacity = "0";
|
|
32424
|
+
this.element.remove();
|
|
32425
|
+
if (this.floatingUIOptions.onHide) {
|
|
32426
|
+
this.floatingUIOptions.onHide();
|
|
32427
|
+
}
|
|
32428
|
+
this.isVisible = false;
|
|
32429
|
+
}
|
|
32430
|
+
destroy() {
|
|
32431
|
+
this.hide();
|
|
32432
|
+
this.element.removeEventListener("mousedown", this.mousedownHandler, { capture: true });
|
|
32433
|
+
window.removeEventListener("resize", this.resizeHandler);
|
|
32434
|
+
this.scrollTarget.removeEventListener("scroll", this.resizeHandler);
|
|
32435
|
+
this.editor.off("focus", this.focusHandler);
|
|
32436
|
+
this.editor.off("blur", this.blurHandler);
|
|
32437
|
+
this.editor.off("transaction", this.transactionHandler);
|
|
32438
|
+
if (this.floatingUIOptions.onDestroy) {
|
|
32439
|
+
this.floatingUIOptions.onDestroy();
|
|
32440
|
+
}
|
|
32441
|
+
}
|
|
32442
|
+
};
|
|
32443
|
+
var FloatingMenuPlugin = (options) => {
|
|
32444
|
+
return new Plugin({
|
|
32445
|
+
key: typeof options.pluginKey === "string" ? new PluginKey(options.pluginKey) : options.pluginKey,
|
|
32446
|
+
view: (view) => new FloatingMenuView({ view, ...options })
|
|
32447
|
+
});
|
|
32448
|
+
};
|
|
32449
|
+
Extension.create({
|
|
32450
|
+
name: "floatingMenu",
|
|
32451
|
+
addOptions() {
|
|
32452
|
+
return {
|
|
32453
|
+
element: null,
|
|
32454
|
+
options: {},
|
|
32455
|
+
pluginKey: "floatingMenu",
|
|
32456
|
+
updateDelay: void 0,
|
|
32457
|
+
resizeDelay: void 0,
|
|
32458
|
+
appendTo: void 0,
|
|
32459
|
+
shouldShow: null
|
|
32460
|
+
};
|
|
32461
|
+
},
|
|
32462
|
+
addCommands() {
|
|
32463
|
+
return {
|
|
32464
|
+
updateFloatingMenuPosition: () => ({ tr: tr2, dispatch }) => {
|
|
32465
|
+
if (dispatch) {
|
|
32466
|
+
tr2.setMeta(this.options.pluginKey, "updatePosition");
|
|
32467
|
+
}
|
|
32468
|
+
return true;
|
|
32469
|
+
}
|
|
32470
|
+
};
|
|
32471
|
+
},
|
|
32472
|
+
addProseMirrorPlugins() {
|
|
32473
|
+
if (!this.options.element) {
|
|
32474
|
+
return [];
|
|
32475
|
+
}
|
|
32476
|
+
return [
|
|
32477
|
+
FloatingMenuPlugin({
|
|
32478
|
+
pluginKey: this.options.pluginKey,
|
|
32479
|
+
editor: this.editor,
|
|
32480
|
+
element: this.options.element,
|
|
32481
|
+
updateDelay: this.options.updateDelay,
|
|
32482
|
+
resizeDelay: this.options.resizeDelay,
|
|
32483
|
+
options: this.options.options,
|
|
32484
|
+
appendTo: this.options.appendTo,
|
|
32485
|
+
shouldShow: this.options.shouldShow
|
|
32486
|
+
})
|
|
32487
|
+
];
|
|
32488
|
+
}
|
|
32489
|
+
});
|
|
32490
|
+
function getAutoPluginKey(pluginKey, defaultName) {
|
|
32491
|
+
return pluginKey != null ? pluginKey : new PluginKey(defaultName);
|
|
32492
|
+
}
|
|
32493
|
+
var useIsomorphicLayoutEffect2 = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
32494
|
+
var PLUGIN_MANAGED_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
32495
|
+
"left",
|
|
32496
|
+
"opacity",
|
|
32497
|
+
"position",
|
|
32498
|
+
"top",
|
|
32499
|
+
"visibility",
|
|
32500
|
+
"width"
|
|
32501
|
+
]);
|
|
32502
|
+
var UNITLESS_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
|
|
32503
|
+
"animationIterationCount",
|
|
32504
|
+
"aspectRatio",
|
|
32505
|
+
"borderImageOutset",
|
|
32506
|
+
"borderImageSlice",
|
|
32507
|
+
"borderImageWidth",
|
|
32508
|
+
"columnCount",
|
|
32509
|
+
"columns",
|
|
32510
|
+
"fillOpacity",
|
|
32511
|
+
"flex",
|
|
32512
|
+
"flexGrow",
|
|
32513
|
+
"flexShrink",
|
|
32514
|
+
"fontWeight",
|
|
32515
|
+
"gridArea",
|
|
32516
|
+
"gridColumn",
|
|
32517
|
+
"gridColumnEnd",
|
|
32518
|
+
"gridColumnStart",
|
|
32519
|
+
"gridRow",
|
|
32520
|
+
"gridRowEnd",
|
|
32521
|
+
"gridRowStart",
|
|
32522
|
+
"lineClamp",
|
|
32523
|
+
"lineHeight",
|
|
32524
|
+
"opacity",
|
|
32525
|
+
"order",
|
|
32526
|
+
"orphans",
|
|
32527
|
+
"scale",
|
|
32528
|
+
"stopOpacity",
|
|
32529
|
+
"strokeDasharray",
|
|
32530
|
+
"strokeDashoffset",
|
|
32531
|
+
"strokeMiterlimit",
|
|
32532
|
+
"strokeOpacity",
|
|
32533
|
+
"strokeWidth",
|
|
32534
|
+
"tabSize",
|
|
32535
|
+
"widows",
|
|
32536
|
+
"zIndex",
|
|
32537
|
+
"zoom"
|
|
32538
|
+
]);
|
|
32539
|
+
var ATTRIBUTE_EXCLUSIONS = /* @__PURE__ */ new Set(["children", "className", "style"]);
|
|
32540
|
+
var DIRECT_PROPERTY_KEYS = /* @__PURE__ */ new Set(["tabIndex"]);
|
|
32541
|
+
var FORWARDED_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
|
|
32542
|
+
"accessKey",
|
|
32543
|
+
"autoCapitalize",
|
|
32544
|
+
"contentEditable",
|
|
32545
|
+
"contextMenu",
|
|
32546
|
+
"dir",
|
|
32547
|
+
"draggable",
|
|
32548
|
+
"enterKeyHint",
|
|
32549
|
+
"hidden",
|
|
32550
|
+
"id",
|
|
32551
|
+
"lang",
|
|
32552
|
+
"nonce",
|
|
32553
|
+
"role",
|
|
32554
|
+
"slot",
|
|
32555
|
+
"spellCheck",
|
|
32556
|
+
"tabIndex",
|
|
32557
|
+
"title",
|
|
32558
|
+
"translate"
|
|
32559
|
+
]);
|
|
32560
|
+
var SPECIAL_EVENT_NAMES = {
|
|
32561
|
+
Blur: "focusout",
|
|
32562
|
+
DoubleClick: "dblclick",
|
|
32563
|
+
Focus: "focusin",
|
|
32564
|
+
MouseEnter: "mouseenter",
|
|
32565
|
+
MouseLeave: "mouseleave"
|
|
32566
|
+
};
|
|
32567
|
+
function isEventProp(key, value) {
|
|
32568
|
+
return /^on[A-Z]/.test(key) && typeof value === "function";
|
|
32569
|
+
}
|
|
32570
|
+
function toAttributeName(key) {
|
|
32571
|
+
if (key.startsWith("aria-") || key.startsWith("data-")) {
|
|
32572
|
+
return key;
|
|
32573
|
+
}
|
|
32574
|
+
return key;
|
|
32575
|
+
}
|
|
32576
|
+
function isForwardedAttributeKey(key) {
|
|
32577
|
+
return key.startsWith("aria-") || key.startsWith("data-") || FORWARDED_ATTRIBUTE_KEYS.has(key);
|
|
32578
|
+
}
|
|
32579
|
+
function toStylePropertyName(key) {
|
|
32580
|
+
if (key.startsWith("--")) {
|
|
32581
|
+
return key;
|
|
32582
|
+
}
|
|
32583
|
+
return key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
32584
|
+
}
|
|
32585
|
+
function toEventConfig(key) {
|
|
32586
|
+
var _a;
|
|
32587
|
+
const useCapture = key.endsWith("Capture");
|
|
32588
|
+
const baseKey = useCapture ? key.slice(0, -7) : key;
|
|
32589
|
+
const reactEventName = baseKey.slice(2);
|
|
32590
|
+
const eventName = (_a = SPECIAL_EVENT_NAMES[reactEventName]) != null ? _a : reactEventName.toLowerCase();
|
|
32591
|
+
return {
|
|
32592
|
+
eventName,
|
|
32593
|
+
options: useCapture ? { capture: true } : void 0
|
|
32594
|
+
};
|
|
32595
|
+
}
|
|
32596
|
+
function createSyntheticEvent(element, nativeEvent) {
|
|
32597
|
+
let defaultPrevented = nativeEvent.defaultPrevented;
|
|
32598
|
+
let propagationStopped = false;
|
|
32599
|
+
const syntheticEvent = Object.create(nativeEvent);
|
|
32600
|
+
Object.defineProperties(syntheticEvent, {
|
|
32601
|
+
nativeEvent: { value: nativeEvent },
|
|
32602
|
+
currentTarget: { value: element },
|
|
32603
|
+
target: { value: nativeEvent.target },
|
|
32604
|
+
persist: { value: () => void 0 },
|
|
32605
|
+
isDefaultPrevented: { value: () => defaultPrevented },
|
|
32606
|
+
isPropagationStopped: { value: () => propagationStopped },
|
|
32607
|
+
preventDefault: {
|
|
32608
|
+
value: () => {
|
|
32609
|
+
defaultPrevented = true;
|
|
32610
|
+
nativeEvent.preventDefault();
|
|
32611
|
+
}
|
|
32612
|
+
},
|
|
32613
|
+
stopPropagation: {
|
|
32614
|
+
value: () => {
|
|
32615
|
+
propagationStopped = true;
|
|
32616
|
+
nativeEvent.stopPropagation();
|
|
32617
|
+
}
|
|
32618
|
+
}
|
|
32619
|
+
});
|
|
32620
|
+
return syntheticEvent;
|
|
32621
|
+
}
|
|
32622
|
+
function isDirectPropertyKey(key) {
|
|
32623
|
+
return DIRECT_PROPERTY_KEYS.has(key);
|
|
32624
|
+
}
|
|
32625
|
+
function setDirectProperty(element, key, value) {
|
|
32626
|
+
if (key === "tabIndex") {
|
|
32627
|
+
element.tabIndex = Number(value);
|
|
32628
|
+
return;
|
|
32629
|
+
}
|
|
32630
|
+
element[key] = value;
|
|
32631
|
+
}
|
|
32632
|
+
function clearDirectProperty(element, key) {
|
|
32633
|
+
if (key === "tabIndex") {
|
|
32634
|
+
element.removeAttribute("tabindex");
|
|
32635
|
+
return;
|
|
32636
|
+
}
|
|
32637
|
+
const propertyValue = element[key];
|
|
32638
|
+
if (typeof propertyValue === "boolean") {
|
|
32639
|
+
element[key] = false;
|
|
32640
|
+
return;
|
|
32641
|
+
}
|
|
32642
|
+
if (typeof propertyValue === "number") {
|
|
32643
|
+
element[key] = 0;
|
|
32644
|
+
return;
|
|
32645
|
+
}
|
|
32646
|
+
element[key] = "";
|
|
32647
|
+
}
|
|
32648
|
+
function toStyleValue(styleName, value) {
|
|
32649
|
+
if (typeof value !== "number" || value === 0 || styleName.startsWith("--") || UNITLESS_STYLE_PROPERTIES.has(styleName)) {
|
|
32650
|
+
return String(value);
|
|
32651
|
+
}
|
|
32652
|
+
return `${value}px`;
|
|
32653
|
+
}
|
|
32654
|
+
function removeStyleProperty(element, styleName) {
|
|
32655
|
+
if (PLUGIN_MANAGED_STYLE_PROPERTIES.has(styleName)) {
|
|
32656
|
+
return;
|
|
32657
|
+
}
|
|
32658
|
+
element.style.removeProperty(toStylePropertyName(styleName));
|
|
32659
|
+
}
|
|
32660
|
+
function applyStyleProperty(element, styleName, value) {
|
|
32661
|
+
if (PLUGIN_MANAGED_STYLE_PROPERTIES.has(styleName)) {
|
|
32662
|
+
return;
|
|
32663
|
+
}
|
|
32664
|
+
element.style.setProperty(toStylePropertyName(styleName), toStyleValue(styleName, value));
|
|
32665
|
+
}
|
|
32666
|
+
function syncAttributes(element, prevProps, nextProps) {
|
|
32667
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(prevProps), ...Object.keys(nextProps)]);
|
|
32668
|
+
allKeys.forEach((key) => {
|
|
32669
|
+
if (ATTRIBUTE_EXCLUSIONS.has(key) || !isForwardedAttributeKey(key) || isEventProp(key, prevProps[key]) || isEventProp(key, nextProps[key])) {
|
|
32670
|
+
return;
|
|
32671
|
+
}
|
|
32672
|
+
const prevValue = prevProps[key];
|
|
32673
|
+
const nextValue = nextProps[key];
|
|
32674
|
+
if (prevValue === nextValue) {
|
|
32675
|
+
return;
|
|
32676
|
+
}
|
|
32677
|
+
const attributeName = toAttributeName(key);
|
|
32678
|
+
if (nextValue == null || nextValue === false) {
|
|
32679
|
+
if (isDirectPropertyKey(key)) {
|
|
32680
|
+
clearDirectProperty(element, key);
|
|
32681
|
+
}
|
|
32682
|
+
element.removeAttribute(attributeName);
|
|
32683
|
+
return;
|
|
32684
|
+
}
|
|
32685
|
+
if (nextValue === true) {
|
|
32686
|
+
if (isDirectPropertyKey(key)) {
|
|
32687
|
+
setDirectProperty(element, key, true);
|
|
32688
|
+
}
|
|
32689
|
+
element.setAttribute(attributeName, "");
|
|
32690
|
+
return;
|
|
32691
|
+
}
|
|
32692
|
+
if (isDirectPropertyKey(key)) {
|
|
32693
|
+
setDirectProperty(element, key, nextValue);
|
|
32694
|
+
return;
|
|
32695
|
+
}
|
|
32696
|
+
element.setAttribute(attributeName, String(nextValue));
|
|
32697
|
+
});
|
|
32698
|
+
}
|
|
32699
|
+
function syncClassName(element, prevClassName, nextClassName) {
|
|
32700
|
+
if (prevClassName === nextClassName) {
|
|
32701
|
+
return;
|
|
32702
|
+
}
|
|
32703
|
+
if (nextClassName) {
|
|
32704
|
+
element.className = nextClassName;
|
|
32705
|
+
return;
|
|
32706
|
+
}
|
|
32707
|
+
element.removeAttribute("class");
|
|
32708
|
+
}
|
|
32709
|
+
function syncStyles(element, prevStyle, nextStyle) {
|
|
32710
|
+
const previousStyle = prevStyle != null ? prevStyle : {};
|
|
32711
|
+
const currentStyle = nextStyle != null ? nextStyle : {};
|
|
32712
|
+
const allStyleNames = /* @__PURE__ */ new Set([...Object.keys(previousStyle), ...Object.keys(currentStyle)]);
|
|
32713
|
+
allStyleNames.forEach((styleName) => {
|
|
32714
|
+
const prevValue = previousStyle[styleName];
|
|
32715
|
+
const nextValue = currentStyle[styleName];
|
|
32716
|
+
if (prevValue === nextValue) {
|
|
32717
|
+
return;
|
|
32718
|
+
}
|
|
32719
|
+
if (nextValue == null) {
|
|
32720
|
+
removeStyleProperty(element, styleName);
|
|
32721
|
+
return;
|
|
32722
|
+
}
|
|
32723
|
+
applyStyleProperty(element, styleName, nextValue);
|
|
32724
|
+
});
|
|
32725
|
+
}
|
|
32726
|
+
function syncEventListeners(element, prevListeners, nextProps) {
|
|
32727
|
+
prevListeners.forEach(({ eventName, listener, options }) => {
|
|
32728
|
+
element.removeEventListener(eventName, listener, options);
|
|
32729
|
+
});
|
|
32730
|
+
const nextListeners = [];
|
|
32731
|
+
Object.entries(nextProps).forEach(([key, value]) => {
|
|
32732
|
+
if (!isEventProp(key, value)) {
|
|
32733
|
+
return;
|
|
32734
|
+
}
|
|
32735
|
+
const { eventName, options } = toEventConfig(key);
|
|
32736
|
+
const listener = (event) => {
|
|
32737
|
+
value(createSyntheticEvent(element, event));
|
|
32738
|
+
};
|
|
32739
|
+
element.addEventListener(eventName, listener, options);
|
|
32740
|
+
nextListeners.push({ eventName, listener, options });
|
|
32741
|
+
});
|
|
32742
|
+
return nextListeners;
|
|
32743
|
+
}
|
|
32744
|
+
function useMenuElementProps(element, props) {
|
|
32745
|
+
const previousPropsRef = useRef({});
|
|
32746
|
+
const listenersRef = useRef([]);
|
|
32747
|
+
useIsomorphicLayoutEffect2(() => {
|
|
32748
|
+
const previousProps = previousPropsRef.current;
|
|
32749
|
+
syncClassName(element, previousProps.className, props.className);
|
|
32750
|
+
syncStyles(element, previousProps.style, props.style);
|
|
32751
|
+
syncAttributes(element, previousProps, props);
|
|
32752
|
+
listenersRef.current = syncEventListeners(element, listenersRef.current, props);
|
|
32753
|
+
previousPropsRef.current = props;
|
|
32754
|
+
return () => {
|
|
32755
|
+
listenersRef.current.forEach(({ eventName, listener, options }) => {
|
|
32756
|
+
element.removeEventListener(eventName, listener, options);
|
|
32757
|
+
});
|
|
32758
|
+
listenersRef.current = [];
|
|
32759
|
+
};
|
|
32760
|
+
}, [element, props]);
|
|
32761
|
+
}
|
|
32762
|
+
var BubbleMenu2 = React.forwardRef(
|
|
32763
|
+
({
|
|
32764
|
+
pluginKey,
|
|
32765
|
+
editor,
|
|
32766
|
+
updateDelay,
|
|
32767
|
+
resizeDelay,
|
|
32768
|
+
appendTo,
|
|
32769
|
+
shouldShow = null,
|
|
32770
|
+
getReferencedVirtualElement,
|
|
32771
|
+
options,
|
|
32772
|
+
children,
|
|
32773
|
+
...restProps
|
|
32774
|
+
}, ref) => {
|
|
32775
|
+
const menuEl = useRef(document.createElement("div"));
|
|
32776
|
+
const resolvedPluginKey = useRef(
|
|
32777
|
+
getAutoPluginKey(pluginKey, "bubbleMenu")
|
|
32778
|
+
).current;
|
|
32779
|
+
useMenuElementProps(menuEl.current, restProps);
|
|
32780
|
+
if (typeof ref === "function") {
|
|
32781
|
+
ref(menuEl.current);
|
|
32782
|
+
} else if (ref) {
|
|
32783
|
+
ref.current = menuEl.current;
|
|
32784
|
+
}
|
|
32785
|
+
const { editor: currentEditor } = useCurrentEditor();
|
|
32786
|
+
const pluginEditor = editor || currentEditor;
|
|
32787
|
+
const bubbleMenuPluginProps = {
|
|
32788
|
+
updateDelay,
|
|
32789
|
+
resizeDelay,
|
|
32790
|
+
appendTo,
|
|
32791
|
+
pluginKey: resolvedPluginKey,
|
|
32792
|
+
shouldShow,
|
|
32793
|
+
getReferencedVirtualElement,
|
|
32794
|
+
options
|
|
32795
|
+
};
|
|
32796
|
+
const bubbleMenuPluginPropsRef = useRef(bubbleMenuPluginProps);
|
|
32797
|
+
bubbleMenuPluginPropsRef.current = bubbleMenuPluginProps;
|
|
32798
|
+
const [pluginInitialized, setPluginInitialized] = useState(false);
|
|
32799
|
+
const skipFirstUpdateRef = useRef(true);
|
|
32800
|
+
useEffect(() => {
|
|
32801
|
+
if (pluginEditor == null ? void 0 : pluginEditor.isDestroyed) {
|
|
32802
|
+
return;
|
|
32803
|
+
}
|
|
32804
|
+
if (!pluginEditor) {
|
|
32805
|
+
console.warn(
|
|
32806
|
+
"BubbleMenu component is not rendered inside of an editor component or does not have editor prop."
|
|
32807
|
+
);
|
|
32808
|
+
return;
|
|
32809
|
+
}
|
|
32810
|
+
const bubbleMenuElement = menuEl.current;
|
|
32811
|
+
bubbleMenuElement.style.visibility = "hidden";
|
|
32812
|
+
bubbleMenuElement.style.position = "absolute";
|
|
32813
|
+
const plugin = BubbleMenuPlugin({
|
|
32814
|
+
...bubbleMenuPluginPropsRef.current,
|
|
32815
|
+
editor: pluginEditor,
|
|
32816
|
+
element: bubbleMenuElement
|
|
32817
|
+
});
|
|
32818
|
+
pluginEditor.registerPlugin(plugin);
|
|
32819
|
+
const createdPluginKey = bubbleMenuPluginPropsRef.current.pluginKey;
|
|
32820
|
+
skipFirstUpdateRef.current = true;
|
|
32821
|
+
setPluginInitialized(true);
|
|
32822
|
+
return () => {
|
|
32823
|
+
setPluginInitialized(false);
|
|
32824
|
+
pluginEditor.unregisterPlugin(createdPluginKey);
|
|
32825
|
+
window.requestAnimationFrame(() => {
|
|
32826
|
+
if (bubbleMenuElement.parentNode) {
|
|
32827
|
+
bubbleMenuElement.parentNode.removeChild(bubbleMenuElement);
|
|
32828
|
+
}
|
|
32829
|
+
});
|
|
32830
|
+
};
|
|
32831
|
+
}, [pluginEditor]);
|
|
32832
|
+
useEffect(() => {
|
|
32833
|
+
if (!pluginInitialized || !pluginEditor || pluginEditor.isDestroyed) {
|
|
32834
|
+
return;
|
|
32835
|
+
}
|
|
32836
|
+
if (skipFirstUpdateRef.current) {
|
|
32837
|
+
skipFirstUpdateRef.current = false;
|
|
32838
|
+
return;
|
|
32839
|
+
}
|
|
32840
|
+
pluginEditor.view.dispatch(
|
|
32841
|
+
pluginEditor.state.tr.setMeta(resolvedPluginKey, {
|
|
32842
|
+
type: "updateOptions",
|
|
32843
|
+
options: bubbleMenuPluginPropsRef.current
|
|
32844
|
+
})
|
|
32845
|
+
);
|
|
32846
|
+
}, [
|
|
32847
|
+
pluginInitialized,
|
|
32848
|
+
pluginEditor,
|
|
32849
|
+
updateDelay,
|
|
32850
|
+
resizeDelay,
|
|
32851
|
+
shouldShow,
|
|
32852
|
+
options,
|
|
32853
|
+
appendTo,
|
|
32854
|
+
getReferencedVirtualElement,
|
|
32855
|
+
resolvedPluginKey
|
|
32856
|
+
]);
|
|
32857
|
+
return createPortal(children, menuEl.current);
|
|
32858
|
+
}
|
|
32859
|
+
);
|
|
32860
|
+
React.forwardRef(
|
|
32861
|
+
({
|
|
32862
|
+
pluginKey,
|
|
32863
|
+
editor,
|
|
32864
|
+
updateDelay,
|
|
32865
|
+
resizeDelay,
|
|
32866
|
+
appendTo,
|
|
32867
|
+
shouldShow = null,
|
|
32868
|
+
options,
|
|
32869
|
+
children,
|
|
32870
|
+
...restProps
|
|
32871
|
+
}, ref) => {
|
|
32872
|
+
const menuEl = useRef(document.createElement("div"));
|
|
32873
|
+
const resolvedPluginKey = useRef(
|
|
32874
|
+
getAutoPluginKey(pluginKey, "floatingMenu")
|
|
32875
|
+
).current;
|
|
32876
|
+
useMenuElementProps(menuEl.current, restProps);
|
|
32877
|
+
if (typeof ref === "function") {
|
|
32878
|
+
ref(menuEl.current);
|
|
32879
|
+
} else if (ref) {
|
|
32880
|
+
ref.current = menuEl.current;
|
|
32881
|
+
}
|
|
32882
|
+
const { editor: currentEditor } = useCurrentEditor();
|
|
32883
|
+
const pluginEditor = editor || currentEditor;
|
|
32884
|
+
const floatingMenuPluginProps = {
|
|
32885
|
+
updateDelay,
|
|
32886
|
+
resizeDelay,
|
|
32887
|
+
appendTo,
|
|
32888
|
+
pluginKey: resolvedPluginKey,
|
|
32889
|
+
shouldShow,
|
|
32890
|
+
options
|
|
32891
|
+
};
|
|
32892
|
+
const floatingMenuPluginPropsRef = useRef(floatingMenuPluginProps);
|
|
32893
|
+
floatingMenuPluginPropsRef.current = floatingMenuPluginProps;
|
|
32894
|
+
const [pluginInitialized, setPluginInitialized] = useState(false);
|
|
32895
|
+
const skipFirstUpdateRef = useRef(true);
|
|
32896
|
+
useEffect(() => {
|
|
32897
|
+
if (pluginEditor == null ? void 0 : pluginEditor.isDestroyed) {
|
|
32898
|
+
return;
|
|
32899
|
+
}
|
|
32900
|
+
if (!pluginEditor) {
|
|
32901
|
+
console.warn(
|
|
32902
|
+
"FloatingMenu component is not rendered inside of an editor component or does not have editor prop."
|
|
32903
|
+
);
|
|
32904
|
+
return;
|
|
32905
|
+
}
|
|
32906
|
+
const floatingMenuElement = menuEl.current;
|
|
32907
|
+
floatingMenuElement.style.visibility = "hidden";
|
|
32908
|
+
floatingMenuElement.style.position = "absolute";
|
|
32909
|
+
const plugin = FloatingMenuPlugin({
|
|
32910
|
+
...floatingMenuPluginPropsRef.current,
|
|
32911
|
+
editor: pluginEditor,
|
|
32912
|
+
element: floatingMenuElement
|
|
32913
|
+
});
|
|
32914
|
+
pluginEditor.registerPlugin(plugin);
|
|
32915
|
+
const createdPluginKey = floatingMenuPluginPropsRef.current.pluginKey;
|
|
32916
|
+
skipFirstUpdateRef.current = true;
|
|
32917
|
+
setPluginInitialized(true);
|
|
32918
|
+
return () => {
|
|
32919
|
+
setPluginInitialized(false);
|
|
32920
|
+
pluginEditor.unregisterPlugin(createdPluginKey);
|
|
32921
|
+
window.requestAnimationFrame(() => {
|
|
32922
|
+
if (floatingMenuElement.parentNode) {
|
|
32923
|
+
floatingMenuElement.parentNode.removeChild(floatingMenuElement);
|
|
32924
|
+
}
|
|
32925
|
+
});
|
|
32926
|
+
};
|
|
32927
|
+
}, [pluginEditor]);
|
|
32928
|
+
useEffect(() => {
|
|
32929
|
+
if (!pluginInitialized || !pluginEditor || pluginEditor.isDestroyed) {
|
|
32930
|
+
return;
|
|
32931
|
+
}
|
|
32932
|
+
if (skipFirstUpdateRef.current) {
|
|
32933
|
+
skipFirstUpdateRef.current = false;
|
|
32934
|
+
return;
|
|
32935
|
+
}
|
|
32936
|
+
pluginEditor.view.dispatch(
|
|
32937
|
+
pluginEditor.state.tr.setMeta(resolvedPluginKey, {
|
|
32938
|
+
type: "updateOptions",
|
|
32939
|
+
options: floatingMenuPluginPropsRef.current
|
|
32940
|
+
})
|
|
32941
|
+
);
|
|
32942
|
+
}, [
|
|
32943
|
+
pluginInitialized,
|
|
32944
|
+
pluginEditor,
|
|
32945
|
+
updateDelay,
|
|
32946
|
+
resizeDelay,
|
|
32947
|
+
shouldShow,
|
|
32948
|
+
options,
|
|
32949
|
+
appendTo,
|
|
32950
|
+
resolvedPluginKey
|
|
32951
|
+
]);
|
|
32952
|
+
return createPortal(children, menuEl.current);
|
|
32953
|
+
}
|
|
32954
|
+
);
|
|
32955
|
+
|
|
32956
|
+
// src/table.ts
|
|
32957
|
+
var openEditorTableCommands = [
|
|
32958
|
+
"addRowBefore",
|
|
32959
|
+
"addRowAfter",
|
|
32960
|
+
"deleteRow",
|
|
32961
|
+
"addColumnBefore",
|
|
32962
|
+
"addColumnAfter",
|
|
32963
|
+
"deleteColumn",
|
|
32964
|
+
"toggleHeaderRow",
|
|
32965
|
+
"toggleHeaderColumn",
|
|
32966
|
+
"mergeCells",
|
|
32967
|
+
"splitCell",
|
|
32968
|
+
"deleteTable"
|
|
32969
|
+
];
|
|
32970
|
+
var INACTIVE_TABLE_STATE = {
|
|
32971
|
+
active: false,
|
|
32972
|
+
rows: 0,
|
|
32973
|
+
columns: 0,
|
|
32974
|
+
headerRow: false,
|
|
32975
|
+
headerColumn: false,
|
|
32976
|
+
cellSelection: false,
|
|
32977
|
+
canMergeCells: false,
|
|
32978
|
+
canSplitCell: false
|
|
32979
|
+
};
|
|
32980
|
+
var findSelectedTable = (editor) => {
|
|
32981
|
+
const { $from } = editor.state.selection;
|
|
32982
|
+
for (let depth = $from.depth; depth >= 0; depth -= 1) {
|
|
32983
|
+
const node = $from.node(depth);
|
|
32984
|
+
if (node.type.name === "table") return node;
|
|
32985
|
+
}
|
|
32986
|
+
return null;
|
|
32987
|
+
};
|
|
32988
|
+
var allCellsMatch = (table, predicate) => {
|
|
32989
|
+
let matches2 = true;
|
|
32990
|
+
table.forEach((row, _offset, rowIndex) => {
|
|
32991
|
+
row.forEach((cell, _cellOffset, columnIndex) => {
|
|
32992
|
+
if (!predicate(cell, rowIndex, columnIndex)) matches2 = false;
|
|
32993
|
+
});
|
|
32994
|
+
});
|
|
32995
|
+
return matches2;
|
|
32996
|
+
};
|
|
32997
|
+
var getOpenEditorTableState = (editor) => {
|
|
32998
|
+
if (!editor || editor.isDestroyed) return INACTIVE_TABLE_STATE;
|
|
32999
|
+
const table = findSelectedTable(editor);
|
|
33000
|
+
if (!table) return INACTIVE_TABLE_STATE;
|
|
33001
|
+
const map2 = TableMap.get(table);
|
|
33002
|
+
return {
|
|
33003
|
+
active: true,
|
|
33004
|
+
rows: map2.height,
|
|
33005
|
+
columns: map2.width,
|
|
33006
|
+
headerRow: table.childCount > 0 && allCellsMatch(
|
|
33007
|
+
table,
|
|
33008
|
+
(cell, rowIndex) => rowIndex !== 0 || cell.type.name === "tableHeader"
|
|
33009
|
+
),
|
|
33010
|
+
headerColumn: table.childCount > 0 && allCellsMatch(
|
|
33011
|
+
table,
|
|
33012
|
+
(cell, _rowIndex, columnIndex) => columnIndex !== 0 || cell.type.name === "tableHeader"
|
|
33013
|
+
),
|
|
33014
|
+
cellSelection: editor.state.selection instanceof CellSelection,
|
|
33015
|
+
canMergeCells: editor.can().mergeCells(),
|
|
33016
|
+
canSplitCell: editor.can().splitCell()
|
|
33017
|
+
};
|
|
33018
|
+
};
|
|
33019
|
+
var canRunOpenEditorTableCommand = (editor, command2) => {
|
|
33020
|
+
if (!editor || editor.isDestroyed || !findSelectedTable(editor)) return false;
|
|
33021
|
+
const state = getOpenEditorTableState(editor);
|
|
33022
|
+
if (command2 === "deleteRow" && state.rows <= 1) return false;
|
|
33023
|
+
if (command2 === "deleteColumn" && state.columns <= 1) return false;
|
|
33024
|
+
switch (command2) {
|
|
33025
|
+
case "addRowBefore":
|
|
33026
|
+
return editor.can().addRowBefore();
|
|
33027
|
+
case "addRowAfter":
|
|
33028
|
+
return editor.can().addRowAfter();
|
|
33029
|
+
case "deleteRow":
|
|
33030
|
+
return editor.can().deleteRow();
|
|
33031
|
+
case "addColumnBefore":
|
|
33032
|
+
return editor.can().addColumnBefore();
|
|
33033
|
+
case "addColumnAfter":
|
|
33034
|
+
return editor.can().addColumnAfter();
|
|
33035
|
+
case "deleteColumn":
|
|
33036
|
+
return editor.can().deleteColumn();
|
|
33037
|
+
case "toggleHeaderRow":
|
|
33038
|
+
return editor.can().toggleHeaderRow();
|
|
33039
|
+
case "toggleHeaderColumn":
|
|
33040
|
+
return editor.can().toggleHeaderColumn();
|
|
33041
|
+
case "mergeCells":
|
|
33042
|
+
return editor.can().mergeCells();
|
|
33043
|
+
case "splitCell":
|
|
33044
|
+
return editor.can().splitCell();
|
|
33045
|
+
case "deleteTable":
|
|
33046
|
+
return editor.can().deleteTable();
|
|
33047
|
+
}
|
|
33048
|
+
};
|
|
33049
|
+
var runOpenEditorTableCommand = (editor, command2) => {
|
|
33050
|
+
if (!canRunOpenEditorTableCommand(editor, command2) || !editor) return false;
|
|
33051
|
+
let executed = false;
|
|
33052
|
+
switch (command2) {
|
|
33053
|
+
case "addRowBefore":
|
|
33054
|
+
executed = editor.commands.addRowBefore();
|
|
33055
|
+
break;
|
|
33056
|
+
case "addRowAfter":
|
|
33057
|
+
executed = editor.commands.addRowAfter();
|
|
33058
|
+
break;
|
|
33059
|
+
case "deleteRow":
|
|
33060
|
+
executed = editor.commands.deleteRow();
|
|
33061
|
+
break;
|
|
33062
|
+
case "addColumnBefore":
|
|
33063
|
+
executed = editor.commands.addColumnBefore();
|
|
33064
|
+
break;
|
|
33065
|
+
case "addColumnAfter":
|
|
33066
|
+
executed = editor.commands.addColumnAfter();
|
|
33067
|
+
break;
|
|
33068
|
+
case "deleteColumn":
|
|
33069
|
+
executed = editor.commands.deleteColumn();
|
|
33070
|
+
break;
|
|
33071
|
+
case "toggleHeaderRow":
|
|
33072
|
+
executed = editor.commands.toggleHeaderRow();
|
|
33073
|
+
break;
|
|
33074
|
+
case "toggleHeaderColumn":
|
|
33075
|
+
executed = editor.commands.toggleHeaderColumn();
|
|
33076
|
+
break;
|
|
33077
|
+
case "mergeCells":
|
|
33078
|
+
executed = editor.commands.mergeCells();
|
|
33079
|
+
break;
|
|
33080
|
+
case "splitCell":
|
|
33081
|
+
executed = editor.commands.splitCell();
|
|
33082
|
+
break;
|
|
33083
|
+
case "deleteTable":
|
|
33084
|
+
executed = editor.commands.deleteTable();
|
|
33085
|
+
break;
|
|
33086
|
+
}
|
|
33087
|
+
if (executed && editor.view) editor.commands.focus();
|
|
33088
|
+
return executed;
|
|
33089
|
+
};
|
|
33090
|
+
var createOpenEditorTableController = (getEditor) => ({
|
|
33091
|
+
getState: () => getOpenEditorTableState(getEditor()),
|
|
33092
|
+
can: (command2) => canRunOpenEditorTableCommand(getEditor(), command2),
|
|
33093
|
+
run: (command2) => runOpenEditorTableCommand(getEditor(), command2)
|
|
33094
|
+
});
|
|
33095
|
+
var OpenEditorPageRuntimeContext = createContext(void 0);
|
|
33096
|
+
var OpenEditorAttachmentRuntimeContext = createContext(void 0);
|
|
33097
|
+
var defineOpenEditorReactExtension = (extension) => extension;
|
|
33098
|
+
var defineOpenEditorReactNode = ({
|
|
33099
|
+
block,
|
|
33100
|
+
node,
|
|
33101
|
+
component,
|
|
33102
|
+
...extension
|
|
33103
|
+
}) => ({
|
|
33104
|
+
...extension,
|
|
33105
|
+
block,
|
|
33106
|
+
tiptapExtensions: [
|
|
33107
|
+
Node3.create({
|
|
33108
|
+
...node,
|
|
33109
|
+
name: block.nodeType ?? block.name,
|
|
33110
|
+
addNodeView() {
|
|
33111
|
+
return ReactNodeViewRenderer(component);
|
|
33112
|
+
}
|
|
33113
|
+
})
|
|
33114
|
+
]
|
|
33115
|
+
});
|
|
33116
|
+
var EMPTY_EXTENSIONS = [];
|
|
33117
|
+
var COMMON_HTML_ATTRIBUTES = ["id", "class", "title", "lang", "dir", "data-id", "style"];
|
|
33118
|
+
var LAYOUT_ATTRIBUTES = ["align", "width", "height"];
|
|
33119
|
+
var URL_ATTRIBUTES = /* @__PURE__ */ new Set(["href", "src"]);
|
|
33120
|
+
var FORBIDDEN_PASTE_TAGS = /* @__PURE__ */ new Set(["script", "iframe", "object", "embed", "meta", "base"]);
|
|
33121
|
+
var createStandardAttributes = (attributeNames) => Object.fromEntries(
|
|
33122
|
+
attributeNames.map((attribute) => [
|
|
33123
|
+
attribute,
|
|
33124
|
+
{
|
|
33125
|
+
default: null,
|
|
33126
|
+
parseHTML: (element) => element.getAttribute(attribute),
|
|
33127
|
+
renderHTML: (attributes) => attributes[attribute] ? { [attribute]: attributes[attribute] } : {}
|
|
33128
|
+
}
|
|
33129
|
+
])
|
|
33130
|
+
);
|
|
33131
|
+
var isSafePastedUrl = (value, context, allowDataImage) => allowDataImage && /^data:image\//i.test(value.trim()) || openEditorPublicUrlPolicy(value, context) !== null;
|
|
33132
|
+
var sanitizePastedHtml = (html) => {
|
|
33133
|
+
const parser = new DOMParser();
|
|
33134
|
+
const parsed = parser.parseFromString(html, "text/html");
|
|
33135
|
+
const isFromOpenEditor = /data-openeditor-|oe-|node-/.test(html);
|
|
33136
|
+
const preservedAttributes = {
|
|
33137
|
+
a: ["href", "target", "rel"],
|
|
33138
|
+
img: ["src", "alt", "width", "height"],
|
|
33139
|
+
td: ["colspan", "rowspan"],
|
|
33140
|
+
th: ["colspan", "rowspan", "scope"],
|
|
33141
|
+
table: ["border", "cellpadding", "cellspacing"],
|
|
33142
|
+
"*": ["id"]
|
|
33143
|
+
};
|
|
33144
|
+
for (const tag of FORBIDDEN_PASTE_TAGS) {
|
|
33145
|
+
for (const element of Array.from(parsed.body.getElementsByTagName(tag))) {
|
|
33146
|
+
element.remove();
|
|
33147
|
+
}
|
|
33148
|
+
}
|
|
33149
|
+
for (const element of Array.from(parsed.body.querySelectorAll("[href], [src]"))) {
|
|
33150
|
+
const allowDataImage = element.tagName.toLowerCase() === "img";
|
|
33151
|
+
for (const attribute of URL_ATTRIBUTES) {
|
|
33152
|
+
const value = element.getAttribute(attribute);
|
|
33153
|
+
const context = attribute === "src" ? "image" : "link";
|
|
33154
|
+
if (value !== null && !isSafePastedUrl(value, context, allowDataImage && attribute === "src")) {
|
|
33155
|
+
element.removeAttribute(attribute);
|
|
33156
|
+
}
|
|
33157
|
+
}
|
|
33158
|
+
}
|
|
33159
|
+
if (isFromOpenEditor) {
|
|
33160
|
+
return parsed.body.innerHTML;
|
|
33161
|
+
}
|
|
33162
|
+
const sanitizeElement = (node) => {
|
|
33163
|
+
if (node.nodeType === window.Node.ELEMENT_NODE) {
|
|
33164
|
+
const element = node;
|
|
33165
|
+
const tagName = element.tagName.toLowerCase();
|
|
33166
|
+
const allowed = /* @__PURE__ */ new Set([...preservedAttributes[tagName] ?? [], ...preservedAttributes["*"] ?? []]);
|
|
33167
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
33168
|
+
if (attribute.name.startsWith("data-") || !allowed.has(attribute.name)) {
|
|
33169
|
+
element.removeAttribute(attribute.name);
|
|
33170
|
+
}
|
|
33171
|
+
}
|
|
33172
|
+
}
|
|
33173
|
+
for (const child of Array.from(node.childNodes)) {
|
|
33174
|
+
sanitizeElement(child);
|
|
33175
|
+
}
|
|
33176
|
+
};
|
|
33177
|
+
sanitizeElement(parsed.body);
|
|
33178
|
+
return parsed.body.innerHTML;
|
|
33179
|
+
};
|
|
33180
|
+
var Columns = Node3.create({
|
|
33181
|
+
name: "columns",
|
|
33182
|
+
group: "block",
|
|
33183
|
+
content: "column+",
|
|
33184
|
+
isolating: true,
|
|
33185
|
+
defining: true,
|
|
33186
|
+
addAttributes() {
|
|
33187
|
+
return createStandardAttributes([...COMMON_HTML_ATTRIBUTES, ...LAYOUT_ATTRIBUTES, "cellspacing"]);
|
|
33188
|
+
},
|
|
33189
|
+
parseHTML() {
|
|
33190
|
+
return [{ tag: "section[data-openeditor-columns]" }];
|
|
33191
|
+
},
|
|
33192
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
33193
|
+
const count = node.childCount;
|
|
33194
|
+
return [
|
|
33195
|
+
"section",
|
|
33196
|
+
mergeAttributes(
|
|
33197
|
+
{
|
|
33198
|
+
class: "oe-columns",
|
|
33199
|
+
"data-openeditor-columns": count,
|
|
33200
|
+
style: `--oe-column-count:${Math.min(Math.max(count, 2), 4)};${HTMLAttributes.style ?? ""}`
|
|
33201
|
+
},
|
|
33202
|
+
HTMLAttributes
|
|
33203
|
+
),
|
|
33204
|
+
0
|
|
33205
|
+
];
|
|
33206
|
+
},
|
|
33207
|
+
addCommands() {
|
|
33208
|
+
return {
|
|
33209
|
+
insertColumns: (count = 2) => ({ commands }) => commands.insertContent({
|
|
33210
|
+
type: "columns",
|
|
33211
|
+
content: Array.from({ length: count }, (_, index) => ({
|
|
33212
|
+
type: "column",
|
|
33213
|
+
content: [
|
|
33214
|
+
{
|
|
33215
|
+
type: "paragraph",
|
|
33216
|
+
content: [{ type: "text", text: `Column ${index + 1}` }]
|
|
33217
|
+
}
|
|
33218
|
+
]
|
|
33219
|
+
}))
|
|
33220
|
+
})
|
|
33221
|
+
};
|
|
33222
|
+
},
|
|
33223
|
+
addKeyboardShortcuts() {
|
|
33224
|
+
return {
|
|
33225
|
+
Backspace: ({ editor }) => {
|
|
33226
|
+
const { selection } = editor.state;
|
|
33227
|
+
if (!(selection instanceof NodeSelection) || selection.node.type.name !== "columns") {
|
|
33228
|
+
return false;
|
|
33229
|
+
}
|
|
33230
|
+
const allColumnsEmpty = Array.from(
|
|
33231
|
+
{ length: selection.node.childCount },
|
|
33232
|
+
(_, index) => selection.node.child(index)
|
|
33233
|
+
).every(
|
|
33234
|
+
(column) => column.childCount === 1 && column.firstChild?.type.name === "paragraph" && column.firstChild.childCount === 0
|
|
33235
|
+
);
|
|
33236
|
+
if (!allColumnsEmpty) {
|
|
33237
|
+
return false;
|
|
33238
|
+
}
|
|
33239
|
+
editor.view.dispatch(
|
|
33240
|
+
editor.state.tr.replaceWith(selection.from, selection.to, editor.state.schema.nodes.paragraph.create())
|
|
33241
|
+
);
|
|
33242
|
+
return true;
|
|
33243
|
+
}
|
|
33244
|
+
};
|
|
33245
|
+
}
|
|
33246
|
+
});
|
|
33247
|
+
var Column = Node3.create({
|
|
33248
|
+
name: "column",
|
|
33249
|
+
content: "block+",
|
|
33250
|
+
isolating: true,
|
|
33251
|
+
defining: true,
|
|
33252
|
+
addAttributes() {
|
|
33253
|
+
return createStandardAttributes([...COMMON_HTML_ATTRIBUTES, ...LAYOUT_ATTRIBUTES]);
|
|
33254
|
+
},
|
|
33255
|
+
parseHTML() {
|
|
33256
|
+
return [{ tag: "div[data-openeditor-column]" }];
|
|
33257
|
+
},
|
|
33258
|
+
renderHTML({ HTMLAttributes }) {
|
|
33259
|
+
return ["div", mergeAttributes({ "data-openeditor-column": "", class: "oe-column" }, HTMLAttributes), 0];
|
|
33260
|
+
}
|
|
33261
|
+
});
|
|
33262
|
+
var Divider = index_default.extend({
|
|
33263
|
+
addAttributes() {
|
|
33264
|
+
return {
|
|
33265
|
+
...createStandardAttributes(["class", "style"]),
|
|
33266
|
+
class: {
|
|
33267
|
+
default: "oe-divider"
|
|
33268
|
+
}
|
|
33269
|
+
};
|
|
31153
33270
|
},
|
|
31154
33271
|
addInputRules() {
|
|
31155
33272
|
return [
|
|
@@ -31215,7 +33332,7 @@ var OpenEditorTaskItemNodeView = ({ editor, node, updateAttributes: updateAttrib
|
|
|
31215
33332
|
/* @__PURE__ */ jsx(NodeViewContent, { as: "div" })
|
|
31216
33333
|
] });
|
|
31217
33334
|
};
|
|
31218
|
-
var BaseUiTaskItem =
|
|
33335
|
+
var BaseUiTaskItem = index_default5.extend({
|
|
31219
33336
|
addNodeView() {
|
|
31220
33337
|
return ReactNodeViewRenderer(OpenEditorTaskItemNodeView);
|
|
31221
33338
|
}
|
|
@@ -31311,11 +33428,11 @@ var attachmentSnapshotFromNode = (node) => ({
|
|
|
31311
33428
|
size: typeof node.attrs?.size === "number" ? node.attrs.size : null,
|
|
31312
33429
|
url: typeof node.attrs?.url === "string" ? node.attrs.url : null
|
|
31313
33430
|
});
|
|
31314
|
-
var formatAttachmentSize = (
|
|
31315
|
-
if (
|
|
31316
|
-
if (
|
|
33431
|
+
var formatAttachmentSize = (size3) => {
|
|
33432
|
+
if (size3 === null || !Number.isFinite(size3) || size3 < 0) return "";
|
|
33433
|
+
if (size3 < 1024) return `${size3} B`;
|
|
31317
33434
|
const units = ["KB", "MB", "GB", "TB"];
|
|
31318
|
-
let value =
|
|
33435
|
+
let value = size3 / 1024;
|
|
31319
33436
|
let unit = 0;
|
|
31320
33437
|
while (value >= 1024 && unit < units.length - 1) {
|
|
31321
33438
|
value /= 1024;
|
|
@@ -31766,28 +33883,70 @@ var MermaidDiagram = Node3.create({
|
|
|
31766
33883
|
return ReactNodeViewRenderer(OpenEditorDiagramNodeView);
|
|
31767
33884
|
}
|
|
31768
33885
|
});
|
|
31769
|
-
var
|
|
31770
|
-
|
|
33886
|
+
var openEditorSlashSuggestionPluginKey = new PluginKey("openEditorSlashSuggestion");
|
|
33887
|
+
var slashStateFromSuggestion = (props) => {
|
|
33888
|
+
const rect = props.clientRect?.() ?? props.decorationNode?.getBoundingClientRect() ?? props.editor.view.coordsAtPos(props.range.to);
|
|
33889
|
+
const anchorRect = toOverlayRect(rect);
|
|
33890
|
+
return {
|
|
33891
|
+
query: props.query,
|
|
33892
|
+
from: props.range.from,
|
|
33893
|
+
to: props.range.to,
|
|
33894
|
+
left: rect.left,
|
|
33895
|
+
top: rect.bottom + 8,
|
|
33896
|
+
anchorRect
|
|
33897
|
+
};
|
|
33898
|
+
};
|
|
33899
|
+
var createSlashSuggestionExtension = ({
|
|
33900
|
+
onStateChange,
|
|
33901
|
+
onKeyDown
|
|
33902
|
+
}) => Extension.create({
|
|
33903
|
+
name: "openEditorSlashSuggestion",
|
|
33904
|
+
addProseMirrorPlugins() {
|
|
33905
|
+
return [
|
|
33906
|
+
Suggestion({
|
|
33907
|
+
editor: this.editor,
|
|
33908
|
+
pluginKey: openEditorSlashSuggestionPluginKey,
|
|
33909
|
+
char: "/",
|
|
33910
|
+
allowSpaces: true,
|
|
33911
|
+
allowedPrefixes: [" "],
|
|
33912
|
+
decorationClass: "oe-slash-suggestion",
|
|
33913
|
+
items: () => [],
|
|
33914
|
+
render: () => ({
|
|
33915
|
+
onStart: (props) => onStateChange(slashStateFromSuggestion(props)),
|
|
33916
|
+
onUpdate: (props) => onStateChange(slashStateFromSuggestion(props)),
|
|
33917
|
+
onExit: () => onStateChange(null),
|
|
33918
|
+
onKeyDown: ({ event }) => onKeyDown(event)
|
|
33919
|
+
})
|
|
33920
|
+
})
|
|
33921
|
+
];
|
|
33922
|
+
}
|
|
33923
|
+
});
|
|
33924
|
+
var createEditorExtensions = (getPlaceholder, customExtensions, slashSuggestion) => [
|
|
33925
|
+
index_default9.configure({
|
|
31771
33926
|
attributeName: OPENEDITOR_BLOCK_ID_ATTR,
|
|
31772
33927
|
types: "all",
|
|
31773
33928
|
generateID: () => createBlockId()
|
|
31774
33929
|
}),
|
|
31775
|
-
|
|
33930
|
+
index_default10.configure({ horizontalRule: false, link: false, underline: false }),
|
|
31776
33931
|
Divider,
|
|
31777
33932
|
index_default2.configure({ allowBase64: true }),
|
|
31778
33933
|
index_default3.configure({ openOnClick: false }),
|
|
31779
|
-
|
|
31780
|
-
|
|
33934
|
+
index_default8,
|
|
33935
|
+
index_default6,
|
|
31781
33936
|
BaseUiTaskItem.configure({ nested: true }),
|
|
31782
|
-
|
|
31783
|
-
|
|
31784
|
-
|
|
33937
|
+
TableKit.configure({
|
|
33938
|
+
table: {
|
|
33939
|
+
resizable: true,
|
|
33940
|
+
lastColumnResizable: false,
|
|
33941
|
+
HTMLAttributes: { "data-openeditor-table": "" }
|
|
33942
|
+
},
|
|
33943
|
+
tableRow: {},
|
|
33944
|
+
tableHeader: {},
|
|
33945
|
+
tableCell: {}
|
|
31785
33946
|
}),
|
|
31786
|
-
index_default7,
|
|
31787
|
-
index_default6,
|
|
31788
|
-
index_default5,
|
|
31789
|
-
index_default10.configure({ types: ["heading", "paragraph"] }),
|
|
33947
|
+
index_default7.configure({ types: ["heading", "paragraph"] }),
|
|
31790
33948
|
index_default4.configure({ placeholder: () => getPlaceholder(), showOnlyCurrent: true }),
|
|
33949
|
+
createSlashSuggestionExtension(slashSuggestion),
|
|
31791
33950
|
Columns,
|
|
31792
33951
|
Column,
|
|
31793
33952
|
ToggleList,
|
|
@@ -31815,60 +33974,6 @@ var toOverlayRect = (coordinates) => ({
|
|
|
31815
33974
|
width: coordinates.right - coordinates.left,
|
|
31816
33975
|
height: coordinates.bottom - coordinates.top
|
|
31817
33976
|
});
|
|
31818
|
-
var getSlashState = (editor) => {
|
|
31819
|
-
const { selection } = editor.state;
|
|
31820
|
-
if (!selection.empty) {
|
|
31821
|
-
return null;
|
|
31822
|
-
}
|
|
31823
|
-
const { $from } = selection;
|
|
31824
|
-
const textBeforeCursor = $from.parent.textBetween(0, $from.parentOffset, "\n", "\n");
|
|
31825
|
-
const match = /(?:^|\s)\/([\w -]*)$/.exec(textBeforeCursor);
|
|
31826
|
-
if (!match) {
|
|
31827
|
-
return null;
|
|
31828
|
-
}
|
|
31829
|
-
const query = match[1] ?? "";
|
|
31830
|
-
const from2 = $from.pos - query.length - 1;
|
|
31831
|
-
const to = $from.pos;
|
|
31832
|
-
const coordinates = editor.view.coordsAtPos(to);
|
|
31833
|
-
const anchorRect = toOverlayRect(coordinates);
|
|
31834
|
-
return {
|
|
31835
|
-
query,
|
|
31836
|
-
from: from2,
|
|
31837
|
-
to,
|
|
31838
|
-
left: coordinates.left,
|
|
31839
|
-
top: coordinates.bottom + 8,
|
|
31840
|
-
anchorRect
|
|
31841
|
-
};
|
|
31842
|
-
};
|
|
31843
|
-
var getSelectionBubbleState = (editor) => {
|
|
31844
|
-
const { selection } = editor.state;
|
|
31845
|
-
if (!(selection instanceof TextSelection) || selection.empty || editor.state.doc.textBetween(selection.from, selection.to).length === 0) {
|
|
31846
|
-
return null;
|
|
31847
|
-
}
|
|
31848
|
-
const domSelection = typeof window === "undefined" ? null : window.getSelection();
|
|
31849
|
-
const selectedRange = domSelection?.rangeCount ? domSelection.getRangeAt(0) : null;
|
|
31850
|
-
const selectedRect2 = selectedRange?.getBoundingClientRect();
|
|
31851
|
-
if (selectedRange && editor.view.dom.contains(selectedRange.commonAncestorContainer) && selectedRect2 && selectedRect2.width > 0 && selectedRect2.height > 0) {
|
|
31852
|
-
return {
|
|
31853
|
-
left: selectedRect2.left + selectedRect2.width / 2,
|
|
31854
|
-
top: selectedRect2.top,
|
|
31855
|
-
anchorRect: toOverlayRect(selectedRect2)
|
|
31856
|
-
};
|
|
31857
|
-
}
|
|
31858
|
-
const fromCoordinates = editor.view.coordsAtPos(selection.from);
|
|
31859
|
-
const toCoordinates = editor.view.coordsAtPos(selection.to);
|
|
31860
|
-
const anchorRect = toOverlayRect({
|
|
31861
|
-
left: Math.min(fromCoordinates.left, toCoordinates.left),
|
|
31862
|
-
right: Math.max(fromCoordinates.right, toCoordinates.right),
|
|
31863
|
-
top: Math.min(fromCoordinates.top, toCoordinates.top),
|
|
31864
|
-
bottom: Math.max(fromCoordinates.bottom, toCoordinates.bottom)
|
|
31865
|
-
});
|
|
31866
|
-
return {
|
|
31867
|
-
left: (fromCoordinates.left + toCoordinates.right) / 2,
|
|
31868
|
-
top: Math.min(fromCoordinates.top, toCoordinates.top) - 8,
|
|
31869
|
-
anchorRect
|
|
31870
|
-
};
|
|
31871
|
-
};
|
|
31872
33977
|
var regenerateClipboardNodeIds = (value) => {
|
|
31873
33978
|
if (Array.isArray(value)) return value.map(regenerateClipboardNodeIds);
|
|
31874
33979
|
if (!value || typeof value !== "object") return value;
|
|
@@ -31901,11 +34006,8 @@ var useOpenEditorController = ({
|
|
|
31901
34006
|
const [document2, setDocument] = useState(() => normalizeDocument(initialDocument));
|
|
31902
34007
|
const [selectedBlock, setSelectedBlock] = useState("paragraph");
|
|
31903
34008
|
const [slashState, setSlashState] = useState(null);
|
|
31904
|
-
const [selectionBubbleState, setSelectionBubbleState] = useState(null);
|
|
31905
34009
|
const [blockInteraction] = useState(createBlockInteractionStore);
|
|
31906
|
-
const
|
|
31907
|
-
const slashStateRef = useRef(null);
|
|
31908
|
-
const selectionBubbleStateRef = useRef(null);
|
|
34010
|
+
const slashKeyboardHandlerRef = useRef(null);
|
|
31909
34011
|
const documentMetaRef = useRef(document2.meta);
|
|
31910
34012
|
const placeholderRef = useRef(placeholder);
|
|
31911
34013
|
placeholderRef.current = placeholder;
|
|
@@ -31928,13 +34030,22 @@ var useOpenEditorController = ({
|
|
|
31928
34030
|
const exporters = useMemo(() => createReactExporters(extensions), [extensions]);
|
|
31929
34031
|
const editor = useEditor({
|
|
31930
34032
|
immediatelyRender: false,
|
|
31931
|
-
extensions: createEditorExtensions(
|
|
34033
|
+
extensions: createEditorExtensions(
|
|
34034
|
+
() => placeholderRef.current,
|
|
34035
|
+
extensions,
|
|
34036
|
+
{
|
|
34037
|
+
onStateChange: setSlashState,
|
|
34038
|
+
onKeyDown: (event) => slashKeyboardHandlerRef.current?.(event) ?? false
|
|
34039
|
+
}
|
|
34040
|
+
),
|
|
31932
34041
|
content: toProseMirrorDocument(document2),
|
|
31933
34042
|
editable,
|
|
31934
34043
|
editorProps: {
|
|
31935
34044
|
attributes: {
|
|
31936
34045
|
class: "oe-prosemirror",
|
|
31937
|
-
"aria-label": "OpenEditor document"
|
|
34046
|
+
"aria-label": "OpenEditor document",
|
|
34047
|
+
"aria-multiline": "true",
|
|
34048
|
+
role: "textbox"
|
|
31938
34049
|
},
|
|
31939
34050
|
transformPastedHTML: sanitizePastedHtml,
|
|
31940
34051
|
handlePaste: (view, event) => {
|
|
@@ -31981,15 +34092,6 @@ var useOpenEditorController = ({
|
|
|
31981
34092
|
}
|
|
31982
34093
|
event.preventDefault();
|
|
31983
34094
|
return true;
|
|
31984
|
-
},
|
|
31985
|
-
handleDOMEvents: {
|
|
31986
|
-
pointerdown: (_view, event) => {
|
|
31987
|
-
if (event.button === 0) {
|
|
31988
|
-
isPointerSelectingRef.current = true;
|
|
31989
|
-
setSelectionBubbleState(null);
|
|
31990
|
-
}
|
|
31991
|
-
return false;
|
|
31992
|
-
}
|
|
31993
34095
|
}
|
|
31994
34096
|
},
|
|
31995
34097
|
onUpdate: ({ editor: currentEditor }) => {
|
|
@@ -31999,16 +34101,8 @@ var useOpenEditorController = ({
|
|
|
31999
34101
|
);
|
|
32000
34102
|
setDocument(nextDocument);
|
|
32001
34103
|
onChangeRef.current?.(nextDocument);
|
|
32002
|
-
setSlashState(getSlashState(currentEditor));
|
|
32003
|
-
setSelectionBubbleState(
|
|
32004
|
-
isPointerSelectingRef.current ? null : getSelectionBubbleState(currentEditor)
|
|
32005
|
-
);
|
|
32006
34104
|
},
|
|
32007
34105
|
onSelectionUpdate: ({ editor: currentEditor }) => {
|
|
32008
|
-
setSlashState(getSlashState(currentEditor));
|
|
32009
|
-
setSelectionBubbleState(
|
|
32010
|
-
isPointerSelectingRef.current ? null : getSelectionBubbleState(currentEditor)
|
|
32011
|
-
);
|
|
32012
34106
|
if (currentEditor.state.selection instanceof NodeSelection) {
|
|
32013
34107
|
blockInteraction.setActiveBlock(selectedBlockRef(currentEditor, registry));
|
|
32014
34108
|
}
|
|
@@ -32020,53 +34114,6 @@ var useOpenEditorController = ({
|
|
|
32020
34114
|
useEffect(() => {
|
|
32021
34115
|
if (editor && !editor.isDestroyed) editor.view.dispatch(editor.state.tr);
|
|
32022
34116
|
}, [editor, placeholder]);
|
|
32023
|
-
useEffect(() => {
|
|
32024
|
-
slashStateRef.current = slashState;
|
|
32025
|
-
}, [slashState]);
|
|
32026
|
-
useEffect(() => {
|
|
32027
|
-
selectionBubbleStateRef.current = selectionBubbleState;
|
|
32028
|
-
}, [selectionBubbleState]);
|
|
32029
|
-
useEffect(() => {
|
|
32030
|
-
if (!editor || typeof window === "undefined") return;
|
|
32031
|
-
const finishPointerSelection = () => {
|
|
32032
|
-
if (!isPointerSelectingRef.current) return;
|
|
32033
|
-
isPointerSelectingRef.current = false;
|
|
32034
|
-
setSelectionBubbleState(getSelectionBubbleState(editor));
|
|
32035
|
-
};
|
|
32036
|
-
window.addEventListener("pointerup", finishPointerSelection, true);
|
|
32037
|
-
window.addEventListener("pointercancel", finishPointerSelection, true);
|
|
32038
|
-
return () => {
|
|
32039
|
-
window.removeEventListener("pointerup", finishPointerSelection, true);
|
|
32040
|
-
window.removeEventListener("pointercancel", finishPointerSelection, true);
|
|
32041
|
-
};
|
|
32042
|
-
}, [editor]);
|
|
32043
|
-
useEffect(() => {
|
|
32044
|
-
if (!editor || typeof window === "undefined") {
|
|
32045
|
-
return;
|
|
32046
|
-
}
|
|
32047
|
-
let animationFrame = 0;
|
|
32048
|
-
const refreshOverlayAnchors = () => {
|
|
32049
|
-
if (!slashStateRef.current && !selectionBubbleStateRef.current) {
|
|
32050
|
-
return;
|
|
32051
|
-
}
|
|
32052
|
-
window.cancelAnimationFrame(animationFrame);
|
|
32053
|
-
animationFrame = window.requestAnimationFrame(() => {
|
|
32054
|
-
if (slashStateRef.current) {
|
|
32055
|
-
setSlashState(getSlashState(editor));
|
|
32056
|
-
}
|
|
32057
|
-
if (selectionBubbleStateRef.current) {
|
|
32058
|
-
setSelectionBubbleState(getSelectionBubbleState(editor));
|
|
32059
|
-
}
|
|
32060
|
-
});
|
|
32061
|
-
};
|
|
32062
|
-
window.addEventListener("scroll", refreshOverlayAnchors, true);
|
|
32063
|
-
window.addEventListener("resize", refreshOverlayAnchors);
|
|
32064
|
-
return () => {
|
|
32065
|
-
window.cancelAnimationFrame(animationFrame);
|
|
32066
|
-
window.removeEventListener("scroll", refreshOverlayAnchors, true);
|
|
32067
|
-
window.removeEventListener("resize", refreshOverlayAnchors);
|
|
32068
|
-
};
|
|
32069
|
-
}, [editor]);
|
|
32070
34117
|
const insertBlock = (blockName = selectedBlock, range) => {
|
|
32071
34118
|
if (!editor || !isBlockEnabled(blockName)) {
|
|
32072
34119
|
return false;
|
|
@@ -32225,6 +34272,12 @@ var useOpenEditorController = ({
|
|
|
32225
34272
|
const redo2 = () => {
|
|
32226
34273
|
editor?.chain().focus().redo().run();
|
|
32227
34274
|
};
|
|
34275
|
+
const table = createOpenEditorTableController(() => editor);
|
|
34276
|
+
const dismissSlashMenu = () => {
|
|
34277
|
+
if (editor && !editor.isDestroyed) {
|
|
34278
|
+
exitSuggestion(editor.view, openEditorSlashSuggestionPluginKey);
|
|
34279
|
+
}
|
|
34280
|
+
};
|
|
32228
34281
|
const controller = {
|
|
32229
34282
|
document: document2,
|
|
32230
34283
|
editor,
|
|
@@ -32237,6 +34290,18 @@ var useOpenEditorController = ({
|
|
|
32237
34290
|
setSelectedBlock,
|
|
32238
34291
|
getContent: () => document2,
|
|
32239
34292
|
setContent: setContent2,
|
|
34293
|
+
focus: () => {
|
|
34294
|
+
editor?.commands.focus();
|
|
34295
|
+
},
|
|
34296
|
+
getPositionRect: (position) => {
|
|
34297
|
+
if (!editor || editor.isDestroyed) return null;
|
|
34298
|
+
try {
|
|
34299
|
+
const boundedPosition = Math.max(0, Math.min(position, editor.state.doc.content.size));
|
|
34300
|
+
return toOverlayRect(editor.view.coordsAtPos(boundedPosition));
|
|
34301
|
+
} catch {
|
|
34302
|
+
return null;
|
|
34303
|
+
}
|
|
34304
|
+
},
|
|
32240
34305
|
setParagraph,
|
|
32241
34306
|
toggleHeading,
|
|
32242
34307
|
toggleBold,
|
|
@@ -32249,6 +34314,7 @@ var useOpenEditorController = ({
|
|
|
32249
34314
|
toggleTaskList,
|
|
32250
34315
|
toggleBlockquote,
|
|
32251
34316
|
toggleCodeBlock,
|
|
34317
|
+
table,
|
|
32252
34318
|
undo: undo2,
|
|
32253
34319
|
redo: redo2,
|
|
32254
34320
|
insertBlock,
|
|
@@ -32266,7 +34332,13 @@ var useOpenEditorController = ({
|
|
|
32266
34332
|
resolveBlockAt,
|
|
32267
34333
|
getRootElement: () => editor?.view.dom ?? null,
|
|
32268
34334
|
setBlockHandleLocked: (locked) => {
|
|
32269
|
-
editor
|
|
34335
|
+
if (!editor || editor.isDestroyed) return;
|
|
34336
|
+
const transaction = editor.state.tr.setMeta("lockDragHandle", locked);
|
|
34337
|
+
if (!locked) {
|
|
34338
|
+
transaction.setMeta(openEditorBlockHandlePluginKey, { targetPos: null });
|
|
34339
|
+
blockInteraction.setActiveBlock(null);
|
|
34340
|
+
}
|
|
34341
|
+
editor.view.dispatch(transaction);
|
|
32270
34342
|
},
|
|
32271
34343
|
isActive: (name, attributes) => editor?.isActive(name, attributes) ?? false,
|
|
32272
34344
|
slashMenuItems,
|
|
@@ -32275,10 +34347,108 @@ var useOpenEditorController = ({
|
|
|
32275
34347
|
attachmentRuntime,
|
|
32276
34348
|
enabledBlocks,
|
|
32277
34349
|
slashState,
|
|
32278
|
-
|
|
34350
|
+
dismissSlashMenu,
|
|
34351
|
+
registerSlashMenuKeyboardHandler: (handler) => {
|
|
34352
|
+
slashKeyboardHandlerRef.current = handler;
|
|
34353
|
+
return () => {
|
|
34354
|
+
if (slashKeyboardHandlerRef.current === handler) {
|
|
34355
|
+
slashKeyboardHandlerRef.current = null;
|
|
34356
|
+
}
|
|
34357
|
+
};
|
|
34358
|
+
}
|
|
32279
34359
|
};
|
|
32280
34360
|
return controller;
|
|
32281
34361
|
};
|
|
34362
|
+
var getScrollTarget = (element) => {
|
|
34363
|
+
let ancestor = element;
|
|
34364
|
+
while (ancestor) {
|
|
34365
|
+
const style2 = getComputedStyle(ancestor);
|
|
34366
|
+
if (/(auto|overlay|scroll)/.test(`${style2.overflow} ${style2.overflowX} ${style2.overflowY}`)) {
|
|
34367
|
+
return ancestor;
|
|
34368
|
+
}
|
|
34369
|
+
ancestor = ancestor.parentElement;
|
|
34370
|
+
}
|
|
34371
|
+
return window;
|
|
34372
|
+
};
|
|
34373
|
+
var OpenEditorBubbleMenu = ({
|
|
34374
|
+
controller,
|
|
34375
|
+
children,
|
|
34376
|
+
className,
|
|
34377
|
+
container,
|
|
34378
|
+
scrollTarget,
|
|
34379
|
+
style: style2
|
|
34380
|
+
}) => {
|
|
34381
|
+
const editor = controller.editor;
|
|
34382
|
+
if (!editor || editor.isDestroyed) return null;
|
|
34383
|
+
const resolvedScrollTarget = scrollTarget ?? getScrollTarget(editor.view.dom);
|
|
34384
|
+
return /* @__PURE__ */ jsx(
|
|
34385
|
+
BubbleMenu2,
|
|
34386
|
+
{
|
|
34387
|
+
appendTo: container ?? void 0,
|
|
34388
|
+
className,
|
|
34389
|
+
editor,
|
|
34390
|
+
options: {
|
|
34391
|
+
placement: "top",
|
|
34392
|
+
offset: 10,
|
|
34393
|
+
flip: { padding: 12 },
|
|
34394
|
+
hide: true,
|
|
34395
|
+
shift: { padding: 12 },
|
|
34396
|
+
scrollTarget: resolvedScrollTarget,
|
|
34397
|
+
strategy: "fixed"
|
|
34398
|
+
},
|
|
34399
|
+
shouldShow: ({ state, from: from2, to }) => state.selection instanceof TextSelection && !state.selection.empty && state.doc.textBetween(from2, to).length > 0,
|
|
34400
|
+
style: style2,
|
|
34401
|
+
children
|
|
34402
|
+
}
|
|
34403
|
+
);
|
|
34404
|
+
};
|
|
34405
|
+
var selectedTableElement = (editor) => {
|
|
34406
|
+
const { $from } = editor.state.selection;
|
|
34407
|
+
for (let depth = $from.depth; depth > 0; depth -= 1) {
|
|
34408
|
+
if ($from.node(depth).type.name !== "table") continue;
|
|
34409
|
+
const dom = editor.view.nodeDOM($from.before(depth));
|
|
34410
|
+
if (!(dom instanceof HTMLElement)) return null;
|
|
34411
|
+
if (dom.matches("table")) return dom;
|
|
34412
|
+
return dom.querySelector("table");
|
|
34413
|
+
}
|
|
34414
|
+
return null;
|
|
34415
|
+
};
|
|
34416
|
+
var OpenEditorTableBubbleMenu = ({
|
|
34417
|
+
controller,
|
|
34418
|
+
children,
|
|
34419
|
+
className,
|
|
34420
|
+
container,
|
|
34421
|
+
style: style2
|
|
34422
|
+
}) => {
|
|
34423
|
+
const editor = controller.editor;
|
|
34424
|
+
const state = useEditorState({
|
|
34425
|
+
editor,
|
|
34426
|
+
selector: ({ editor: currentEditor }) => getOpenEditorTableState(currentEditor)
|
|
34427
|
+
});
|
|
34428
|
+
if (!editor || editor.isDestroyed) return null;
|
|
34429
|
+
return /* @__PURE__ */ jsx(
|
|
34430
|
+
BubbleMenu2,
|
|
34431
|
+
{
|
|
34432
|
+
appendTo: container ?? void 0,
|
|
34433
|
+
className,
|
|
34434
|
+
editor,
|
|
34435
|
+
getReferencedVirtualElement: () => selectedTableElement(editor),
|
|
34436
|
+
options: {
|
|
34437
|
+
placement: "top-start",
|
|
34438
|
+
offset: 8,
|
|
34439
|
+
flip: { padding: 12 },
|
|
34440
|
+
hide: true,
|
|
34441
|
+
shift: { padding: 12 },
|
|
34442
|
+
scrollTarget: getScrollTarget(editor.view.dom),
|
|
34443
|
+
strategy: "fixed"
|
|
34444
|
+
},
|
|
34445
|
+
pluginKey: "openEditorTableBubbleMenu",
|
|
34446
|
+
shouldShow: () => controller.editable && getOpenEditorTableState(editor).active,
|
|
34447
|
+
style: style2,
|
|
34448
|
+
children: children(state ?? getOpenEditorTableState(editor))
|
|
34449
|
+
}
|
|
34450
|
+
);
|
|
34451
|
+
};
|
|
32282
34452
|
var useOpenEditorBlockInteraction = (controller) => useSyncExternalStore$1(
|
|
32283
34453
|
controller.blockInteraction.subscribe,
|
|
32284
34454
|
controller.blockInteraction.getSnapshot,
|
|
@@ -32716,6 +34886,6 @@ var OpenEditorViewer = ({
|
|
|
32716
34886
|
};
|
|
32717
34887
|
var useOpenEditor = useOpenEditorController;
|
|
32718
34888
|
|
|
32719
|
-
export { NodeViewContent, NodeViewWrapper, OpenEditorBlockDragHandle, OpenEditorContent, OpenEditorPageHeader, OpenEditorThemeProvider, OpenEditorViewer, createOpenEditorThemeStyle, defineOpenEditorReactExtension, defineOpenEditorReactNode, formatAttachmentSize, getDefaultBlockPickerItems, getDefaultSlashMenuItems, openEditorThemeTokenNames, sortBlockPickerItems, sortSlashMenuItems, useOpenEditor, useOpenEditorBlockInteraction, useOpenEditorController, useOpenEditorThemeStyle };
|
|
34889
|
+
export { NodeViewContent, NodeViewWrapper, OpenEditorBlockDragHandle, OpenEditorBubbleMenu, OpenEditorContent, OpenEditorPageHeader, OpenEditorTableBubbleMenu, OpenEditorThemeProvider, OpenEditorViewer, canRunOpenEditorTableCommand, createOpenEditorThemeStyle, defineOpenEditorReactExtension, defineOpenEditorReactNode, formatAttachmentSize, getDefaultBlockPickerItems, getDefaultSlashMenuItems, getOpenEditorTableState, openEditorTableCommands, openEditorThemeTokenNames, runOpenEditorTableCommand, sortBlockPickerItems, sortSlashMenuItems, useOpenEditor, useOpenEditorBlockInteraction, useOpenEditorController, useOpenEditorThemeStyle };
|
|
32720
34890
|
//# sourceMappingURL=index.js.map
|
|
32721
34891
|
//# sourceMappingURL=index.js.map
|