@kerebron/editor-kits 0.4.7 → 0.4.9

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 (72) hide show
  1. package/esm/AdvancedEditorKit.d.ts.map +1 -0
  2. package/esm/{editor-kits/src/AdvancedEditorKit.js → AdvancedEditorKit.js} +3 -13
  3. package/esm/CodeEditorKit.d.ts.map +1 -0
  4. package/esm/{editor-kits/src/CodeEditorKit.js → CodeEditorKit.js} +3 -13
  5. package/esm/DevAdvancedEditorKit.d.ts.map +1 -0
  6. package/esm/{editor-kits/src/DevAdvancedEditorKit.js → DevAdvancedEditorKit.js} +3 -13
  7. package/esm/LspEditorKit.d.ts.map +1 -0
  8. package/esm/{editor-kits/src/LspEditorKit.js → LspEditorKit.js} +3 -18
  9. package/esm/YjsEditorKit.d.ts.map +1 -0
  10. package/esm/{editor-kits/src/YjsEditorKit.js → YjsEditorKit.js} +4 -18
  11. package/esm/mod.d.ts +1 -0
  12. package/esm/mod.d.ts.map +1 -0
  13. package/esm/mod.js +1 -0
  14. package/package.json +20 -24
  15. package/esm/editor/src/commands/mod.d.ts +0 -7
  16. package/esm/editor/src/commands/mod.d.ts.map +0 -1
  17. package/esm/editor/src/commands/mod.js +0 -76
  18. package/esm/editor/src/commands/types.d.ts +0 -18
  19. package/esm/editor/src/commands/types.d.ts.map +0 -1
  20. package/esm/editor/src/commands/types.js +0 -1
  21. package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
  22. package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
  23. package/esm/editor/src/plugins/keymap/keymap.js +0 -125
  24. package/esm/editor/src/plugins/keymap/mod.d.ts +0 -2
  25. package/esm/editor/src/plugins/keymap/mod.d.ts.map +0 -1
  26. package/esm/editor/src/plugins/keymap/mod.js +0 -1
  27. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
  28. package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
  29. package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
  30. package/esm/editor-kits/src/AdvancedEditorKit.d.ts.map +0 -1
  31. package/esm/editor-kits/src/CodeEditorKit.d.ts.map +0 -1
  32. package/esm/editor-kits/src/DevAdvancedEditorKit.d.ts.map +0 -1
  33. package/esm/editor-kits/src/LspEditorKit.d.ts.map +0 -1
  34. package/esm/editor-kits/src/YjsEditorKit.d.ts.map +0 -1
  35. package/esm/editor-kits/src/mod.d.ts +0 -5
  36. package/esm/editor-kits/src/mod.d.ts.map +0 -1
  37. package/esm/editor-kits/src/mod.js +0 -4
  38. package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts +0 -7
  39. package/esm/extension-basic-editor/src/ExtensionBaseKeymap.d.ts.map +0 -1
  40. package/esm/extension-basic-editor/src/ExtensionBaseKeymap.js +0 -63
  41. package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts +0 -11
  42. package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.d.ts.map +0 -1
  43. package/esm/extension-basic-editor/src/ExtensionBasicCodeEditor.js +0 -71
  44. package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts +0 -19
  45. package/esm/extension-basic-editor/src/ExtensionDropcursor.d.ts.map +0 -1
  46. package/esm/extension-basic-editor/src/ExtensionDropcursor.js +0 -238
  47. package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts +0 -32
  48. package/esm/extension-basic-editor/src/ExtensionGapcursor.d.ts.map +0 -1
  49. package/esm/extension-basic-editor/src/ExtensionGapcursor.js +0 -266
  50. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +0 -15
  51. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +0 -1
  52. package/esm/extension-basic-editor/src/ExtensionHtml.js +0 -108
  53. package/esm/extension-basic-editor/src/ExtensionSelection.d.ts +0 -11
  54. package/esm/extension-basic-editor/src/ExtensionSelection.d.ts.map +0 -1
  55. package/esm/extension-basic-editor/src/ExtensionSelection.js +0 -237
  56. package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts +0 -7
  57. package/esm/extension-basic-editor/src/NodeDocumentCode.d.ts.map +0 -1
  58. package/esm/extension-basic-editor/src/NodeDocumentCode.js +0 -37
  59. package/esm/extension-basic-editor/src/NodeText.d.ts +0 -7
  60. package/esm/extension-basic-editor/src/NodeText.d.ts.map +0 -1
  61. package/esm/extension-basic-editor/src/NodeText.js +0 -17
  62. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +0 -24
  63. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +0 -1
  64. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +0 -35
  65. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +0 -25
  66. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +0 -1
  67. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +0 -96
  68. /package/esm/{editor-kits/src/AdvancedEditorKit.d.ts → AdvancedEditorKit.d.ts} +0 -0
  69. /package/esm/{editor-kits/src/CodeEditorKit.d.ts → CodeEditorKit.d.ts} +0 -0
  70. /package/esm/{editor-kits/src/DevAdvancedEditorKit.d.ts → DevAdvancedEditorKit.d.ts} +0 -0
  71. /package/esm/{editor-kits/src/LspEditorKit.d.ts → LspEditorKit.d.ts} +0 -0
  72. /package/esm/{editor-kits/src/YjsEditorKit.d.ts → YjsEditorKit.d.ts} +0 -0
@@ -1,124 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"AdvancedEditorKit.d.ts","sourceRoot":"","sources":["../../../src/editor-kits/src/AdvancedEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,qBAAa,iBAAkB,SAAQ,SAAS;IACrC,IAAI,SAAqB;IAClC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAElB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAcxE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"CodeEditorKit.d.ts","sourceRoot":"","sources":["../../../src/editor-kits/src/CodeEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAOhE,qBAAa,aAAc,SAAQ,SAAS;IACjC,IAAI,SAAyB;IACtC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAElB,IAAI,EAAE,MAAM;CAazB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DevAdvancedEditorKit.d.ts","sourceRoot":"","sources":["../../../src/editor-kits/src/DevAdvancedEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAItE,qBAAa,oBAAqB,SAAQ,SAAS;IACxC,IAAI,SAAyB;IACtC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAElB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAexE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LspEditorKit.d.ts","sourceRoot":"","sources":["../../../src/editor-kits/src/LspEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAMhF,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,kBAAkB,CAAC;CACrC;AAeD,qBAAa,YAAa,SAAQ,SAAS;IAChC,IAAI,SAAa;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAE9B,EAAE,EAAE,MAAM,CAAM;IAEhB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,kBAAkB;gBAK3C,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;IAW3C,OAAO;CAkCjB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"YjsEditorKit.d.ts","sourceRoot":"","sources":["../../../src/editor-kits/src/YjsEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAgB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEpE,qBAAa,YAAa,SAAQ,SAAS;IA8BJ,OAAO,CAAC,IAAI;IA7BxC,IAAI,SAAgB;IAC7B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAE9B,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM;gBA0BjC,UAAU,EAAE,WAAW,EAAU,IAAI,EAAE,CAAC,CAAC,GAAG;CAOzD"}
@@ -1,5 +0,0 @@
1
- export * from './AdvancedEditorKit.js';
2
- export * from './DevAdvancedEditorKit.js';
3
- export * from './LspEditorKit.js';
4
- export * from './YjsEditorKit.js';
5
- //# sourceMappingURL=mod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/editor-kits/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './AdvancedEditorKit.js';
2
- export * from './DevAdvancedEditorKit.js';
3
- export * from './LspEditorKit.js';
4
- export * from './YjsEditorKit.js';
@@ -1,7 +0,0 @@
1
- import { Extension } from '@kerebron/editor';
2
- import { type CommandShortcuts } from '../../editor/src/commands/mod.js';
3
- export declare class ExtensionBaseKeymap extends Extension {
4
- name: string;
5
- getKeyboardShortcuts(): Partial<CommandShortcuts>;
6
- }
7
- //# sourceMappingURL=ExtensionBaseKeymap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtensionBaseKeymap.d.ts","sourceRoot":"","sources":["../../../src/extension-basic-editor/src/ExtensionBaseKeymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AA4CzE,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,IAAI,SAAiB;IAEZ,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAe3D"}
@@ -1,63 +0,0 @@
1
- import { Extension } from '@kerebron/editor';
2
- /// A basic keymap containing bindings not specific to any schema.
3
- /// Binds the following keys (when multiple commands are listed, they
4
- /// are chained with [`chainCommands`](#commands.chainCommands)):
5
- ///
6
- /// * **Enter** to `newlineInCode`, `createParagraphNear`, `liftEmptyBlock`, `splitBlock`
7
- /// * **Mod-Enter** to `exitCode`
8
- /// * **Backspace** and **Mod-Backspace** to `deleteSelection`, `joinBackward`, `selectNodeBackward`
9
- /// * **Delete** and **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`
10
- /// * **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`
11
- /// * **Mod-a** to `selectAll`
12
- const pcBaseKeymap = {
13
- 'Mod-Enter': 'exitCode',
14
- 'Backspace': 'backspace',
15
- 'Mod-Backspace': 'backspace',
16
- 'Shift-Backspace': 'backspace',
17
- 'Delete': 'del',
18
- 'Mod-Delete': 'del',
19
- 'Mod-a': 'selectAll',
20
- };
21
- /// A copy of `pcBaseKeymap` that also binds **Ctrl-h** like Backspace,
22
- /// **Ctrl-d** like Delete, **Alt-Backspace** like Ctrl-Backspace, and
23
- /// **Ctrl-Alt-Backspace**, **Alt-Delete**, and **Alt-d** like
24
- /// Ctrl-Delete.
25
- const macBaseKeymap = {
26
- ...pcBaseKeymap,
27
- 'Ctrl-h': pcBaseKeymap['Backspace'],
28
- 'Alt-Backspace': pcBaseKeymap['Mod-Backspace'],
29
- 'Ctrl-d': pcBaseKeymap['Delete'],
30
- 'Ctrl-Alt-Backspace': pcBaseKeymap['Mod-Delete'],
31
- 'Alt-Delete': pcBaseKeymap['Mod-Delete'],
32
- 'Alt-d': pcBaseKeymap['Mod-Delete'],
33
- 'Ctrl-a': 'selectTextblockStart',
34
- 'Ctrl-e': 'selectTextblockEnd',
35
- };
36
- const mac = /(Mac|iPhone|iPod|iPad)/i.test(navigator?.platform);
37
- const baseKeymap = mac
38
- ? macBaseKeymap
39
- : pcBaseKeymap;
40
- export class ExtensionBaseKeymap extends Extension {
41
- constructor() {
42
- super(...arguments);
43
- Object.defineProperty(this, "name", {
44
- enumerable: true,
45
- configurable: true,
46
- writable: true,
47
- value: 'base-keymap'
48
- });
49
- }
50
- getKeyboardShortcuts() {
51
- const shortcuts = {
52
- 'Enter': 'enter',
53
- 'Alt-ArrowUp': 'joinUp',
54
- 'Alt-ArrowDown': 'joinDown',
55
- 'Mod-BracketLeft': 'lift',
56
- 'Escape': 'selectParentNode',
57
- };
58
- for (const key in baseKeymap) {
59
- shortcuts[key] = baseKeymap[key];
60
- }
61
- return shortcuts;
62
- }
63
- }
@@ -1,11 +0,0 @@
1
- import { Node } from 'prosemirror-model';
2
- import { AnyExtensionOrReq, Extension, RawTextResult } from '@kerebron/editor';
3
- export declare class ExtensionBasicCodeEditor extends Extension {
4
- name: string;
5
- requires: AnyExtensionOrReq[];
6
- constructor({ lang }: {
7
- lang: string;
8
- });
9
- toRawText(doc: Node): RawTextResult;
10
- }
11
- //# sourceMappingURL=ExtensionBasicCodeEditor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtensionBasicCodeEditor.d.ts","sourceRoot":"","sources":["../../../src/extension-basic-editor/src/ExtensionBasicCodeEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EACL,iBAAiB,EACjB,SAAS,EAET,aAAa,EACd,MAAM,kBAAkB,CAAC;AAW1B,qBAAa,wBAAyB,SAAQ,SAAS;IACrD,IAAI,SAAuB;IAC3B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAElB,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAetC,SAAS,CAAC,GAAG,EAAE,IAAI,GAAG,aAAa;CA4CpC"}
@@ -1,71 +0,0 @@
1
- import { Extension, } from '@kerebron/editor';
2
- import { NodeDocumentCode } from './NodeDocumentCode.js';
3
- import { ExtensionSelection } from './ExtensionSelection.js';
4
- import { ExtensionBaseKeymap } from './ExtensionBaseKeymap.js';
5
- import { ExtensionDropcursor } from './ExtensionDropcursor.js';
6
- import { ExtensionGapcursor } from './ExtensionGapcursor.js';
7
- import { ExtensionHtml } from './ExtensionHtml.js';
8
- import { NodeText } from './NodeText.js';
9
- import { ExtensionRemoteSelection } from './remote-selection/ExtensionRemoteSelection.js';
10
- export class ExtensionBasicCodeEditor extends Extension {
11
- constructor({ lang }) {
12
- super();
13
- Object.defineProperty(this, "name", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: 'basic-code-editor'
18
- });
19
- Object.defineProperty(this, "requires", {
20
- enumerable: true,
21
- configurable: true,
22
- writable: true,
23
- value: void 0
24
- });
25
- this.requires = [
26
- new ExtensionBaseKeymap(),
27
- new ExtensionDropcursor(),
28
- new ExtensionGapcursor(),
29
- new ExtensionHtml(),
30
- new ExtensionRemoteSelection(),
31
- new ExtensionSelection(),
32
- new NodeDocumentCode({ lang }),
33
- new NodeText(),
34
- ];
35
- }
36
- toRawText(doc) {
37
- const topNodeType = this.editor.schema.topNodeType;
38
- const spec = topNodeType.spec;
39
- const singleNodeDoc = spec.content?.indexOf('*') === -1;
40
- if (!singleNodeDoc) {
41
- throw new Error('Not a single node doc');
42
- }
43
- if (doc.children.length !== 1) {
44
- throw new Error('Not a single node doc');
45
- }
46
- const codeBlock = doc.children[0];
47
- const content = codeBlock.content.content
48
- .map((node) => node.text)
49
- .join('');
50
- const lines = content.split('\n');
51
- const rawTextMap = [];
52
- let nodeIdx = 1;
53
- let targetPos = 0;
54
- let targetRow = 0;
55
- for (const line of lines) {
56
- rawTextMap.push({
57
- nodeIdx: nodeIdx,
58
- targetRow,
59
- targetCol: 0,
60
- targetPos,
61
- });
62
- targetRow++;
63
- targetPos += line.length + 1;
64
- nodeIdx += line.length + 1;
65
- }
66
- return {
67
- content,
68
- rawTextMap,
69
- };
70
- }
71
- }
@@ -1,19 +0,0 @@
1
- import { Plugin } from 'prosemirror-state';
2
- import { Extension } from '@kerebron/editor';
3
- interface DropCursorOptions {
4
- color?: string | false;
5
- width?: number;
6
- class?: string;
7
- }
8
- export declare function dropCursor(options?: DropCursorOptions): Plugin;
9
- export declare class ExtensionDropcursor extends Extension {
10
- name: string;
11
- options: {
12
- color: string;
13
- width: number;
14
- class: undefined;
15
- };
16
- getProseMirrorPlugins(): Plugin[];
17
- }
18
- export {};
19
- //# sourceMappingURL=ExtensionDropcursor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtensionDropcursor.d.ts","sourceRoot":"","sources":["../../../src/extension-basic-editor/src/ExtensionDropcursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,UAAU,iBAAiB;IAEzB,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAGvB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAUD,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAMlE;AA+KD,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,IAAI,SAAgB;IAEpB,OAAO;;;;MAIL;IAEO,qBAAqB,IAAI,MAAM,EAAE;CAK3C"}
@@ -1,238 +0,0 @@
1
- import { Plugin } from 'prosemirror-state';
2
- import { dropPoint } from 'prosemirror-transform';
3
- import { Extension } from '@kerebron/editor';
4
- /// Create a plugin that, when added to a ProseMirror instance,
5
- /// causes a decoration to show up at the drop position when something
6
- /// is dragged over the editor.
7
- ///
8
- /// Nodes may add a `disableDropCursor` property to their spec to
9
- /// control the showing of a drop cursor inside them. This may be a
10
- /// boolean or a function, which will be called with a view and a
11
- /// position, and should return a boolean.
12
- export function dropCursor(options = {}) {
13
- return new Plugin({
14
- view(editorView) {
15
- return new DropCursorView(editorView, options);
16
- },
17
- });
18
- }
19
- class DropCursorView {
20
- constructor(editorView, options) {
21
- Object.defineProperty(this, "editorView", {
22
- enumerable: true,
23
- configurable: true,
24
- writable: true,
25
- value: editorView
26
- });
27
- Object.defineProperty(this, "width", {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: void 0
32
- });
33
- Object.defineProperty(this, "color", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: void 0
38
- });
39
- Object.defineProperty(this, "class", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: void 0
44
- });
45
- Object.defineProperty(this, "cursorPos", {
46
- enumerable: true,
47
- configurable: true,
48
- writable: true,
49
- value: null
50
- });
51
- Object.defineProperty(this, "element", {
52
- enumerable: true,
53
- configurable: true,
54
- writable: true,
55
- value: null
56
- });
57
- Object.defineProperty(this, "timeout", {
58
- enumerable: true,
59
- configurable: true,
60
- writable: true,
61
- value: -1
62
- });
63
- Object.defineProperty(this, "handlers", {
64
- enumerable: true,
65
- configurable: true,
66
- writable: true,
67
- value: void 0
68
- });
69
- this.width = options.width ?? 1;
70
- this.color = options.color === false
71
- ? undefined
72
- : (options.color || 'black');
73
- this.class = options.class;
74
- this.handlers = ['dragover', 'dragend', 'drop', 'dragleave'].map((name) => {
75
- let handler = (e) => {
76
- this[name](e);
77
- };
78
- editorView.dom.addEventListener(name, handler);
79
- return { name, handler };
80
- });
81
- }
82
- destroy() {
83
- this.handlers.forEach(({ name, handler }) => this.editorView.dom.removeEventListener(name, handler));
84
- }
85
- update(editorView, prevState) {
86
- if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
87
- if (this.cursorPos > editorView.state.doc.content.size) {
88
- this.setCursor(null);
89
- }
90
- else
91
- this.updateOverlay();
92
- }
93
- }
94
- setCursor(pos) {
95
- if (pos == this.cursorPos)
96
- return;
97
- this.cursorPos = pos;
98
- if (pos == null) {
99
- this.element.parentNode.removeChild(this.element);
100
- this.element = null;
101
- }
102
- else {
103
- this.updateOverlay();
104
- }
105
- }
106
- updateOverlay() {
107
- let $pos = this.editorView.state.doc.resolve(this.cursorPos);
108
- let isBlock = !$pos.parent.inlineContent, rect;
109
- let editorDOM = this.editorView.dom, editorRect = editorDOM.getBoundingClientRect();
110
- let scaleX = editorRect.width / editorDOM.offsetWidth, scaleY = editorRect.height / editorDOM.offsetHeight;
111
- if (isBlock) {
112
- let before = $pos.nodeBefore, after = $pos.nodeAfter;
113
- if (before || after) {
114
- let node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));
115
- if (node) {
116
- let nodeRect = node.getBoundingClientRect();
117
- let top = before ? nodeRect.bottom : nodeRect.top;
118
- if (before && after) {
119
- top = (top +
120
- this.editorView.nodeDOM(this.cursorPos)
121
- .getBoundingClientRect().top) / 2;
122
- }
123
- let halfWidth = (this.width / 2) * scaleY;
124
- rect = {
125
- left: nodeRect.left,
126
- right: nodeRect.right,
127
- top: top - halfWidth,
128
- bottom: top + halfWidth,
129
- };
130
- }
131
- }
132
- }
133
- if (!rect) {
134
- let coords = this.editorView.coordsAtPos(this.cursorPos);
135
- let halfWidth = (this.width / 2) * scaleX;
136
- rect = {
137
- left: coords.left - halfWidth,
138
- right: coords.left + halfWidth,
139
- top: coords.top,
140
- bottom: coords.bottom,
141
- };
142
- }
143
- let parent = this.editorView.dom.offsetParent;
144
- if (!this.element) {
145
- this.element = parent.appendChild(document.createElement('div'));
146
- if (this.class)
147
- this.element.className = this.class;
148
- this.element.style.cssText =
149
- 'position: absolute; z-index: 50; pointer-events: none;';
150
- if (this.color) {
151
- this.element.style.backgroundColor = this.color;
152
- }
153
- }
154
- this.element.classList.toggle('prosemirror-dropcursor-block', isBlock);
155
- this.element.classList.toggle('prosemirror-dropcursor-inline', !isBlock);
156
- let parentLeft, parentTop;
157
- if (!parent ||
158
- parent == document.body && getComputedStyle(parent).position == 'static') {
159
- parentLeft = -pageXOffset;
160
- parentTop = -pageYOffset;
161
- }
162
- else {
163
- let rect = parent.getBoundingClientRect();
164
- let parentScaleX = rect.width / parent.offsetWidth, parentScaleY = rect.height / parent.offsetHeight;
165
- parentLeft = rect.left - parent.scrollLeft * parentScaleX;
166
- parentTop = rect.top - parent.scrollTop * parentScaleY;
167
- }
168
- this.element.style.left = (rect.left - parentLeft) / scaleX + 'px';
169
- this.element.style.top = (rect.top - parentTop) / scaleY + 'px';
170
- this.element.style.width = (rect.right - rect.left) / scaleX + 'px';
171
- this.element.style.height = (rect.bottom - rect.top) / scaleY + 'px';
172
- }
173
- scheduleRemoval(timeout) {
174
- clearTimeout(this.timeout);
175
- this.timeout = setTimeout(() => this.setCursor(null), timeout);
176
- }
177
- dragover(event) {
178
- if (!this.editorView.editable)
179
- return;
180
- let pos = this.editorView.posAtCoords({
181
- left: event.clientX,
182
- top: event.clientY,
183
- });
184
- let node = pos && pos.inside >= 0 &&
185
- this.editorView.state.doc.nodeAt(pos.inside);
186
- let disableDropCursor = node && node.type.spec.disableDropCursor;
187
- let disabled = typeof disableDropCursor == 'function'
188
- ? disableDropCursor(this.editorView, pos, event)
189
- : disableDropCursor;
190
- if (pos && !disabled) {
191
- let target = pos.pos;
192
- if (this.editorView.dragging && this.editorView.dragging.slice) {
193
- let point = dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);
194
- if (point != null)
195
- target = point;
196
- }
197
- this.setCursor(target);
198
- this.scheduleRemoval(5000);
199
- }
200
- }
201
- dragend() {
202
- this.scheduleRemoval(20);
203
- }
204
- drop() {
205
- this.scheduleRemoval(20);
206
- }
207
- dragleave(event) {
208
- if (!this.editorView.dom.contains(event.relatedTarget)) {
209
- this.setCursor(null);
210
- }
211
- }
212
- }
213
- export class ExtensionDropcursor extends Extension {
214
- constructor() {
215
- super(...arguments);
216
- Object.defineProperty(this, "name", {
217
- enumerable: true,
218
- configurable: true,
219
- writable: true,
220
- value: 'dropcursor'
221
- });
222
- Object.defineProperty(this, "options", {
223
- enumerable: true,
224
- configurable: true,
225
- writable: true,
226
- value: {
227
- color: 'currentColor',
228
- width: 1,
229
- class: undefined,
230
- }
231
- });
232
- }
233
- getProseMirrorPlugins() {
234
- return [
235
- dropCursor(this.options),
236
- ];
237
- }
238
- }
@@ -1,32 +0,0 @@
1
- import { Plugin, Selection } from 'prosemirror-state';
2
- import { Node, ResolvedPos, Slice } from 'prosemirror-model';
3
- import { Mappable } from 'prosemirror-transform';
4
- import { Extension } from '@kerebron/editor';
5
- export declare class GapCursor extends Selection {
6
- constructor($pos: ResolvedPos);
7
- map(doc: Node, mapping: Mappable): Selection;
8
- content(): Slice;
9
- eq(other: Selection): boolean;
10
- toJSON(): any;
11
- static fromJSONToGapCursor(doc: Node, json: any): GapCursor;
12
- getBookmark(): GapBookmark;
13
- static valid($pos: ResolvedPos): any;
14
- static findGapCursorFrom($pos: ResolvedPos, dir: number, mustMove?: boolean): ResolvedPos | null;
15
- }
16
- declare class GapBookmark {
17
- readonly pos: number;
18
- constructor(pos: number);
19
- map(mapping: Mappable): GapBookmark;
20
- resolve(doc: Node): Selection;
21
- }
22
- export declare class ExtensionGapcursor extends Extension {
23
- name: string;
24
- options: {
25
- color: string;
26
- width: number;
27
- class: undefined;
28
- };
29
- getProseMirrorPlugins(): Plugin[];
30
- }
31
- export {};
32
- //# sourceMappingURL=ExtensionGapcursor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExtensionGapcursor.d.ts","sourceRoot":"","sources":["../../../src/extension-basic-editor/src/ExtensionGapcursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EACN,SAAS,EAEV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAY,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C,qBAAa,SAAU,SAAQ,SAAS;gBAE1B,IAAI,EAAE,WAAW;IAK7B,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,GAAG,SAAS;IAKnC,OAAO;IAIhB,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO;IAI7B,MAAM,IAAI,GAAG;IAKb,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,SAAS;IAQlD,WAAW,IAAI,WAAW;IAKnC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW;IAY9B,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,UAAQ;CA0C1E;AAID,cAAM,WAAW;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM;IAEhC,GAAG,CAAC,OAAO,EAAE,QAAQ;IAGrB,OAAO,CAAC,GAAG,EAAE,IAAI,GAAG,SAAS;CAI9B;AA4ID,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,IAAI,SAAe;IAEnB,OAAO;;;;MAIL;IAEO,qBAAqB,IAAI,MAAM,EAAE;CAK3C"}