@tiptap/core 2.0.0-beta.139 → 2.0.0-beta.142
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/defaultBlockAt.d.ts +2 -0
- package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +2 -0
- package/dist/packages/core/src/index.d.ts +1 -0
- package/dist/packages/core/src/style.d.ts +1 -1
- package/dist/packages/core/src/types.d.ts +4 -3
- package/dist/tiptap-core.cjs.js +39 -6
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +39 -7
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +39 -6
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/ExtensionManager.ts +3 -2
- package/src/NodeView.ts +6 -1
- package/src/commands/focus.ts +9 -2
- package/src/helpers/defaultBlockAt.ts +13 -0
- package/src/helpers/isExtensionRulesEnabled.ts +15 -0
- package/src/index.ts +1 -0
- package/src/style.ts +1 -0
- package/src/types.ts +5 -3
package/dist/tiptap-core.esm.js
CHANGED
|
@@ -509,13 +509,19 @@ function resolveSelection(state, position = null) {
|
|
|
509
509
|
to: 0,
|
|
510
510
|
};
|
|
511
511
|
}
|
|
512
|
+
const { size } = state.doc.content;
|
|
512
513
|
if (position === 'end') {
|
|
513
|
-
const { size } = state.doc.content;
|
|
514
514
|
return {
|
|
515
515
|
from: size,
|
|
516
516
|
to: size,
|
|
517
517
|
};
|
|
518
518
|
}
|
|
519
|
+
if (position === 'all') {
|
|
520
|
+
return {
|
|
521
|
+
from: 0,
|
|
522
|
+
to: size,
|
|
523
|
+
};
|
|
524
|
+
}
|
|
519
525
|
return {
|
|
520
526
|
from: position,
|
|
521
527
|
to: position,
|
|
@@ -1173,7 +1179,7 @@ function getSplittedAttributes(extensionAttributes, typeName, attributes) {
|
|
|
1173
1179
|
}));
|
|
1174
1180
|
}
|
|
1175
1181
|
|
|
1176
|
-
function defaultBlockAt(match) {
|
|
1182
|
+
function defaultBlockAt$1(match) {
|
|
1177
1183
|
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
1178
1184
|
const { type } = match.edge(i);
|
|
1179
1185
|
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
@@ -1217,7 +1223,7 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
|
|
|
1217
1223
|
}
|
|
1218
1224
|
const deflt = $from.depth === 0
|
|
1219
1225
|
? undefined
|
|
1220
|
-
: defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1226
|
+
: defaultBlockAt$1($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1221
1227
|
let types = atEnd && deflt
|
|
1222
1228
|
? [{
|
|
1223
1229
|
type: deflt,
|
|
@@ -2672,6 +2678,18 @@ function getSchemaTypeByName(name, schema) {
|
|
|
2672
2678
|
return schema.nodes[name] || schema.marks[name] || null;
|
|
2673
2679
|
}
|
|
2674
2680
|
|
|
2681
|
+
function isExtensionRulesEnabled(extension, enabled) {
|
|
2682
|
+
if (Array.isArray(enabled)) {
|
|
2683
|
+
return enabled.some(enabledExtension => {
|
|
2684
|
+
const name = typeof enabledExtension === 'string'
|
|
2685
|
+
? enabledExtension
|
|
2686
|
+
: enabledExtension.name;
|
|
2687
|
+
return name === extension.name;
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2690
|
+
return enabled;
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2675
2693
|
function findDuplicates(items) {
|
|
2676
2694
|
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
2677
2695
|
return [...new Set(filtered)];
|
|
@@ -2826,11 +2844,11 @@ class ExtensionManager {
|
|
|
2826
2844
|
plugins.push(keyMapPlugin);
|
|
2827
2845
|
}
|
|
2828
2846
|
const addInputRules = getExtensionField(extension, 'addInputRules', context);
|
|
2829
|
-
if (editor.options.enableInputRules && addInputRules) {
|
|
2847
|
+
if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
|
|
2830
2848
|
inputRules.push(...addInputRules());
|
|
2831
2849
|
}
|
|
2832
2850
|
const addPasteRules = getExtensionField(extension, 'addPasteRules', context);
|
|
2833
|
-
if (editor.options.enablePasteRules && addPasteRules) {
|
|
2851
|
+
if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
|
|
2834
2852
|
pasteRules.push(...addPasteRules());
|
|
2835
2853
|
}
|
|
2836
2854
|
const addProseMirrorPlugins = getExtensionField(extension, 'addProseMirrorPlugins', context);
|
|
@@ -2962,6 +2980,7 @@ img.ProseMirror-separator {
|
|
|
2962
2980
|
display: none;
|
|
2963
2981
|
pointer-events: none;
|
|
2964
2982
|
position: absolute;
|
|
2983
|
+
margin: 0;
|
|
2965
2984
|
}
|
|
2966
2985
|
|
|
2967
2986
|
.ProseMirror-gapcursor:after {
|
|
@@ -3628,7 +3647,10 @@ class NodeView {
|
|
|
3628
3647
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
3629
3648
|
// this will lead to a re-render of the node view on enter
|
|
3630
3649
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
3631
|
-
if (this.dom.contains(mutation.target)
|
|
3650
|
+
if (this.dom.contains(mutation.target)
|
|
3651
|
+
&& mutation.type === 'childList'
|
|
3652
|
+
&& isiOS()
|
|
3653
|
+
&& this.editor.isFocused) {
|
|
3632
3654
|
const changedNodes = [
|
|
3633
3655
|
...Array.from(mutation.addedNodes),
|
|
3634
3656
|
...Array.from(mutation.removedNodes),
|
|
@@ -3938,6 +3960,16 @@ function textPasteRule(config) {
|
|
|
3938
3960
|
});
|
|
3939
3961
|
}
|
|
3940
3962
|
|
|
3963
|
+
function defaultBlockAt(match) {
|
|
3964
|
+
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
3965
|
+
const { type } = match.edge(i);
|
|
3966
|
+
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
3967
|
+
return type;
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
return null;
|
|
3971
|
+
}
|
|
3972
|
+
|
|
3941
3973
|
function findChildren(node, predicate) {
|
|
3942
3974
|
const nodesWithPos = [];
|
|
3943
3975
|
node.descendants((child, pos) => {
|
|
@@ -4077,5 +4109,5 @@ function posToDOMRect(view, from, to) {
|
|
|
4077
4109
|
};
|
|
4078
4110
|
}
|
|
4079
4111
|
|
|
4080
|
-
export { Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, extensions, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, 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 };
|
|
4112
|
+
export { Editor, Extension, InputRule, Mark, Node, NodeView, PasteRule, Tracker, callOrReturn, defaultBlockAt, extensions, findChildren, findChildrenInRange, findParentNode, findParentNodeClosestToPos, generateHTML, generateJSON, generateText, getAttributes, 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 };
|
|
4081
4113
|
//# sourceMappingURL=tiptap-core.esm.js.map
|