@tiptap/core 2.0.0-beta.141 → 2.0.0-beta.145
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/commands/focus.d.ts +3 -1
- package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +2 -0
- package/dist/packages/core/src/index.d.ts +1 -0
- package/dist/tiptap-core.cjs.js +32 -32
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +32 -33
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +32 -32
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/Extension.ts +7 -14
- package/src/Mark.ts +7 -14
- package/src/Node.ts +7 -14
- package/src/commands/focus.ts +16 -3
- package/src/helpers/defaultBlockAt.ts +13 -0
- package/src/index.ts +1 -0
- package/src/utilities/isPlainObject.ts +4 -1
|
@@ -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';
|
package/dist/tiptap-core.cjs.js
CHANGED
|
@@ -15,8 +15,9 @@ function getType(value) {
|
|
|
15
15
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
16
16
|
}
|
|
17
17
|
function isPlainObject(value) {
|
|
18
|
-
if (getType(value) !== 'Object')
|
|
18
|
+
if (getType(value) !== 'Object') {
|
|
19
19
|
return false;
|
|
20
|
+
}
|
|
20
21
|
return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -131,15 +132,9 @@ class Extension {
|
|
|
131
132
|
if (extendedConfig.defaultOptions) {
|
|
132
133
|
console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
|
|
133
134
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
: extension.parent.options;
|
|
138
|
-
if (extendedConfig.addOptions) {
|
|
139
|
-
extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
|
|
140
|
-
name: extension.name,
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
135
|
+
extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
|
|
136
|
+
name: extension.name,
|
|
137
|
+
}));
|
|
143
138
|
extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
|
|
144
139
|
name: extension.name,
|
|
145
140
|
options: extension.options,
|
|
@@ -531,7 +526,11 @@ function resolveSelection(state, position = null) {
|
|
|
531
526
|
to: position,
|
|
532
527
|
};
|
|
533
528
|
}
|
|
534
|
-
const focus = (position = null) => ({ editor, view, tr, dispatch, }) => {
|
|
529
|
+
const focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {
|
|
530
|
+
options = {
|
|
531
|
+
scrollIntoView: true,
|
|
532
|
+
...options,
|
|
533
|
+
};
|
|
535
534
|
const delayedFocus = () => {
|
|
536
535
|
// focus within `requestAnimationFrame` breaks focus on iOS
|
|
537
536
|
// so we have to call this
|
|
@@ -543,7 +542,9 @@ const focus = (position = null) => ({ editor, view, tr, dispatch, }) => {
|
|
|
543
542
|
requestAnimationFrame(() => {
|
|
544
543
|
if (!editor.isDestroyed) {
|
|
545
544
|
view.focus();
|
|
546
|
-
|
|
545
|
+
if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {
|
|
546
|
+
editor.commands.scrollIntoView();
|
|
547
|
+
}
|
|
547
548
|
}
|
|
548
549
|
});
|
|
549
550
|
};
|
|
@@ -1183,7 +1184,7 @@ function getSplittedAttributes(extensionAttributes, typeName, attributes) {
|
|
|
1183
1184
|
}));
|
|
1184
1185
|
}
|
|
1185
1186
|
|
|
1186
|
-
function defaultBlockAt(match) {
|
|
1187
|
+
function defaultBlockAt$1(match) {
|
|
1187
1188
|
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
1188
1189
|
const { type } = match.edge(i);
|
|
1189
1190
|
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
@@ -1227,7 +1228,7 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
|
|
|
1227
1228
|
}
|
|
1228
1229
|
const deflt = $from.depth === 0
|
|
1229
1230
|
? undefined
|
|
1230
|
-
: defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1231
|
+
: defaultBlockAt$1($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1231
1232
|
let types = atEnd && deflt
|
|
1232
1233
|
? [{
|
|
1233
1234
|
type: deflt,
|
|
@@ -3421,15 +3422,9 @@ class Node {
|
|
|
3421
3422
|
if (extendedConfig.defaultOptions) {
|
|
3422
3423
|
console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
|
|
3423
3424
|
}
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
: extension.parent.options;
|
|
3428
|
-
if (extendedConfig.addOptions) {
|
|
3429
|
-
extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
|
|
3430
|
-
name: extension.name,
|
|
3431
|
-
}));
|
|
3432
|
-
}
|
|
3425
|
+
extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
|
|
3426
|
+
name: extension.name,
|
|
3427
|
+
}));
|
|
3433
3428
|
extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
|
|
3434
3429
|
name: extension.name,
|
|
3435
3430
|
options: extension.options,
|
|
@@ -3492,15 +3487,9 @@ class Mark {
|
|
|
3492
3487
|
if (extendedConfig.defaultOptions) {
|
|
3493
3488
|
console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
|
|
3494
3489
|
}
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
: extension.parent.options;
|
|
3499
|
-
if (extendedConfig.addOptions) {
|
|
3500
|
-
extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
|
|
3501
|
-
name: extension.name,
|
|
3502
|
-
}));
|
|
3503
|
-
}
|
|
3490
|
+
extension.options = callOrReturn(getExtensionField(extension, 'addOptions', {
|
|
3491
|
+
name: extension.name,
|
|
3492
|
+
}));
|
|
3504
3493
|
extension.storage = callOrReturn(getExtensionField(extension, 'addStorage', {
|
|
3505
3494
|
name: extension.name,
|
|
3506
3495
|
options: extension.options,
|
|
@@ -3964,6 +3953,16 @@ function textPasteRule(config) {
|
|
|
3964
3953
|
});
|
|
3965
3954
|
}
|
|
3966
3955
|
|
|
3956
|
+
function defaultBlockAt(match) {
|
|
3957
|
+
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
3958
|
+
const { type } = match.edge(i);
|
|
3959
|
+
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
3960
|
+
return type;
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
return null;
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3967
3966
|
function findChildren(node, predicate) {
|
|
3968
3967
|
const nodesWithPos = [];
|
|
3969
3968
|
node.descendants((child, pos) => {
|
|
@@ -4112,6 +4111,7 @@ exports.NodeView = NodeView;
|
|
|
4112
4111
|
exports.PasteRule = PasteRule;
|
|
4113
4112
|
exports.Tracker = Tracker;
|
|
4114
4113
|
exports.callOrReturn = callOrReturn;
|
|
4114
|
+
exports.defaultBlockAt = defaultBlockAt;
|
|
4115
4115
|
exports.extensions = extensions;
|
|
4116
4116
|
exports.findChildren = findChildren;
|
|
4117
4117
|
exports.findChildrenInRange = findChildrenInRange;
|