@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.umd.js
CHANGED
|
@@ -155,6 +155,7 @@
|
|
|
155
155
|
pos,
|
|
156
156
|
parent,
|
|
157
157
|
index,
|
|
158
|
+
range,
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
161
|
else if (node.isText) {
|
|
@@ -169,7 +170,7 @@
|
|
|
169
170
|
return text;
|
|
170
171
|
}
|
|
171
172
|
|
|
172
|
-
function
|
|
173
|
+
function getTextSerializersFromSchema(schema) {
|
|
173
174
|
return Object.fromEntries(Object
|
|
174
175
|
.entries(schema.nodes)
|
|
175
176
|
.filter(([, node]) => node.spec.toText)
|
|
@@ -190,7 +191,7 @@
|
|
|
190
191
|
const { ranges } = selection;
|
|
191
192
|
const from = Math.min(...ranges.map(range => range.$from.pos));
|
|
192
193
|
const to = Math.max(...ranges.map(range => range.$to.pos));
|
|
193
|
-
const textSerializers =
|
|
194
|
+
const textSerializers = getTextSerializersFromSchema(schema);
|
|
194
195
|
const range = { from, to };
|
|
195
196
|
return getTextBetween(doc, range, {
|
|
196
197
|
textSerializers,
|
|
@@ -402,7 +403,10 @@
|
|
|
402
403
|
if (!$pos || !type) {
|
|
403
404
|
return;
|
|
404
405
|
}
|
|
405
|
-
|
|
406
|
+
let start = $pos.parent.childAfter($pos.parentOffset);
|
|
407
|
+
if ($pos.parentOffset === start.offset && start.offset !== 0) {
|
|
408
|
+
start = $pos.parent.childBefore($pos.parentOffset);
|
|
409
|
+
}
|
|
406
410
|
if (!start.node) {
|
|
407
411
|
return;
|
|
408
412
|
}
|
|
@@ -410,7 +414,7 @@
|
|
|
410
414
|
if (!mark) {
|
|
411
415
|
return;
|
|
412
416
|
}
|
|
413
|
-
let startIndex =
|
|
417
|
+
let startIndex = start.index;
|
|
414
418
|
let startPos = $pos.start() + start.offset;
|
|
415
419
|
let endIndex = startIndex + 1;
|
|
416
420
|
let endPos = startPos + start.node.nodeSize;
|
|
@@ -2254,12 +2258,15 @@
|
|
|
2254
2258
|
return JSON.stringify(defaultContent) === JSON.stringify(content);
|
|
2255
2259
|
}
|
|
2256
2260
|
|
|
2257
|
-
function createStyleTag(style) {
|
|
2261
|
+
function createStyleTag(style, nonce) {
|
|
2258
2262
|
const tipTapStyleTag = document.querySelector('style[data-tiptap-style]');
|
|
2259
2263
|
if (tipTapStyleTag !== null) {
|
|
2260
2264
|
return tipTapStyleTag;
|
|
2261
2265
|
}
|
|
2262
2266
|
const styleNode = document.createElement('style');
|
|
2267
|
+
if (nonce) {
|
|
2268
|
+
styleNode.setAttribute('nonce', nonce);
|
|
2269
|
+
}
|
|
2263
2270
|
styleNode.setAttribute('data-tiptap-style', '');
|
|
2264
2271
|
styleNode.innerHTML = style;
|
|
2265
2272
|
document.getElementsByTagName('head')[0].appendChild(styleNode);
|
|
@@ -3215,6 +3222,7 @@ img.ProseMirror-separator {
|
|
|
3215
3222
|
element: document.createElement('div'),
|
|
3216
3223
|
content: '',
|
|
3217
3224
|
injectCSS: true,
|
|
3225
|
+
injectNonce: undefined,
|
|
3218
3226
|
extensions: [],
|
|
3219
3227
|
autofocus: false,
|
|
3220
3228
|
editable: true,
|
|
@@ -3286,7 +3294,7 @@ img.ProseMirror-separator {
|
|
|
3286
3294
|
*/
|
|
3287
3295
|
injectCSS() {
|
|
3288
3296
|
if (this.options.injectCSS && document) {
|
|
3289
|
-
this.css = createStyleTag(style);
|
|
3297
|
+
this.css = createStyleTag(style, this.options.injectNonce);
|
|
3290
3298
|
}
|
|
3291
3299
|
}
|
|
3292
3300
|
/**
|
|
@@ -3517,7 +3525,7 @@ img.ProseMirror-separator {
|
|
|
3517
3525
|
blockSeparator,
|
|
3518
3526
|
textSerializers: {
|
|
3519
3527
|
...textSerializers,
|
|
3520
|
-
...
|
|
3528
|
+
...getTextSerializersFromSchema(this.schema),
|
|
3521
3529
|
},
|
|
3522
3530
|
});
|
|
3523
3531
|
}
|
|
@@ -3713,7 +3721,7 @@ img.ProseMirror-separator {
|
|
|
3713
3721
|
return null;
|
|
3714
3722
|
}
|
|
3715
3723
|
onDragStart(event) {
|
|
3716
|
-
var _a, _b, _c;
|
|
3724
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
3717
3725
|
const { view } = this.editor;
|
|
3718
3726
|
const target = event.target;
|
|
3719
3727
|
// get the drag handle element
|
|
@@ -3732,10 +3740,13 @@ img.ProseMirror-separator {
|
|
|
3732
3740
|
if (this.dom !== dragHandle) {
|
|
3733
3741
|
const domBox = this.dom.getBoundingClientRect();
|
|
3734
3742
|
const handleBox = dragHandle.getBoundingClientRect();
|
|
3735
|
-
|
|
3736
|
-
|
|
3743
|
+
// In React, we have to go through nativeEvent to reach offsetX/offsetY.
|
|
3744
|
+
const offsetX = (_c = event.offsetX) !== null && _c !== void 0 ? _c : (_d = event.nativeEvent) === null || _d === void 0 ? void 0 : _d.offsetX;
|
|
3745
|
+
const offsetY = (_e = event.offsetY) !== null && _e !== void 0 ? _e : (_f = event.nativeEvent) === null || _f === void 0 ? void 0 : _f.offsetY;
|
|
3746
|
+
x = handleBox.x - domBox.x + offsetX;
|
|
3747
|
+
y = handleBox.y - domBox.y + offsetY;
|
|
3737
3748
|
}
|
|
3738
|
-
(
|
|
3749
|
+
(_g = event.dataTransfer) === null || _g === void 0 ? void 0 : _g.setDragImage(this.dom, x, y);
|
|
3739
3750
|
// we need to tell ProseMirror that we want to move the whole node
|
|
3740
3751
|
// so we create a NodeSelection
|
|
3741
3752
|
const selection = prosemirrorState.NodeSelection.create(view.state.doc, this.getPos());
|
|
@@ -4253,7 +4264,7 @@ img.ProseMirror-separator {
|
|
|
4253
4264
|
blockSeparator,
|
|
4254
4265
|
textSerializers: {
|
|
4255
4266
|
...textSerializers,
|
|
4256
|
-
...
|
|
4267
|
+
...getTextSerializersFromSchema(schema),
|
|
4257
4268
|
},
|
|
4258
4269
|
});
|
|
4259
4270
|
}
|
|
@@ -4443,6 +4454,7 @@ img.ProseMirror-separator {
|
|
|
4443
4454
|
exports.getSchema = getSchema;
|
|
4444
4455
|
exports.getText = getText;
|
|
4445
4456
|
exports.getTextBetween = getTextBetween;
|
|
4457
|
+
exports.getTextSerializersFromSchema = getTextSerializersFromSchema;
|
|
4446
4458
|
exports.inputRulesPlugin = inputRulesPlugin;
|
|
4447
4459
|
exports.isActive = isActive;
|
|
4448
4460
|
exports.isList = isList;
|