@kerebron/extension-basic-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 (146) hide show
  1. package/esm/ExtensionBaseKeymap.d.ts +7 -0
  2. package/esm/ExtensionBaseKeymap.d.ts.map +1 -0
  3. package/esm/ExtensionBaseKeymap.js +55 -0
  4. package/esm/ExtensionBasicCodeEditor.d.ts +11 -0
  5. package/esm/ExtensionBasicCodeEditor.d.ts.map +1 -0
  6. package/esm/ExtensionBasicCodeEditor.js +61 -0
  7. package/esm/ExtensionBasicEditor.d.ts +49 -0
  8. package/esm/ExtensionBasicEditor.d.ts.map +1 -0
  9. package/esm/ExtensionBasicEditor.js +94 -0
  10. package/esm/ExtensionDropcursor.d.ts +19 -0
  11. package/esm/ExtensionDropcursor.d.ts.map +1 -0
  12. package/esm/ExtensionDropcursor.js +186 -0
  13. package/esm/ExtensionGapcursor.d.ts +32 -0
  14. package/esm/ExtensionGapcursor.d.ts.map +1 -0
  15. package/esm/ExtensionGapcursor.js +249 -0
  16. package/esm/ExtensionHistory.d.ts +14 -0
  17. package/esm/ExtensionHistory.d.ts.map +1 -0
  18. package/esm/ExtensionHistory.js +34 -0
  19. package/esm/ExtensionHtml.d.ts +15 -0
  20. package/esm/ExtensionHtml.d.ts.map +1 -0
  21. package/esm/ExtensionHtml.js +99 -0
  22. package/esm/ExtensionMediaUpload.d.ts +24 -0
  23. package/esm/ExtensionMediaUpload.d.ts.map +1 -0
  24. package/esm/ExtensionMediaUpload.js +167 -0
  25. package/esm/ExtensionSelection.d.ts +11 -0
  26. package/esm/ExtensionSelection.d.ts.map +1 -0
  27. package/esm/ExtensionSelection.js +229 -0
  28. package/esm/ExtensionTextAlign.d.ts +11 -0
  29. package/esm/ExtensionTextAlign.d.ts.map +1 -0
  30. package/esm/ExtensionTextAlign.js +39 -0
  31. package/esm/MarkBookmark.d.ts +8 -0
  32. package/esm/MarkBookmark.d.ts.map +1 -0
  33. package/esm/MarkBookmark.js +16 -0
  34. package/esm/MarkChange.d.ts +8 -0
  35. package/esm/MarkChange.d.ts.map +1 -0
  36. package/esm/MarkChange.js +13 -0
  37. package/esm/MarkCode.d.ts +11 -0
  38. package/esm/MarkCode.d.ts.map +1 -0
  39. package/esm/MarkCode.js +23 -0
  40. package/esm/MarkHighlight.d.ts +8 -0
  41. package/esm/MarkHighlight.d.ts.map +1 -0
  42. package/esm/MarkHighlight.js +35 -0
  43. package/esm/MarkItalic.d.ts +11 -0
  44. package/esm/MarkItalic.d.ts.map +1 -0
  45. package/esm/MarkItalic.js +29 -0
  46. package/esm/MarkLink.d.ts +8 -0
  47. package/esm/MarkLink.d.ts.map +1 -0
  48. package/esm/MarkLink.js +29 -0
  49. package/esm/MarkStrike.d.ts +11 -0
  50. package/esm/MarkStrike.d.ts.map +1 -0
  51. package/esm/MarkStrike.js +26 -0
  52. package/esm/MarkStrong.d.ts +11 -0
  53. package/esm/MarkStrong.d.ts.map +1 -0
  54. package/esm/MarkStrong.js +38 -0
  55. package/esm/MarkSubscript.d.ts +11 -0
  56. package/esm/MarkSubscript.d.ts.map +1 -0
  57. package/esm/MarkSubscript.js +30 -0
  58. package/esm/MarkSuperscript.d.ts +11 -0
  59. package/esm/MarkSuperscript.d.ts.map +1 -0
  60. package/esm/MarkSuperscript.js +30 -0
  61. package/esm/MarkTextColor.d.ts +8 -0
  62. package/esm/MarkTextColor.d.ts.map +1 -0
  63. package/esm/MarkTextColor.js +27 -0
  64. package/esm/MarkUnderline.d.ts +11 -0
  65. package/esm/MarkUnderline.d.ts.map +1 -0
  66. package/esm/MarkUnderline.js +33 -0
  67. package/esm/NodeAside.d.ts +8 -0
  68. package/esm/NodeAside.d.ts.map +1 -0
  69. package/esm/NodeAside.js +16 -0
  70. package/esm/NodeBlockquote.d.ts +13 -0
  71. package/esm/NodeBlockquote.d.ts.map +1 -0
  72. package/esm/NodeBlockquote.js +34 -0
  73. package/esm/NodeBookmark.d.ts +8 -0
  74. package/esm/NodeBookmark.d.ts.map +1 -0
  75. package/esm/NodeBookmark.js +19 -0
  76. package/esm/NodeBulletList.d.ts +13 -0
  77. package/esm/NodeBulletList.d.ts.map +1 -0
  78. package/esm/NodeBulletList.js +34 -0
  79. package/esm/NodeCodeBlock.d.ts +9 -0
  80. package/esm/NodeCodeBlock.d.ts.map +1 -0
  81. package/esm/NodeCodeBlock.js +50 -0
  82. package/esm/NodeDefinitionDesc.d.ts +8 -0
  83. package/esm/NodeDefinitionDesc.d.ts.map +1 -0
  84. package/esm/NodeDefinitionDesc.js +16 -0
  85. package/esm/NodeDefinitionList.d.ts +13 -0
  86. package/esm/NodeDefinitionList.d.ts.map +1 -0
  87. package/esm/NodeDefinitionList.js +28 -0
  88. package/esm/NodeDefinitionTerm.d.ts +8 -0
  89. package/esm/NodeDefinitionTerm.d.ts.map +1 -0
  90. package/esm/NodeDefinitionTerm.js +16 -0
  91. package/esm/NodeDocument.d.ts +7 -0
  92. package/esm/NodeDocument.d.ts.map +1 -0
  93. package/esm/NodeDocument.js +19 -0
  94. package/esm/NodeDocumentCode.d.ts +7 -0
  95. package/esm/NodeDocumentCode.d.ts.map +1 -0
  96. package/esm/NodeDocumentCode.js +29 -0
  97. package/esm/NodeFrontmatter.d.ts +8 -0
  98. package/esm/NodeFrontmatter.d.ts.map +1 -0
  99. package/esm/NodeFrontmatter.js +16 -0
  100. package/esm/NodeHardBreak.d.ts +14 -0
  101. package/esm/NodeHardBreak.d.ts.map +1 -0
  102. package/esm/NodeHardBreak.js +67 -0
  103. package/esm/NodeHeading.d.ts +13 -0
  104. package/esm/NodeHeading.d.ts.map +1 -0
  105. package/esm/NodeHeading.js +49 -0
  106. package/esm/NodeHorizontalRule.d.ts +11 -0
  107. package/esm/NodeHorizontalRule.d.ts.map +1 -0
  108. package/esm/NodeHorizontalRule.js +29 -0
  109. package/esm/NodeImage.d.ts +8 -0
  110. package/esm/NodeImage.d.ts.map +1 -0
  111. package/esm/NodeImage.js +33 -0
  112. package/esm/NodeInlineShortCode.d.ts +11 -0
  113. package/esm/NodeInlineShortCode.d.ts.map +1 -0
  114. package/esm/NodeInlineShortCode.js +39 -0
  115. package/esm/NodeListItem.d.ts +14 -0
  116. package/esm/NodeListItem.d.ts.map +1 -0
  117. package/esm/NodeListItem.js +201 -0
  118. package/esm/NodeMath.d.ts +8 -0
  119. package/esm/NodeMath.d.ts.map +1 -0
  120. package/esm/NodeMath.js +99 -0
  121. package/esm/NodeOrderedList.d.ts +23 -0
  122. package/esm/NodeOrderedList.d.ts.map +1 -0
  123. package/esm/NodeOrderedList.js +52 -0
  124. package/esm/NodeParagraph.d.ts +11 -0
  125. package/esm/NodeParagraph.d.ts.map +1 -0
  126. package/esm/NodeParagraph.js +44 -0
  127. package/esm/NodeTaskItem.d.ts +24 -0
  128. package/esm/NodeTaskItem.d.ts.map +1 -0
  129. package/esm/NodeTaskItem.js +146 -0
  130. package/esm/NodeTaskList.d.ts +11 -0
  131. package/esm/NodeTaskList.d.ts.map +1 -0
  132. package/esm/NodeTaskList.js +25 -0
  133. package/esm/NodeText.d.ts +7 -0
  134. package/esm/NodeText.d.ts.map +1 -0
  135. package/esm/NodeText.js +9 -0
  136. package/esm/NodeVideo.d.ts +8 -0
  137. package/esm/NodeVideo.d.ts.map +1 -0
  138. package/esm/NodeVideo.js +45 -0
  139. package/esm/package.json +3 -0
  140. package/esm/remote-selection/ExtensionRemoteSelection.d.ts +24 -0
  141. package/esm/remote-selection/ExtensionRemoteSelection.d.ts.map +1 -0
  142. package/esm/remote-selection/ExtensionRemoteSelection.js +22 -0
  143. package/esm/remote-selection/remoteSelectionPlugin.d.ts +25 -0
  144. package/esm/remote-selection/remoteSelectionPlugin.d.ts.map +1 -0
  145. package/esm/remote-selection/remoteSelectionPlugin.js +96 -0
  146. package/package.json +2 -3
@@ -0,0 +1,229 @@
1
+ import { Fragment, Slice, } from 'prosemirror-model';
2
+ import { AllSelection, TextSelection, } from 'prosemirror-state';
3
+ import { Extension } from '@kerebron/editor';
4
+ import { createNodeFromObject } from '@kerebron/editor/utilities';
5
+ function normalizeSiblings(fragment, $context) {
6
+ if (fragment.childCount < 2)
7
+ return fragment;
8
+ for (let d = $context.depth; d >= 0; d--) {
9
+ let parent = $context.node(d);
10
+ let match = parent.contentMatchAt($context.index(d));
11
+ let lastWrap;
12
+ let result = [];
13
+ fragment.forEach((node) => {
14
+ if (!result)
15
+ return;
16
+ let wrap = match.findWrapping(node.type);
17
+ let inLast;
18
+ if (!wrap)
19
+ return result = null;
20
+ if (inLast = result.length && lastWrap.length &&
21
+ addToSibling(wrap, lastWrap, node, result[result.length - 1], 0)) {
22
+ result[result.length - 1] = inLast;
23
+ }
24
+ else {
25
+ if (result.length) {
26
+ result[result.length - 1] = closeRight(result[result.length - 1], lastWrap.length);
27
+ }
28
+ let wrapped = withWrappers(node, wrap);
29
+ result.push(wrapped);
30
+ match = match.matchType(wrapped.type);
31
+ lastWrap = wrap;
32
+ }
33
+ });
34
+ if (result)
35
+ return Fragment.from(result);
36
+ }
37
+ return fragment;
38
+ }
39
+ function withWrappers(node, wrap, from = 0) {
40
+ for (let i = wrap.length - 1; i >= from; i--) {
41
+ node = wrap[i].create(null, Fragment.from(node));
42
+ }
43
+ return node;
44
+ }
45
+ function addToSibling(wrap, lastWrap, node, sibling, depth) {
46
+ if (depth < wrap.length && depth < lastWrap.length &&
47
+ wrap[depth] == lastWrap[depth]) {
48
+ let inner = addToSibling(wrap, lastWrap, node, sibling.lastChild, depth + 1);
49
+ if (inner) {
50
+ return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner));
51
+ }
52
+ let match = sibling.contentMatchAt(sibling.childCount);
53
+ if (match.matchType(depth == wrap.length - 1 ? node.type : wrap[depth + 1])) {
54
+ return sibling.copy(sibling.content.append(Fragment.from(withWrappers(node, wrap, depth + 1))));
55
+ }
56
+ }
57
+ }
58
+ function closeRight(node, depth) {
59
+ if (depth == 0)
60
+ return node;
61
+ let fragment = node.content.replaceChild(node.childCount - 1, closeRight(node.lastChild, depth - 1));
62
+ let fill = node.contentMatchAt(node.childCount).fillBefore(Fragment.empty, true);
63
+ return node.copy(fragment.append(fill));
64
+ }
65
+ function closeRange(fragment, side, from, to, depth, openEnd) {
66
+ let node = side < 0 ? fragment.firstChild : fragment.lastChild, inner = node.content;
67
+ if (fragment.childCount > 1)
68
+ openEnd = 0;
69
+ if (depth < to - 1) {
70
+ inner = closeRange(inner, side, from, to, depth + 1, openEnd);
71
+ }
72
+ if (depth >= from) {
73
+ inner = side < 0
74
+ ? node.contentMatchAt(0).fillBefore(inner, openEnd <= depth).append(inner)
75
+ : inner.append(node.contentMatchAt(node.childCount).fillBefore(Fragment.empty, true));
76
+ }
77
+ return fragment.replaceChild(side < 0 ? 0 : fragment.childCount - 1, node.copy(inner));
78
+ }
79
+ function closeSlice(slice, openStart, openEnd) {
80
+ if (openStart < slice.openStart) {
81
+ slice = new Slice(closeRange(slice.content, -1, openStart, slice.openStart, 0, slice.openEnd), openStart, slice.openEnd);
82
+ }
83
+ if (openEnd < slice.openEnd) {
84
+ slice = new Slice(closeRange(slice.content, 1, openEnd, slice.openEnd, 0, 0), slice.openStart, openEnd);
85
+ }
86
+ return slice;
87
+ }
88
+ function sliceSingleNode(slice) {
89
+ return slice.openStart == 0 && slice.openEnd == 0 &&
90
+ slice.content.childCount == 1
91
+ ? slice.content.firstChild
92
+ : null;
93
+ }
94
+ function fixSlice(slice, $context) {
95
+ slice = Slice.maxOpen(normalizeSiblings(slice.content, $context), true);
96
+ if (slice.openStart || slice.openEnd) {
97
+ let openStart = 0, openEnd = 0;
98
+ for (let node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating; openStart++, node = node.firstChild
99
+ // deno-lint-ignore no-empty
100
+ ) { }
101
+ for (let node = slice.content.lastChild; openEnd < slice.openEnd && !node.type.spec.isolating; openEnd++, node = node.lastChild
102
+ // deno-lint-ignore no-empty
103
+ ) { }
104
+ slice = closeSlice(slice, openStart, openEnd);
105
+ }
106
+ return slice;
107
+ }
108
+ function sliceHasOnlyText(slice) {
109
+ return slice.content.content.every((node) => node.isInline);
110
+ }
111
+ const selectAll = () => {
112
+ return function (state, dispatch, view) {
113
+ const tr = state.tr.setSelection(new AllSelection(state.doc));
114
+ if (view) {
115
+ view.dispatch(tr);
116
+ }
117
+ return true;
118
+ };
119
+ };
120
+ function textPositionsToResolvedPos(textPosVec, doc, paraNum) {
121
+ const retVal = textPosVec.map((x) => -1);
122
+ let currentTextPos = 0;
123
+ let inParaRange = false;
124
+ function callback(currentPos, level, idx, textLen) {
125
+ if (!inParaRange) {
126
+ return;
127
+ }
128
+ for (let i = 0; i < textPosVec.length; i++) {
129
+ const val = textPosVec[i];
130
+ if (val >= currentTextPos && val < currentTextPos + textLen) {
131
+ retVal[i] = currentPos + (val - currentTextPos);
132
+ }
133
+ }
134
+ currentTextPos += textLen;
135
+ }
136
+ function treeTraverse(node, level = 0, idx = 0, currentPos = 0) {
137
+ if (level === 1 && idx === paraNum) {
138
+ inParaRange = true;
139
+ }
140
+ let textLen = 0;
141
+ if (node.isText && node.text) {
142
+ textLen = node.text?.length;
143
+ }
144
+ else if (node.isLeaf) {
145
+ textLen = 1;
146
+ }
147
+ if (textLen > 0) {
148
+ callback(currentPos, level, idx, textLen);
149
+ }
150
+ node.forEach((child, offset, childIndex) => {
151
+ treeTraverse(child, level + 1, childIndex, currentPos + offset + 1);
152
+ });
153
+ }
154
+ treeTraverse(doc);
155
+ if (inParaRange) {
156
+ for (let i = 0; i < textPosVec.length; i++) {
157
+ const val = textPosVec[i];
158
+ if (retVal[i] === -1) {
159
+ if (val < currentTextPos) {
160
+ retVal[i] = 1;
161
+ }
162
+ else {
163
+ retVal[i] = doc.nodeSize - 1;
164
+ }
165
+ }
166
+ }
167
+ }
168
+ return retVal.map((x) => doc.resolve(x - 1));
169
+ }
170
+ const selectText = (textStart, length, paraNum = 0) => {
171
+ return function (state, dispatch, view) {
172
+ const [$head, $anchor] = textPositionsToResolvedPos([textStart + length, textStart], state.doc, paraNum);
173
+ const tr = state.tr.setSelection(new TextSelection($anchor, $head));
174
+ if (view) {
175
+ view.dispatch(tr);
176
+ }
177
+ return true;
178
+ };
179
+ };
180
+ export class ExtensionSelection extends Extension {
181
+ name = 'selection';
182
+ extractSelection() {
183
+ const state = this.editor.state;
184
+ const { from, to } = state.selection;
185
+ const slice = state.doc.slice(from, to);
186
+ if (sliceHasOnlyText(slice)) {
187
+ const para = state.schema.nodes.paragraph.create(null, slice.content);
188
+ return state.schema.topNodeType.createAndFill(null, [para]);
189
+ }
190
+ return state.schema.topNodeType.createAndFill(null, slice.content);
191
+ }
192
+ replaceSelection(otherDoc) {
193
+ const preferPlain = false;
194
+ const view = this.editor.view;
195
+ const state = this.editor.state;
196
+ let slice;
197
+ if (otherDoc.type?.name === 'doc') {
198
+ otherDoc = createNodeFromObject(otherDoc.toJSON(), this.editor.schema);
199
+ }
200
+ slice = new Slice(otherDoc.content, 1, 1);
201
+ const $context = state.selection.$from;
202
+ slice = fixSlice(slice, $context);
203
+ let singleNode = sliceSingleNode(slice);
204
+ let tr = singleNode
205
+ ? state.tr.replaceSelectionWith(singleNode, preferPlain)
206
+ : state.tr.replaceSelection(slice);
207
+ view.dispatch(tr.scrollIntoView());
208
+ }
209
+ appendSelection(otherDoc) {
210
+ const view = this.editor.view;
211
+ const { state } = view;
212
+ let slice;
213
+ if (otherDoc.type?.name === 'doc') {
214
+ otherDoc = createNodeFromObject(otherDoc.toJSON(), this.editor.schema);
215
+ }
216
+ slice = new Slice(otherDoc.content, 1, 1);
217
+ const $context = view.state.selection.$from;
218
+ slice = fixSlice(slice, $context);
219
+ const tr = state.tr.insert(view.state.selection.to, slice.content);
220
+ view.dispatch(tr.scrollIntoView());
221
+ }
222
+ getCommandFactories(editor) {
223
+ this.editor = editor;
224
+ return {
225
+ 'selectAll': () => selectAll(),
226
+ 'selectText': (...args) => selectText(...args),
227
+ };
228
+ }
229
+ }
@@ -0,0 +1,11 @@
1
+ import { type CoreEditor, Extension } from '@kerebron/editor';
2
+ import { type CommandFactories } from '@kerebron/editor/commands';
3
+ /**
4
+ * Extension that adds text alignment commands.
5
+ * Works by setting a 'textAlign' attribute on block nodes that support it.
6
+ */
7
+ export declare class ExtensionTextAlign extends Extension {
8
+ name: string;
9
+ getCommandFactories(editor: CoreEditor): Partial<CommandFactories>;
10
+ }
11
+ //# sourceMappingURL=ExtensionTextAlign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionTextAlign.d.ts","sourceRoot":"","sources":["../src/ExtensionTextAlign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAIlE;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,IAAI,SAAe;IAEV,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAoC5E"}
@@ -0,0 +1,39 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ /**
3
+ * Extension that adds text alignment commands.
4
+ * Works by setting a 'textAlign' attribute on block nodes that support it.
5
+ */
6
+ export class ExtensionTextAlign extends Extension {
7
+ name = 'textAlign';
8
+ getCommandFactories(editor) {
9
+ const setAlignment = (align) => {
10
+ return (state, dispatch) => {
11
+ const { selection, tr } = state;
12
+ const { from, to } = selection;
13
+ let changed = false;
14
+ state.doc.nodesBetween(from, to, (node, pos) => {
15
+ // Check if this node type has a textAlign attribute
16
+ if (node.isBlock &&
17
+ node.type.spec.attrs &&
18
+ 'textAlign' in node.type.spec.attrs) {
19
+ tr.setNodeMarkup(pos, undefined, {
20
+ ...node.attrs,
21
+ textAlign: align,
22
+ });
23
+ changed = true;
24
+ }
25
+ });
26
+ if (changed && dispatch) {
27
+ dispatch(tr);
28
+ }
29
+ return changed;
30
+ };
31
+ };
32
+ return {
33
+ setTextAlignLeft: () => setAlignment('left'),
34
+ setTextAlignCenter: () => setAlignment('center'),
35
+ setTextAlignRight: () => setAlignment('right'),
36
+ setTextAlignJustify: () => setAlignment('justify'),
37
+ };
38
+ }
39
+ }
@@ -0,0 +1,8 @@
1
+ import { MarkSpec } from 'prosemirror-model';
2
+ import { Mark } from '@kerebron/editor';
3
+ export declare class MarkBookmark extends Mark {
4
+ name: string;
5
+ requires: string[];
6
+ getMarkSpec(): MarkSpec;
7
+ }
8
+ //# sourceMappingURL=MarkBookmark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkBookmark.d.ts","sourceRoot":"","sources":["../src/MarkBookmark.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,qBAAa,YAAa,SAAQ,IAAI;IAC3B,IAAI,SAAc;IAC3B,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;CAWjC"}
@@ -0,0 +1,16 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkBookmark extends Mark {
3
+ name = 'bookmark';
4
+ requires = ['doc'];
5
+ getMarkSpec() {
6
+ return {
7
+ attrs: {
8
+ id: {},
9
+ },
10
+ parseDOM: [],
11
+ toDOM(mark) {
12
+ return ['a', { id: mark.attrs.id }, 0];
13
+ },
14
+ };
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ import { MarkSpec } from 'prosemirror-model';
2
+ import { Mark } from '@kerebron/editor';
3
+ export declare class MarkChange extends Mark {
4
+ name: string;
5
+ requires: string[];
6
+ getMarkSpec(): MarkSpec;
7
+ }
8
+ //# sourceMappingURL=MarkChange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkChange.d.ts","sourceRoot":"","sources":["../src/MarkChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAY;IACzB,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;CAQjC"}
@@ -0,0 +1,13 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkChange extends Mark {
3
+ name = 'change';
4
+ requires = ['doc'];
5
+ getMarkSpec() {
6
+ return {
7
+ parseDOM: [],
8
+ toDOM() {
9
+ return ['change', 0];
10
+ },
11
+ };
12
+ }
13
+ }
@@ -0,0 +1,11 @@
1
+ import type { MarkSpec, MarkType } from 'prosemirror-model';
2
+ import { type CoreEditor, Mark } from '@kerebron/editor';
3
+ import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
4
+ export declare class MarkCode extends Mark {
5
+ name: string;
6
+ requires: string[];
7
+ getMarkSpec(): MarkSpec;
8
+ getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
9
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
10
+ }
11
+ //# sourceMappingURL=MarkCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkCode.d.ts","sourceRoot":"","sources":["../src/MarkCode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,QAAS,SAAQ,IAAI;IACvB,IAAI,SAAU;IACvB,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;IASvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAK3D"}
@@ -0,0 +1,23 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkCode extends Mark {
3
+ name = 'code';
4
+ requires = ['doc'];
5
+ getMarkSpec() {
6
+ return {
7
+ parseDOM: [{ tag: 'code' }],
8
+ toDOM() {
9
+ return ['code', 0];
10
+ },
11
+ };
12
+ }
13
+ getCommandFactories(editor, type) {
14
+ return {
15
+ 'toggleCode': () => editor.commandFactories.toggleMark(type),
16
+ };
17
+ }
18
+ getKeyboardShortcuts() {
19
+ return {
20
+ 'Mod-`': 'toggleCode',
21
+ };
22
+ }
23
+ }
@@ -0,0 +1,8 @@
1
+ import { type MarkSpec } from 'prosemirror-model';
2
+ import { Mark } from '@kerebron/editor';
3
+ /** Mark for text highlight (background color) */
4
+ export declare class MarkHighlight extends Mark {
5
+ name: string;
6
+ getMarkSpec(): MarkSpec;
7
+ }
8
+ //# sourceMappingURL=MarkHighlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkHighlight.d.ts","sourceRoot":"","sources":["../src/MarkHighlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,iDAAiD;AACjD,qBAAa,aAAc,SAAQ,IAAI;IAC5B,IAAI,SAAe;IAEnB,WAAW,IAAI,QAAQ;CA8BjC"}
@@ -0,0 +1,35 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ /** Mark for text highlight (background color) */
3
+ export class MarkHighlight extends Mark {
4
+ name = 'highlight';
5
+ getMarkSpec() {
6
+ return {
7
+ attrs: {
8
+ color: { default: null },
9
+ },
10
+ parseDOM: [
11
+ {
12
+ tag: 'mark',
13
+ getAttrs(dom) {
14
+ const color = dom.style.backgroundColor;
15
+ return color ? { color } : { color: 'yellow' };
16
+ },
17
+ },
18
+ {
19
+ tag: 'span[style*="background-color"]',
20
+ getAttrs(dom) {
21
+ const color = dom.style.backgroundColor;
22
+ return color ? { color } : false;
23
+ },
24
+ },
25
+ ],
26
+ toDOM(mark) {
27
+ const { color } = mark.attrs;
28
+ const bgColor = color || 'yellow';
29
+ return ['mark', {
30
+ style: `background-color: ${bgColor}; color: inherit;`,
31
+ }, 0];
32
+ },
33
+ };
34
+ }
35
+ }
@@ -0,0 +1,11 @@
1
+ import { type CoreEditor, Mark } from '@kerebron/editor';
2
+ import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
3
+ import type { MarkSpec, MarkType } from 'prosemirror-model';
4
+ export declare class MarkItalic extends Mark {
5
+ name: string;
6
+ requires: string[];
7
+ getMarkSpec(): MarkSpec;
8
+ getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
9
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
10
+ }
11
+ //# 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,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAQ;IACrB,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;IAcvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAM3D"}
@@ -0,0 +1,29 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkItalic extends Mark {
3
+ name = 'em';
4
+ requires = ['doc'];
5
+ getMarkSpec() {
6
+ return {
7
+ parseDOM: [
8
+ { tag: 'i' },
9
+ { tag: 'em' },
10
+ { style: 'font-assets=italic' },
11
+ { style: 'font-assets=normal', clearMark: (m) => m.type.name == 'em' },
12
+ ],
13
+ toDOM() {
14
+ return ['em', 0];
15
+ },
16
+ };
17
+ }
18
+ getCommandFactories(editor, type) {
19
+ return {
20
+ 'toggleItalic': () => editor.commandFactories.toggleMark(type),
21
+ };
22
+ }
23
+ getKeyboardShortcuts() {
24
+ return {
25
+ 'Mod-i': 'toggleItalic',
26
+ 'Mod-I': 'toggleItalic',
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,8 @@
1
+ import { MarkSpec } from 'prosemirror-model';
2
+ import { Mark } from '@kerebron/editor';
3
+ export declare class MarkLink extends Mark {
4
+ name: string;
5
+ requires: string[];
6
+ getMarkSpec(): MarkSpec;
7
+ }
8
+ //# sourceMappingURL=MarkLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkLink.d.ts","sourceRoot":"","sources":["../src/MarkLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,qBAAa,QAAS,SAAQ,IAAI;IACvB,IAAI,SAAU;IACvB,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;CAwBjC"}
@@ -0,0 +1,29 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkLink extends Mark {
3
+ name = 'link';
4
+ requires = ['doc'];
5
+ getMarkSpec() {
6
+ return {
7
+ attrs: {
8
+ href: {},
9
+ title: { default: null },
10
+ },
11
+ inclusive: false,
12
+ parseDOM: [
13
+ {
14
+ tag: 'a[href]',
15
+ getAttrs(dom) {
16
+ return {
17
+ href: dom.getAttribute('href'),
18
+ title: dom.getAttribute('title'),
19
+ };
20
+ },
21
+ },
22
+ ],
23
+ toDOM(node) {
24
+ const { href, title } = node.attrs;
25
+ return ['a', { href, title }, 0];
26
+ },
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,11 @@
1
+ import { type CoreEditor, Mark } from '@kerebron/editor';
2
+ import type { MarkSpec, MarkType } from 'prosemirror-model';
3
+ import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
4
+ export declare class MarkStrike extends Mark {
5
+ name: string;
6
+ requires: string[];
7
+ getMarkSpec(): MarkSpec;
8
+ getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
9
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
10
+ }
11
+ //# sourceMappingURL=MarkStrike.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkStrike.d.ts","sourceRoot":"","sources":["../src/MarkStrike.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAY;IACzB,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;CAM3D"}
@@ -0,0 +1,26 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkStrike extends Mark {
3
+ name = 'strike';
4
+ requires = ['doc'];
5
+ getMarkSpec() {
6
+ return {
7
+ parseDOM: [
8
+ { tag: 'strike' },
9
+ ],
10
+ toDOM() {
11
+ return ['strike', 0];
12
+ },
13
+ };
14
+ }
15
+ getCommandFactories(editor, type) {
16
+ return {
17
+ 'toggleStrike': () => editor.commandFactories.toggleMark(type),
18
+ };
19
+ }
20
+ getKeyboardShortcuts() {
21
+ return {
22
+ 'Mod-s': 'toggleStrike',
23
+ 'Mod-S': 'toggleStrike',
24
+ };
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ import { type CoreEditor, Mark } from '@kerebron/editor';
2
+ import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
3
+ import { MarkSpec, type MarkType } from 'prosemirror-model';
4
+ export declare class MarkStrong extends Mark {
5
+ name: string;
6
+ requires: string[];
7
+ getMarkSpec(): MarkSpec;
8
+ getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
9
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
10
+ }
11
+ //# 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,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,qBAAa,UAAW,SAAQ,IAAI;IACzB,IAAI,SAAY;IACzB,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;IAyBvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAM3D"}
@@ -0,0 +1,38 @@
1
+ import { Mark } from '@kerebron/editor';
2
+ export class MarkStrong extends Mark {
3
+ name = 'strong';
4
+ requires = ['doc'];
5
+ getMarkSpec() {
6
+ return {
7
+ parseDOM: [
8
+ { tag: 'strong' },
9
+ // This works around a Google Docs misbehavior where
10
+ // pasted content will be inexplicably wrapped in `<b>`
11
+ // tags with a font-weight normal.
12
+ {
13
+ tag: 'b',
14
+ getAttrs: (node) => node.style.fontWeight != 'normal' && null,
15
+ },
16
+ { style: 'font-weight=400', clearMark: (m) => m.type.name == 'strong' },
17
+ {
18
+ style: 'font-weight',
19
+ getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null,
20
+ },
21
+ ],
22
+ toDOM() {
23
+ return ['strong', 0];
24
+ },
25
+ };
26
+ }
27
+ getCommandFactories(editor, type) {
28
+ return {
29
+ 'toggleStrong': () => editor.commandFactories.toggleMark(type),
30
+ };
31
+ }
32
+ getKeyboardShortcuts() {
33
+ return {
34
+ 'Mod-b': 'toggleStrong',
35
+ 'Mod-B': 'toggleStrong',
36
+ };
37
+ }
38
+ }
@@ -0,0 +1,11 @@
1
+ import { type CoreEditor, Mark } from '@kerebron/editor';
2
+ import type { MarkSpec, MarkType } from 'prosemirror-model';
3
+ import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
4
+ export declare class MarkSubscript extends Mark {
5
+ name: string;
6
+ requires: string[];
7
+ getMarkSpec(): MarkSpec;
8
+ getCommandFactories(editor: CoreEditor, type: MarkType): Partial<CommandFactories>;
9
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
10
+ }
11
+ //# sourceMappingURL=MarkSubscript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkSubscript.d.ts","sourceRoot":"","sources":["../src/MarkSubscript.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,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;IAgBvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAK3D"}