@tiptap/core 2.0.0-beta.165 → 2.0.0-beta.169
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/selectTextblockEnd.d.ts +12 -0
- package/dist/packages/core/src/commands/selectTextblockStart.d.ts +12 -0
- package/dist/packages/core/src/extensions/commands.d.ts +4 -0
- package/dist/packages/core/src/utilities/isMacOS.d.ts +1 -0
- package/dist/tiptap-core.cjs.js +70 -16
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +71 -17
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +70 -16
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/commands/insertContentAt.ts +12 -1
- package/src/commands/keyboardShortcut.ts +3 -3
- package/src/commands/selectTextblockEnd.ts +19 -0
- package/src/commands/selectTextblockStart.ts +19 -0
- package/src/extensions/commands.ts +6 -0
- package/src/extensions/keymap.ts +35 -7
- package/src/helpers/injectExtensionAttributesToParseRule.ts +14 -20
- package/src/utilities/isMacOS.ts +5 -0
package/dist/tiptap-core.umd.js
CHANGED
|
@@ -668,6 +668,7 @@
|
|
|
668
668
|
let { from, to } = typeof position === 'number'
|
|
669
669
|
? { from: position, to: position }
|
|
670
670
|
: position;
|
|
671
|
+
let isOnlyTextContent = true;
|
|
671
672
|
let isOnlyBlockContent = true;
|
|
672
673
|
const nodes = isFragment(content)
|
|
673
674
|
? content
|
|
@@ -675,6 +676,9 @@
|
|
|
675
676
|
nodes.forEach(node => {
|
|
676
677
|
// check if added node is valid
|
|
677
678
|
node.check();
|
|
679
|
+
isOnlyTextContent = isOnlyTextContent
|
|
680
|
+
? node.isText && node.marks.length === 0
|
|
681
|
+
: false;
|
|
678
682
|
isOnlyBlockContent = isOnlyBlockContent
|
|
679
683
|
? node.isBlock
|
|
680
684
|
: false;
|
|
@@ -694,7 +698,14 @@
|
|
|
694
698
|
to += 1;
|
|
695
699
|
}
|
|
696
700
|
}
|
|
697
|
-
|
|
701
|
+
// if there is only plain text we have to use `insertText`
|
|
702
|
+
// because this will keep the current marks
|
|
703
|
+
if (isOnlyTextContent) {
|
|
704
|
+
tr.insertText(value, from, to);
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
tr.replaceWith(from, to, content);
|
|
708
|
+
}
|
|
698
709
|
// set cursor at end of inserted content
|
|
699
710
|
if (options.updateSelection) {
|
|
700
711
|
selectionToInsertionEnd(tr, tr.steps.length - 1, -1);
|
|
@@ -726,7 +737,12 @@
|
|
|
726
737
|
joinForward: joinForward
|
|
727
738
|
});
|
|
728
739
|
|
|
729
|
-
|
|
740
|
+
function isMacOS() {
|
|
741
|
+
return typeof navigator !== 'undefined'
|
|
742
|
+
? /Mac/.test(navigator.platform)
|
|
743
|
+
: false;
|
|
744
|
+
}
|
|
745
|
+
|
|
730
746
|
function normalizeKeyName(name) {
|
|
731
747
|
const parts = name.split(/-(?!$)/);
|
|
732
748
|
let result = parts[parts.length - 1];
|
|
@@ -752,7 +768,7 @@
|
|
|
752
768
|
shift = true;
|
|
753
769
|
}
|
|
754
770
|
else if (/^mod$/i.test(mod)) {
|
|
755
|
-
if (
|
|
771
|
+
if (isiOS() || isMacOS()) {
|
|
756
772
|
meta = true;
|
|
757
773
|
}
|
|
758
774
|
else {
|
|
@@ -1004,6 +1020,26 @@
|
|
|
1004
1020
|
selectParentNode: selectParentNode
|
|
1005
1021
|
});
|
|
1006
1022
|
|
|
1023
|
+
// @ts-ignore
|
|
1024
|
+
const selectTextblockEnd = () => ({ state, dispatch }) => {
|
|
1025
|
+
return prosemirrorCommands.selectTextblockEnd(state, dispatch);
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
var selectTextblockEnd$1 = /*#__PURE__*/Object.freeze({
|
|
1029
|
+
__proto__: null,
|
|
1030
|
+
selectTextblockEnd: selectTextblockEnd
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
// @ts-ignore
|
|
1034
|
+
const selectTextblockStart = () => ({ state, dispatch }) => {
|
|
1035
|
+
return prosemirrorCommands.selectTextblockStart(state, dispatch);
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
var selectTextblockStart$1 = /*#__PURE__*/Object.freeze({
|
|
1039
|
+
__proto__: null,
|
|
1040
|
+
selectTextblockStart: selectTextblockStart
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1007
1043
|
function createDocument(content, schema, parseOptions = {}) {
|
|
1008
1044
|
return createNodeFromContent(content, schema, { slice: false, parseOptions });
|
|
1009
1045
|
}
|
|
@@ -1802,6 +1838,8 @@
|
|
|
1802
1838
|
...selectNodeBackward$1,
|
|
1803
1839
|
...selectNodeForward$1,
|
|
1804
1840
|
...selectParentNode$1,
|
|
1841
|
+
...selectTextblockEnd$1,
|
|
1842
|
+
...selectTextblockStart$1,
|
|
1805
1843
|
...setContent$1,
|
|
1806
1844
|
...setMark$1,
|
|
1807
1845
|
...setMeta$1,
|
|
@@ -2041,13 +2079,14 @@
|
|
|
2041
2079
|
() => commands.joinForward(),
|
|
2042
2080
|
() => commands.selectNodeForward(),
|
|
2043
2081
|
]);
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2082
|
+
const handleEnter = () => this.editor.commands.first(({ commands }) => [
|
|
2083
|
+
() => commands.newlineInCode(),
|
|
2084
|
+
() => commands.createParagraphNear(),
|
|
2085
|
+
() => commands.liftEmptyBlock(),
|
|
2086
|
+
() => commands.splitBlock(),
|
|
2087
|
+
]);
|
|
2088
|
+
const baseKeymap = {
|
|
2089
|
+
Enter: handleEnter,
|
|
2051
2090
|
'Mod-Enter': () => this.editor.commands.exitCode(),
|
|
2052
2091
|
Backspace: handleBackspace,
|
|
2053
2092
|
'Mod-Backspace': handleBackspace,
|
|
@@ -2056,6 +2095,26 @@
|
|
|
2056
2095
|
'Mod-Delete': handleDelete,
|
|
2057
2096
|
'Mod-a': () => this.editor.commands.selectAll(),
|
|
2058
2097
|
};
|
|
2098
|
+
const pcKeymap = {
|
|
2099
|
+
...baseKeymap,
|
|
2100
|
+
Home: () => this.editor.commands.selectTextblockStart(),
|
|
2101
|
+
End: () => this.editor.commands.selectTextblockEnd(),
|
|
2102
|
+
};
|
|
2103
|
+
const macKeymap = {
|
|
2104
|
+
...baseKeymap,
|
|
2105
|
+
'Ctrl-h': handleBackspace,
|
|
2106
|
+
'Alt-Backspace': handleBackspace,
|
|
2107
|
+
'Ctrl-d': handleDelete,
|
|
2108
|
+
'Ctrl-Alt-Backspace': handleDelete,
|
|
2109
|
+
'Alt-Delete': handleDelete,
|
|
2110
|
+
'Alt-d': handleDelete,
|
|
2111
|
+
'Ctrl-a': () => this.editor.commands.selectTextblockStart(),
|
|
2112
|
+
'Ctrl-e': () => this.editor.commands.selectTextblockEnd(),
|
|
2113
|
+
};
|
|
2114
|
+
if (isiOS() || isMacOS()) {
|
|
2115
|
+
return macKeymap;
|
|
2116
|
+
}
|
|
2117
|
+
return pcKeymap;
|
|
2059
2118
|
},
|
|
2060
2119
|
addProseMirrorPlugins() {
|
|
2061
2120
|
return [
|
|
@@ -2675,15 +2734,10 @@
|
|
|
2675
2734
|
if (oldAttributes === false) {
|
|
2676
2735
|
return false;
|
|
2677
2736
|
}
|
|
2678
|
-
const newAttributes = extensionAttributes
|
|
2679
|
-
.filter(item => item.attribute.rendered)
|
|
2680
|
-
.reduce((items, item) => {
|
|
2737
|
+
const newAttributes = extensionAttributes.reduce((items, item) => {
|
|
2681
2738
|
const value = item.attribute.parseHTML
|
|
2682
2739
|
? item.attribute.parseHTML(node)
|
|
2683
2740
|
: fromString(node.getAttribute(item.name));
|
|
2684
|
-
if (isObject(value)) {
|
|
2685
|
-
console.warn(`[tiptap warn]: BREAKING CHANGE: "parseHTML" for your attribute "${item.name}" returns an object but should return the value itself. If this is expected you can ignore this message. This warning will be removed in one of the next releases. Further information: https://github.com/ueberdosis/tiptap/issues/1863`);
|
|
2686
|
-
}
|
|
2687
2741
|
if (value === null || value === undefined) {
|
|
2688
2742
|
return items;
|
|
2689
2743
|
}
|