@tiptap/core 3.21.0 → 3.22.1
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/dist/index.cjs +66 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +62 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/NodeView.ts +10 -1
- package/src/__tests__/htmlEntities.test.ts +55 -0
- package/src/commands/extendMarkRange.ts +3 -2
- package/src/extensions/delete.ts +2 -1
- package/src/helpers/getMarkRange.ts +7 -2
- package/src/lib/ResizableNodeView.ts +1 -1
- package/src/utilities/htmlEntities.ts +26 -0
- package/src/utilities/index.ts +2 -0
- package/src/utilities/nodeViewPositionRegistry.ts +70 -0
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
Tracker: () => Tracker,
|
|
39
39
|
callOrReturn: () => callOrReturn,
|
|
40
40
|
canInsertNode: () => canInsertNode,
|
|
41
|
+
cancelPositionCheck: () => cancelPositionCheck,
|
|
41
42
|
combineTransactionSteps: () => combineTransactionSteps,
|
|
42
43
|
commands: () => commands_exports,
|
|
43
44
|
createAtomBlockMarkdownSpec: () => createAtomBlockMarkdownSpec,
|
|
@@ -49,9 +50,11 @@ __export(index_exports, {
|
|
|
49
50
|
createMappablePosition: () => createMappablePosition,
|
|
50
51
|
createNodeFromContent: () => createNodeFromContent,
|
|
51
52
|
createStyleTag: () => createStyleTag,
|
|
53
|
+
decodeHtmlEntities: () => decodeHtmlEntities,
|
|
52
54
|
defaultBlockAt: () => defaultBlockAt,
|
|
53
55
|
deleteProps: () => deleteProps,
|
|
54
56
|
elementFromString: () => elementFromString,
|
|
57
|
+
encodeHtmlEntities: () => encodeHtmlEntities,
|
|
55
58
|
escapeForRegEx: () => escapeForRegEx,
|
|
56
59
|
extensions: () => extensions_exports,
|
|
57
60
|
findChildren: () => findChildren,
|
|
@@ -130,6 +133,7 @@ __export(index_exports, {
|
|
|
130
133
|
resolveExtensions: () => resolveExtensions,
|
|
131
134
|
resolveFocusPosition: () => resolveFocusPosition,
|
|
132
135
|
rewriteUnknownContent: () => rewriteUnknownContent,
|
|
136
|
+
schedulePositionCheck: () => schedulePositionCheck,
|
|
133
137
|
selectionToInsertionEnd: () => selectionToInsertionEnd,
|
|
134
138
|
serializeAttributes: () => serializeAttributes,
|
|
135
139
|
sortExtensions: () => sortExtensions,
|
|
@@ -535,7 +539,6 @@ function isMarkInSet(marks, type, attributes = {}) {
|
|
|
535
539
|
return !!findMarkInSet(marks, type, attributes);
|
|
536
540
|
}
|
|
537
541
|
function getMarkRange($pos, type, attributes) {
|
|
538
|
-
var _a;
|
|
539
542
|
if (!$pos || !type) {
|
|
540
543
|
return;
|
|
541
544
|
}
|
|
@@ -546,7 +549,12 @@ function getMarkRange($pos, type, attributes) {
|
|
|
546
549
|
if (!start.node || !start.node.marks.some((mark2) => mark2.type === type)) {
|
|
547
550
|
return;
|
|
548
551
|
}
|
|
549
|
-
|
|
552
|
+
if (!attributes) {
|
|
553
|
+
const firstMark = start.node.marks.find((mark2) => mark2.type === type);
|
|
554
|
+
if (firstMark) {
|
|
555
|
+
attributes = firstMark.attrs;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
550
558
|
const mark = findMarkInSet([...start.node.marks], type, attributes);
|
|
551
559
|
if (!mark) {
|
|
552
560
|
return;
|
|
@@ -581,7 +589,7 @@ function getMarkType(nameOrType, schema) {
|
|
|
581
589
|
}
|
|
582
590
|
|
|
583
591
|
// src/commands/extendMarkRange.ts
|
|
584
|
-
var extendMarkRange = (typeOrName, attributes
|
|
592
|
+
var extendMarkRange = (typeOrName, attributes) => ({ tr, state, dispatch }) => {
|
|
585
593
|
const type = getMarkType(typeOrName, state.schema);
|
|
586
594
|
const { doc, selection } = tr;
|
|
587
595
|
const { $from, from, to } = selection;
|
|
@@ -4150,7 +4158,7 @@ var Delete = Extension.create({
|
|
|
4150
4158
|
const newEnd = mapping.slice(index).map(step.to);
|
|
4151
4159
|
const oldStart = mapping.invert().map(newStart, -1);
|
|
4152
4160
|
const oldEnd = mapping.invert().map(newEnd);
|
|
4153
|
-
const foundBeforeMark = (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark));
|
|
4161
|
+
const foundBeforeMark = newStart > 0 ? (_a3 = nextTransaction.doc.nodeAt(newStart - 1)) == null ? void 0 : _a3.marks.some((mark) => mark.eq(step.mark)) : false;
|
|
4154
4162
|
const foundAfterMark = (_b3 = nextTransaction.doc.nodeAt(newEnd)) == null ? void 0 : _b3.marks.some((mark) => mark.eq(step.mark));
|
|
4155
4163
|
this.editor.emit("delete", {
|
|
4156
4164
|
type: "mark",
|
|
@@ -5724,7 +5732,7 @@ var ResizableNodeView = class {
|
|
|
5724
5732
|
const element = document.createElement("div");
|
|
5725
5733
|
element.dataset.resizeContainer = "";
|
|
5726
5734
|
element.dataset.node = this.node.type.name;
|
|
5727
|
-
element.style.display = "flex";
|
|
5735
|
+
element.style.display = this.node.type.isInline ? "inline-flex" : "flex";
|
|
5728
5736
|
if (this.classNames.container) {
|
|
5729
5737
|
element.className = this.classNames.container;
|
|
5730
5738
|
}
|
|
@@ -6075,6 +6083,14 @@ function escapeForRegEx(string) {
|
|
|
6075
6083
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
6076
6084
|
}
|
|
6077
6085
|
|
|
6086
|
+
// src/utilities/htmlEntities.ts
|
|
6087
|
+
function decodeHtmlEntities(text) {
|
|
6088
|
+
return text.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
|
|
6089
|
+
}
|
|
6090
|
+
function encodeHtmlEntities(text) {
|
|
6091
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
6092
|
+
}
|
|
6093
|
+
|
|
6078
6094
|
// src/utilities/isFirefox.ts
|
|
6079
6095
|
function isFirefox() {
|
|
6080
6096
|
return typeof navigator !== "undefined" ? /Firefox/.test(navigator.userAgent) : false;
|
|
@@ -6578,6 +6594,45 @@ ${indentedChild}`;
|
|
|
6578
6594
|
return output;
|
|
6579
6595
|
}
|
|
6580
6596
|
|
|
6597
|
+
// src/utilities/nodeViewPositionRegistry.ts
|
|
6598
|
+
var positionUpdateRegistries = /* @__PURE__ */ new WeakMap();
|
|
6599
|
+
function schedulePositionCheck(editor, callback) {
|
|
6600
|
+
let registry = positionUpdateRegistries.get(editor);
|
|
6601
|
+
if (!registry) {
|
|
6602
|
+
const newRegistry = {
|
|
6603
|
+
callbacks: /* @__PURE__ */ new Set(),
|
|
6604
|
+
rafId: null,
|
|
6605
|
+
handler: () => {
|
|
6606
|
+
if (newRegistry.rafId !== null) {
|
|
6607
|
+
cancelAnimationFrame(newRegistry.rafId);
|
|
6608
|
+
}
|
|
6609
|
+
newRegistry.rafId = requestAnimationFrame(() => {
|
|
6610
|
+
newRegistry.rafId = null;
|
|
6611
|
+
newRegistry.callbacks.forEach((cb) => cb());
|
|
6612
|
+
});
|
|
6613
|
+
}
|
|
6614
|
+
};
|
|
6615
|
+
positionUpdateRegistries.set(editor, newRegistry);
|
|
6616
|
+
editor.on("update", newRegistry.handler);
|
|
6617
|
+
registry = newRegistry;
|
|
6618
|
+
}
|
|
6619
|
+
registry.callbacks.add(callback);
|
|
6620
|
+
}
|
|
6621
|
+
function cancelPositionCheck(editor, callback) {
|
|
6622
|
+
const registry = positionUpdateRegistries.get(editor);
|
|
6623
|
+
if (!registry) {
|
|
6624
|
+
return;
|
|
6625
|
+
}
|
|
6626
|
+
registry.callbacks.delete(callback);
|
|
6627
|
+
if (registry.callbacks.size === 0) {
|
|
6628
|
+
if (registry.rafId !== null) {
|
|
6629
|
+
cancelAnimationFrame(registry.rafId);
|
|
6630
|
+
}
|
|
6631
|
+
editor.off("update", registry.handler);
|
|
6632
|
+
positionUpdateRegistries.delete(editor);
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
|
|
6581
6636
|
// src/MarkView.ts
|
|
6582
6637
|
function updateMarkViewAttributes(checkMark, editor, attrs = {}) {
|
|
6583
6638
|
const { state } = editor;
|
|
@@ -6784,6 +6839,7 @@ var NodeView = class {
|
|
|
6784
6839
|
return false;
|
|
6785
6840
|
}
|
|
6786
6841
|
const isDragEvent = event.type.startsWith("drag");
|
|
6842
|
+
const isDragOverEnterEvent = event.type === "dragover" || event.type === "dragenter";
|
|
6787
6843
|
const isDropEvent = event.type === "drop";
|
|
6788
6844
|
const isInput = ["INPUT", "BUTTON", "SELECT", "TEXTAREA"].includes(target.tagName) || target.isContentEditable;
|
|
6789
6845
|
if (isInput && !isDropEvent && !isDragEvent) {
|
|
@@ -6832,7 +6888,7 @@ var NodeView = class {
|
|
|
6832
6888
|
);
|
|
6833
6889
|
}
|
|
6834
6890
|
}
|
|
6835
|
-
if (isDragging || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
6891
|
+
if (isDragging || isDragOverEnterEvent || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) {
|
|
6836
6892
|
return false;
|
|
6837
6893
|
}
|
|
6838
6894
|
return true;
|
|
@@ -7021,6 +7077,7 @@ var Tracker = class {
|
|
|
7021
7077
|
Tracker,
|
|
7022
7078
|
callOrReturn,
|
|
7023
7079
|
canInsertNode,
|
|
7080
|
+
cancelPositionCheck,
|
|
7024
7081
|
combineTransactionSteps,
|
|
7025
7082
|
commands,
|
|
7026
7083
|
createAtomBlockMarkdownSpec,
|
|
@@ -7032,9 +7089,11 @@ var Tracker = class {
|
|
|
7032
7089
|
createMappablePosition,
|
|
7033
7090
|
createNodeFromContent,
|
|
7034
7091
|
createStyleTag,
|
|
7092
|
+
decodeHtmlEntities,
|
|
7035
7093
|
defaultBlockAt,
|
|
7036
7094
|
deleteProps,
|
|
7037
7095
|
elementFromString,
|
|
7096
|
+
encodeHtmlEntities,
|
|
7038
7097
|
escapeForRegEx,
|
|
7039
7098
|
extensions,
|
|
7040
7099
|
findChildren,
|
|
@@ -7113,6 +7172,7 @@ var Tracker = class {
|
|
|
7113
7172
|
resolveExtensions,
|
|
7114
7173
|
resolveFocusPosition,
|
|
7115
7174
|
rewriteUnknownContent,
|
|
7175
|
+
schedulePositionCheck,
|
|
7116
7176
|
selectionToInsertionEnd,
|
|
7117
7177
|
serializeAttributes,
|
|
7118
7178
|
sortExtensions,
|