@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.
@@ -737,7 +737,12 @@
737
737
  joinForward: joinForward
738
738
  });
739
739
 
740
- const mac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false;
740
+ function isMacOS() {
741
+ return typeof navigator !== 'undefined'
742
+ ? /Mac/.test(navigator.platform)
743
+ : false;
744
+ }
745
+
741
746
  function normalizeKeyName(name) {
742
747
  const parts = name.split(/-(?!$)/);
743
748
  let result = parts[parts.length - 1];
@@ -763,7 +768,7 @@
763
768
  shift = true;
764
769
  }
765
770
  else if (/^mod$/i.test(mod)) {
766
- if (mac) {
771
+ if (isiOS() || isMacOS()) {
767
772
  meta = true;
768
773
  }
769
774
  else {
@@ -1015,6 +1020,26 @@
1015
1020
  selectParentNode: selectParentNode
1016
1021
  });
1017
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
+
1018
1043
  function createDocument(content, schema, parseOptions = {}) {
1019
1044
  return createNodeFromContent(content, schema, { slice: false, parseOptions });
1020
1045
  }
@@ -1813,6 +1838,8 @@
1813
1838
  ...selectNodeBackward$1,
1814
1839
  ...selectNodeForward$1,
1815
1840
  ...selectParentNode$1,
1841
+ ...selectTextblockEnd$1,
1842
+ ...selectTextblockStart$1,
1816
1843
  ...setContent$1,
1817
1844
  ...setMark$1,
1818
1845
  ...setMeta$1,
@@ -2052,13 +2079,14 @@
2052
2079
  () => commands.joinForward(),
2053
2080
  () => commands.selectNodeForward(),
2054
2081
  ]);
2055
- return {
2056
- Enter: () => this.editor.commands.first(({ commands }) => [
2057
- () => commands.newlineInCode(),
2058
- () => commands.createParagraphNear(),
2059
- () => commands.liftEmptyBlock(),
2060
- () => commands.splitBlock(),
2061
- ]),
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,
2062
2090
  'Mod-Enter': () => this.editor.commands.exitCode(),
2063
2091
  Backspace: handleBackspace,
2064
2092
  'Mod-Backspace': handleBackspace,
@@ -2067,6 +2095,26 @@
2067
2095
  'Mod-Delete': handleDelete,
2068
2096
  'Mod-a': () => this.editor.commands.selectAll(),
2069
2097
  };
2098
+ const pcKeymap = {
2099
+ ...baseKeymap,
2100
+ Home: () => this.editor.commands.selectTextblockStart(),
2101
+ End: () => this.editor.commands.selectTextblockStart(),
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;
2070
2118
  },
2071
2119
  addProseMirrorPlugins() {
2072
2120
  return [