@kerebron/extension-basic-editor 0.0.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 (70) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +31 -0
  3. package/esm/ExtensionBaseKeymap.d.ts +8 -0
  4. package/esm/ExtensionBaseKeymap.d.ts.map +1 -0
  5. package/esm/ExtensionBaseKeymap.js +37 -0
  6. package/esm/ExtensionBasicEditor.d.ts +26 -0
  7. package/esm/ExtensionBasicEditor.d.ts.map +1 -0
  8. package/esm/ExtensionBasicEditor.js +59 -0
  9. package/esm/ExtensionDropcursor.d.ts +12 -0
  10. package/esm/ExtensionDropcursor.d.ts.map +1 -0
  11. package/esm/ExtensionDropcursor.js +28 -0
  12. package/esm/ExtensionGapcursor.d.ts +12 -0
  13. package/esm/ExtensionGapcursor.d.ts.map +1 -0
  14. package/esm/ExtensionGapcursor.js +28 -0
  15. package/esm/ExtensionHistory.d.ts +14 -0
  16. package/esm/ExtensionHistory.d.ts.map +1 -0
  17. package/esm/ExtensionHistory.js +49 -0
  18. package/esm/MarkCode.d.ts +14 -0
  19. package/esm/MarkCode.d.ts.map +1 -0
  20. package/esm/MarkCode.js +45 -0
  21. package/esm/MarkItalic.d.ts +13 -0
  22. package/esm/MarkItalic.d.ts.map +1 -0
  23. package/esm/MarkItalic.js +51 -0
  24. package/esm/MarkLink.d.ts +18 -0
  25. package/esm/MarkLink.d.ts.map +1 -0
  26. package/esm/MarkLink.js +74 -0
  27. package/esm/MarkStrong.d.ts +14 -0
  28. package/esm/MarkStrong.d.ts.map +1 -0
  29. package/esm/MarkStrong.js +60 -0
  30. package/esm/MarkUnderline.d.ts +13 -0
  31. package/esm/MarkUnderline.d.ts.map +1 -0
  32. package/esm/MarkUnderline.js +55 -0
  33. package/esm/NodeAside.d.ts +11 -0
  34. package/esm/NodeAside.d.ts.map +1 -0
  35. package/esm/NodeAside.js +37 -0
  36. package/esm/NodeBlockquote.d.ts +16 -0
  37. package/esm/NodeBlockquote.d.ts.map +1 -0
  38. package/esm/NodeBlockquote.js +56 -0
  39. package/esm/NodeBulletList.d.ts +16 -0
  40. package/esm/NodeBulletList.d.ts.map +1 -0
  41. package/esm/NodeBulletList.js +56 -0
  42. package/esm/NodeDocument.d.ts +7 -0
  43. package/esm/NodeDocument.d.ts.map +1 -0
  44. package/esm/NodeDocument.js +26 -0
  45. package/esm/NodeHardBreak.d.ts +11 -0
  46. package/esm/NodeHardBreak.d.ts.map +1 -0
  47. package/esm/NodeHardBreak.js +98 -0
  48. package/esm/NodeHeading.d.ts +24 -0
  49. package/esm/NodeHeading.d.ts.map +1 -0
  50. package/esm/NodeHeading.js +75 -0
  51. package/esm/NodeHorizontalRule.d.ts +11 -0
  52. package/esm/NodeHorizontalRule.d.ts.map +1 -0
  53. package/esm/NodeHorizontalRule.js +43 -0
  54. package/esm/NodeImage.d.ts +25 -0
  55. package/esm/NodeImage.d.ts.map +1 -0
  56. package/esm/NodeImage.js +68 -0
  57. package/esm/NodeListItem.d.ts +13 -0
  58. package/esm/NodeListItem.d.ts.map +1 -0
  59. package/esm/NodeListItem.js +217 -0
  60. package/esm/NodeOrderedList.d.ts +22 -0
  61. package/esm/NodeOrderedList.d.ts.map +1 -0
  62. package/esm/NodeOrderedList.js +72 -0
  63. package/esm/NodeParagraph.d.ts +14 -0
  64. package/esm/NodeParagraph.d.ts.map +1 -0
  65. package/esm/NodeParagraph.js +47 -0
  66. package/esm/NodeText.d.ts +8 -0
  67. package/esm/NodeText.d.ts.map +1 -0
  68. package/esm/NodeText.js +23 -0
  69. package/esm/package.json +3 -0
  70. package/package.json +78 -0
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Permission is hereby granted, free of charge, to any
2
+ person obtaining a copy of this software and associated
3
+ documentation files (the "Software"), to deal in the
4
+ Software without restriction, including without
5
+ limitation the rights to use, copy, modify, merge,
6
+ publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software
8
+ is furnished to do so, subject to the following
9
+ conditions:
10
+
11
+ The above copyright notice and this permission notice
12
+ shall be included in all copies or substantial portions
13
+ of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+ DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Kerebron basic editor extension
2
+
3
+ Set of basic editor extensions, marks and nodes
4
+
5
+ Features:
6
+
7
+ - bold, italic, image, hr...
8
+ - basic keymap
9
+ - cursors: drop and gap
10
+ - history
11
+
12
+ ## Usage:
13
+
14
+ ```js
15
+ import { ExtensionBasicEditor } from '@kerebron/extension-basic-editor';
16
+
17
+ this.editor = new CoreEditor({
18
+ element: htmlElement,
19
+ extensions: [
20
+ new ExtensionBasicEditor(),
21
+ ],
22
+ });
23
+ ```
24
+
25
+ ```js
26
+ this.editor.setDocument('# TEST \n\n1. aaa\n2. bbb', 'text/x-markdown');
27
+ ```
28
+
29
+ ```js
30
+ const markdown = this.editor.getDocument('text/x-markdown');
31
+ ```
@@ -0,0 +1,8 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import { type Commands, type CommandShortcuts } from '@kerebron/editor/commands';
3
+ export declare class ExtensionBaseKeymap extends Extension {
4
+ name: string;
5
+ getCommands(): Partial<Commands>;
6
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
7
+ }
8
+ //# sourceMappingURL=ExtensionBaseKeymap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionBaseKeymap.d.ts","sourceRoot":"","sources":["../src/ExtensionBaseKeymap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQ7C,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,IAAI,SAAiB;IAErB,WAAW,IAAI,OAAO,CAAC,QAAQ,CAAC;IAgBhC,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAclD"}
@@ -0,0 +1,37 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import { baseKeymap, joinDown, joinUp, lift, selectParentNode, } from '@kerebron/editor/commands';
3
+ export class ExtensionBaseKeymap extends Extension {
4
+ constructor() {
5
+ super(...arguments);
6
+ Object.defineProperty(this, "name", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: 'base-keymap'
11
+ });
12
+ }
13
+ getCommands() {
14
+ const commands = {
15
+ joinUp: () => (state, dispatch) => joinUp(state, dispatch),
16
+ joinDown: () => (state, dispatch) => joinDown(state, dispatch),
17
+ lift: () => (state, dispatch) => lift(state, dispatch),
18
+ selectParentNode: () => (state, dispatch) => selectParentNode(state, dispatch),
19
+ };
20
+ for (const key in baseKeymap) {
21
+ commands[this.name + '_' + key] = () => baseKeymap[key];
22
+ }
23
+ return commands;
24
+ }
25
+ getKeyboardShortcuts() {
26
+ const shortcuts = {
27
+ 'Alt-ArrowUp': 'joinUp',
28
+ 'Alt-ArrowDown': 'joinDown',
29
+ 'Mod-BracketLeft': 'lift',
30
+ 'Escape': 'selectParentNode',
31
+ };
32
+ for (const key in baseKeymap) {
33
+ shortcuts[key] = this.name + '_' + key;
34
+ }
35
+ return shortcuts;
36
+ }
37
+ }
@@ -0,0 +1,26 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import { ExtensionBaseKeymap } from './ExtensionBaseKeymap.js';
3
+ import { ExtensionDropcursor } from './ExtensionDropcursor.js';
4
+ import { ExtensionGapcursor } from './ExtensionGapcursor.js';
5
+ import { NodeDocument } from './NodeDocument.js';
6
+ import { NodeText } from './NodeText.js';
7
+ import { NodeParagraph } from './NodeParagraph.js';
8
+ import { NodeHardBreak } from './NodeHardBreak.js';
9
+ import { NodeHorizontalRule } from './NodeHorizontalRule.js';
10
+ import { NodeOrderedList } from './NodeOrderedList.js';
11
+ import { NodeBulletList } from './NodeBulletList.js';
12
+ import { NodeListItem } from './NodeListItem.js';
13
+ import { NodeImage } from './NodeImage.js';
14
+ import { NodeBlockquote } from './NodeBlockquote.js';
15
+ import { NodeAside } from './NodeAside.js';
16
+ import { NodeHeading } from './NodeHeading.js';
17
+ import { MarkLink } from './MarkLink.js';
18
+ import { MarkStrong } from './MarkStrong.js';
19
+ import { MarkItalic } from './MarkItalic.js';
20
+ import { MarkUnderline } from './MarkUnderline.js';
21
+ import { MarkCode } from './MarkCode.js';
22
+ export declare class ExtensionBasicEditor extends Extension {
23
+ name: string;
24
+ requires: (ExtensionBaseKeymap | ExtensionDropcursor | ExtensionGapcursor | NodeDocument | NodeText | NodeParagraph | NodeHardBreak | NodeHorizontalRule | NodeOrderedList | NodeBulletList | NodeListItem | NodeImage | NodeBlockquote | NodeAside | NodeHeading | MarkLink | MarkStrong | MarkItalic | MarkUnderline | MarkCode)[];
25
+ }
26
+ //# sourceMappingURL=ExtensionBasicEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionBasicEditor.d.ts","sourceRoot":"","sources":["../src/ExtensionBasicEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,qBAAa,oBAAqB,SAAQ,SAAS;IACjD,IAAI,SAAkB;IACtB,QAAQ,6TAqBN;CACH"}
@@ -0,0 +1,59 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import { ExtensionBaseKeymap } from './ExtensionBaseKeymap.js';
3
+ import { ExtensionDropcursor } from './ExtensionDropcursor.js';
4
+ import { ExtensionGapcursor } from './ExtensionGapcursor.js';
5
+ import { NodeDocument } from './NodeDocument.js';
6
+ import { NodeText } from './NodeText.js';
7
+ import { NodeParagraph } from './NodeParagraph.js';
8
+ import { NodeHardBreak } from './NodeHardBreak.js';
9
+ import { NodeHorizontalRule } from './NodeHorizontalRule.js';
10
+ import { NodeOrderedList } from './NodeOrderedList.js';
11
+ import { NodeBulletList } from './NodeBulletList.js';
12
+ import { NodeListItem } from './NodeListItem.js';
13
+ import { NodeImage } from './NodeImage.js';
14
+ import { NodeBlockquote } from './NodeBlockquote.js';
15
+ import { NodeAside } from './NodeAside.js';
16
+ import { NodeHeading } from './NodeHeading.js';
17
+ import { MarkLink } from './MarkLink.js';
18
+ import { MarkStrong } from './MarkStrong.js';
19
+ import { MarkItalic } from './MarkItalic.js';
20
+ import { MarkUnderline } from './MarkUnderline.js';
21
+ import { MarkCode } from './MarkCode.js';
22
+ export class ExtensionBasicEditor extends Extension {
23
+ constructor() {
24
+ super(...arguments);
25
+ Object.defineProperty(this, "name", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: 'basic-editor'
30
+ });
31
+ Object.defineProperty(this, "requires", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: [
36
+ new ExtensionBaseKeymap(),
37
+ new ExtensionDropcursor(),
38
+ new ExtensionGapcursor(),
39
+ new NodeDocument(),
40
+ new NodeText(),
41
+ new NodeParagraph(),
42
+ new NodeHardBreak(),
43
+ new NodeHorizontalRule(),
44
+ new NodeOrderedList(),
45
+ new NodeBulletList(),
46
+ new NodeListItem(),
47
+ new NodeImage(),
48
+ new NodeBlockquote(),
49
+ new NodeAside(),
50
+ new NodeHeading(),
51
+ new MarkLink(),
52
+ new MarkItalic(),
53
+ new MarkStrong(),
54
+ new MarkUnderline(),
55
+ new MarkCode(),
56
+ ]
57
+ });
58
+ }
59
+ }
@@ -0,0 +1,12 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { Extension } from '@kerebron/editor';
3
+ export declare class ExtensionDropcursor extends Extension {
4
+ name: string;
5
+ options: {
6
+ color: string;
7
+ width: number;
8
+ class: undefined;
9
+ };
10
+ getProseMirrorPlugins(): Plugin[];
11
+ }
12
+ //# sourceMappingURL=ExtensionDropcursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionDropcursor.d.ts","sourceRoot":"","sources":["../src/ExtensionDropcursor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,mBAAoB,SAAQ,SAAS;IAChD,IAAI,SAAgB;IAEpB,OAAO;;;;MAIL;IAEF,qBAAqB,IAAI,MAAM,EAAE;CAKlC"}
@@ -0,0 +1,28 @@
1
+ import { dropCursor } from 'prosemirror-dropcursor';
2
+ import { Extension } from '@kerebron/editor';
3
+ export class ExtensionDropcursor extends Extension {
4
+ constructor() {
5
+ super(...arguments);
6
+ Object.defineProperty(this, "name", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: 'dropcursor'
11
+ });
12
+ Object.defineProperty(this, "options", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: {
17
+ color: 'currentColor',
18
+ width: 1,
19
+ class: undefined,
20
+ }
21
+ });
22
+ }
23
+ getProseMirrorPlugins() {
24
+ return [
25
+ dropCursor(this.options),
26
+ ];
27
+ }
28
+ }
@@ -0,0 +1,12 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { Extension } from '@kerebron/editor';
3
+ export declare class ExtensionGapcursor extends Extension {
4
+ name: string;
5
+ options: {
6
+ color: string;
7
+ width: number;
8
+ class: undefined;
9
+ };
10
+ getProseMirrorPlugins(): Plugin[];
11
+ }
12
+ //# sourceMappingURL=ExtensionGapcursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionGapcursor.d.ts","sourceRoot":"","sources":["../src/ExtensionGapcursor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,IAAI,SAAe;IAEnB,OAAO;;;;MAIL;IAEO,qBAAqB,IAAI,MAAM,EAAE;CAK3C"}
@@ -0,0 +1,28 @@
1
+ import { gapCursor } from 'prosemirror-gapcursor';
2
+ import { Extension } from '@kerebron/editor';
3
+ export class ExtensionGapcursor extends Extension {
4
+ constructor() {
5
+ super(...arguments);
6
+ Object.defineProperty(this, "name", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: 'gapcursor'
11
+ });
12
+ Object.defineProperty(this, "options", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: {
17
+ color: 'currentColor',
18
+ width: 1,
19
+ class: undefined,
20
+ }
21
+ });
22
+ }
23
+ getProseMirrorPlugins() {
24
+ return [
25
+ gapCursor(),
26
+ ];
27
+ }
28
+ }
@@ -0,0 +1,14 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { type CoreEditor, Extension } from '@kerebron/editor';
3
+ import { type Commands, type CommandShortcuts } from '@kerebron/editor/commands';
4
+ export declare class ExtensionHistory extends Extension {
5
+ name: string;
6
+ options: {
7
+ depth: number;
8
+ newGroupDelay: number;
9
+ };
10
+ getCommands(editor: CoreEditor): Partial<Commands>;
11
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
12
+ getProseMirrorPlugins(): Plugin[];
13
+ }
14
+ //# sourceMappingURL=ExtensionHistory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionHistory.d.ts","sourceRoot":"","sources":["../src/ExtensionHistory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,IAAI,SAAa;IAEjB,OAAO;;;MAGL;IAEO,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQlD,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAiBjD,qBAAqB,IAAI,MAAM,EAAE;CAK3C"}
@@ -0,0 +1,49 @@
1
+ import { history, redo, undo } from 'prosemirror-history';
2
+ import { undoInputRule } from 'prosemirror-inputrules';
3
+ import { Extension } from '@kerebron/editor';
4
+ export class ExtensionHistory extends Extension {
5
+ constructor() {
6
+ super(...arguments);
7
+ Object.defineProperty(this, "name", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: 'history'
12
+ });
13
+ Object.defineProperty(this, "options", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: {
18
+ depth: 100,
19
+ newGroupDelay: 500,
20
+ }
21
+ });
22
+ }
23
+ getCommands(editor) {
24
+ return {
25
+ 'undo': () => undo,
26
+ 'redo': () => redo,
27
+ 'undoInputRule': () => undoInputRule,
28
+ };
29
+ }
30
+ getKeyboardShortcuts() {
31
+ const mac = typeof navigator != 'undefined'
32
+ ? /Mac|iP(hone|[oa]d)/.test(navigator.platform)
33
+ : false;
34
+ const shortcuts = {
35
+ 'Backspace': 'undoInputRule',
36
+ 'Mod-z': 'undo',
37
+ 'Mod-y': 'redo',
38
+ };
39
+ if (!mac) {
40
+ shortcuts['Mod-y'] = 'redo';
41
+ }
42
+ return shortcuts;
43
+ }
44
+ getProseMirrorPlugins() {
45
+ return [
46
+ history(this.options),
47
+ ];
48
+ }
49
+ }
@@ -0,0 +1,14 @@
1
+ import { MarkSpec, MarkType } from 'prosemirror-model';
2
+ import { CoreEditor, Mark } from '@kerebron/editor';
3
+ import { Commands, CommandShortcuts } from '@kerebron/editor/commands';
4
+ export declare class MarkCode extends Mark {
5
+ name: string;
6
+ requires: string[];
7
+ automerge: {
8
+ markName: string;
9
+ };
10
+ getMarkSpec(): MarkSpec;
11
+ getCommands(editor: CoreEditor, type: MarkType): Partial<Commands>;
12
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
13
+ }
14
+ //# sourceMappingURL=MarkCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkCode.d.ts","sourceRoot":"","sources":["../src/MarkCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,QAAS,SAAQ,IAAI;IACvB,IAAI,SAAU;IACvB,QAAQ,WAAW;IAEnB,SAAS;;MAEP;IAEF,WAAW,IAAI,QAAQ;IASvB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAMlE,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAKlD"}
@@ -0,0 +1,45 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ import { toggleMark, } from '@kerebron/editor/commands';
3
+ export class MarkCode extends Mark {
4
+ constructor() {
5
+ super(...arguments);
6
+ Object.defineProperty(this, "name", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: 'code'
11
+ });
12
+ Object.defineProperty(this, "requires", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: ['doc']
17
+ });
18
+ Object.defineProperty(this, "automerge", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: {
23
+ markName: 'code',
24
+ }
25
+ });
26
+ }
27
+ getMarkSpec() {
28
+ return {
29
+ parseDOM: [{ tag: 'code' }],
30
+ toDOM() {
31
+ return ['code', 0];
32
+ },
33
+ };
34
+ }
35
+ getCommands(editor, type) {
36
+ return {
37
+ 'toggleCode': () => toggleMark(type),
38
+ };
39
+ }
40
+ getKeyboardShortcuts() {
41
+ return {
42
+ 'Mod-`': 'toggleCode',
43
+ };
44
+ }
45
+ }
@@ -0,0 +1,13 @@
1
+ import { CoreEditor, Mark } from '@kerebron/editor';
2
+ import { Commands, CommandShortcuts } from '@kerebron/editor/commands';
3
+ export declare class MarkItalic extends Mark {
4
+ name: string;
5
+ requires: string[];
6
+ automerge: {
7
+ markName: string;
8
+ };
9
+ getMarkSpec(): MarkSpec;
10
+ getCommands(editor: CoreEditor, type: MarkType): Partial<Commands>;
11
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
12
+ }
13
+ //# sourceMappingURL=MarkItalic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkItalic.d.ts","sourceRoot":"","sources":["../src/MarkItalic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAQ;IACrB,QAAQ,WAAW;IAEnB,SAAS;;MAEP;IAEF,WAAW,IAAI,QAAQ;IAcvB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAMlE,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAMlD"}
@@ -0,0 +1,51 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ import { toggleMark, } from '@kerebron/editor/commands';
3
+ export class MarkItalic extends Mark {
4
+ constructor() {
5
+ super(...arguments);
6
+ Object.defineProperty(this, "name", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: 'em'
11
+ });
12
+ Object.defineProperty(this, "requires", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: ['doc']
17
+ });
18
+ Object.defineProperty(this, "automerge", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: {
23
+ markName: 'em',
24
+ }
25
+ });
26
+ }
27
+ getMarkSpec() {
28
+ return {
29
+ parseDOM: [
30
+ { tag: 'i' },
31
+ { tag: 'em' },
32
+ { style: 'font-assets=italic' },
33
+ { style: 'font-assets=normal', clearMark: (m) => m.type.name == 'em' },
34
+ ],
35
+ toDOM() {
36
+ return ['em', 0];
37
+ },
38
+ };
39
+ }
40
+ getCommands(editor, type) {
41
+ return {
42
+ 'toggleItalic': () => toggleMark(type),
43
+ };
44
+ }
45
+ getKeyboardShortcuts() {
46
+ return {
47
+ 'Mod-i': 'toggleItalic',
48
+ 'Mod-I': 'toggleItalic',
49
+ };
50
+ }
51
+ }
@@ -0,0 +1,18 @@
1
+ import { MarkSpec, Mark as PmMark } from 'prosemirror-model';
2
+ import { Mark } from '@kerebron/editor';
3
+ export declare class MarkLink extends Mark {
4
+ name: string;
5
+ requires: string[];
6
+ automerge: {
7
+ markName: string;
8
+ parsers: {
9
+ fromAutomerge: (mark: string) => {
10
+ href: any;
11
+ title: any;
12
+ };
13
+ fromProsemirror: (mark: PmMark) => string;
14
+ };
15
+ };
16
+ getMarkSpec(): MarkSpec;
17
+ }
18
+ //# sourceMappingURL=MarkLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkLink.d.ts","sourceRoot":"","sources":["../src/MarkLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,qBAAa,QAAS,SAAQ,IAAI;IACvB,IAAI,SAAU;IACvB,QAAQ,WAAW;IAEnB,SAAS;;;kCAGiB,MAAM;;;;oCAiBJ,MAAM;;MAMhC;IAEO,WAAW,IAAI,QAAQ;CAwBjC"}
@@ -0,0 +1,74 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkLink extends Mark {
3
+ constructor() {
4
+ super(...arguments);
5
+ Object.defineProperty(this, "name", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: 'link'
10
+ });
11
+ Object.defineProperty(this, "requires", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: ['doc']
16
+ });
17
+ Object.defineProperty(this, "automerge", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: {
22
+ markName: 'link',
23
+ parsers: {
24
+ fromAutomerge: (mark /*: am.MarkValue*/) => {
25
+ if (typeof mark === 'string') {
26
+ try {
27
+ const value = JSON.parse(mark);
28
+ return {
29
+ href: value.href || '',
30
+ title: value.title || '',
31
+ };
32
+ }
33
+ catch (e) {
34
+ console.warn('failed to parse link mark as JSON');
35
+ }
36
+ }
37
+ return {
38
+ href: '',
39
+ title: '',
40
+ };
41
+ },
42
+ fromProsemirror: (mark) => JSON.stringify({
43
+ href: mark.attrs.href,
44
+ title: mark.attrs.title,
45
+ }),
46
+ },
47
+ }
48
+ });
49
+ }
50
+ getMarkSpec() {
51
+ return {
52
+ attrs: {
53
+ href: {},
54
+ title: { default: null },
55
+ },
56
+ inclusive: false,
57
+ parseDOM: [
58
+ {
59
+ tag: 'a[href]',
60
+ getAttrs(dom) {
61
+ return {
62
+ href: dom.getAttribute('href'),
63
+ title: dom.getAttribute('title'),
64
+ };
65
+ },
66
+ },
67
+ ],
68
+ toDOM(node) {
69
+ const { href, title } = node.attrs;
70
+ return ['a', { href, title }, 0];
71
+ },
72
+ };
73
+ }
74
+ }
@@ -0,0 +1,14 @@
1
+ import { CoreEditor, Mark } from '@kerebron/editor';
2
+ import { Commands, CommandShortcuts } from '@kerebron/editor/commands';
3
+ import { MarkType } from 'prosemirror-model';
4
+ export declare class MarkStrong extends Mark {
5
+ name: string;
6
+ requires: string[];
7
+ automerge: {
8
+ markName: string;
9
+ };
10
+ getMarkSpec(): MarkSpec;
11
+ getCommands(editor: CoreEditor, type: MarkType): Partial<Commands>;
12
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
13
+ }
14
+ //# sourceMappingURL=MarkStrong.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkStrong.d.ts","sourceRoot":"","sources":["../src/MarkStrong.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAY;IACzB,QAAQ,WAAW;IAEnB,SAAS;;MAEP;IAEF,WAAW,IAAI,QAAQ;IAyBvB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAMlE,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAMlD"}