@tiptap/core 2.0.0-beta.140 → 2.0.0-beta.144
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/packages/core/src/style.d.ts +1 -1
- package/dist/packages/core/src/types.d.ts +1 -1
- package/dist/tiptap-core.cjs.js +31 -6
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +31 -7
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +31 -6
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/commands/focus.ts +25 -5
- package/src/helpers/defaultBlockAt.ts +13 -0
- package/src/index.ts +1 -0
- package/src/style.ts +1 -0
- package/src/types.ts +1 -1
- 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';
|
|
@@ -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;
|
|
@@ -179,7 +179,7 @@ export declare type ChainedCommands = {
|
|
|
179
179
|
export declare type CanCommands = SingleCommands & {
|
|
180
180
|
chain: () => ChainedCommands;
|
|
181
181
|
};
|
|
182
|
-
export declare type FocusPosition = 'start' | 'end' | number | boolean | null;
|
|
182
|
+
export declare type FocusPosition = 'start' | 'end' | 'all' | number | boolean | null;
|
|
183
183
|
export declare type Range = {
|
|
184
184
|
from: number;
|
|
185
185
|
to: number;
|
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
|
|
|
@@ -513,19 +514,29 @@ function resolveSelection(state, position = null) {
|
|
|
513
514
|
to: 0,
|
|
514
515
|
};
|
|
515
516
|
}
|
|
517
|
+
const { size } = state.doc.content;
|
|
516
518
|
if (position === 'end') {
|
|
517
|
-
const { size } = state.doc.content;
|
|
518
519
|
return {
|
|
519
520
|
from: size,
|
|
520
521
|
to: size,
|
|
521
522
|
};
|
|
522
523
|
}
|
|
524
|
+
if (position === 'all') {
|
|
525
|
+
return {
|
|
526
|
+
from: 0,
|
|
527
|
+
to: size,
|
|
528
|
+
};
|
|
529
|
+
}
|
|
523
530
|
return {
|
|
524
531
|
from: position,
|
|
525
532
|
to: position,
|
|
526
533
|
};
|
|
527
534
|
}
|
|
528
|
-
const focus = (position = null) => ({ editor, view, tr, dispatch, }) => {
|
|
535
|
+
const focus = (position = null, options) => ({ editor, view, tr, dispatch, }) => {
|
|
536
|
+
options = {
|
|
537
|
+
scrollIntoView: true,
|
|
538
|
+
...options,
|
|
539
|
+
};
|
|
529
540
|
const delayedFocus = () => {
|
|
530
541
|
// focus within `requestAnimationFrame` breaks focus on iOS
|
|
531
542
|
// so we have to call this
|
|
@@ -537,7 +548,9 @@ const focus = (position = null) => ({ editor, view, tr, dispatch, }) => {
|
|
|
537
548
|
requestAnimationFrame(() => {
|
|
538
549
|
if (!editor.isDestroyed) {
|
|
539
550
|
view.focus();
|
|
540
|
-
|
|
551
|
+
if (options === null || options === void 0 ? void 0 : options.scrollIntoView) {
|
|
552
|
+
editor.commands.scrollIntoView();
|
|
553
|
+
}
|
|
541
554
|
}
|
|
542
555
|
});
|
|
543
556
|
};
|
|
@@ -1177,7 +1190,7 @@ function getSplittedAttributes(extensionAttributes, typeName, attributes) {
|
|
|
1177
1190
|
}));
|
|
1178
1191
|
}
|
|
1179
1192
|
|
|
1180
|
-
function defaultBlockAt(match) {
|
|
1193
|
+
function defaultBlockAt$1(match) {
|
|
1181
1194
|
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
1182
1195
|
const { type } = match.edge(i);
|
|
1183
1196
|
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
@@ -1221,7 +1234,7 @@ const splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor
|
|
|
1221
1234
|
}
|
|
1222
1235
|
const deflt = $from.depth === 0
|
|
1223
1236
|
? undefined
|
|
1224
|
-
: defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1237
|
+
: defaultBlockAt$1($from.node(-1).contentMatchAt($from.indexAfter(-1)));
|
|
1225
1238
|
let types = atEnd && deflt
|
|
1226
1239
|
? [{
|
|
1227
1240
|
type: deflt,
|
|
@@ -2978,6 +2991,7 @@ img.ProseMirror-separator {
|
|
|
2978
2991
|
display: none;
|
|
2979
2992
|
pointer-events: none;
|
|
2980
2993
|
position: absolute;
|
|
2994
|
+
margin: 0;
|
|
2981
2995
|
}
|
|
2982
2996
|
|
|
2983
2997
|
.ProseMirror-gapcursor:after {
|
|
@@ -3957,6 +3971,16 @@ function textPasteRule(config) {
|
|
|
3957
3971
|
});
|
|
3958
3972
|
}
|
|
3959
3973
|
|
|
3974
|
+
function defaultBlockAt(match) {
|
|
3975
|
+
for (let i = 0; i < match.edgeCount; i += 1) {
|
|
3976
|
+
const { type } = match.edge(i);
|
|
3977
|
+
if (type.isTextblock && !type.hasRequiredAttrs()) {
|
|
3978
|
+
return type;
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
return null;
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3960
3984
|
function findChildren(node, predicate) {
|
|
3961
3985
|
const nodesWithPos = [];
|
|
3962
3986
|
node.descendants((child, pos) => {
|
|
@@ -4105,6 +4129,7 @@ exports.NodeView = NodeView;
|
|
|
4105
4129
|
exports.PasteRule = PasteRule;
|
|
4106
4130
|
exports.Tracker = Tracker;
|
|
4107
4131
|
exports.callOrReturn = callOrReturn;
|
|
4132
|
+
exports.defaultBlockAt = defaultBlockAt;
|
|
4108
4133
|
exports.extensions = extensions;
|
|
4109
4134
|
exports.findChildren = findChildren;
|
|
4110
4135
|
exports.findChildrenInRange = findChildrenInRange;
|