@tiptap/core 2.0.0-beta.175 → 2.0.0-beta.176
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/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +3 -0
- package/dist/packages/core/src/index.d.ts +1 -0
- package/dist/packages/core/src/types.d.ts +2 -0
- package/dist/packages/core/src/utilities/createStyleTag.d.ts +1 -1
- package/dist/tiptap-core.cjs.js +24 -12
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +24 -13
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +24 -12
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/Editor.ts +4 -3
- package/src/NodeView.ts +6 -2
- package/src/extensions/clipboardTextSerializer.ts +2 -2
- package/src/helpers/generateText.ts +2 -2
- package/src/helpers/getMarkRange.ts +6 -2
- package/src/helpers/getTextBetween.ts +1 -0
- package/src/helpers/{getTextSeralizersFromSchema.ts → getTextSerializersFromSchema.ts} +1 -1
- package/src/index.ts +1 -0
- package/src/types.ts +2 -0
- package/src/utilities/createStyleTag.ts +5 -1
- package/dist/packages/core/src/helpers/getTextSeralizersFromSchema.d.ts +0 -3
package/dist/tiptap-core.esm.js
CHANGED
|
@@ -157,6 +157,7 @@ function getTextBetween(startNode, range, options) {
|
|
|
157
157
|
pos,
|
|
158
158
|
parent,
|
|
159
159
|
index,
|
|
160
|
+
range,
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
163
|
else if (node.isText) {
|
|
@@ -171,7 +172,7 @@ function getTextBetween(startNode, range, options) {
|
|
|
171
172
|
return text;
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
function
|
|
175
|
+
function getTextSerializersFromSchema(schema) {
|
|
175
176
|
return Object.fromEntries(Object
|
|
176
177
|
.entries(schema.nodes)
|
|
177
178
|
.filter(([, node]) => node.spec.toText)
|
|
@@ -192,7 +193,7 @@ const ClipboardTextSerializer = Extension.create({
|
|
|
192
193
|
const { ranges } = selection;
|
|
193
194
|
const from = Math.min(...ranges.map(range => range.$from.pos));
|
|
194
195
|
const to = Math.max(...ranges.map(range => range.$to.pos));
|
|
195
|
-
const textSerializers =
|
|
196
|
+
const textSerializers = getTextSerializersFromSchema(schema);
|
|
196
197
|
const range = { from, to };
|
|
197
198
|
return getTextBetween(doc, range, {
|
|
198
199
|
textSerializers,
|
|
@@ -404,7 +405,10 @@ function getMarkRange($pos, type, attributes = {}) {
|
|
|
404
405
|
if (!$pos || !type) {
|
|
405
406
|
return;
|
|
406
407
|
}
|
|
407
|
-
|
|
408
|
+
let start = $pos.parent.childAfter($pos.parentOffset);
|
|
409
|
+
if ($pos.parentOffset === start.offset && start.offset !== 0) {
|
|
410
|
+
start = $pos.parent.childBefore($pos.parentOffset);
|
|
411
|
+
}
|
|
408
412
|
if (!start.node) {
|
|
409
413
|
return;
|
|
410
414
|
}
|
|
@@ -412,7 +416,7 @@ function getMarkRange($pos, type, attributes = {}) {
|
|
|
412
416
|
if (!mark) {
|
|
413
417
|
return;
|
|
414
418
|
}
|
|
415
|
-
let startIndex =
|
|
419
|
+
let startIndex = start.index;
|
|
416
420
|
let startPos = $pos.start() + start.offset;
|
|
417
421
|
let endIndex = startIndex + 1;
|
|
418
422
|
let endPos = startPos + start.node.nodeSize;
|
|
@@ -2256,12 +2260,15 @@ function isNodeEmpty(node) {
|
|
|
2256
2260
|
return JSON.stringify(defaultContent) === JSON.stringify(content);
|
|
2257
2261
|
}
|
|
2258
2262
|
|
|
2259
|
-
function createStyleTag(style) {
|
|
2263
|
+
function createStyleTag(style, nonce) {
|
|
2260
2264
|
const tipTapStyleTag = document.querySelector('style[data-tiptap-style]');
|
|
2261
2265
|
if (tipTapStyleTag !== null) {
|
|
2262
2266
|
return tipTapStyleTag;
|
|
2263
2267
|
}
|
|
2264
2268
|
const styleNode = document.createElement('style');
|
|
2269
|
+
if (nonce) {
|
|
2270
|
+
styleNode.setAttribute('nonce', nonce);
|
|
2271
|
+
}
|
|
2265
2272
|
styleNode.setAttribute('data-tiptap-style', '');
|
|
2266
2273
|
styleNode.innerHTML = style;
|
|
2267
2274
|
document.getElementsByTagName('head')[0].appendChild(styleNode);
|
|
@@ -3217,6 +3224,7 @@ class Editor extends EventEmitter {
|
|
|
3217
3224
|
element: document.createElement('div'),
|
|
3218
3225
|
content: '',
|
|
3219
3226
|
injectCSS: true,
|
|
3227
|
+
injectNonce: undefined,
|
|
3220
3228
|
extensions: [],
|
|
3221
3229
|
autofocus: false,
|
|
3222
3230
|
editable: true,
|
|
@@ -3288,7 +3296,7 @@ class Editor extends EventEmitter {
|
|
|
3288
3296
|
*/
|
|
3289
3297
|
injectCSS() {
|
|
3290
3298
|
if (this.options.injectCSS && document) {
|
|
3291
|
-
this.css = createStyleTag(style);
|
|
3299
|
+
this.css = createStyleTag(style, this.options.injectNonce);
|
|
3292
3300
|
}
|
|
3293
3301
|
}
|
|
3294
3302
|
/**
|
|
@@ -3519,7 +3527,7 @@ class Editor extends EventEmitter {
|
|
|
3519
3527
|
blockSeparator,
|
|
3520
3528
|
textSerializers: {
|
|
3521
3529
|
...textSerializers,
|
|
3522
|
-
...
|
|
3530
|
+
...getTextSerializersFromSchema(this.schema),
|
|
3523
3531
|
},
|
|
3524
3532
|
});
|
|
3525
3533
|
}
|
|
@@ -3715,7 +3723,7 @@ class NodeView {
|
|
|
3715
3723
|
return null;
|
|
3716
3724
|
}
|
|
3717
3725
|
onDragStart(event) {
|
|
3718
|
-
var _a, _b, _c;
|
|
3726
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3719
3727
|
const { view } = this.editor;
|
|
3720
3728
|
const target = event.target;
|
|
3721
3729
|
// get the drag handle element
|
|
@@ -3734,10 +3742,13 @@ class NodeView {
|
|
|
3734
3742
|
if (this.dom !== dragHandle) {
|
|
3735
3743
|
const domBox = this.dom.getBoundingClientRect();
|
|
3736
3744
|
const handleBox = dragHandle.getBoundingClientRect();
|
|
3737
|
-
|
|
3738
|
-
|
|
3745
|
+
// In React, we have to go through nativeEvent to reach offsetX/offsetY.
|
|
3746
|
+
const offsetX = (_c = event.offsetX) !== null && _c !== void 0 ? _c : (_d = event.nativeEvent) === null || _d === void 0 ? void 0 : _d.offsetX;
|
|
3747
|
+
const offsetY = (_e = event.offsetY) !== null && _e !== void 0 ? _e : (_f = event.nativeEvent) === null || _f === void 0 ? void 0 : _f.offsetY;
|
|
3748
|
+
x = handleBox.x - domBox.x + offsetX;
|
|
3749
|
+
y = handleBox.y - domBox.y + offsetY;
|
|
3739
3750
|
}
|
|
3740
|
-
(
|
|
3751
|
+
(_g = event.dataTransfer) === null || _g === void 0 ? void 0 : _g.setDragImage(this.dom, x, y);
|
|
3741
3752
|
// we need to tell ProseMirror that we want to move the whole node
|
|
3742
3753
|
// so we create a NodeSelection
|
|
3743
3754
|
const selection = NodeSelection.create(view.state.doc, this.getPos());
|
|
@@ -4255,7 +4266,7 @@ function generateText(doc, extensions, options) {
|
|
|
4255
4266
|
blockSeparator,
|
|
4256
4267
|
textSerializers: {
|
|
4257
4268
|
...textSerializers,
|
|
4258
|
-
...
|
|
4269
|
+
...getTextSerializersFromSchema(schema),
|
|
4259
4270
|
},
|
|
4260
4271
|
});
|
|
4261
4272
|
}
|
|
@@ -4410,5 +4421,5 @@ function posToDOMRect(view, from, to) {
|
|
|
4410
4421
|
};
|
|
4411
4422
|
}
|
|
4412
4423
|
|
|
4413
|
-
export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, defaultBlockAt, escapeForRegEx, extensions, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, inputRulesPlugin, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, markInputRule, markPasteRule, mergeAttributes, nodeInputRule, pasteRulesPlugin, posToDOMRect, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
4424
|
+
export { CommandManager, Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, combineTransactionSteps, defaultBlockAt, escapeForRegEx, extensions, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAttributes, getNodeType, getSchema, getText, getTextBetween, getTextSerializersFromSchema, inputRulesPlugin, isActive, isList, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isTextSelection, markInputRule, markPasteRule, mergeAttributes, nodeInputRule, pasteRulesPlugin, posToDOMRect, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
4414
4425
|
//# sourceMappingURL=tiptap-core.esm.js.map
|