@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
|
@@ -19,6 +19,7 @@ export { default as markPasteRule } from './pasteRules/markPasteRule';
|
|
|
19
19
|
export { default as textPasteRule } from './pasteRules/textPasteRule';
|
|
20
20
|
export { default as callOrReturn } from './utilities/callOrReturn';
|
|
21
21
|
export { default as mergeAttributes } from './utilities/mergeAttributes';
|
|
22
|
+
export { default as defaultBlockAt } from './helpers/defaultBlockAt';
|
|
22
23
|
export { default as getExtensionField } from './helpers/getExtensionField';
|
|
23
24
|
export { default as findChildren } from './helpers/findChildren';
|
|
24
25
|
export { default as findChildrenInRange } from './helpers/findChildrenInRange';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const style = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}";
|
|
1
|
+
declare const style = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 1px !important;\n height: 1px !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}";
|
|
2
2
|
export default style;
|
|
@@ -47,6 +47,7 @@ export interface EditorEvents {
|
|
|
47
47
|
};
|
|
48
48
|
destroy: void;
|
|
49
49
|
}
|
|
50
|
+
export declare type EnableRules = (AnyExtension | string)[] | boolean;
|
|
50
51
|
export interface EditorOptions {
|
|
51
52
|
element: Element;
|
|
52
53
|
content: Content;
|
|
@@ -56,8 +57,8 @@ export interface EditorOptions {
|
|
|
56
57
|
editable: boolean;
|
|
57
58
|
editorProps: EditorProps;
|
|
58
59
|
parseOptions: ParseOptions;
|
|
59
|
-
enableInputRules:
|
|
60
|
-
enablePasteRules:
|
|
60
|
+
enableInputRules: EnableRules;
|
|
61
|
+
enablePasteRules: EnableRules;
|
|
61
62
|
enableCoreExtensions: boolean;
|
|
62
63
|
onBeforeCreate: (props: EditorEvents['beforeCreate']) => void;
|
|
63
64
|
onCreate: (props: EditorEvents['create']) => void;
|
|
@@ -178,7 +179,7 @@ export declare type ChainedCommands = {
|
|
|
178
179
|
export declare type CanCommands = SingleCommands & {
|
|
179
180
|
chain: () => ChainedCommands;
|
|
180
181
|
};
|
|
181
|
-
export declare type FocusPosition = 'start' | 'end' | number | boolean | null;
|
|
182
|
+
export declare type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null;
|
|
182
183
|
export declare type Range = {
|
|
183
184
|
from: number;
|
|
184
185
|
to: number;
|
package/dist/tiptap-core.cjs.js
CHANGED
|
@@ -513,13 +513,19 @@ function resolveSelection(state, position = null) {
|
|
|
513
513
|
to: 0,
|
|
514
514
|
};
|
|
515
515
|
}
|
|
516
|
+
const { size } = state.doc.content;
|
|
516
517
|
if (position === 'end') {
|
|
517
|
-
const { size } = state.doc.content;
|
|
518
518
|
return {
|
|
519
519
|
from: size,
|
|
520
520
|
to: size,
|
|
521
521
|
};
|
|
522
522
|
}
|
|
523
|
+
if (position === 'all') {
|
|
524
|
+
return {
|
|
525
|
+
from: 0,
|
|
526
|
+
to: size,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
523
529
|
return {
|
|
524
530
|
from: position,
|
|
525
531
|
to: position,
|
|
@@ -1177,7 +1183,7 @@ function getSplittedAttributes(extensionAttributes, typeName, attributes) {
|
|
|
1177
1183
|
}));
|
|
1178
1184
|
}
|
|
1179
1185
|
|
|
1180
|
-
function defaultBlockAt(match) {
|
|
1186
|
+
function defaultBlockAt$1(match) {
|
|
1181
1187
|
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
1182
1188
|
const { type } = match.edge(i);
|
|
1183
1189
|
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
@@ -1221,7 +1227,7 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
|
|
|
1221
1227
|
}
|
|
1222
1228
|
const deflt = $from.depth === 0
|
|
1223
1229
|
? undefined
|
|
1224
|
-
: defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1230
|
+
: defaultBlockAt$1($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1225
1231
|
let types = atEnd && deflt
|
|
1226
1232
|
? [{
|
|
1227
1233
|
type: deflt,
|
|
@@ -2676,6 +2682,18 @@ function getSchemaTypeByName(name, schema) {
|
|
|
2676
2682
|
return schema.nodes[name] || schema.marks[name] || null;
|
|
2677
2683
|
}
|
|
2678
2684
|
|
|
2685
|
+
function isExtensionRulesEnabled(extension, enabled) {
|
|
2686
|
+
if (Array.isArray(enabled)) {
|
|
2687
|
+
return enabled.some(enabledExtension => {
|
|
2688
|
+
const name = typeof enabledExtension === 'string'
|
|
2689
|
+
? enabledExtension
|
|
2690
|
+
: enabledExtension.name;
|
|
2691
|
+
return name === extension.name;
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
return enabled;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2679
2697
|
function findDuplicates(items) {
|
|
2680
2698
|
const filtered = items.filter((el, index) => items.indexOf(el) !== index);
|
|
2681
2699
|
return [...new Set(filtered)];
|
|
@@ -2830,11 +2848,11 @@ class ExtensionManager {
|
|
|
2830
2848
|
plugins.push(keyMapPlugin);
|
|
2831
2849
|
}
|
|
2832
2850
|
const addInputRules = getExtensionField(extension, 'addInputRules', context);
|
|
2833
|
-
if (editor.options.enableInputRules && addInputRules) {
|
|
2851
|
+
if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {
|
|
2834
2852
|
inputRules.push(...addInputRules());
|
|
2835
2853
|
}
|
|
2836
2854
|
const addPasteRules = getExtensionField(extension, 'addPasteRules', context);
|
|
2837
|
-
if (editor.options.enablePasteRules && addPasteRules) {
|
|
2855
|
+
if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {
|
|
2838
2856
|
pasteRules.push(...addPasteRules());
|
|
2839
2857
|
}
|
|
2840
2858
|
const addProseMirrorPlugins = getExtensionField(extension, 'addProseMirrorPlugins', context);
|
|
@@ -2966,6 +2984,7 @@ img.ProseMirror-separator {
|
|
|
2966
2984
|
display: none;
|
|
2967
2985
|
pointer-events: none;
|
|
2968
2986
|
position: absolute;
|
|
2987
|
+
margin: 0;
|
|
2969
2988
|
}
|
|
2970
2989
|
|
|
2971
2990
|
.ProseMirror-gapcursor:after {
|
|
@@ -3632,7 +3651,10 @@ class NodeView {
|
|
|
3632
3651
|
// this is because ProseMirror can’t preventDispatch on enter
|
|
3633
3652
|
// this will lead to a re-render of the node view on enter
|
|
3634
3653
|
// see: https://github.com/ueberdosis/tiptap/issues/1214
|
|
3635
|
-
if (this.dom.contains(mutation.target)
|
|
3654
|
+
if (this.dom.contains(mutation.target)
|
|
3655
|
+
&& mutation.type === 'childList'
|
|
3656
|
+
&& isiOS()
|
|
3657
|
+
&& this.editor.isFocused) {
|
|
3636
3658
|
const changedNodes = [
|
|
3637
3659
|
...Array.from(mutation.addedNodes),
|
|
3638
3660
|
...Array.from(mutation.removedNodes),
|
|
@@ -3942,6 +3964,16 @@ function textPasteRule(config) {
|
|
|
3942
3964
|
});
|
|
3943
3965
|
}
|
|
3944
3966
|
|
|
3967
|
+
function defaultBlockAt(match) {
|
|
3968
|
+
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
3969
|
+
const { type } = match.edge(i);
|
|
3970
|
+
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
3971
|
+
return type;
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
return null;
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3945
3977
|
function findChildren(node, predicate) {
|
|
3946
3978
|
const nodesWithPos = [];
|
|
3947
3979
|
node.descendants((child, pos) => {
|
|
@@ -4090,6 +4122,7 @@ exports.NodeView = NodeView;
|
|
|
4090
4122
|
exports.PasteRule = PasteRule;
|
|
4091
4123
|
exports.Tracker = Tracker;
|
|
4092
4124
|
exports.callOrReturn = callOrReturn;
|
|
4125
|
+
exports.defaultBlockAt = defaultBlockAt;
|
|
4093
4126
|
exports.extensions = extensions;
|
|
4094
4127
|
exports.findChildren = findChildren;
|
|
4095
4128
|
exports.findChildrenInRange = findChildrenInRange;
|