@kerebron/extension-basic-editor 0.2.0 → 0.4.1

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.
Files changed (197) hide show
  1. package/README.md +4 -2
  2. package/esm/editor/src/CoreEditor.d.ts +24 -9
  3. package/esm/editor/src/CoreEditor.d.ts.map +1 -1
  4. package/esm/editor/src/CoreEditor.js +125 -70
  5. package/esm/editor/src/DummyEditorView.d.ts +60 -0
  6. package/esm/editor/src/DummyEditorView.d.ts.map +1 -0
  7. package/esm/editor/src/DummyEditorView.js +277 -0
  8. package/esm/editor/src/Extension.d.ts +15 -10
  9. package/esm/editor/src/Extension.d.ts.map +1 -1
  10. package/esm/editor/src/Extension.js +23 -3
  11. package/esm/editor/src/ExtensionManager.d.ts +9 -9
  12. package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
  13. package/esm/editor/src/ExtensionManager.js +81 -74
  14. package/esm/editor/src/Mark.d.ts +11 -6
  15. package/esm/editor/src/Mark.d.ts.map +1 -1
  16. package/esm/editor/src/Mark.js +19 -2
  17. package/esm/editor/src/Node.d.ts +18 -13
  18. package/esm/editor/src/Node.d.ts.map +1 -1
  19. package/esm/editor/src/Node.js +22 -5
  20. package/esm/editor/src/commands/CommandManager.d.ts +14 -11
  21. package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
  22. package/esm/editor/src/commands/CommandManager.js +64 -6
  23. package/esm/editor/src/commands/baseCommandFactories.d.ts +3 -0
  24. package/esm/editor/src/commands/baseCommandFactories.d.ts.map +1 -0
  25. package/esm/editor/src/commands/baseCommandFactories.js +836 -0
  26. package/esm/editor/src/commands/keyCommandFactories.d.ts +3 -0
  27. package/esm/editor/src/commands/keyCommandFactories.d.ts.map +1 -0
  28. package/esm/editor/src/commands/keyCommandFactories.js +10 -0
  29. package/esm/editor/src/commands/mod.d.ts +5 -47
  30. package/esm/editor/src/commands/mod.d.ts.map +1 -1
  31. package/esm/editor/src/commands/mod.js +14 -866
  32. package/esm/editor/src/commands/replaceCommandFactories.d.ts +3 -0
  33. package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +1 -0
  34. package/esm/editor/src/commands/replaceCommandFactories.js +94 -0
  35. package/esm/editor/src/commands/types.d.ts +18 -0
  36. package/esm/editor/src/commands/types.d.ts.map +1 -0
  37. package/esm/editor/src/commands/types.js +1 -0
  38. package/esm/editor/src/mod.d.ts +3 -0
  39. package/esm/editor/src/mod.d.ts.map +1 -1
  40. package/esm/editor/src/mod.js +3 -0
  41. package/esm/editor/src/nodeToTreeString.d.ts +8 -2
  42. package/esm/editor/src/nodeToTreeString.d.ts.map +1 -1
  43. package/esm/editor/src/nodeToTreeString.js +47 -29
  44. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +6 -0
  45. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +1 -0
  46. package/esm/editor/src/plugins/TrackSelecionPlugin.js +24 -0
  47. package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +2 -2
  48. package/esm/editor/src/plugins/keymap/keymap.d.ts +11 -0
  49. package/esm/editor/src/plugins/keymap/keymap.d.ts.map +1 -0
  50. package/esm/editor/src/plugins/keymap/keymap.js +125 -0
  51. package/esm/editor/src/plugins/keymap/mod.d.ts +2 -0
  52. package/esm/editor/src/plugins/keymap/mod.d.ts.map +1 -0
  53. package/esm/editor/src/plugins/keymap/mod.js +1 -0
  54. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +4 -0
  55. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +1 -0
  56. package/esm/editor/src/plugins/keymap/w3c-keyname.js +124 -0
  57. package/esm/editor/src/types.d.ts +30 -7
  58. package/esm/editor/src/types.d.ts.map +1 -1
  59. package/esm/editor/src/ui.d.ts +15 -0
  60. package/esm/editor/src/ui.d.ts.map +1 -0
  61. package/esm/editor/src/ui.js +16 -0
  62. package/esm/editor/src/utilities/SmartOutput.d.ts +41 -0
  63. package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -0
  64. package/esm/editor/src/utilities/SmartOutput.js +228 -0
  65. package/esm/editor/src/utilities/createNodeFromContent.d.ts +4 -3
  66. package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +1 -1
  67. package/esm/editor/src/utilities/createNodeFromContent.js +4 -5
  68. package/esm/editor/src/utilities/getHtmlAttributes.d.ts +8 -3
  69. package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +1 -1
  70. package/esm/editor/src/utilities/getShadowRoot.d.ts +2 -0
  71. package/esm/editor/src/utilities/getShadowRoot.d.ts.map +1 -0
  72. package/esm/editor/src/utilities/getShadowRoot.js +16 -0
  73. package/esm/editor/src/utilities/mod.d.ts +3 -0
  74. package/esm/editor/src/utilities/mod.d.ts.map +1 -1
  75. package/esm/editor/src/utilities/mod.js +3 -0
  76. package/esm/editor/src/utilities/toRawTextResult.d.ts +3 -0
  77. package/esm/editor/src/utilities/toRawTextResult.d.ts.map +1 -0
  78. package/esm/editor/src/utilities/toRawTextResult.js +21 -0
  79. package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts +1 -2
  80. package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts.map +1 -1
  81. package/esm/extension-basic-editor/src/ExtensionBaseKeymap.js +40 -14
  82. package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts +11 -0
  83. package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts.map +1 -0
  84. package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.js +71 -0
  85. package/esm/extension-basic-editor/src/ExtensionBasicEditor.d.ts +23 -9
  86. package/esm/extension-basic-editor/src/ExtensionBasicEditor.d.ts.map +1 -1
  87. package/esm/extension-basic-editor/src/ExtensionBasicEditor.js +38 -8
  88. package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts +7 -0
  89. package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts.map +1 -1
  90. package/esm/extension-basic-editor/src/ExtensionDropcursor.js +211 -1
  91. package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts +21 -1
  92. package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts.map +1 -1
  93. package/esm/extension-basic-editor/src/ExtensionGapcursor.js +239 -1
  94. package/esm/extension-basic-editor/src/ExtensionHistory.d.ts +4 -3
  95. package/esm/extension-basic-editor/src/ExtensionHistory.d.ts.map +1 -1
  96. package/esm/extension-basic-editor/src/ExtensionHistory.js +29 -3
  97. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +1 -1
  98. package/esm/extension-basic-editor/src/ExtensionHtml.js +7 -4
  99. package/esm/extension-basic-editor/src/ExtensionMediaUpload.d.ts +24 -0
  100. package/esm/extension-basic-editor/src/ExtensionMediaUpload.d.ts.map +1 -0
  101. package/esm/extension-basic-editor/src/ExtensionMediaUpload.js +176 -0
  102. package/esm/extension-basic-editor/src/ExtensionSelection.d.ts +11 -0
  103. package/esm/extension-basic-editor/src/ExtensionSelection.d.ts.map +1 -0
  104. package/esm/extension-basic-editor/src/ExtensionSelection.js +237 -0
  105. package/esm/extension-basic-editor/src/MarkBookmark.d.ts.map +1 -1
  106. package/esm/extension-basic-editor/src/MarkChange.d.ts.map +1 -1
  107. package/esm/extension-basic-editor/src/MarkCode.d.ts +4 -7
  108. package/esm/extension-basic-editor/src/MarkCode.d.ts.map +1 -1
  109. package/esm/extension-basic-editor/src/MarkCode.js +2 -11
  110. package/esm/extension-basic-editor/src/MarkHighlight.d.ts +8 -0
  111. package/esm/extension-basic-editor/src/MarkHighlight.d.ts.map +1 -0
  112. package/esm/extension-basic-editor/src/MarkHighlight.js +43 -0
  113. package/esm/extension-basic-editor/src/MarkItalic.d.ts +4 -6
  114. package/esm/extension-basic-editor/src/MarkItalic.d.ts.map +1 -1
  115. package/esm/extension-basic-editor/src/MarkItalic.js +2 -11
  116. package/esm/extension-basic-editor/src/MarkLink.d.ts +1 -11
  117. package/esm/extension-basic-editor/src/MarkLink.d.ts.map +1 -1
  118. package/esm/extension-basic-editor/src/MarkLink.js +0 -32
  119. package/esm/extension-basic-editor/src/MarkStrike.d.ts +11 -0
  120. package/esm/extension-basic-editor/src/MarkStrike.d.ts.map +1 -0
  121. package/esm/extension-basic-editor/src/MarkStrike.js +39 -0
  122. package/esm/extension-basic-editor/src/MarkStrong.d.ts +4 -7
  123. package/esm/extension-basic-editor/src/MarkStrong.d.ts.map +1 -1
  124. package/esm/extension-basic-editor/src/MarkStrong.js +2 -11
  125. package/esm/extension-basic-editor/src/MarkTextColor.d.ts +8 -0
  126. package/esm/extension-basic-editor/src/MarkTextColor.d.ts.map +1 -0
  127. package/esm/extension-basic-editor/src/MarkTextColor.js +35 -0
  128. package/esm/extension-basic-editor/src/MarkUnderline.d.ts +3 -5
  129. package/esm/extension-basic-editor/src/MarkUnderline.d.ts.map +1 -1
  130. package/esm/extension-basic-editor/src/MarkUnderline.js +2 -11
  131. package/esm/extension-basic-editor/src/NodeAside.d.ts +0 -3
  132. package/esm/extension-basic-editor/src/NodeAside.d.ts.map +1 -1
  133. package/esm/extension-basic-editor/src/NodeAside.js +0 -8
  134. package/esm/extension-basic-editor/src/NodeBlockquote.d.ts +3 -6
  135. package/esm/extension-basic-editor/src/NodeBlockquote.d.ts.map +1 -1
  136. package/esm/extension-basic-editor/src/NodeBlockquote.js +2 -11
  137. package/esm/extension-basic-editor/src/NodeBulletList.d.ts +4 -7
  138. package/esm/extension-basic-editor/src/NodeBulletList.d.ts.map +1 -1
  139. package/esm/extension-basic-editor/src/NodeBulletList.js +2 -11
  140. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts +9 -0
  141. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts.map +1 -0
  142. package/esm/extension-basic-editor/src/NodeCodeBlock.js +58 -0
  143. package/esm/extension-basic-editor/src/NodeDefinitionDesc.d.ts +8 -0
  144. package/esm/extension-basic-editor/src/NodeDefinitionDesc.d.ts.map +1 -0
  145. package/esm/extension-basic-editor/src/NodeDefinitionDesc.js +29 -0
  146. package/esm/extension-basic-editor/src/NodeDefinitionList.d.ts +13 -0
  147. package/esm/extension-basic-editor/src/NodeDefinitionList.d.ts.map +1 -0
  148. package/esm/extension-basic-editor/src/NodeDefinitionList.js +41 -0
  149. package/esm/extension-basic-editor/src/NodeDefinitionTerm.d.ts +8 -0
  150. package/esm/extension-basic-editor/src/NodeDefinitionTerm.d.ts.map +1 -0
  151. package/esm/extension-basic-editor/src/NodeDefinitionTerm.js +29 -0
  152. package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts +7 -0
  153. package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts.map +1 -0
  154. package/esm/extension-basic-editor/src/NodeDocumentCode.js +37 -0
  155. package/esm/extension-basic-editor/src/NodeFrontmatter.d.ts +8 -0
  156. package/esm/extension-basic-editor/src/NodeFrontmatter.d.ts.map +1 -0
  157. package/esm/extension-basic-editor/src/NodeFrontmatter.js +29 -0
  158. package/esm/extension-basic-editor/src/NodeHardBreak.d.ts +5 -2
  159. package/esm/extension-basic-editor/src/NodeHardBreak.d.ts.map +1 -1
  160. package/esm/extension-basic-editor/src/NodeHardBreak.js +40 -53
  161. package/esm/extension-basic-editor/src/NodeHeading.d.ts +3 -14
  162. package/esm/extension-basic-editor/src/NodeHeading.d.ts.map +1 -1
  163. package/esm/extension-basic-editor/src/NodeHeading.js +2 -15
  164. package/esm/extension-basic-editor/src/NodeHorizontalRule.d.ts +4 -4
  165. package/esm/extension-basic-editor/src/NodeHorizontalRule.d.ts.map +1 -1
  166. package/esm/extension-basic-editor/src/NodeHorizontalRule.js +1 -2
  167. package/esm/extension-basic-editor/src/NodeListItem.d.ts +7 -5
  168. package/esm/extension-basic-editor/src/NodeListItem.d.ts.map +1 -1
  169. package/esm/extension-basic-editor/src/NodeListItem.js +10 -15
  170. package/esm/extension-basic-editor/src/NodeMath.d.ts +8 -0
  171. package/esm/extension-basic-editor/src/NodeMath.d.ts.map +1 -0
  172. package/esm/extension-basic-editor/src/NodeMath.js +112 -0
  173. package/esm/extension-basic-editor/src/NodeOrderedList.d.ts +3 -6
  174. package/esm/extension-basic-editor/src/NodeOrderedList.d.ts.map +1 -1
  175. package/esm/extension-basic-editor/src/NodeOrderedList.js +4 -14
  176. package/esm/extension-basic-editor/src/NodeParagraph.d.ts +2 -5
  177. package/esm/extension-basic-editor/src/NodeParagraph.d.ts.map +1 -1
  178. package/esm/extension-basic-editor/src/NodeParagraph.js +2 -11
  179. package/esm/extension-basic-editor/src/NodeTaskItem.d.ts +24 -0
  180. package/esm/extension-basic-editor/src/NodeTaskItem.d.ts.map +1 -0
  181. package/esm/extension-basic-editor/src/NodeTaskItem.js +153 -0
  182. package/esm/extension-basic-editor/src/NodeTaskList.d.ts +11 -0
  183. package/esm/extension-basic-editor/src/NodeTaskList.d.ts.map +1 -0
  184. package/esm/extension-basic-editor/src/NodeTaskList.js +38 -0
  185. package/esm/extension-basic-editor/src/NodeText.d.ts +0 -1
  186. package/esm/extension-basic-editor/src/NodeText.d.ts.map +1 -1
  187. package/esm/extension-basic-editor/src/NodeText.js +0 -6
  188. package/esm/extension-basic-editor/src/NodeVideo.d.ts +8 -0
  189. package/esm/extension-basic-editor/src/NodeVideo.d.ts.map +1 -0
  190. package/esm/extension-basic-editor/src/NodeVideo.js +58 -0
  191. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +24 -0
  192. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +1 -0
  193. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +35 -0
  194. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +25 -0
  195. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +1 -0
  196. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +96 -0
  197. package/package.json +29 -6
@@ -0,0 +1,3 @@
1
+ import type { CommandFactory } from './mod.js';
2
+ export declare const replaceCommandFactories: Record<string, CommandFactory>;
3
+ //# sourceMappingURL=replaceCommandFactories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replaceCommandFactories.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/replaceCommandFactories.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,UAAU,CAAC;AAwHxD,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAMlE,CAAC"}
@@ -0,0 +1,94 @@
1
+ import { Fragment, Slice } from 'prosemirror-model';
2
+ const replaceRangeText = (range, text) => {
3
+ return (state, dispatch) => {
4
+ const tr = state.tr;
5
+ const from = tr.mapping.map(range.from);
6
+ const to = tr.mapping.map(range.to);
7
+ const frag = Fragment.from(state.schema.text(text));
8
+ const insert = new Slice(frag, 0, 0);
9
+ tr.replace(from, to, insert);
10
+ if (dispatch) {
11
+ dispatch(tr);
12
+ }
13
+ return true;
14
+ };
15
+ };
16
+ const replaceRangeSlice = (range, insert) => {
17
+ return (state, dispatch) => {
18
+ const tr = state.tr;
19
+ const from = tr.mapping.map(range.from);
20
+ const to = tr.mapping.map(range.to);
21
+ tr.replace(from, to, insert);
22
+ if (dispatch) {
23
+ dispatch(tr);
24
+ }
25
+ return true;
26
+ };
27
+ };
28
+ function getTopMostBlockStartForOffset(state, offset) {
29
+ const { doc } = state;
30
+ const $pos = doc.resolve(offset);
31
+ const blockPos = $pos.before($pos.depth);
32
+ if ($pos.depth === 1)
33
+ return blockPos;
34
+ return $pos.start(1);
35
+ }
36
+ function getTopMostBlockEndForOffset(state, offset) {
37
+ const { doc } = state;
38
+ const $pos = doc.resolve(offset);
39
+ return $pos.end(1);
40
+ }
41
+ function getAdjacentTopBlock(state, offset) {
42
+ const { doc } = state;
43
+ if (offset < 0 || offset > doc.content.size) {
44
+ throw new RangeError('Offset is outside the document');
45
+ }
46
+ const $pos = doc.resolve(offset);
47
+ const atBlockStart = $pos.pos === $pos.start($pos.depth);
48
+ if (atBlockStart) {
49
+ return getTopMostBlockStartForOffset(state, offset);
50
+ }
51
+ else {
52
+ return getTopMostBlockEndForOffset(state, offset);
53
+ }
54
+ }
55
+ const insertBlockBefore = (pos, insert) => {
56
+ return (state, dispatch) => {
57
+ const tr = state.tr;
58
+ const blockPos = getTopMostBlockStartForOffset(state, tr.mapping.map(pos));
59
+ tr.insert(blockPos, insert);
60
+ if (dispatch) {
61
+ dispatch(tr);
62
+ }
63
+ return true;
64
+ };
65
+ };
66
+ const insertBlockAfter = (pos, insert) => {
67
+ return (state, dispatch) => {
68
+ const tr = state.tr;
69
+ const blockPos = getTopMostBlockEndForOffset(state, tr.mapping.map(pos));
70
+ tr.insert(blockPos, insert);
71
+ if (dispatch) {
72
+ dispatch(tr);
73
+ }
74
+ return true;
75
+ };
76
+ };
77
+ const insertBlockSmart = (pos, insert) => {
78
+ return (state, dispatch) => {
79
+ const tr = state.tr;
80
+ const blockPos = getAdjacentTopBlock(state, tr.mapping.map(pos));
81
+ tr.insert(blockPos, insert);
82
+ if (dispatch) {
83
+ dispatch(tr);
84
+ }
85
+ return true;
86
+ };
87
+ };
88
+ export const replaceCommandFactories = {
89
+ replaceRangeText,
90
+ replaceRangeSlice,
91
+ insertBlockBefore,
92
+ insertBlockAfter,
93
+ insertBlockSmart,
94
+ };
@@ -0,0 +1,18 @@
1
+ import type { Command } from 'prosemirror-state';
2
+ export { Command };
3
+ export type CommandFactory = (...args: any[]) => Command;
4
+ export interface Commands {
5
+ [name: string]: Command;
6
+ }
7
+ export interface CommandFactories {
8
+ [name: string]: CommandFactory;
9
+ }
10
+ export type CommandShortcuts = {
11
+ [name: string]: string;
12
+ };
13
+ export type ChainedCommands = {
14
+ [Item in keyof Commands]: (...args: unknown[]) => ChainedCommands;
15
+ } & {
16
+ run: () => boolean;
17
+ };
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/commands/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAEzD,MAAM,WAAW,QAAQ;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;CAChC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB;KACC,IAAI,IAAI,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,eAAe;CAClE,GACC;IACA,GAAG,EAAE,MAAM,OAAO,CAAC;CACpB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -3,4 +3,7 @@ export * from './Extension.js';
3
3
  export * from './Mark.js';
4
4
  export * from './Node.js';
5
5
  export * from './nodeToTreeString.js';
6
+ export * from './types.js';
7
+ export * from './utilities/SmartOutput.js';
8
+ export * from './ui.js';
6
9
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/editor/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/editor/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC"}
@@ -3,3 +3,6 @@ export * from './Extension.js';
3
3
  export * from './Mark.js';
4
4
  export * from './Node.js';
5
5
  export * from './nodeToTreeString.js';
6
+ export * from './types.js';
7
+ export * from './utilities/SmartOutput.js';
8
+ export * from './ui.js';
@@ -1,4 +1,10 @@
1
- import { Node } from 'prosemirror-model';
2
- export declare function nodeToTreeString(node: Node | Node[] | readonly Node[], level?: number, currentPos?: number): string;
1
+ import type { Node } from 'prosemirror-model';
2
+ import { SmartOutput } from './utilities/SmartOutput.js';
3
+ export interface NodeAndPos {
4
+ node: Node;
5
+ pos: number;
6
+ }
7
+ export declare function nodeToTreeStringOutput(output: SmartOutput<NodeAndPos>, node: Node | Node[] | readonly Node[], level?: number, currentPos?: number): SmartOutput<NodeAndPos> | undefined;
8
+ export declare function nodeToTreeString(node: Node | Node[] | readonly Node[]): string;
3
9
  export declare function debugNode(node: Node | Node[]): void;
4
10
  //# sourceMappingURL=nodeToTreeString.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAYzC,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,UA0Df;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAE5C"}
1
+ {"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAYzD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,EAC/B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,uCAmEf;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,UAIrE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAE5C"}
@@ -1,3 +1,4 @@
1
+ import { SmartOutput } from './utilities/SmartOutput.js';
1
2
  function trimText(str, maxLen = 20) {
2
3
  str = str.replaceAll('\n', '\\n');
3
4
  if (str.length <= maxLen) {
@@ -5,52 +6,69 @@ function trimText(str, maxLen = 20) {
5
6
  }
6
7
  return str.slice(0, maxLen) + '...';
7
8
  }
8
- export function nodeToTreeString(node, level = 0, currentPos = 0) {
9
+ export function nodeToTreeStringOutput(output, node, level = 0, currentPos = 0) {
9
10
  let delim = '';
10
11
  for (let i = 0; i < level; i++) {
11
12
  delim += ' ';
12
13
  }
13
- let output = '';
14
14
  if (Array.isArray(node)) {
15
15
  for (const child of node) {
16
- output += delim +
17
- nodeToTreeString(child, level + 1, currentPos).replace(/\s+$/gm, '') +
18
- '\n';
16
+ output.log(delim, { node: child, pos: currentPos });
17
+ nodeToTreeStringOutput(output, child, level + 1, currentPos);
18
+ // .replace(/\s+$/gm, '') +
19
+ // '\n'
19
20
  }
20
- return output;
21
+ return;
21
22
  }
22
23
  // https://prosemirror.net/docs/guide/#doc.indexing
23
24
  let line = '';
24
25
  // if (node.type) {
25
- line += ` - [${node.type.name}] `;
26
- // } else {
27
- // line += ` - `;
28
- // }
29
- line += `pos: ${currentPos}, `;
30
- line += `nodeSize: ${node.nodeSize}, `; // isLeaf ? 1 : 2 + this.content.size
31
- line += `epos: ${currentPos + node.nodeSize}, `; // isLeaf ? 1 : 2 + this.content.size
32
- if (node.content) {
33
- line += `fragment.size: ${node.content.size}, `;
34
- }
35
- output += (delim + line) + '\n';
36
- let marksLine = '';
37
- if (node.marks) {
38
- for (const mark of node.marks) {
39
- marksLine += `(${mark.type.name}), `;
26
+ if ('type' in node) {
27
+ line += ` - [${node.type.name}] `;
28
+ // } else {
29
+ // line += ` - `;
30
+ // }
31
+ line += `pos: ${currentPos}, `;
32
+ line += `nodeSize: ${node.nodeSize}, `; // isLeaf ? 1 : 2 + this.content.size
33
+ line += `epos: ${currentPos + node.nodeSize}, `; // isLeaf ? 1 : 2 + this.content.size
34
+ if (node.content) {
35
+ line += `fragment.size: ${node.content.size}, `;
36
+ }
37
+ output.log((delim + line) + '\n', { node, pos: currentPos });
38
+ let marksLine = '';
39
+ if (node.marks) {
40
+ for (const mark of node.marks) {
41
+ marksLine += `(${mark.type.name}), `;
42
+ }
43
+ }
44
+ if (marksLine) {
45
+ output.log((delim + ' ' + marksLine) + '\n', {
46
+ node,
47
+ pos: currentPos,
48
+ });
49
+ }
50
+ if (node.text) {
51
+ output.log((delim + ' "' + trimText(node.text) + '"') + '\n', {
52
+ node,
53
+ pos: currentPos,
54
+ });
40
55
  }
41
- }
42
- if (marksLine) {
43
- output += (delim + ' ' + marksLine) + '\n';
44
- }
45
- if (node.text) {
46
- output += (delim + ' "' + trimText(node.text) + '"') + '\n';
47
56
  }
48
57
  node.forEach((child, offset) => {
49
- output +=
50
- nodeToTreeString(child, level + 1, currentPos + offset + 1).replace(/\s+$/gm, '') + '\n'; // + (node.isLeaf ? 1 : 2)
58
+ // output +=
59
+ nodeToTreeStringOutput(output, child, level + 1, currentPos + offset + 1);
60
+ // .replace(
61
+ // /\s+$/gm,
62
+ // '',
63
+ // ) + '\n'; // + (node.isLeaf ? 1 : 2)
51
64
  });
52
65
  return output;
53
66
  }
67
+ export function nodeToTreeString(node) {
68
+ const output = new SmartOutput();
69
+ nodeToTreeStringOutput(output, node);
70
+ return output.toString();
71
+ }
54
72
  export function debugNode(node) {
55
73
  console.debug(nodeToTreeString(node));
56
74
  }
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import type { CoreEditor } from '../mod.js';
3
+ export declare class TrackSelecionPlugin extends Plugin {
4
+ constructor(editor: CoreEditor);
5
+ }
6
+ //# sourceMappingURL=TrackSelecionPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrackSelecionPlugin.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/plugins/TrackSelecionPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,qBAAa,mBAAoB,SAAQ,MAAM;gBACjC,MAAM,EAAE,UAAU;CAsB/B"}
@@ -0,0 +1,24 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ export class TrackSelecionPlugin extends Plugin {
3
+ constructor(editor) {
4
+ super({
5
+ view(editorView) {
6
+ return {
7
+ update(view, prevState) {
8
+ const state = view.state;
9
+ const prevSelection = prevState.selection;
10
+ const selection = state.selection;
11
+ if (!prevSelection.eq(selection)) {
12
+ const event = new CustomEvent('selection', {
13
+ detail: {
14
+ selection,
15
+ },
16
+ });
17
+ editor.dispatchEvent(event);
18
+ }
19
+ },
20
+ };
21
+ },
22
+ });
23
+ }
24
+ }
@@ -92,14 +92,14 @@ export class InputRulesPlugin extends Plugin {
92
92
  },
93
93
  props: {
94
94
  handleTextInput(view, from, to, text) {
95
- return run(view, from, to, text, rules, InputRulesPlugin);
95
+ return run(view, from, to, text, rules, this);
96
96
  },
97
97
  handleDOMEvents: {
98
98
  compositionend: (view) => {
99
99
  setTimeout(() => {
100
100
  let { $cursor } = view.state.selection;
101
101
  if ($cursor) {
102
- run(view, $cursor.pos, $cursor.pos, '', rules, plugin);
102
+ run(view, $cursor.pos, $cursor.pos, '', rules, this);
103
103
  }
104
104
  });
105
105
  },
@@ -0,0 +1,11 @@
1
+ import { Command, Plugin } from 'prosemirror-state';
2
+ import { EditorView } from 'prosemirror-view';
3
+ export declare class KeymapPlugin extends Plugin {
4
+ constructor(bindings: {
5
+ [key: string]: Command;
6
+ });
7
+ }
8
+ export declare function keydownHandler(bindings: {
9
+ [key: string]: Command;
10
+ }): (view: EditorView, event: KeyboardEvent) => boolean;
11
+ //# sourceMappingURL=keymap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keymap.d.ts","sourceRoot":"","sources":["../../../../../src/editor/src/plugins/keymap/keymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAyE9C,qBAAa,YAAa,SAAQ,MAAM;gBAC1B,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE;CAGjD;AAKD,wBAAgB,cAAc,CAC5B,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GACnC,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,KAAK,OAAO,CA6BrD"}
@@ -0,0 +1,125 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { base, keyName } from './w3c-keyname.js';
3
+ const mac = typeof navigator != 'undefined' &&
4
+ /Mac|iP(hone|[oa]d)/.test(navigator?.platform);
5
+ const windows = typeof navigator != 'undefined' &&
6
+ /Win/.test(navigator?.platform);
7
+ function normalizeKeyName(name) {
8
+ let parts = name.split(/-(?!$)/), result = parts[parts.length - 1];
9
+ if (result == 'Space')
10
+ result = ' ';
11
+ let alt, ctrl, shift, meta;
12
+ for (let i = 0; i < parts.length - 1; i++) {
13
+ let mod = parts[i];
14
+ if (/^(cmd|meta|m)$/i.test(mod))
15
+ meta = true;
16
+ else if (/^a(lt)?$/i.test(mod))
17
+ alt = true;
18
+ else if (/^(c|ctrl|control)$/i.test(mod))
19
+ ctrl = true;
20
+ else if (/^s(hift)?$/i.test(mod))
21
+ shift = true;
22
+ else if (/^mod$/i.test(mod)) {
23
+ if (mac)
24
+ meta = true;
25
+ else
26
+ ctrl = true;
27
+ }
28
+ else
29
+ throw new Error('Unrecognized modifier name: ' + mod);
30
+ }
31
+ if (alt)
32
+ result = 'Alt-' + result;
33
+ if (ctrl)
34
+ result = 'Ctrl-' + result;
35
+ if (meta)
36
+ result = 'Meta-' + result;
37
+ if (shift)
38
+ result = 'Shift-' + result;
39
+ return result;
40
+ }
41
+ function normalize(map) {
42
+ let copy = Object.create(null);
43
+ for (let prop in map)
44
+ copy[normalizeKeyName(prop)] = map[prop];
45
+ return copy;
46
+ }
47
+ function modifiers(name, event, shift = true) {
48
+ if (event.altKey)
49
+ name = 'Alt-' + name;
50
+ if (event.ctrlKey)
51
+ name = 'Ctrl-' + name;
52
+ if (event.metaKey)
53
+ name = 'Meta-' + name;
54
+ if (shift && event.shiftKey)
55
+ name = 'Shift-' + name;
56
+ return name;
57
+ }
58
+ /// Create a keymap plugin for the given set of bindings.
59
+ ///
60
+ /// Bindings should map key names to [command](#commands)-style
61
+ /// functions, which will be called with `(EditorState, dispatch,
62
+ /// EditorView)` arguments, and should return true when they've handled
63
+ /// the key. Note that the view argument isn't part of the command
64
+ /// protocol, but can be used as an escape hatch if a binding needs to
65
+ /// directly interact with the UI.
66
+ ///
67
+ /// Key names may be strings like `"Shift-Ctrl-Enter"`—a key
68
+ /// identifier prefixed with zero or more modifiers. Key identifiers
69
+ /// are based on the strings that can appear in
70
+ /// [`KeyEvent.key`](https:///developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key).
71
+ /// Use lowercase letters to refer to letter keys (or uppercase letters
72
+ /// if you want shift to be held). You may use `"Space"` as an alias
73
+ /// for the `" "` name.
74
+ ///
75
+ /// Modifiers can be given in any order. `Shift-` (or `s-`), `Alt-` (or
76
+ /// `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or
77
+ /// `Meta-`) are recognized. For characters that are created by holding
78
+ /// shift, the `Shift-` prefix is implied, and should not be added
79
+ /// explicitly.
80
+ ///
81
+ /// You can use `Mod-` as a shorthand for `Cmd-` on Mac and `Ctrl-` on
82
+ /// other platforms.
83
+ ///
84
+ /// You can add multiple keymap plugins to an editor. The order in
85
+ /// which they appear determines their precedence (the ones early in
86
+ /// the array get to dispatch first).
87
+ export class KeymapPlugin extends Plugin {
88
+ constructor(bindings) {
89
+ super({ props: { handleKeyDown: keydownHandler(bindings) } });
90
+ }
91
+ }
92
+ /// Given a set of bindings (using the same format as
93
+ /// [`keymap`](#keymap.keymap)), return a [keydown
94
+ /// handler](#view.EditorProps.handleKeyDown) that handles them.
95
+ export function keydownHandler(bindings) {
96
+ let map = normalize(bindings);
97
+ return function (view, event) {
98
+ let name = keyName(event), baseName, direct = map[modifiers(name, event)];
99
+ if (direct && direct(view.state, view.dispatch, view))
100
+ return true;
101
+ // A character key
102
+ if (name.length == 1 && name != ' ') {
103
+ if (event.shiftKey) {
104
+ // In case the name was already modified by shift, try looking
105
+ // it up without its shift modifier
106
+ let noShift = map[modifiers(name, event, false)];
107
+ if (noShift && noShift(view.state, view.dispatch, view))
108
+ return true;
109
+ }
110
+ if ((event.altKey || event.metaKey || event.ctrlKey) &&
111
+ // Ctrl-Alt may be used for AltGr on Windows
112
+ !(windows && event.ctrlKey && event.altKey) &&
113
+ (baseName = base[event.keyCode]) && baseName != name) {
114
+ // Try falling back to the keyCode when there's a modifier
115
+ // active or the character produced isn't ASCII, and our table
116
+ // produces a different name from the the keyCode. See #668,
117
+ // #1060, #1529.
118
+ let fromCode = map[modifiers(baseName, event)];
119
+ if (fromCode && fromCode(view.state, view.dispatch, view))
120
+ return true;
121
+ }
122
+ }
123
+ return false;
124
+ };
125
+ }
@@ -0,0 +1,2 @@
1
+ export * from './keymap.js';
2
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../src/editor/src/plugins/keymap/mod.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './keymap.js';
@@ -0,0 +1,4 @@
1
+ export declare const base: Record<number, string>;
2
+ export declare const shift: Record<number, string>;
3
+ export declare function keyName(event: KeyboardEvent): string;
4
+ //# sourceMappingURL=w3c-keyname.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"w3c-keyname.d.ts","sourceRoot":"","sources":["../../../../../src/editor/src/plugins/keymap/w3c-keyname.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqDvC,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyBxC,CAAC;AAuBF,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,UAmB3C"}
@@ -0,0 +1,124 @@
1
+ export const base = {
2
+ 8: 'Backspace',
3
+ 9: 'Tab',
4
+ 10: 'Enter',
5
+ 12: 'NumLock',
6
+ 13: 'Enter',
7
+ 16: 'Shift',
8
+ 17: 'Control',
9
+ 18: 'Alt',
10
+ 20: 'CapsLock',
11
+ 27: 'Escape',
12
+ 32: ' ',
13
+ 33: 'PageUp',
14
+ 34: 'PageDown',
15
+ 35: 'End',
16
+ 36: 'Home',
17
+ 37: 'ArrowLeft',
18
+ 38: 'ArrowUp',
19
+ 39: 'ArrowRight',
20
+ 40: 'ArrowDown',
21
+ 44: 'PrintScreen',
22
+ 45: 'Insert',
23
+ 46: 'Delete',
24
+ 59: ';',
25
+ 61: '=',
26
+ 91: 'Meta',
27
+ 92: 'Meta',
28
+ 106: '*',
29
+ 107: '+',
30
+ 108: ',',
31
+ 109: '-',
32
+ 110: '.',
33
+ 111: '/',
34
+ 144: 'NumLock',
35
+ 145: 'ScrollLock',
36
+ 160: 'Shift',
37
+ 161: 'Shift',
38
+ 162: 'Control',
39
+ 163: 'Control',
40
+ 164: 'Alt',
41
+ 165: 'Alt',
42
+ 173: '-',
43
+ 186: ';',
44
+ 187: '=',
45
+ 188: ',',
46
+ 189: '-',
47
+ 190: '.',
48
+ 191: '/',
49
+ 192: '`',
50
+ 219: '[',
51
+ 220: '\\',
52
+ 221: ']',
53
+ 222: "'",
54
+ };
55
+ export const shift = {
56
+ 48: ')',
57
+ 49: '!',
58
+ 50: '@',
59
+ 51: '#',
60
+ 52: '$',
61
+ 53: '%',
62
+ 54: '^',
63
+ 55: '&',
64
+ 56: '*',
65
+ 57: '(',
66
+ 59: ':',
67
+ 61: '+',
68
+ 173: '_',
69
+ 186: ':',
70
+ 187: '+',
71
+ 188: '<',
72
+ 189: '_',
73
+ 190: '>',
74
+ 191: '?',
75
+ 192: '~',
76
+ 219: '{',
77
+ 220: '|',
78
+ 221: '}',
79
+ 222: '"',
80
+ };
81
+ const mac = typeof navigator != 'undefined' && /Mac/.test(navigator.platform);
82
+ const ie = typeof navigator != 'undefined' &&
83
+ /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
84
+ // Fill in the digit keys
85
+ for (let i = 0; i < 10; i++)
86
+ base[48 + i] = base[96 + i] = String(i);
87
+ // The function keys
88
+ for (let i = 1; i <= 24; i++)
89
+ base[i + 111] = 'F' + i;
90
+ // And the alphabetic keys
91
+ for (let i = 65; i <= 90; i++) {
92
+ base[i] = String.fromCharCode(i + 32);
93
+ shift[i] = String.fromCharCode(i);
94
+ }
95
+ // For each code that doesn't have a shift-equivalent, copy the base name
96
+ for (const code in base) {
97
+ if (!shift.hasOwnProperty(code))
98
+ shift[code] = base[code];
99
+ }
100
+ export function keyName(event) {
101
+ // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.
102
+ // On IE, shift effect is never included in `.key`.
103
+ const ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||
104
+ ie && event.shiftKey && event.key && event.key.length == 1 ||
105
+ event.key == 'Unidentified';
106
+ let name = (!ignoreKey && event.key) ||
107
+ (event.shiftKey ? shift : base)[event.keyCode] ||
108
+ event.key || 'Unidentified';
109
+ // Edge sometimes produces wrong names (Issue #3)
110
+ if (name == 'Esc')
111
+ name = 'Escape';
112
+ if (name == 'Del')
113
+ name = 'Delete';
114
+ // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/
115
+ if (name == 'Left')
116
+ name = 'ArrowLeft';
117
+ if (name == 'Up')
118
+ name = 'ArrowUp';
119
+ if (name == 'Right')
120
+ name = 'ArrowRight';
121
+ if (name == 'Down')
122
+ name = 'ArrowDown';
123
+ return name;
124
+ }