@kerebron/extension-basic-editor 0.4.25 → 0.4.27

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 (137) hide show
  1. package/package.json +12 -2
  2. package/esm/ExtensionBaseKeymap.d.ts +0 -7
  3. package/esm/ExtensionBaseKeymap.d.ts.map +0 -1
  4. package/esm/ExtensionBaseKeymap.js +0 -55
  5. package/esm/ExtensionBasicCodeEditor.d.ts +0 -11
  6. package/esm/ExtensionBasicCodeEditor.d.ts.map +0 -1
  7. package/esm/ExtensionBasicCodeEditor.js +0 -61
  8. package/esm/ExtensionBasicEditor.d.ts +0 -46
  9. package/esm/ExtensionBasicEditor.d.ts.map +0 -1
  10. package/esm/ExtensionBasicEditor.js +0 -88
  11. package/esm/ExtensionDropcursor.d.ts +0 -19
  12. package/esm/ExtensionDropcursor.d.ts.map +0 -1
  13. package/esm/ExtensionDropcursor.js +0 -186
  14. package/esm/ExtensionGapcursor.d.ts +0 -32
  15. package/esm/ExtensionGapcursor.d.ts.map +0 -1
  16. package/esm/ExtensionGapcursor.js +0 -249
  17. package/esm/ExtensionHistory.d.ts +0 -15
  18. package/esm/ExtensionHistory.d.ts.map +0 -1
  19. package/esm/ExtensionHistory.js +0 -62
  20. package/esm/ExtensionHtml.d.ts +0 -15
  21. package/esm/ExtensionHtml.d.ts.map +0 -1
  22. package/esm/ExtensionHtml.js +0 -99
  23. package/esm/ExtensionMediaUpload.d.ts +0 -24
  24. package/esm/ExtensionMediaUpload.d.ts.map +0 -1
  25. package/esm/ExtensionMediaUpload.js +0 -167
  26. package/esm/ExtensionSelection.d.ts +0 -11
  27. package/esm/ExtensionSelection.d.ts.map +0 -1
  28. package/esm/ExtensionSelection.js +0 -229
  29. package/esm/MarkBookmark.d.ts +0 -8
  30. package/esm/MarkBookmark.d.ts.map +0 -1
  31. package/esm/MarkBookmark.js +0 -16
  32. package/esm/MarkChange.d.ts +0 -8
  33. package/esm/MarkChange.d.ts.map +0 -1
  34. package/esm/MarkChange.js +0 -13
  35. package/esm/MarkCode.d.ts +0 -11
  36. package/esm/MarkCode.d.ts.map +0 -1
  37. package/esm/MarkCode.js +0 -23
  38. package/esm/MarkHighlight.d.ts +0 -8
  39. package/esm/MarkHighlight.d.ts.map +0 -1
  40. package/esm/MarkHighlight.js +0 -35
  41. package/esm/MarkItalic.d.ts +0 -11
  42. package/esm/MarkItalic.d.ts.map +0 -1
  43. package/esm/MarkItalic.js +0 -29
  44. package/esm/MarkLink.d.ts +0 -8
  45. package/esm/MarkLink.d.ts.map +0 -1
  46. package/esm/MarkLink.js +0 -29
  47. package/esm/MarkStrike.d.ts +0 -11
  48. package/esm/MarkStrike.d.ts.map +0 -1
  49. package/esm/MarkStrike.js +0 -26
  50. package/esm/MarkStrong.d.ts +0 -11
  51. package/esm/MarkStrong.d.ts.map +0 -1
  52. package/esm/MarkStrong.js +0 -38
  53. package/esm/MarkTextColor.d.ts +0 -8
  54. package/esm/MarkTextColor.d.ts.map +0 -1
  55. package/esm/MarkTextColor.js +0 -27
  56. package/esm/MarkUnderline.d.ts +0 -11
  57. package/esm/MarkUnderline.d.ts.map +0 -1
  58. package/esm/MarkUnderline.js +0 -33
  59. package/esm/NodeAside.d.ts +0 -8
  60. package/esm/NodeAside.d.ts.map +0 -1
  61. package/esm/NodeAside.js +0 -16
  62. package/esm/NodeBlockquote.d.ts +0 -13
  63. package/esm/NodeBlockquote.d.ts.map +0 -1
  64. package/esm/NodeBlockquote.js +0 -34
  65. package/esm/NodeBookmark.d.ts +0 -8
  66. package/esm/NodeBookmark.d.ts.map +0 -1
  67. package/esm/NodeBookmark.js +0 -19
  68. package/esm/NodeBulletList.d.ts +0 -13
  69. package/esm/NodeBulletList.d.ts.map +0 -1
  70. package/esm/NodeBulletList.js +0 -34
  71. package/esm/NodeCodeBlock.d.ts +0 -9
  72. package/esm/NodeCodeBlock.d.ts.map +0 -1
  73. package/esm/NodeCodeBlock.js +0 -50
  74. package/esm/NodeDefinitionDesc.d.ts +0 -8
  75. package/esm/NodeDefinitionDesc.d.ts.map +0 -1
  76. package/esm/NodeDefinitionDesc.js +0 -16
  77. package/esm/NodeDefinitionList.d.ts +0 -13
  78. package/esm/NodeDefinitionList.d.ts.map +0 -1
  79. package/esm/NodeDefinitionList.js +0 -28
  80. package/esm/NodeDefinitionTerm.d.ts +0 -8
  81. package/esm/NodeDefinitionTerm.d.ts.map +0 -1
  82. package/esm/NodeDefinitionTerm.js +0 -16
  83. package/esm/NodeDocument.d.ts +0 -7
  84. package/esm/NodeDocument.d.ts.map +0 -1
  85. package/esm/NodeDocument.js +0 -19
  86. package/esm/NodeDocumentCode.d.ts +0 -7
  87. package/esm/NodeDocumentCode.d.ts.map +0 -1
  88. package/esm/NodeDocumentCode.js +0 -29
  89. package/esm/NodeFrontmatter.d.ts +0 -8
  90. package/esm/NodeFrontmatter.d.ts.map +0 -1
  91. package/esm/NodeFrontmatter.js +0 -16
  92. package/esm/NodeHardBreak.d.ts +0 -14
  93. package/esm/NodeHardBreak.d.ts.map +0 -1
  94. package/esm/NodeHardBreak.js +0 -67
  95. package/esm/NodeHeading.d.ts +0 -13
  96. package/esm/NodeHeading.d.ts.map +0 -1
  97. package/esm/NodeHeading.js +0 -49
  98. package/esm/NodeHorizontalRule.d.ts +0 -11
  99. package/esm/NodeHorizontalRule.d.ts.map +0 -1
  100. package/esm/NodeHorizontalRule.js +0 -29
  101. package/esm/NodeImage.d.ts +0 -8
  102. package/esm/NodeImage.d.ts.map +0 -1
  103. package/esm/NodeImage.js +0 -33
  104. package/esm/NodeInlineShortCode.d.ts +0 -10
  105. package/esm/NodeInlineShortCode.d.ts.map +0 -1
  106. package/esm/NodeInlineShortCode.js +0 -30
  107. package/esm/NodeListItem.d.ts +0 -15
  108. package/esm/NodeListItem.d.ts.map +0 -1
  109. package/esm/NodeListItem.js +0 -199
  110. package/esm/NodeMath.d.ts +0 -8
  111. package/esm/NodeMath.d.ts.map +0 -1
  112. package/esm/NodeMath.js +0 -99
  113. package/esm/NodeOrderedList.d.ts +0 -23
  114. package/esm/NodeOrderedList.d.ts.map +0 -1
  115. package/esm/NodeOrderedList.js +0 -52
  116. package/esm/NodeParagraph.d.ts +0 -11
  117. package/esm/NodeParagraph.d.ts.map +0 -1
  118. package/esm/NodeParagraph.js +0 -25
  119. package/esm/NodeTaskItem.d.ts +0 -24
  120. package/esm/NodeTaskItem.d.ts.map +0 -1
  121. package/esm/NodeTaskItem.js +0 -139
  122. package/esm/NodeTaskList.d.ts +0 -11
  123. package/esm/NodeTaskList.d.ts.map +0 -1
  124. package/esm/NodeTaskList.js +0 -25
  125. package/esm/NodeText.d.ts +0 -7
  126. package/esm/NodeText.d.ts.map +0 -1
  127. package/esm/NodeText.js +0 -9
  128. package/esm/NodeVideo.d.ts +0 -8
  129. package/esm/NodeVideo.d.ts.map +0 -1
  130. package/esm/NodeVideo.js +0 -45
  131. package/esm/package.json +0 -3
  132. package/esm/remote-selection/ExtensionRemoteSelection.d.ts +0 -24
  133. package/esm/remote-selection/ExtensionRemoteSelection.d.ts.map +0 -1
  134. package/esm/remote-selection/ExtensionRemoteSelection.js +0 -22
  135. package/esm/remote-selection/remoteSelectionPlugin.d.ts +0 -25
  136. package/esm/remote-selection/remoteSelectionPlugin.d.ts.map +0 -1
  137. package/esm/remote-selection/remoteSelectionPlugin.js +0 -96
@@ -1,29 +0,0 @@
1
- import { Node } from '@kerebron/editor';
2
- export class NodeHorizontalRule extends Node {
3
- name = 'hr';
4
- requires = ['doc'];
5
- getNodeSpec() {
6
- return {
7
- group: 'block',
8
- parseDOM: [{ tag: 'hr' }],
9
- toDOM() {
10
- return ['hr'];
11
- },
12
- };
13
- }
14
- getCommandFactories(editor, type) {
15
- return {
16
- 'setHorizontalRule': () => (state, dispatch) => {
17
- if (dispatch) {
18
- dispatch(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
19
- }
20
- return true;
21
- },
22
- };
23
- }
24
- getKeyboardShortcuts() {
25
- return {
26
- 'Mod-_': 'setHorizontalRule',
27
- };
28
- }
29
- }
@@ -1,8 +0,0 @@
1
- import { type NodeSpec } from 'prosemirror-model';
2
- import { Node } from '@kerebron/editor';
3
- export declare class NodeImage extends Node {
4
- name: string;
5
- requires: string[];
6
- getNodeSpec(): NodeSpec;
7
- }
8
- //# sourceMappingURL=NodeImage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeImage.d.ts","sourceRoot":"","sources":["../src/NodeImage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,qBAAa,SAAU,SAAQ,IAAI;IACxB,IAAI,SAAW;IACxB,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;CA4BjC"}
package/esm/NodeImage.js DELETED
@@ -1,33 +0,0 @@
1
- import { Node } from '@kerebron/editor';
2
- export class NodeImage extends Node {
3
- name = 'image';
4
- requires = ['doc'];
5
- getNodeSpec() {
6
- return {
7
- inline: true,
8
- attrs: {
9
- src: {},
10
- alt: { default: null },
11
- title: { default: null },
12
- },
13
- group: 'inline',
14
- draggable: true,
15
- parseDOM: [
16
- {
17
- tag: 'img[src]',
18
- getAttrs(dom) {
19
- return {
20
- src: dom.getAttribute('src'),
21
- title: dom.getAttribute('title'),
22
- alt: dom.getAttribute('alt'),
23
- };
24
- },
25
- },
26
- ],
27
- toDOM(node) {
28
- const { src, alt, title } = node.attrs;
29
- return ['img', { src, alt, title }];
30
- },
31
- };
32
- }
33
- }
@@ -1,10 +0,0 @@
1
- import { NodeSpec, NodeType } from 'prosemirror-model';
2
- import { Node } from '@kerebron/editor';
3
- import { type InputRule } from '@kerebron/editor/plugins/input-rules';
4
- export declare class NodeInlineShortCode extends Node {
5
- name: string;
6
- requires: string[];
7
- getNodeSpec(): NodeSpec;
8
- getInputRules(type: NodeType): InputRule[];
9
- }
10
- //# sourceMappingURL=NodeInlineShortCode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeInlineShortCode.d.ts","sourceRoot":"","sources":["../src/NodeInlineShortCode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,mBAAoB,SAAQ,IAAI;IAClC,IAAI,SAAsB;IACnC,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;IAgBvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;CAcpD"}
@@ -1,30 +0,0 @@
1
- import { Node } from '@kerebron/editor';
2
- import { wrappingInputRule, } from '@kerebron/editor/plugins/input-rules';
3
- export class NodeInlineShortCode extends Node {
4
- name = 'shortcode-inline';
5
- requires = ['doc'];
6
- getNodeSpec() {
7
- return {
8
- inline: true,
9
- group: 'inline',
10
- selectable: true,
11
- attrs: {
12
- name: {},
13
- },
14
- atom: true,
15
- parseDOM: [{ tag: 'span.kb-shortcode-inline' }],
16
- toDOM(mark) {
17
- return ['span', { class: 'kb-shortcode-inline' }, 0];
18
- },
19
- };
20
- }
21
- getInputRules(type) {
22
- return [
23
- wrappingInputRule(/\{\{[^}]+\}\}/, type, (match) => {
24
- return { condition: match[0] };
25
- }, (match, node) => {
26
- return node.attrs.condition === match[1];
27
- }),
28
- ];
29
- }
30
- }
@@ -1,15 +0,0 @@
1
- import { type Attrs, NodeSpec, type NodeType } from 'prosemirror-model';
2
- import type { Command } from 'prosemirror-state';
3
- import { type CoreEditor, Node } from '@kerebron/editor';
4
- import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
5
- export declare function splitListItem(itemType: NodeType, itemAttrs?: Attrs): Command;
6
- export declare function liftListItem(itemType: NodeType): Command;
7
- export declare function sinkListItem(itemType: NodeType): Command;
8
- export declare class NodeListItem extends Node {
9
- name: string;
10
- requires: string[];
11
- getNodeSpec(): NodeSpec;
12
- getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
13
- getKeyboardShortcuts(): Partial<CommandShortcuts>;
14
- }
15
- //# sourceMappingURL=NodeListItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeListItem.d.ts","sourceRoot":"","sources":["../src/NodeListItem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EAGV,QAAQ,EACR,KAAK,QAAQ,EAEd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,OAAO,EAIR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAUnC,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,OAAO,CA+D5E;AAwBD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAgBxD;AAuGD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CA0CxD;AAED,qBAAa,YAAa,SAAQ,IAAI;IAC3B,IAAI,SAAe;IAC5B,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;IAWvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAQnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAO3D"}
@@ -1,199 +0,0 @@
1
- import { Fragment, NodeRange, Slice, } from 'prosemirror-model';
2
- import { Selection } from 'prosemirror-state';
3
- import { Node } from '@kerebron/editor';
4
- import { canJoin, canSplit, liftTarget, ReplaceAroundStep, } from 'prosemirror-transform';
5
- /// Build a command that splits a non-empty textblock at the top level
6
- /// of a list item by also splitting that list item.
7
- export function splitListItem(itemType, itemAttrs) {
8
- return function (state, dispatch) {
9
- const { $from, $to, node } = state.selection;
10
- if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) {
11
- return false;
12
- }
13
- const grandParent = $from.node(-1);
14
- if (grandParent.type != itemType)
15
- return false;
16
- if ($from.parent.content.size == 0 &&
17
- $from.node(-1).childCount == $from.indexAfter(-1)) {
18
- // In an empty block. If this is a nested list, the wrapping
19
- // list item should be split. Otherwise, bail out and let next
20
- // command handle lifting.
21
- if ($from.depth == 3 || $from.node(-3).type != itemType ||
22
- $from.index(-2) != $from.node(-2).childCount - 1)
23
- return false;
24
- if (dispatch) {
25
- let wrap = Fragment.empty;
26
- const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;
27
- // Build a fragment containing empty versions of the structure
28
- // from the outer list item to the parent node of the cursor
29
- for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d--) {
30
- wrap = Fragment.from($from.node(d).copy(wrap));
31
- }
32
- let depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount
33
- ? 1
34
- : $from.indexAfter(-2) < $from.node(-3).childCount
35
- ? 2
36
- : 3;
37
- // Add a second list item with an empty default start node
38
- wrap = wrap.append(Fragment.from(itemType.createAndFill()));
39
- let start = $from.before($from.depth - (depthBefore - 1));
40
- let tr = state.tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0));
41
- let sel = -1;
42
- tr.doc.nodesBetween(start, tr.doc.content.size, (node, pos) => {
43
- if (sel > -1)
44
- return false;
45
- if (node.isTextblock && node.content.size == 0)
46
- sel = pos + 1;
47
- });
48
- if (sel > -1)
49
- tr.setSelection(Selection.near(tr.doc.resolve(sel)));
50
- dispatch(tr.scrollIntoView());
51
- }
52
- return true;
53
- }
54
- let nextType = $to.pos == $from.end()
55
- ? grandParent.contentMatchAt(0).defaultType
56
- : null;
57
- let tr = state.tr.delete($from.pos, $to.pos);
58
- let types = nextType
59
- ? [itemAttrs ? { type: itemType, attrs: itemAttrs } : null, {
60
- type: nextType,
61
- }]
62
- : undefined;
63
- if (!canSplit(tr.doc, $from.pos, 2, types))
64
- return false;
65
- if (dispatch)
66
- dispatch(tr.split($from.pos, 2, types).scrollIntoView());
67
- return true;
68
- };
69
- }
70
- /// Acts like [`splitListItem`](#schema-list.splitListItem), but
71
- /// without resetting the set of active marks at the cursor.
72
- function splitListItemKeepMarks(itemType, itemAttrs) {
73
- let split = splitListItem(itemType, itemAttrs);
74
- return (state, dispatch) => {
75
- return split(state, dispatch && ((tr) => {
76
- let marks = state.storedMarks ||
77
- (state.selection.$to.parentOffset && state.selection.$from.marks());
78
- if (marks)
79
- tr.ensureMarks(marks);
80
- dispatch(tr);
81
- }));
82
- };
83
- }
84
- /// Create a command to lift the list item around the selection up into
85
- /// a wrapping list.
86
- export function liftListItem(itemType) {
87
- return function (state, dispatch) {
88
- let { $from, $to } = state.selection;
89
- let range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
90
- if (!range)
91
- return false;
92
- if (!dispatch)
93
- return true;
94
- if ($from.node(range.depth - 1).type == itemType) { // Inside a parent list
95
- return liftToOuterList(state, dispatch, itemType, range);
96
- } // Outer list node
97
- else {
98
- return liftOutOfList(state, dispatch, range);
99
- }
100
- };
101
- }
102
- function liftToOuterList(state, dispatch, itemType, range) {
103
- let tr = state.tr, end = range.end, endOfList = range.$to.end(range.depth);
104
- if (end < endOfList) {
105
- // There are siblings after the lifted items, which must become
106
- // children of the last item
107
- tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
108
- range = new NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
109
- }
110
- const target = liftTarget(range);
111
- if (target == null)
112
- return false;
113
- tr.lift(range, target);
114
- let $after = tr.doc.resolve(tr.mapping.map(end, -1) - 1);
115
- if (canJoin(tr.doc, $after.pos) &&
116
- $after.nodeBefore.type == $after.nodeAfter.type)
117
- tr.join($after.pos);
118
- dispatch(tr.scrollIntoView());
119
- return true;
120
- }
121
- function liftOutOfList(state, dispatch, range) {
122
- let tr = state.tr, list = range.parent;
123
- // Merge the list items into a single big item
124
- for (let pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {
125
- pos -= list.child(i).nodeSize;
126
- tr.delete(pos - 1, pos + 1);
127
- }
128
- let $start = tr.doc.resolve(range.start), item = $start.nodeAfter;
129
- if (tr.mapping.map(range.end) != range.start + $start.nodeAfter.nodeSize) {
130
- return false;
131
- }
132
- let atStart = range.startIndex == 0, atEnd = range.endIndex == list.childCount;
133
- let parent = $start.node(-1), indexBefore = $start.index(-1);
134
- if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list)))) {
135
- return false;
136
- }
137
- let start = $start.pos, end = start + item.nodeSize;
138
- // Strip off the surrounding list. At the sides where we're not at
139
- // the end of the list, the existing list is closed. At sides where
140
- // this is the end, it is overwritten to its end.
141
- tr.step(new ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty)))
142
- .append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
143
- dispatch(tr.scrollIntoView());
144
- return true;
145
- }
146
- /// Create a command to sink the list item around the selection down
147
- /// into an inner list.
148
- export function sinkListItem(itemType) {
149
- return function (state, dispatch) {
150
- const { $from, $to } = state.selection;
151
- const range = $from.blockRange($to, (node) => node.childCount > 0 && node.firstChild.type == itemType);
152
- if (!range)
153
- return false;
154
- const startIndex = range.startIndex;
155
- if (startIndex == 0)
156
- return false;
157
- const parent = range.parent, nodeBefore = parent.child(startIndex - 1);
158
- if (nodeBefore.type != itemType)
159
- return false;
160
- if (dispatch) {
161
- const nestedBefore = nodeBefore.lastChild &&
162
- nodeBefore.lastChild.type == parent.type;
163
- const inner = Fragment.from(nestedBefore ? itemType.create() : null);
164
- const slice = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
165
- const before = range.start, after = range.end;
166
- dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true))
167
- .scrollIntoView());
168
- }
169
- return true;
170
- };
171
- }
172
- export class NodeListItem extends Node {
173
- name = 'list_item';
174
- requires = ['doc'];
175
- getNodeSpec() {
176
- return {
177
- content: 'paragraph block*',
178
- parseDOM: [{ tag: 'li' }],
179
- defining: true,
180
- toDOM() {
181
- return ['li', 0];
182
- },
183
- };
184
- }
185
- getCommandFactories(editor, type) {
186
- return {
187
- 'splitListItem': () => splitListItem(type),
188
- 'liftListItem': () => liftListItem(type),
189
- 'sinkListItem': () => sinkListItem(type),
190
- };
191
- }
192
- getKeyboardShortcuts() {
193
- return {
194
- 'Enter': 'splitListItem',
195
- 'Tab': 'sinkListItem',
196
- 'Shift-Tab': 'liftListItem',
197
- };
198
- }
199
- }
package/esm/NodeMath.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { type NodeSpec } from 'prosemirror-model';
2
- import { Node } from '@kerebron/editor';
3
- export declare class NodeMath extends Node {
4
- name: string;
5
- requires: string[];
6
- getNodeSpec(): NodeSpec;
7
- }
8
- //# sourceMappingURL=NodeMath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeMath.d.ts","sourceRoot":"","sources":["../src/NodeMath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMxC,qBAAa,QAAS,SAAQ,IAAI;IACvB,IAAI,SAAU;IACvB,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;CA8CjC"}
package/esm/NodeMath.js DELETED
@@ -1,99 +0,0 @@
1
- import { Node } from '@kerebron/editor';
2
- // import { MathMLToLaTeX } from 'mathml-to-latex';
3
- // const latex = MathMLToLaTeX.convert(mathMl);
4
- // https://mathlive.io/mathfield/
5
- export class NodeMath extends Node {
6
- name = 'math';
7
- requires = ['doc'];
8
- getNodeSpec() {
9
- return {
10
- inline: true,
11
- attrs: {
12
- lang: { default: 'mathml' },
13
- content: {},
14
- },
15
- group: 'inline',
16
- draggable: true,
17
- // parseDOM: [
18
- // {
19
- // tag: 'math',
20
- // getAttrs(dom: HTMLElement) {
21
- // return {
22
- // content: dom.outerHTML,
23
- // };
24
- // },
25
- // },
26
- // ],
27
- parseDOM: [{
28
- tag: 'math',
29
- getAttrs: (dom) => ({
30
- lang: 'mathml',
31
- content: new XMLSerializer().serializeToString(dom),
32
- }),
33
- }],
34
- toDOM(node) {
35
- const parser = new DOMParser();
36
- const parsed = parser.parseFromString(node.attrs.content, 'application/xml');
37
- // Check for parsing errors (e.g., invalid XML)
38
- const errorNode = parsed.getElementsByTagName('parsererror');
39
- if (errorNode.length > 0) {
40
- return ['span', { class: 'mathml-error' }, 'Invalid MathML'];
41
- }
42
- // Import and return the parsed MathML element
43
- return document.importNode(parsed.documentElement, true);
44
- // const { xml } = node.attrs;
45
- // return ['math', {}, []];
46
- },
47
- };
48
- }
49
- }
50
- /*
51
- MathML vs. LaTeX: Which is Better for Web Math Equations?
52
- Neither is universally "better"—it depends on your goals (authoring, rendering, accessibility, or storage). MathML and LaTeX serve different primary purposes but can complement each other on the web (e.g., via converters like MathJax). Here's a comparison focused on web use:
53
- Key Differences
54
-
55
- Purpose:
56
-
57
- LaTeX: A human-readable markup language for typesetting math (e.g., $E=mc^2$). It's concise and widely used for authoring documents, papers, and web input. Not native to HTML; requires a processor (e.g., MathJax, KaTeX) to render as HTML/CSS/SVG.
58
- MathML: An XML-based standard (part of HTML5) for describing math structure and presentation (Presentation MathML for visuals; Content MathML for semantics). Designed for direct embedding in web pages (e.g., <math><mi>E</mi>=<mi>m</mi><msup><mi>c</mi><mn>2</mn></msup></math>). Browsers like Firefox and Safari support it natively; others need polyfills.
59
-
60
-
61
- Ease of Authoring:
62
-
63
- LaTeX: Wins for humans—shorter, intuitive syntax familiar to mathematicians. Easier to write/edit manually or in editors like Overleaf. Verbose MathML is painful for hand-coding complex equations.
64
- MathML: Better for programmatic generation (e.g., from tools or APIs) due to its structured XML. Use WYSIWYG editors (like those above) to avoid writing tags.
65
-
66
-
67
- Rendering on Web:
68
-
69
- LaTeX: Requires a JS library (MathJax ~300KB, KaTeX lighter ~100KB) for cross-browser display. Renders beautifully everywhere but adds load time and JS dependency. No native browser support.
70
- MathML: Native in Firefox/Safari (fast, no JS). Improving in Chrome/Edge (as of 2023+), but still needs MathJax fallback for full support. Outputs scalable HTML/CSS without images.
71
-
72
-
73
- Accessibility:
74
-
75
- MathML: Superior—semantic structure allows screen readers (e.g., NVDA with MathCAT, JAWS) to read equations meaningfully (e.g., "E equals m times c squared"). Essential for WCAG/ADA compliance.
76
- LaTeX: Poor native accessibility; screen readers treat it as plain text. MathJax can convert to MathML internally for better support, but raw LaTeX fails.
77
-
78
-
79
- Performance & Compatibility:
80
-
81
- LaTeX: Faster authoring, but rendering depends on the library. Universal via JS, but increases page weight.
82
- MathML: Lightweight native rendering where supported; more robust for search engines/parsing (e.g., Google indexes MathML). Less portable outside web (LaTeX dominates PDFs/print).
83
-
84
-
85
- Storage/Interoperability:
86
-
87
- LaTeX: Compact for databases/files. Easy to convert to MathML (via tools like texmath or Pandoc).
88
- MathML: Better for web standards (XML parsable), but bulkier. Ideal for exchange between math tools.
89
-
90
-
91
-
92
- Recommendation
93
-
94
- Use LaTeX if your focus is easy input/authoring (e.g., users typing equations) and you're okay with a renderer like MathJax. It's more practical for most web projects today due to familiarity and tools. Store as LaTeX, render via JS, and convert to MathML for accessibility if needed.
95
- Use MathML if prioritizing native web standards, accessibility, or programmatic output (e.g., from editors). It's "better" for semantic web math and future-proofing (browser support is growing), but pair with LaTeX input for usability.
96
- Hybrid Approach: Best for web—author in LaTeX, convert/output MathML for display/storage. Libraries like MathJax handle both seamlessly (input LaTeX, output rendered MathML). This gives LaTeX's simplicity with MathML's benefits.
97
-
98
- If accessibility is key, always generate MathML (even from LaTeX source). Test in browsers: LaTeX+MathJax works everywhere; pure MathML shines in Firefox but needs fallbacks elsewhere.
99
- */
@@ -1,23 +0,0 @@
1
- import { NodeSpec, NodeType } from 'prosemirror-model';
2
- import { type CoreEditor, Node } from '@kerebron/editor';
3
- import { type InputRule } from '@kerebron/editor/plugins/input-rules';
4
- import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
5
- export declare class NodeOrderedList extends Node {
6
- name: string;
7
- requires: string[];
8
- attributes: {
9
- type: {
10
- default: string;
11
- fromDom(element: HTMLElement): any;
12
- };
13
- start: {
14
- default: number;
15
- fromDom(element: HTMLElement): number;
16
- };
17
- };
18
- getNodeSpec(): NodeSpec;
19
- getInputRules(type: NodeType): InputRule[];
20
- getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
21
- getKeyboardShortcuts(): Partial<CommandShortcuts>;
22
- }
23
- //# sourceMappingURL=NodeOrderedList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeOrderedList.d.ts","sourceRoot":"","sources":["../src/NodeOrderedList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMzD,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,eAAgB,SAAQ,IAAI;IAC9B,IAAI,SAAkB;IAC/B,QAAQ,WAAW;IAEV,UAAU;;;6BAGE,WAAW;;;;6BAQX,WAAW;;MAM9B;IAEO,WAAW,IAAI,QAAQ;IAWvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAa1C,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAK3D"}
@@ -1,52 +0,0 @@
1
- import { Node } from '@kerebron/editor';
2
- import { getHtmlAttributes, setHtmlAttributes, } from '@kerebron/editor/utilities';
3
- import { wrappingInputRule, } from '@kerebron/editor/plugins/input-rules';
4
- export class NodeOrderedList extends Node {
5
- name = 'ordered_list';
6
- requires = ['doc'];
7
- attributes = {
8
- type: {
9
- default: '1',
10
- fromDom(element) {
11
- return element.hasAttribute('type')
12
- ? element.getAttribute('type')
13
- : '1';
14
- },
15
- },
16
- start: {
17
- default: 1,
18
- fromDom(element) {
19
- return element.hasAttribute('start')
20
- ? +element.getAttribute('start')
21
- : 1;
22
- },
23
- },
24
- };
25
- getNodeSpec() {
26
- return {
27
- group: 'block',
28
- content: 'list_item+',
29
- parseDOM: [
30
- { tag: 'ol', getAttrs: (element) => setHtmlAttributes(this, element) },
31
- ],
32
- toDOM: (node) => ['ol', getHtmlAttributes(this, node), 0],
33
- };
34
- }
35
- getInputRules(type) {
36
- return [
37
- /// Given a list node type, returns an input rule that turns a number
38
- /// followed by a dot at the start of a textblock into an ordered list.
39
- wrappingInputRule(/^(\d+)\.\s$/, type, (match) => ({ order: +match[1] }), (match, node) => node.childCount + node.attrs.order == +match[1]),
40
- ];
41
- }
42
- getCommandFactories(editor, type) {
43
- return {
44
- 'toggleOrderedList': () => editor.commandFactories.wrapInList(type),
45
- };
46
- }
47
- getKeyboardShortcuts() {
48
- return {
49
- 'Shift-Ctrl-7': 'toggleOrderedList',
50
- };
51
- }
52
- }
@@ -1,11 +0,0 @@
1
- import { type NodeSpec, type NodeType } from 'prosemirror-model';
2
- import { type CoreEditor, Node } from '@kerebron/editor';
3
- import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
4
- export declare class NodeParagraph extends Node {
5
- name: string;
6
- requires: string[];
7
- getNodeSpec(): NodeSpec;
8
- getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
9
- getKeyboardShortcuts(): Partial<CommandShortcuts>;
10
- }
11
- //# sourceMappingURL=NodeParagraph.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeParagraph.d.ts","sourceRoot":"","sources":["../src/NodeParagraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,aAAc,SAAQ,IAAI;IAC5B,IAAI,SAAe;IAC5B,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;IAWvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAK3D"}
@@ -1,25 +0,0 @@
1
- import { Node } from '@kerebron/editor';
2
- export class NodeParagraph extends Node {
3
- name = 'paragraph';
4
- requires = ['doc'];
5
- getNodeSpec() {
6
- return {
7
- content: 'inline*',
8
- group: 'block',
9
- parseDOM: [{ tag: 'p' }],
10
- toDOM() {
11
- return ['p', 0];
12
- },
13
- };
14
- }
15
- getCommandFactories(editor, type) {
16
- return {
17
- 'setParagraph': () => editor.commandFactories.setBlockType(type),
18
- };
19
- }
20
- getKeyboardShortcuts() {
21
- return {
22
- 'Shift-Ctrl-0': 'setParagraph',
23
- };
24
- }
25
- }
@@ -1,24 +0,0 @@
1
- import { Node as PmNode, NodeSpec, type NodeType } from 'prosemirror-model';
2
- import { type CoreEditor, Node } from '@kerebron/editor';
3
- import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
4
- import { NodeViewConstructor } from '@kerebron/editor/DummyEditorView';
5
- /**
6
- * Matches a task item to a - [ ] on input.
7
- */
8
- export declare const inputRegex: RegExp;
9
- export interface TaskItemOptions {
10
- onReadOnlyChecked?: (node: PmNode, checked: boolean) => boolean;
11
- nested: boolean;
12
- }
13
- export declare class NodeTaskItem extends Node {
14
- protected config: Partial<TaskItemOptions>;
15
- name: string;
16
- requires: string[];
17
- constructor(config?: Partial<TaskItemOptions>);
18
- getNodeSpec(): NodeSpec;
19
- getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
20
- getNodeView(editor: CoreEditor): NodeViewConstructor;
21
- getKeyboardShortcuts(): Partial<CommandShortcuts>;
22
- getInputRules(type: NodeType): any[];
23
- }
24
- //# sourceMappingURL=NodeTaskItem.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NodeTaskItem.d.ts","sourceRoot":"","sources":["../src/NodeTaskItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAIvE;;GAEG;AACH,eAAO,MAAM,UAAU,QAA2B,CAAC;AAEnD,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;IAChE,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,YAAa,SAAQ,IAAI;cAIE,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC;IAH7D,IAAI,SAAe;IAC5B,QAAQ,WAAW;gBAEmB,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAIlE,WAAW,IAAI,QAAQ;IAyCvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAQnB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,mBAAmB;IA4EpD,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAQjD,aAAa,CAAC,IAAI,EAAE,QAAQ;CAWtC"}