@kerebron/editor 0.4.27 → 0.4.28

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 (110) hide show
  1. package/assets/base.css +114 -0
  2. package/assets/content.css +35 -0
  3. package/assets/gapcursor.css +25 -0
  4. package/assets/index.css +2 -0
  5. package/assets/main.css +8 -0
  6. package/assets/mobile.css +33 -0
  7. package/assets/prosemirror.css +20 -0
  8. package/assets/search.css +6 -0
  9. package/assets/vars.css +110 -0
  10. package/esm/CoreEditor.d.ts +40 -0
  11. package/esm/CoreEditor.d.ts.map +1 -0
  12. package/esm/CoreEditor.js +223 -0
  13. package/esm/DummyEditorView.d.ts +60 -0
  14. package/esm/DummyEditorView.d.ts.map +1 -0
  15. package/esm/DummyEditorView.js +242 -0
  16. package/esm/Extension.d.ts +31 -0
  17. package/esm/Extension.d.ts.map +1 -0
  18. package/esm/Extension.js +34 -0
  19. package/esm/ExtensionManager.d.ts +32 -0
  20. package/esm/ExtensionManager.d.ts.map +1 -0
  21. package/esm/ExtensionManager.js +222 -0
  22. package/esm/Mark.d.ts +23 -0
  23. package/esm/Mark.d.ts.map +1 -0
  24. package/esm/Mark.js +27 -0
  25. package/esm/Node.d.ts +32 -0
  26. package/esm/Node.d.ts.map +1 -0
  27. package/esm/Node.js +36 -0
  28. package/esm/commands/CommandManager.d.ts +24 -0
  29. package/esm/commands/CommandManager.d.ts.map +1 -0
  30. package/esm/commands/CommandManager.js +100 -0
  31. package/esm/commands/baseCommandFactories.d.ts +3 -0
  32. package/esm/commands/baseCommandFactories.d.ts.map +1 -0
  33. package/esm/commands/baseCommandFactories.js +861 -0
  34. package/esm/commands/createChainableState.d.ts +3 -0
  35. package/esm/commands/createChainableState.d.ts.map +1 -0
  36. package/esm/commands/createChainableState.js +29 -0
  37. package/esm/commands/keyCommandFactories.d.ts +3 -0
  38. package/esm/commands/keyCommandFactories.d.ts.map +1 -0
  39. package/esm/commands/keyCommandFactories.js +10 -0
  40. package/esm/commands/mod.d.ts +7 -0
  41. package/esm/commands/mod.d.ts.map +1 -0
  42. package/esm/commands/mod.js +81 -0
  43. package/esm/commands/replaceCommandFactories.d.ts +3 -0
  44. package/esm/commands/replaceCommandFactories.d.ts.map +1 -0
  45. package/esm/commands/replaceCommandFactories.js +94 -0
  46. package/esm/commands/types.d.ts +22 -0
  47. package/esm/commands/types.d.ts.map +1 -0
  48. package/esm/commands/types.js +1 -0
  49. package/esm/mod.d.ts +9 -0
  50. package/esm/mod.d.ts.map +1 -0
  51. package/esm/mod.js +8 -0
  52. package/esm/nodeToTreeString.d.ts +10 -0
  53. package/esm/nodeToTreeString.d.ts.map +1 -0
  54. package/esm/nodeToTreeString.js +74 -0
  55. package/esm/package.json +3 -0
  56. package/esm/plugins/TrackSelecionPlugin.d.ts +6 -0
  57. package/esm/plugins/TrackSelecionPlugin.d.ts.map +1 -0
  58. package/esm/plugins/TrackSelecionPlugin.js +24 -0
  59. package/esm/plugins/input-rules/InputRulesPlugin.d.ts +25 -0
  60. package/esm/plugins/input-rules/InputRulesPlugin.d.ts.map +1 -0
  61. package/esm/plugins/input-rules/InputRulesPlugin.js +168 -0
  62. package/esm/plugins/input-rules/mod.d.ts +3 -0
  63. package/esm/plugins/input-rules/mod.d.ts.map +1 -0
  64. package/esm/plugins/input-rules/mod.js +2 -0
  65. package/esm/plugins/input-rules/rulebuilders.d.ts +6 -0
  66. package/esm/plugins/input-rules/rulebuilders.d.ts.map +1 -0
  67. package/esm/plugins/input-rules/rulebuilders.js +64 -0
  68. package/esm/plugins/keymap/keymap.d.ts +12 -0
  69. package/esm/plugins/keymap/keymap.d.ts.map +1 -0
  70. package/esm/plugins/keymap/keymap.js +125 -0
  71. package/esm/plugins/keymap/mod.d.ts +2 -0
  72. package/esm/plugins/keymap/mod.d.ts.map +1 -0
  73. package/esm/plugins/keymap/mod.js +1 -0
  74. package/esm/plugins/keymap/w3c-keyname.d.ts +4 -0
  75. package/esm/plugins/keymap/w3c-keyname.d.ts.map +1 -0
  76. package/esm/plugins/keymap/w3c-keyname.js +124 -0
  77. package/esm/search/mod.d.ts +3 -0
  78. package/esm/search/mod.d.ts.map +1 -0
  79. package/esm/search/mod.js +2 -0
  80. package/esm/search/query.d.ts +45 -0
  81. package/esm/search/query.d.ts.map +1 -0
  82. package/esm/search/query.js +334 -0
  83. package/esm/search/search.d.ts +32 -0
  84. package/esm/search/search.d.ts.map +1 -0
  85. package/esm/search/search.js +199 -0
  86. package/esm/types.d.ts +59 -0
  87. package/esm/types.d.ts.map +1 -0
  88. package/esm/types.js +1 -0
  89. package/esm/ui.d.ts +15 -0
  90. package/esm/ui.d.ts.map +1 -0
  91. package/esm/ui.js +16 -0
  92. package/esm/utilities/SmartOutput.d.ts +41 -0
  93. package/esm/utilities/SmartOutput.d.ts.map +1 -0
  94. package/esm/utilities/SmartOutput.js +201 -0
  95. package/esm/utilities/createNodeFromContent.d.ts +9 -0
  96. package/esm/utilities/createNodeFromContent.d.ts.map +1 -0
  97. package/esm/utilities/createNodeFromContent.js +32 -0
  98. package/esm/utilities/getHtmlAttributes.d.ts +9 -0
  99. package/esm/utilities/getHtmlAttributes.d.ts.map +1 -0
  100. package/esm/utilities/getHtmlAttributes.js +47 -0
  101. package/esm/utilities/getShadowRoot.d.ts +2 -0
  102. package/esm/utilities/getShadowRoot.d.ts.map +1 -0
  103. package/esm/utilities/getShadowRoot.js +16 -0
  104. package/esm/utilities/mod.d.ts +6 -0
  105. package/esm/utilities/mod.d.ts.map +1 -0
  106. package/esm/utilities/mod.js +5 -0
  107. package/esm/utilities/toRawTextResult.d.ts +3 -0
  108. package/esm/utilities/toRawTextResult.d.ts.map +1 -0
  109. package/esm/utilities/toRawTextResult.js +21 -0
  110. package/package.json +1 -2
package/esm/Node.js ADDED
@@ -0,0 +1,36 @@
1
+ export class Node {
2
+ config;
3
+ type = 'node';
4
+ name = 'node';
5
+ editor;
6
+ attributes = {};
7
+ constructor(config = {}) {
8
+ this.config = config;
9
+ }
10
+ setEditor(editor) {
11
+ this.editor = editor;
12
+ }
13
+ created() {
14
+ }
15
+ getNodeSpec() {
16
+ throw new Error('NodeSpec not defined: ' + this.name);
17
+ }
18
+ getInputRules(type) {
19
+ return [];
20
+ }
21
+ getProseMirrorPlugins() {
22
+ return [];
23
+ }
24
+ getCommandFactories(editor, type) {
25
+ return {};
26
+ }
27
+ getKeyboardShortcuts(editor) {
28
+ return {};
29
+ }
30
+ getNodeView(editor) {
31
+ return undefined;
32
+ }
33
+ getConverters(editor, schema) {
34
+ return {};
35
+ }
36
+ }
@@ -0,0 +1,24 @@
1
+ import type { EditorState, Transaction } from 'prosemirror-state';
2
+ import type { CoreEditor } from '../CoreEditor.js';
3
+ import type { ChainedCommands, CommandFactories, CommandFactory } from './types.js';
4
+ type CommandRunner = (...args: any[]) => boolean;
5
+ export declare class CommandManager {
6
+ private editor;
7
+ readonly commandFactories: {
8
+ [key: string]: CommandFactory;
9
+ };
10
+ readonly run: {
11
+ [key: string]: CommandRunner;
12
+ };
13
+ private debug;
14
+ constructor(editor: CoreEditor);
15
+ mergeCommandFactories(toInsert: Partial<CommandFactories>, extName: string): void;
16
+ private overwriteCommandFactory;
17
+ get state(): EditorState;
18
+ get chain(): () => ChainedCommands;
19
+ get can(): () => ChainedCommands;
20
+ createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
21
+ createCan(startTr?: Transaction): ChainedCommands;
22
+ }
23
+ export {};
24
+ //# sourceMappingURL=CommandManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandManager.d.ts","sourceRoot":"","sources":["../../src/commands/CommandManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EACV,eAAe,EAEf,gBAAgB,EAChB,cAAc,EACf,MAAM,YAAY,CAAC;AAMpB,KAAK,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAEjD,qBAAa,cAAc;IAOvB,OAAO,CAAC,MAAM;IANhB,SAAgB,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAM;IACzE,SAAgB,GAAG,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAM;IAE3D,OAAO,CAAC,KAAK,CAAQ;gBAGX,MAAM,EAAE,UAAU;IAOrB,qBAAqB,CAC1B,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CAAC,EACnC,OAAO,EAAE,MAAM;IAWjB,OAAO,CAAC,uBAAuB;IAqC/B,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,IAAI,KAAK,IAAI,MAAM,eAAe,CAEjC;IAED,IAAI,GAAG,IAAI,MAAM,eAAe,CAE/B;IAEM,WAAW,CAChB,OAAO,CAAC,EAAE,WAAW,EACrB,cAAc,UAAO,GACpB,eAAe;IA4CX,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,eAAe;CAGzD"}
@@ -0,0 +1,100 @@
1
+ import { EditorView } from 'prosemirror-view';
2
+ import { createChainableState } from './createChainableState.js';
3
+ import { baseCommandFactories } from './baseCommandFactories.js';
4
+ import { keyCommandFactories } from './keyCommandFactories.js';
5
+ import { replaceCommandFactories } from './replaceCommandFactories.js';
6
+ export class CommandManager {
7
+ editor;
8
+ commandFactories = {};
9
+ run = {};
10
+ debug = true;
11
+ constructor(editor) {
12
+ this.editor = editor;
13
+ this.mergeCommandFactories(baseCommandFactories, 'baseCommand');
14
+ this.mergeCommandFactories(keyCommandFactories, 'key');
15
+ this.mergeCommandFactories(replaceCommandFactories, 'replace');
16
+ }
17
+ mergeCommandFactories(toInsert, extName) {
18
+ for (const key in toInsert) {
19
+ const commandFactory = toInsert[key];
20
+ if (!commandFactory) {
21
+ continue;
22
+ }
23
+ this.overwriteCommandFactory(extName, key, commandFactory);
24
+ }
25
+ }
26
+ overwriteCommandFactory(extName, name, commandFactory) {
27
+ if (this.debug) {
28
+ const wrappedFactory = (...args) => {
29
+ const realCommand = commandFactory(...args);
30
+ const command = (state, dispatch, view) => {
31
+ if (dispatch) {
32
+ console.debug(`Command: ${extName}.${name}`);
33
+ }
34
+ return realCommand(state, dispatch, view);
35
+ };
36
+ return command;
37
+ };
38
+ this.commandFactories[name] = wrappedFactory;
39
+ }
40
+ else {
41
+ this.commandFactories[name] = commandFactory;
42
+ }
43
+ this.run[name] = (...args) => {
44
+ const factory = this.commandFactories[name];
45
+ const command = factory(...args);
46
+ const state = this.editor.state;
47
+ const view = this.editor.view;
48
+ if (view instanceof EditorView) {
49
+ return command(state, view.dispatch, view);
50
+ }
51
+ else {
52
+ return command(state, view.dispatch);
53
+ }
54
+ };
55
+ }
56
+ get state() {
57
+ return this.editor.state;
58
+ }
59
+ get chain() {
60
+ return () => this.createChain();
61
+ }
62
+ get can() {
63
+ return () => this.createCan();
64
+ }
65
+ createChain(startTr, shouldDispatch = true) {
66
+ const { commandFactories, editor, state } = this;
67
+ const { view } = editor;
68
+ const callbacks = [];
69
+ const hasStartTransaction = !!startTr;
70
+ const tr = startTr || state.tr;
71
+ const chainedState = createChainableState(tr, state);
72
+ const fakeDispatch = () => undefined;
73
+ const chain = {
74
+ ...Object.fromEntries(Object.entries(commandFactories).map(([name, commandFactory]) => {
75
+ const chainedCommand = (...args) => {
76
+ const command = commandFactory(...args);
77
+ const callback = command(chainedState, shouldDispatch ? fakeDispatch : undefined);
78
+ callbacks.push(callback);
79
+ return chain;
80
+ };
81
+ return [name, chainedCommand];
82
+ })),
83
+ run: () => {
84
+ if (!hasStartTransaction &&
85
+ shouldDispatch &&
86
+ !tr.getMeta('preventDispatch')) {
87
+ view.dispatch(tr);
88
+ }
89
+ return callbacks.every((callback) => callback === true);
90
+ },
91
+ chain: () => {
92
+ return this.createChain(tr, shouldDispatch);
93
+ },
94
+ };
95
+ return chain;
96
+ }
97
+ createCan(startTr) {
98
+ return this.createChain(startTr, false);
99
+ }
100
+ }
@@ -0,0 +1,3 @@
1
+ import { CommandFactory } from './types.js';
2
+ export declare const baseCommandFactories: Record<string, CommandFactory>;
3
+ //# sourceMappingURL=baseCommandFactories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseCommandFactories.d.ts","sourceRoot":"","sources":["../../src/commands/baseCommandFactories.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAgB,cAAc,EAAE,MAAM,YAAY,CAAC;AAihC1D,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA6B/D,CAAC"}