@tiptap/core 2.0.0-beta.166 → 2.0.0-beta.167
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 +57 -9
- package/dist/tiptap-core.cjs.js.map +1 -1
- package/dist/tiptap-core.esm.js +58 -10
- package/dist/tiptap-core.esm.js.map +1 -1
- package/dist/tiptap-core.umd.js +57 -9
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +5 -5
- 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/utilities/isMacOS.ts +5 -0
package/dist/tiptap-core.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin, PluginKey, TextSelection, Selection, NodeSelection, EditorState } from 'prosemirror-state';
|
|
2
2
|
import { liftTarget, ReplaceStep, ReplaceAroundStep, canSplit, canJoin, findWrapping, Transform } from 'prosemirror-transform';
|
|
3
|
-
import { createParagraphNear as createParagraphNear$2, deleteSelection as deleteSelection$2, exitCode as exitCode$2, joinBackward as joinBackward$2, joinForward as joinForward$2, lift as lift$2, liftEmptyBlock as liftEmptyBlock$2, newlineInCode as newlineInCode$2, selectNodeBackward as selectNodeBackward$2, selectNodeForward as selectNodeForward$2, selectParentNode as selectParentNode$2, setBlockType, wrapIn as wrapIn$2 } from 'prosemirror-commands';
|
|
3
|
+
import { createParagraphNear as createParagraphNear$2, deleteSelection as deleteSelection$2, exitCode as exitCode$2, joinBackward as joinBackward$2, joinForward as joinForward$2, lift as lift$2, liftEmptyBlock as liftEmptyBlock$2, newlineInCode as newlineInCode$2, selectNodeBackward as selectNodeBackward$2, selectNodeForward as selectNodeForward$2, selectParentNode as selectParentNode$2, selectTextblockEnd as selectTextblockEnd$2, selectTextblockStart as selectTextblockStart$2, setBlockType, wrapIn as wrapIn$2 } from 'prosemirror-commands';
|
|
4
4
|
import { Fragment, DOMParser, Slice, DOMSerializer, Schema, Node as Node$1 } from 'prosemirror-model';
|
|
5
5
|
import { liftListItem as liftListItem$2, sinkListItem as sinkListItem$2, wrapInList as wrapInList$2 } from 'prosemirror-schema-list';
|
|
6
6
|
import { EditorView } from 'prosemirror-view';
|
|
@@ -739,7 +739,12 @@ var joinForward$1 = /*#__PURE__*/Object.freeze({
|
|
|
739
739
|
joinForward: joinForward
|
|
740
740
|
});
|
|
741
741
|
|
|
742
|
-
|
|
742
|
+
function isMacOS() {
|
|
743
|
+
return typeof navigator !== 'undefined'
|
|
744
|
+
? /Mac/.test(navigator.platform)
|
|
745
|
+
: false;
|
|
746
|
+
}
|
|
747
|
+
|
|
743
748
|
function normalizeKeyName(name) {
|
|
744
749
|
const parts = name.split(/-(?!$)/);
|
|
745
750
|
let result = parts[parts.length - 1];
|
|
@@ -765,7 +770,7 @@ function normalizeKeyName(name) {
|
|
|
765
770
|
shift = true;
|
|
766
771
|
}
|
|
767
772
|
else if (/^mod$/i.test(mod)) {
|
|
768
|
-
if (
|
|
773
|
+
if (isiOS() || isMacOS()) {
|
|
769
774
|
meta = true;
|
|
770
775
|
}
|
|
771
776
|
else {
|
|
@@ -1017,6 +1022,26 @@ var selectParentNode$1 = /*#__PURE__*/Object.freeze({
|
|
|
1017
1022
|
selectParentNode: selectParentNode
|
|
1018
1023
|
});
|
|
1019
1024
|
|
|
1025
|
+
// @ts-ignore
|
|
1026
|
+
const selectTextblockEnd = () => ({ state, dispatch }) => {
|
|
1027
|
+
return selectTextblockEnd$2(state, dispatch);
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
var selectTextblockEnd$1 = /*#__PURE__*/Object.freeze({
|
|
1031
|
+
__proto__: null,
|
|
1032
|
+
selectTextblockEnd: selectTextblockEnd
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
// @ts-ignore
|
|
1036
|
+
const selectTextblockStart = () => ({ state, dispatch }) => {
|
|
1037
|
+
return selectTextblockStart$2(state, dispatch);
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
var selectTextblockStart$1 = /*#__PURE__*/Object.freeze({
|
|
1041
|
+
__proto__: null,
|
|
1042
|
+
selectTextblockStart: selectTextblockStart
|
|
1043
|
+
});
|
|
1044
|
+
|
|
1020
1045
|
function createDocument(content, schema, parseOptions = {}) {
|
|
1021
1046
|
return createNodeFromContent(content, schema, { slice: false, parseOptions });
|
|
1022
1047
|
}
|
|
@@ -1815,6 +1840,8 @@ const Commands = Extension.create({
|
|
|
1815
1840
|
...selectNodeBackward$1,
|
|
1816
1841
|
...selectNodeForward$1,
|
|
1817
1842
|
...selectParentNode$1,
|
|
1843
|
+
...selectTextblockEnd$1,
|
|
1844
|
+
...selectTextblockStart$1,
|
|
1818
1845
|
...setContent$1,
|
|
1819
1846
|
...setMark$1,
|
|
1820
1847
|
...setMeta$1,
|
|
@@ -2054,13 +2081,14 @@ const Keymap = Extension.create({
|
|
|
2054
2081
|
() => commands.joinForward(),
|
|
2055
2082
|
() => commands.selectNodeForward(),
|
|
2056
2083
|
]);
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2084
|
+
const handleEnter = () => this.editor.commands.first(({ commands }) => [
|
|
2085
|
+
() => commands.newlineInCode(),
|
|
2086
|
+
() => commands.createParagraphNear(),
|
|
2087
|
+
() => commands.liftEmptyBlock(),
|
|
2088
|
+
() => commands.splitBlock(),
|
|
2089
|
+
]);
|
|
2090
|
+
const baseKeymap = {
|
|
2091
|
+
Enter: handleEnter,
|
|
2064
2092
|
'Mod-Enter': () => this.editor.commands.exitCode(),
|
|
2065
2093
|
Backspace: handleBackspace,
|
|
2066
2094
|
'Mod-Backspace': handleBackspace,
|
|
@@ -2069,6 +2097,26 @@ const Keymap = Extension.create({
|
|
|
2069
2097
|
'Mod-Delete': handleDelete,
|
|
2070
2098
|
'Mod-a': () => this.editor.commands.selectAll(),
|
|
2071
2099
|
};
|
|
2100
|
+
const pcKeymap = {
|
|
2101
|
+
...baseKeymap,
|
|
2102
|
+
Home: () => this.editor.commands.selectTextblockStart(),
|
|
2103
|
+
End: () => this.editor.commands.selectTextblockStart(),
|
|
2104
|
+
};
|
|
2105
|
+
const macKeymap = {
|
|
2106
|
+
...baseKeymap,
|
|
2107
|
+
'Ctrl-h': handleBackspace,
|
|
2108
|
+
'Alt-Backspace': handleBackspace,
|
|
2109
|
+
'Ctrl-d': handleDelete,
|
|
2110
|
+
'Ctrl-Alt-Backspace': handleDelete,
|
|
2111
|
+
'Alt-Delete': handleDelete,
|
|
2112
|
+
'Alt-d': handleDelete,
|
|
2113
|
+
'Ctrl-a': () => this.editor.commands.selectTextblockStart(),
|
|
2114
|
+
'Ctrl-e': () => this.editor.commands.selectTextblockEnd(),
|
|
2115
|
+
};
|
|
2116
|
+
if (isiOS() || isMacOS()) {
|
|
2117
|
+
return macKeymap;
|
|
2118
|
+
}
|
|
2119
|
+
return pcKeymap;
|
|
2072
2120
|
},
|
|
2073
2121
|
addProseMirrorPlugins() {
|
|
2074
2122
|
return [
|