@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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RawCommands } from '../types';
|
|
2
|
+
declare module '@tiptap/core' {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
selectTextblockEnd: {
|
|
5
|
+
/**
|
|
6
|
+
* Moves the cursor to the end of current text block.
|
|
7
|
+
*/
|
|
8
|
+
selectTextblockEnd: () => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const selectTextblockEnd: RawCommands['selectTextblockEnd'];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RawCommands } from '../types';
|
|
2
|
+
declare module '@tiptap/core' {
|
|
3
|
+
interface Commands<ReturnType> {
|
|
4
|
+
selectTextblockStart: {
|
|
5
|
+
/**
|
|
6
|
+
* Moves the cursor to the start of current text block.
|
|
7
|
+
*/
|
|
8
|
+
selectTextblockStart: () => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const selectTextblockStart: RawCommands['selectTextblockStart'];
|
|
@@ -28,6 +28,8 @@ import * as selectAll from '../commands/selectAll';
|
|
|
28
28
|
import * as selectNodeBackward from '../commands/selectNodeBackward';
|
|
29
29
|
import * as selectNodeForward from '../commands/selectNodeForward';
|
|
30
30
|
import * as selectParentNode from '../commands/selectParentNode';
|
|
31
|
+
import * as selectTextblockEnd from '../commands/selectTextblockEnd';
|
|
32
|
+
import * as selectTextblockStart from '../commands/selectTextblockStart';
|
|
31
33
|
import * as setContent from '../commands/setContent';
|
|
32
34
|
import * as setMark from '../commands/setMark';
|
|
33
35
|
import * as setMeta from '../commands/setMeta';
|
|
@@ -76,6 +78,8 @@ export { selectAll };
|
|
|
76
78
|
export { selectNodeBackward };
|
|
77
79
|
export { selectNodeForward };
|
|
78
80
|
export { selectParentNode };
|
|
81
|
+
export { selectTextblockEnd };
|
|
82
|
+
export { selectTextblockStart };
|
|
79
83
|
export { setContent };
|
|
80
84
|
export { setMark };
|
|
81
85
|
export { setMeta };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isMacOS(): boolean;
|
package/dist/tiptap-core.cjs.js
CHANGED
|
@@ -743,7 +743,12 @@ var joinForward$1 = /*#__PURE__*/Object.freeze({
|
|
|
743
743
|
joinForward: joinForward
|
|
744
744
|
});
|
|
745
745
|
|
|
746
|
-
|
|
746
|
+
function isMacOS() {
|
|
747
|
+
return typeof navigator !== 'undefined'
|
|
748
|
+
? /Mac/.test(navigator.platform)
|
|
749
|
+
: false;
|
|
750
|
+
}
|
|
751
|
+
|
|
747
752
|
function normalizeKeyName(name) {
|
|
748
753
|
const parts = name.split(/-(?!$)/);
|
|
749
754
|
let result = parts[parts.length - 1];
|
|
@@ -769,7 +774,7 @@ function normalizeKeyName(name) {
|
|
|
769
774
|
shift = true;
|
|
770
775
|
}
|
|
771
776
|
else if (/^mod$/i.test(mod)) {
|
|
772
|
-
if (
|
|
777
|
+
if (isiOS() || isMacOS()) {
|
|
773
778
|
meta = true;
|
|
774
779
|
}
|
|
775
780
|
else {
|
|
@@ -1021,6 +1026,26 @@ var selectParentNode$1 = /*#__PURE__*/Object.freeze({
|
|
|
1021
1026
|
selectParentNode: selectParentNode
|
|
1022
1027
|
});
|
|
1023
1028
|
|
|
1029
|
+
// @ts-ignore
|
|
1030
|
+
const selectTextblockEnd = () => ({ state, dispatch }) => {
|
|
1031
|
+
return prosemirrorCommands.selectTextblockEnd(state, dispatch);
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
var selectTextblockEnd$1 = /*#__PURE__*/Object.freeze({
|
|
1035
|
+
__proto__: null,
|
|
1036
|
+
selectTextblockEnd: selectTextblockEnd
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
// @ts-ignore
|
|
1040
|
+
const selectTextblockStart = () => ({ state, dispatch }) => {
|
|
1041
|
+
return prosemirrorCommands.selectTextblockStart(state, dispatch);
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
var selectTextblockStart$1 = /*#__PURE__*/Object.freeze({
|
|
1045
|
+
__proto__: null,
|
|
1046
|
+
selectTextblockStart: selectTextblockStart
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1024
1049
|
function createDocument(content, schema, parseOptions = {}) {
|
|
1025
1050
|
return createNodeFromContent(content, schema, { slice: false, parseOptions });
|
|
1026
1051
|
}
|
|
@@ -1819,6 +1844,8 @@ const Commands = Extension.create({
|
|
|
1819
1844
|
...selectNodeBackward$1,
|
|
1820
1845
|
...selectNodeForward$1,
|
|
1821
1846
|
...selectParentNode$1,
|
|
1847
|
+
...selectTextblockEnd$1,
|
|
1848
|
+
...selectTextblockStart$1,
|
|
1822
1849
|
...setContent$1,
|
|
1823
1850
|
...setMark$1,
|
|
1824
1851
|
...setMeta$1,
|
|
@@ -2058,13 +2085,14 @@ const Keymap = Extension.create({
|
|
|
2058
2085
|
() => commands.joinForward(),
|
|
2059
2086
|
() => commands.selectNodeForward(),
|
|
2060
2087
|
]);
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2088
|
+
const handleEnter = () => this.editor.commands.first(({ commands }) => [
|
|
2089
|
+
() => commands.newlineInCode(),
|
|
2090
|
+
() => commands.createParagraphNear(),
|
|
2091
|
+
() => commands.liftEmptyBlock(),
|
|
2092
|
+
() => commands.splitBlock(),
|
|
2093
|
+
]);
|
|
2094
|
+
const baseKeymap = {
|
|
2095
|
+
Enter: handleEnter,
|
|
2068
2096
|
'Mod-Enter': () => this.editor.commands.exitCode(),
|
|
2069
2097
|
Backspace: handleBackspace,
|
|
2070
2098
|
'Mod-Backspace': handleBackspace,
|
|
@@ -2073,6 +2101,26 @@ const Keymap = Extension.create({
|
|
|
2073
2101
|
'Mod-Delete': handleDelete,
|
|
2074
2102
|
'Mod-a': () => this.editor.commands.selectAll(),
|
|
2075
2103
|
};
|
|
2104
|
+
const pcKeymap = {
|
|
2105
|
+
...baseKeymap,
|
|
2106
|
+
Home: () => this.editor.commands.selectTextblockStart(),
|
|
2107
|
+
End: () => this.editor.commands.selectTextblockStart(),
|
|
2108
|
+
};
|
|
2109
|
+
const macKeymap = {
|
|
2110
|
+
...baseKeymap,
|
|
2111
|
+
'Ctrl-h': handleBackspace,
|
|
2112
|
+
'Alt-Backspace': handleBackspace,
|
|
2113
|
+
'Ctrl-d': handleDelete,
|
|
2114
|
+
'Ctrl-Alt-Backspace': handleDelete,
|
|
2115
|
+
'Alt-Delete': handleDelete,
|
|
2116
|
+
'Alt-d': handleDelete,
|
|
2117
|
+
'Ctrl-a': () => this.editor.commands.selectTextblockStart(),
|
|
2118
|
+
'Ctrl-e': () => this.editor.commands.selectTextblockEnd(),
|
|
2119
|
+
};
|
|
2120
|
+
if (isiOS() || isMacOS()) {
|
|
2121
|
+
return macKeymap;
|
|
2122
|
+
}
|
|
2123
|
+
return pcKeymap;
|
|
2076
2124
|
},
|
|
2077
2125
|
addProseMirrorPlugins() {
|
|
2078
2126
|
return [
|