@tiptap/core 2.0.0-beta.137 → 2.0.0-beta.140
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/Editor.d.ts +2 -2
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
- package/dist/packages/core/src/types.d.ts +3 -2
- package/dist/tiptap-core.cjs.js +29 -8
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +29 -8
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +29 -8
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/Editor.ts +2 -1
- package/src/ExtensionManager.ts +3 -2
- package/src/NodeView.ts +6 -1
- package/src/commands/insertContentAt.ts +13 -6
- package/src/helpers/isExtensionRulesEnabled.ts +15 -0
- package/src/types.ts +4 -2
package/dist/tiptap-core.umd.js
CHANGED
|
@@ -641,6 +641,9 @@
|
|
|
641
641
|
tr.setSelection(prosemirrorState.Selection.near(tr.doc.resolve(end), bias));
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
+
const isFragment = (nodeOrFragment) => {
|
|
645
|
+
return nodeOrFragment.toString().startsWith('<');
|
|
646
|
+
};
|
|
644
647
|
const insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) => {
|
|
645
648
|
if (dispatch) {
|
|
646
649
|
options = {
|
|
@@ -662,7 +665,10 @@
|
|
|
662
665
|
? { from: position, to: position }
|
|
663
666
|
: position;
|
|
664
667
|
let isOnlyBlockContent = true;
|
|
665
|
-
|
|
668
|
+
const nodes = isFragment(content)
|
|
669
|
+
? content
|
|
670
|
+
: [content];
|
|
671
|
+
nodes.forEach(node => {
|
|
666
672
|
isOnlyBlockContent = isOnlyBlockContent
|
|
667
673
|
? node.isBlock
|
|
668
674
|
: false;
|
|
@@ -673,10 +679,10 @@
|
|
|
673
679
|
// replace an empty paragraph by an inserted image
|
|
674
680
|
// instead of inserting the image below the paragraph
|
|
675
681
|
if (from === to && isOnlyBlockContent) {
|
|
676
|
-
const
|
|
677
|
-
const isEmptyTextBlock =
|
|
678
|
-
&&
|
|
679
|
-
&&
|
|
682
|
+
const { parent } = tr.doc.resolve(from);
|
|
683
|
+
const isEmptyTextBlock = parent.isTextblock
|
|
684
|
+
&& !parent.type.spec.code
|
|
685
|
+
&& !parent.childCount;
|
|
680
686
|
if (isEmptyTextBlock) {
|
|
681
687
|
from -= 1;
|
|
682
688
|
to += 1;
|
|
@@ -2664,6 +2670,18 @@
|
|
|
2664
2670
|
return schema.nodes[name] || schema.marks[name] || null;
|
|
2665
2671
|
}
|
|
2666
2672
|
|
|
2673
|
+
function isExtensionRulesEnabled(extension, enabled) {
|
|
2674
|
+
if (Array.isArray(enabled)) {
|
|
2675
|
+
return enabled.some(enabledExtension => {
|
|
2676
|
+
const name = typeof enabledExtension === 'string'
|
|
2677
|
+
? enabledExtension
|
|
2678
|
+
: enabledExtension.name;
|
|
2679
|
+
return name === extension.name;
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
return enabled;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2667
2685
|
function findDuplicates(items) {
|
|
2668
2686
|
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
2669
2687
|
return [...new Set(filtered)];
|
|
@@ -2818,11 +2836,11 @@
|
|
|
2818
2836
|
plugins.push(keyMapPlugin);
|
|
2819
2837
|
}
|
|
2820
2838
|
const addInputRules = getExtensionField(extension, 'addInputRules', context);
|
|
2821
|
-
if (editor.options.enableInputRules && addInputRules) {
|
|
2839
|
+
if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
|
|
2822
2840
|
inputRules.push(...addInputRules());
|
|
2823
2841
|
}
|
|
2824
2842
|
const addPasteRules = getExtensionField(extension, 'addPasteRules', context);
|
|
2825
|
-
if (editor.options.enablePasteRules && addPasteRules) {
|
|
2843
|
+
if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
|
|
2826
2844
|
pasteRules.push(...addPasteRules());
|
|
2827
2845
|
}
|
|
2828
2846
|
const addProseMirrorPlugins = getExtensionField(extension, 'addProseMirrorPlugins', context);
|
|
@@ -3620,7 +3638,10 @@ img.ProseMirror-separator {
|
|
|
3620
3638
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
3621
3639
|
// this will lead to a re-render of the node view on enter
|
|
3622
3640
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
3623
|
-
if (this.dom.contains(mutation.target)
|
|
3641
|
+
if (this.dom.contains(mutation.target)
|
|
3642
|
+
&& mutation.type === 'childList'
|
|
3643
|
+
&& isiOS()
|
|
3644
|
+
&& this.editor.isFocused) {
|
|
3624
3645
|
const changedNodes = [
|
|
3625
3646
|
...Array.from(mutation.addedNodes),
|
|
3626
3647
|
...Array.from(mutation.removedNodes),
|