@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
@@ -0,0 +1,6 @@
1
+ import { Attrs, Node, NodeType } from 'prosemirror-model';
2
+ import { InputRule } from './InputRulesPlugin.js';
3
+ export declare function wrappingInputRule(regexp: RegExp, nodeType: NodeType, getAttrs?: Attrs | null | ((matches: RegExpMatchArray) => Attrs | null), joinPredicate?: (match: RegExpMatchArray, node: Node) => boolean): InputRule;
4
+ export declare function textblockTypeInputRule(regexp: RegExp, nodeType: NodeType, getAttrs?: Attrs | null | ((match: RegExpMatchArray) => Attrs | null)): InputRule;
5
+ export declare function replaceInlineNode(regexp: RegExp, nodeType: NodeType, getAttrs?: Attrs | null | ((matches: RegExpMatchArray) => Attrs | null)): InputRule;
6
+ //# sourceMappingURL=rulebuilders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rulebuilders.d.ts","sourceRoot":"","sources":["../../../src/plugins/input-rules/rulebuilders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAY,IAAI,EAAE,QAAQ,EAAS,MAAM,mBAAmB,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAiBlD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,gBAAgB,KAAK,KAAK,GAAG,IAAI,CAAQ,EAC7E,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,KAAK,OAAO,aAmBjE;AAQD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,KAAK,GAAG,IAAI,CAAQ,aAgB5E;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,gBAAgB,KAAK,KAAK,GAAG,IAAI,CAAQ,aAY9E"}
@@ -0,0 +1,64 @@
1
+ import { canJoin, findWrapping } from 'prosemirror-transform';
2
+ import { Fragment, Slice } from 'prosemirror-model';
3
+ import { InputRule } from './InputRulesPlugin.js';
4
+ /// Build an input rule for automatically wrapping a textblock when a
5
+ /// given string is typed. The `regexp` argument is
6
+ /// directly passed through to the `InputRule` constructor. You'll
7
+ /// probably want the regexp to start with `^`, so that the pattern can
8
+ /// only occur at the start of a textblock.
9
+ ///
10
+ /// `nodeType` is the type of node to wrap in. If it needs attributes,
11
+ /// you can either pass them directly, or pass a function that will
12
+ /// compute them from the regular expression match.
13
+ ///
14
+ /// By default, if there's a node with the same type above the newly
15
+ /// wrapped node, the rule will try to [join](#transform.Transform.join) those
16
+ /// two nodes. You can pass a join predicate, which takes a regular
17
+ /// expression match and the node before the wrapped node, and can
18
+ /// return a boolean to indicate whether a join should happen.
19
+ export function wrappingInputRule(regexp, nodeType, getAttrs = null, joinPredicate) {
20
+ return new InputRule(regexp, (state, match, start, end) => {
21
+ const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
22
+ const tr = state.tr.delete(start, end);
23
+ const $start = tr.doc.resolve(start);
24
+ const range = $start.blockRange();
25
+ const wrapping = range && findWrapping(range, nodeType, attrs);
26
+ if (!wrapping)
27
+ return null;
28
+ tr.wrap(range, wrapping);
29
+ const before = tr.doc.resolve(start - 1).nodeBefore;
30
+ if (before && before.type == nodeType && canJoin(tr.doc, start - 1) &&
31
+ (!joinPredicate || joinPredicate(match, before))) {
32
+ tr.join(start - 1);
33
+ }
34
+ return tr;
35
+ });
36
+ }
37
+ /// Build an input rule that changes the type of a textblock when the
38
+ /// matched text is typed into it. You'll usually want to start your
39
+ /// regexp with `^` to that it is only matched at the start of a
40
+ /// textblock. The optional `getAttrs` parameter can be used to compute
41
+ /// the new node's attributes, and works the same as in the
42
+ /// `wrappingInputRule` function.
43
+ export function textblockTypeInputRule(regexp, nodeType, getAttrs = null) {
44
+ return new InputRule(regexp, (state, match, start, end) => {
45
+ const $start = state.doc.resolve(start);
46
+ const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
47
+ if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType))
48
+ return null;
49
+ return state.tr
50
+ .delete(start, end)
51
+ .setBlockType(start, start, nodeType, attrs);
52
+ });
53
+ }
54
+ export function replaceInlineNode(regexp, nodeType, getAttrs = null) {
55
+ return new InputRule(regexp, (state, match, start, end) => {
56
+ const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
57
+ const node = nodeType.createAndFill(attrs);
58
+ const slice = new Slice(Fragment.from(node), 0, 0);
59
+ const tr = state.tr;
60
+ const from = tr.mapping.map(start);
61
+ const to = tr.mapping.map(end);
62
+ return tr.replace(from, to, slice);
63
+ });
64
+ }
@@ -0,0 +1,12 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import type { Command } from '../../commands/types.js';
4
+ export declare class KeymapPlugin extends Plugin {
5
+ constructor(bindings: {
6
+ [key: string]: Command;
7
+ });
8
+ }
9
+ export declare function keydownHandler(bindings: {
10
+ [key: string]: Command;
11
+ }): (view: EditorView, event: KeyboardEvent) => boolean;
12
+ //# sourceMappingURL=keymap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keymap.d.ts","sourceRoot":"","sources":["../../../src/plugins/keymap/keymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAyEvD,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/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/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
+ }
@@ -0,0 +1,3 @@
1
+ export * from './query.js';
2
+ export * from './search.js';
3
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/search/mod.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './query.js';
2
+ export * from './search.js';
@@ -0,0 +1,45 @@
1
+ import { EditorState } from 'prosemirror-state';
2
+ import { Slice } from 'prosemirror-model';
3
+ export declare class SearchQuery {
4
+ readonly search: string;
5
+ readonly caseSensitive: boolean;
6
+ readonly literal: boolean;
7
+ readonly regexp: boolean;
8
+ readonly replace: string;
9
+ readonly valid: boolean;
10
+ readonly wholeWord: boolean;
11
+ readonly filter: ((state: EditorState, result: SearchResult) => boolean) | null;
12
+ impl: QueryImpl;
13
+ constructor(config: {
14
+ search: string;
15
+ caseSensitive?: boolean;
16
+ literal?: boolean;
17
+ regexp?: boolean;
18
+ replace?: string;
19
+ wholeWord?: boolean;
20
+ filter?: (state: EditorState, result: SearchResult) => boolean;
21
+ });
22
+ eq(other: SearchQuery): boolean;
23
+ findNext(state: EditorState, from?: number, to?: number): SearchResult | null;
24
+ findPrev(state: EditorState, from?: number, to?: number): SearchResult | null;
25
+ checkResult(state: EditorState, result: SearchResult): boolean;
26
+ unquote(string: string): string;
27
+ getReplacements(state: EditorState, result: SearchResult): {
28
+ from: number;
29
+ to: number;
30
+ insert: Slice;
31
+ }[];
32
+ }
33
+ export interface SearchResult {
34
+ from: number;
35
+ to: number;
36
+ match: RegExpMatchArray | null;
37
+ matchStart: number;
38
+ }
39
+ interface QueryImpl {
40
+ findNext(state: EditorState, from: number, to: number): SearchResult | null;
41
+ findPrev(state: EditorState, from: number, to: number): SearchResult | null;
42
+ }
43
+ export declare function validRegExp(source: string): boolean;
44
+ export {};
45
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/search/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAkB,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1D,qBAAa,WAAW;IAEtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAIhC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAG1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAGzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAGzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAGxB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,QAAQ,CAAC,MAAM,EACX,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,GACvD,IAAI,CAAC;IAGT,IAAI,EAAE,SAAS,CAAC;gBAGJ,MAAM,EAAE;QAElB,MAAM,EAAE,MAAM,CAAC;QAEf,aAAa,CAAC,EAAE,OAAO,CAAC;QAIxB,OAAO,CAAC,EAAE,OAAO,CAAC;QAElB,MAAM,CAAC,EAAE,OAAO,CAAC;QAEjB,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB,SAAS,CAAC,EAAE,OAAO,CAAC;QAGpB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC;KAChE;IAiBD,EAAE,CAAC,KAAK,EAAE,WAAW;IAQrB,QAAQ,CACN,KAAK,EAAE,WAAW,EAClB,IAAI,GAAE,MAAU,EAChB,EAAE,GAAE,MAA+B;IAYrC,QAAQ,CACN,KAAK,EAAE,WAAW,EAClB,IAAI,GAAE,MAA+B,EACrC,EAAE,GAAE,MAAU;IAWhB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY;IAQpD,OAAO,CAAC,MAAM,EAAE,MAAM;IAgBtB,eAAe,CACb,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,GACnB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAA;KAAE,EAAE;CAuCjD;AAID,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,SAAS;IACjB,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;IAC5E,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAAC;CAC7E;AA8JD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,WAOzC"}