@kerebron/extension-basic-editor 0.9.2 → 0.9.3
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.
- package/esm/ExtensionSelection.d.ts +14 -0
- package/esm/ExtensionSelection.js.map +1 -1
- package/esm/ExtensionTextAlign.d.ts +12 -0
- package/esm/ExtensionTextAlign.js.map +1 -1
- package/esm/ExtensionUser.d.ts +10 -0
- package/esm/ExtensionUser.js.map +1 -1
- package/esm/MarkCode.d.ts +6 -0
- package/esm/MarkCode.js.map +1 -1
- package/esm/MarkItalic.d.ts +6 -0
- package/esm/MarkItalic.js.map +1 -1
- package/esm/MarkStrike.d.ts +6 -0
- package/esm/MarkStrike.js.map +1 -1
- package/esm/MarkStrong.d.ts +6 -0
- package/esm/MarkStrong.js.map +1 -1
- package/esm/MarkSubscript.d.ts +6 -0
- package/esm/MarkSubscript.js.map +1 -1
- package/esm/MarkSuperscript.d.ts +6 -0
- package/esm/MarkSuperscript.js.map +1 -1
- package/esm/MarkUnderline.d.ts +6 -0
- package/esm/MarkUnderline.js.map +1 -1
- package/esm/NodeBlockquote.d.ts +6 -0
- package/esm/NodeBlockquote.js.map +1 -1
- package/esm/NodeCommentAnchor.d.ts +11 -0
- package/esm/NodeCommentAnchor.js.map +1 -1
- package/esm/NodeDefinitionList.d.ts +6 -0
- package/esm/NodeDefinitionList.js.map +1 -1
- package/esm/NodeDocument.d.ts +22 -0
- package/esm/NodeDocument.js.map +1 -1
- package/esm/NodeHardBreak.d.ts +6 -0
- package/esm/NodeHardBreak.js.map +1 -1
- package/esm/NodeHeading.d.ts +16 -0
- package/esm/NodeHeading.js.map +1 -1
- package/esm/NodeHorizontalRule.d.ts +6 -0
- package/esm/NodeHorizontalRule.js.map +1 -1
- package/esm/NodeInlineShortCode.d.ts +11 -1
- package/esm/NodeInlineShortCode.js.map +1 -1
- package/esm/NodeParagraph.d.ts +6 -0
- package/esm/NodeParagraph.js.map +1 -1
- package/esm/lists/NodeBulletList.d.ts +6 -0
- package/esm/lists/NodeBulletList.js.map +1 -1
- package/esm/lists/NodeListItem.d.ts +10 -0
- package/esm/lists/NodeListItem.js.map +1 -1
- package/esm/lists/NodeOrderedList.d.ts +6 -0
- package/esm/lists/NodeOrderedList.js.map +1 -1
- package/esm/lists/NodeTaskItem.d.ts +10 -0
- package/esm/lists/NodeTaskItem.js.map +1 -1
- package/esm/lists/NodeTaskList.d.ts +6 -0
- package/esm/lists/NodeTaskList.js.map +1 -1
- package/esm/media/ExtensionPaste.d.ts +16 -0
- package/esm/media/ExtensionPaste.js +2 -2
- package/esm/media/ExtensionPaste.js.map +1 -1
- package/package.json +14 -2
- package/src/ExtensionSelection.ts +19 -0
- package/src/ExtensionTextAlign.ts +13 -0
- package/src/ExtensionUser.ts +11 -0
- package/src/MarkCode.ts +7 -0
- package/src/MarkItalic.ts +7 -0
- package/src/MarkStrike.ts +7 -0
- package/src/MarkStrong.ts +7 -0
- package/src/MarkSubscript.ts +7 -0
- package/src/MarkSuperscript.ts +7 -0
- package/src/MarkUnderline.ts +7 -0
- package/src/NodeBlockquote.ts +7 -0
- package/src/NodeCommentAnchor.ts +12 -0
- package/src/NodeDefinitionList.ts +8 -4
- package/src/NodeDocument.ts +23 -0
- package/src/NodeHardBreak.ts +7 -0
- package/src/NodeHeading.ts +17 -0
- package/src/NodeHorizontalRule.ts +8 -0
- package/src/NodeInlineShortCode.ts +16 -0
- package/src/NodeParagraph.ts +7 -0
- package/src/lists/NodeBulletList.ts +7 -0
- package/src/lists/NodeListItem.ts +11 -0
- package/src/lists/NodeOrderedList.ts +8 -0
- package/src/lists/NodeTaskItem.ts +11 -0
- package/src/lists/NodeTaskList.ts +9 -2
- package/src/media/ExtensionPaste.ts +19 -2
|
@@ -2,6 +2,12 @@ import { NodeSpec, NodeType } from 'prosemirror-model';
|
|
|
2
2
|
import { type CoreEditor, Node } from '@kerebron/editor';
|
|
3
3
|
import { type InputRule } from '@kerebron/editor/plugins/input-rules';
|
|
4
4
|
import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
|
|
5
|
+
declare module '@kerebron/editor/commands' {
|
|
6
|
+
interface Commands<ReturnType = any> {
|
|
7
|
+
/** Toggle an ordered list around the selection. */
|
|
8
|
+
toggleOrderedList: () => ReturnType;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
5
11
|
export declare class NodeOrderedList extends Node {
|
|
6
12
|
name: string;
|
|
7
13
|
requires: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeOrderedList.js","sourceRoot":"","sources":["../../src/lists/NodeOrderedList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEL,iBAAiB,GAClB,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeOrderedList.js","sourceRoot":"","sources":["../../src/lists/NodeOrderedList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEL,iBAAiB,GAClB,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAS3C,MAAM,OAAO,eAAgB,SAAQ,IAAI;IAC9B,IAAI,GAAG,cAAc,CAAC;IAC/B,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;IAEV,UAAU,GAAG;QACpB,IAAI,EAAE;YACJ,OAAO,EAAE,GAAG;YACZ,OAAO,CAAC,OAAoB;gBAC1B,OAAO,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC;oBACjC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC;oBAC9B,CAAC,CAAC,GAAG,CAAC;YACV,CAAC;SAC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AE;gBACxB,OAAO,UAAU,CAAC,cAAc,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;YAC5D,CAAC;SACF,CAAC;IACJ,CAAC;IAEQ,oBAAoB;QAC3B,OAAO;YACL,cAAc,EAAE,mBAAmB;SACpC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -2,6 +2,16 @@ import { Node as PmNode, NodeSpec, type NodeType } from 'prosemirror-model';
|
|
|
2
2
|
import { type CoreEditor, Node } from '@kerebron/editor';
|
|
3
3
|
import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
|
|
4
4
|
import { NodeViewConstructor } from '@kerebron/editor/DummyEditorView';
|
|
5
|
+
declare module '@kerebron/editor/commands' {
|
|
6
|
+
interface Commands<ReturnType = any> {
|
|
7
|
+
/** Split the current task item at the cursor (Enter). */
|
|
8
|
+
splitListItem: () => ReturnType;
|
|
9
|
+
/** Lift the task item, decreasing nesting (Shift-Tab). */
|
|
10
|
+
liftListItem: () => ReturnType;
|
|
11
|
+
/** Increase nesting of the task item (Tab). */
|
|
12
|
+
sinkListItem: () => ReturnType;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
5
15
|
export interface TaskItemOptions {
|
|
6
16
|
onReadOnlyChecked?: (node: PmNode, checked: boolean) => boolean;
|
|
7
17
|
nested: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTaskItem.js","sourceRoot":"","sources":["../../src/lists/NodeTaskItem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeTaskItem.js","sourceRoot":"","sources":["../../src/lists/NodeTaskItem.ts"],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C,IAAI;6BAC/C;4BACD,CAAC,MAAM,CAAC;yBACT;wBACD,CAAC,KAAK,EAAE,CAAC,CAAC;qBACX;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;IAEQ,mBAAmB,CAC1B,MAAkB,EAClB,IAAc;QAEd,OAAO;YACL,eAAe,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;YAC1C,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;YACxC,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;SACzC,CAAC;IACJ,CAAC;IAEQ,WAAW,CAAC,MAAkB;QACrC,OAAO,CAAC,GAAG,IAAI,EAAE,EAAE;YACjB,OAAO,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC;IAEQ,oBAAoB;QAC3B,OAAO;YACL,OAAO,EAAE,eAAe;YACxB,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,cAAc;SAC5B,CAAC;IACJ,CAAC;IAEQ,aAAa,CAAC,IAAc;QACnC,MAAM,UAAU,GAAG,wBAAwB,CAAC;QAE5C,OAAO;YACL,iBAAiB,CACf,UAAU,EACV,IAAI,EACJ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACV,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG;aACzC,CAAC,CACH;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { NodeSpec } from 'prosemirror-model';
|
|
2
2
|
import { Node } from '@kerebron/editor';
|
|
3
3
|
import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
|
|
4
|
+
declare module '@kerebron/editor/commands' {
|
|
5
|
+
interface Commands<ReturnType = any> {
|
|
6
|
+
/** Toggle a task list around the selection. */
|
|
7
|
+
toggleTaskList: () => ReturnType;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
4
10
|
export declare class NodeTaskList extends Node {
|
|
5
11
|
name: string;
|
|
6
12
|
requires: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTaskList.js","sourceRoot":"","sources":["../../src/lists/NodeTaskList.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"NodeTaskList.js","sourceRoot":"","sources":["../../src/lists/NodeTaskList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAS3C,MAAM,OAAO,YAAa,SAAQ,IAAI;IAC3B,IAAI,GAAG,WAAW,CAAC;IAC5B,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;IAEV,WAAW;QAClB,OAAO;YACL,OAAO,EAAE,YAAY;YACrB,KAAK,EAAE,YAAY;YACnB,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,iBAAiB,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;YACnD,KAAK,EAAE,GAAG,EAAE;gBACV,OAAO,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;YAC/C,CAAC;SACF,CAAC;IACJ,CAAC;IAEQ,mBAAmB;QAC1B,OAAO;YACL,gBAAgB,EAAE,GAAG,EAAE;gBACrB,OAAO,UAAU,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAC9C,CAAC;SACF,CAAC;IACJ,CAAC;IAEQ,oBAAoB;QAC3B,OAAO;YACL,cAAc,EAAE,gBAAgB;SACjC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { Plugin, PluginKey, Transaction } from 'prosemirror-state';
|
|
2
2
|
import { CommandFactories } from '@kerebron/editor/commands';
|
|
3
3
|
import { type CoreEditor, Extension } from '@kerebron/editor';
|
|
4
|
+
declare module '@kerebron/editor/commands' {
|
|
5
|
+
interface Commands<ReturnType = any> {
|
|
6
|
+
/**
|
|
7
|
+
* Read the currently registered paste rules.
|
|
8
|
+
*
|
|
9
|
+
* @param cb Called with the active paste rules.
|
|
10
|
+
*/
|
|
11
|
+
getPasteRules: (cb: (pasteRules: PasteRule[]) => void) => ReturnType;
|
|
12
|
+
/**
|
|
13
|
+
* Replace the plugin's active paste rules.
|
|
14
|
+
*
|
|
15
|
+
* @param pasteRules The new paste rules.
|
|
16
|
+
*/
|
|
17
|
+
setPasteRules: (pasteRules: PasteRule[]) => ReturnType;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
4
20
|
type PasteRuleStep = PasteRuleStepDefault | PasteRuleStepReplaceTag | PasteRuleStepMetaSet;
|
|
5
21
|
interface PasteRuleStepDefault {
|
|
6
22
|
match: string | ((node: Node) => Node[]);
|
|
@@ -44,7 +44,7 @@ class PasteState {
|
|
|
44
44
|
const editor = this.editor;
|
|
45
45
|
let replaceDocument = false;
|
|
46
46
|
const metaOps = [];
|
|
47
|
-
const yaml = editor.
|
|
47
|
+
const yaml = editor.di.resolve('yaml');
|
|
48
48
|
for (const rule of this.pasteRules) {
|
|
49
49
|
if ('string' === typeof rule.match) {
|
|
50
50
|
const matched = getElementsByXPath(rule.match, body);
|
|
@@ -172,7 +172,7 @@ export class ExtensionPaste extends Extension {
|
|
|
172
172
|
event.preventDefault();
|
|
173
173
|
(async () => {
|
|
174
174
|
if (!(cloned.state.selection instanceof AllSelection)) {
|
|
175
|
-
cloned.
|
|
175
|
+
cloned.di.register('frontmatter', new BlankFrontmatterServiceImpl());
|
|
176
176
|
}
|
|
177
177
|
cloned.chain().keepSelection().run();
|
|
178
178
|
const md = new TextDecoder().decode(await cloned.saveDocument('text/x-markdown'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionPaste.js","sourceRoot":"","sources":["../../src/media/Extens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QAC7C,MAAM,aAAa,GAAmB,CACpC,EAAqC,EACrC,EAAE;YACF,OAAO,CAAC,KAAkB,EAAE,QAAoC,EAAE,EAAE;gBAClE,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;gBACpB,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;gBAElD,IAAI,QAAQ,EAAE,CAAC;oBACb,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACf,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,aAAa,GAAmB,CAAC,UAAuB,EAAE,EAAE;YAChE,OAAO,CAAC,KAAkB,EAAE,QAAoC,EAAE,EAAE;gBAClE,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;gBACpB,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,CAAC;gBAE1D,IAAI,QAAQ,EAAE,CAAC;oBACb,QAAQ,CAAC,EAAE,CAAC,CAAC;gBACf,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;QACJ,CAAC,CAAC;QAEF,OAAO;YACL,aAAa;YACb,aAAa;SACd,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-basic-editor",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/BasicEditorKit.js",
|
|
6
6
|
"exports": {
|
|
@@ -132,6 +132,18 @@
|
|
|
132
132
|
"import": "./esm/NodeHeading.js",
|
|
133
133
|
"default": "./esm/NodeHeading.js"
|
|
134
134
|
},
|
|
135
|
+
"./NodeDefinitionList": {
|
|
136
|
+
"import": "./esm/NodeDefinitionList.js",
|
|
137
|
+
"default": "./esm/NodeDefinitionList.js"
|
|
138
|
+
},
|
|
139
|
+
"./NodeDefinitionTerm": {
|
|
140
|
+
"import": "./esm/NodeDefinitionTerm.js",
|
|
141
|
+
"default": "./esm/NodeDefinitionTerm.js"
|
|
142
|
+
},
|
|
143
|
+
"./NodeDefinitionDesc": {
|
|
144
|
+
"import": "./esm/NodeDefinitionDesc.js",
|
|
145
|
+
"default": "./esm/NodeDefinitionDesc.js"
|
|
146
|
+
},
|
|
135
147
|
"./MarkCode": {
|
|
136
148
|
"import": "./esm/MarkCode.js",
|
|
137
149
|
"default": "./esm/MarkCode.js"
|
|
@@ -170,7 +182,7 @@
|
|
|
170
182
|
"assets"
|
|
171
183
|
],
|
|
172
184
|
"dependencies": {
|
|
173
|
-
"@kerebron/editor": "0.9.
|
|
185
|
+
"@kerebron/editor": "0.9.3",
|
|
174
186
|
"prosemirror-model": "1.25.11",
|
|
175
187
|
"prosemirror-state": "1.4.4",
|
|
176
188
|
"prosemirror-transform": "1.10.4",
|
|
@@ -20,6 +20,25 @@ import type {
|
|
|
20
20
|
import { createNodeFromObject } from '@kerebron/editor/utilities';
|
|
21
21
|
import { EditorView } from 'prosemirror-view';
|
|
22
22
|
|
|
23
|
+
declare module '@kerebron/editor/commands' {
|
|
24
|
+
interface Commands<ReturnType = any> {
|
|
25
|
+
/** Select the entire document. */
|
|
26
|
+
selectAll: () => ReturnType;
|
|
27
|
+
/**
|
|
28
|
+
* Create a text selection from character offsets within a paragraph.
|
|
29
|
+
*
|
|
30
|
+
* @param textStart Zero-based character offset inside the paragraph.
|
|
31
|
+
* @param length Length of the selection in characters.
|
|
32
|
+
* @param paraNum Index of the target paragraph.
|
|
33
|
+
*/
|
|
34
|
+
selectText: (
|
|
35
|
+
textStart: number,
|
|
36
|
+
length: number,
|
|
37
|
+
paraNum?: number,
|
|
38
|
+
) => ReturnType;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
23
42
|
function normalizeSiblings(fragment: Fragment, $context: ResolvedPos) {
|
|
24
43
|
if (fragment.childCount < 2) return fragment;
|
|
25
44
|
for (let d = $context.depth; d >= 0; d--) {
|
|
@@ -2,6 +2,19 @@ import { type CoreEditor, Extension } from '@kerebron/editor';
|
|
|
2
2
|
import { type EditorState, type Transaction } from 'prosemirror-state';
|
|
3
3
|
import { type CommandFactories } from '@kerebron/editor/commands';
|
|
4
4
|
|
|
5
|
+
declare module '@kerebron/editor/commands' {
|
|
6
|
+
interface Commands<ReturnType = any> {
|
|
7
|
+
/** Reset `textAlign` on the selected blocks (align left). */
|
|
8
|
+
setTextAlignLeft: () => ReturnType;
|
|
9
|
+
/** Center-align the selected blocks. */
|
|
10
|
+
setTextAlignCenter: () => ReturnType;
|
|
11
|
+
/** Right-align the selected blocks. */
|
|
12
|
+
setTextAlignRight: () => ReturnType;
|
|
13
|
+
/** Justify the selected blocks. */
|
|
14
|
+
setTextAlignJustify: () => ReturnType;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
type TextAlign = undefined | 'center' | 'right' | 'justify';
|
|
6
19
|
|
|
7
20
|
/**
|
package/src/ExtensionUser.ts
CHANGED
|
@@ -4,6 +4,17 @@ import { CommandFactories, Extension } from '@kerebron/editor';
|
|
|
4
4
|
import { CommandFactory } from '@kerebron/editor/commands';
|
|
5
5
|
import { ColorMapper, generateRandomUser, User } from '@kerebron/editor/user';
|
|
6
6
|
|
|
7
|
+
declare module '@kerebron/editor/commands' {
|
|
8
|
+
interface Commands<ReturnType = any> {
|
|
9
|
+
/**
|
|
10
|
+
* Change the active user.
|
|
11
|
+
*
|
|
12
|
+
* @param user The new user to associate with subsequent edits.
|
|
13
|
+
*/
|
|
14
|
+
changeUser: (user: User) => ReturnType;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
export const userPluginKey = new PluginKey<UserPluginState>('user');
|
|
8
19
|
|
|
9
20
|
interface UserPluginState {
|
package/src/MarkCode.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
type CommandShortcuts,
|
|
6
6
|
} from '@kerebron/editor/commands';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Toggle the `code` mark on the current selection. */
|
|
11
|
+
toggleCode: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export class MarkCode extends Mark {
|
|
9
16
|
override name = 'code';
|
|
10
17
|
requires = ['doc'];
|
package/src/MarkItalic.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
} from '@kerebron/editor/commands';
|
|
6
6
|
import type { MarkSpec, MarkType } from 'prosemirror-model';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Toggle the `em` (italic) mark on the current selection. */
|
|
11
|
+
toggleItalic: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export class MarkItalic extends Mark {
|
|
9
16
|
override name = 'em';
|
|
10
17
|
requires = ['doc'];
|
package/src/MarkStrike.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
type CommandShortcuts,
|
|
6
6
|
} from '@kerebron/editor/commands';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Toggle the `strike` (strikethrough) mark on the current selection. */
|
|
11
|
+
toggleStrike: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export class MarkStrike extends Mark {
|
|
9
16
|
override name = 'strike';
|
|
10
17
|
requires = ['doc'];
|
package/src/MarkStrong.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
} from '@kerebron/editor/commands';
|
|
6
6
|
import { MarkSpec, type MarkType } from 'prosemirror-model';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Toggle the `strong` (bold) mark on the current selection. */
|
|
11
|
+
toggleStrong: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export class MarkStrong extends Mark {
|
|
9
16
|
override name = 'strong';
|
|
10
17
|
requires = ['doc'];
|
package/src/MarkSubscript.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
type CommandShortcuts,
|
|
6
6
|
} from '@kerebron/editor/commands';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Toggle the `subscript` mark on current selection. */
|
|
11
|
+
toggleSubscript: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export class MarkSubscript extends Mark {
|
|
9
16
|
override name = 'subscript';
|
|
10
17
|
requires = ['doc'];
|
package/src/MarkSuperscript.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
type CommandShortcuts,
|
|
6
6
|
} from '@kerebron/editor/commands';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Toggle the `superscript` mark on current selection. */
|
|
11
|
+
toggleSuperscript: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export class MarkSuperscript extends Mark {
|
|
9
16
|
override name = 'superscript';
|
|
10
17
|
requires = ['doc'];
|
package/src/MarkUnderline.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
} from '@kerebron/editor/commands';
|
|
6
6
|
import type { MarkSpec, MarkType } from 'prosemirror-model';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Toggle the `underline` mark on the current selection. */
|
|
11
|
+
toggleUnderline: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export class MarkUnderline extends Mark {
|
|
9
16
|
override name = 'underline';
|
|
10
17
|
requires = ['doc'];
|
package/src/NodeBlockquote.ts
CHANGED
|
@@ -10,6 +10,13 @@ import {
|
|
|
10
10
|
wrappingInputRule,
|
|
11
11
|
} from '@kerebron/editor/plugins/input-rules';
|
|
12
12
|
|
|
13
|
+
declare module '@kerebron/editor/commands' {
|
|
14
|
+
interface Commands<ReturnType = any> {
|
|
15
|
+
/** Wrap the selection in a blockquote, or lift it out if already wrapped. */
|
|
16
|
+
toggleBlockquote: () => ReturnType;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
export class NodeBlockquote extends Node {
|
|
14
21
|
override name = 'blockquote';
|
|
15
22
|
requires = ['doc'];
|
package/src/NodeCommentAnchor.ts
CHANGED
|
@@ -12,6 +12,18 @@ import { type CommandFactories } from '@kerebron/editor/commands';
|
|
|
12
12
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
13
13
|
import { CommandFactory } from '@kerebron/editor/commands';
|
|
14
14
|
|
|
15
|
+
declare module '@kerebron/editor/commands' {
|
|
16
|
+
interface Commands<ReturnType = any> {
|
|
17
|
+
/**
|
|
18
|
+
* Insert opening/closing `comment` anchor nodes around the current selection.
|
|
19
|
+
*
|
|
20
|
+
* @param id Unique comment identifier.
|
|
21
|
+
* @param active Whether the comment anchor is active.
|
|
22
|
+
*/
|
|
23
|
+
addComment: (id: string, active: boolean) => ReturnType;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
function collectCommentAnchors(doc: PmNode) {
|
|
16
28
|
const starts = new Map();
|
|
17
29
|
const ends = new Map();
|
|
@@ -5,10 +5,14 @@ import {
|
|
|
5
5
|
type CommandFactories,
|
|
6
6
|
type CommandShortcuts,
|
|
7
7
|
} from '@kerebron/editor/commands';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { type InputRule } from '@kerebron/editor/plugins/input-rules';
|
|
9
|
+
|
|
10
|
+
declare module '@kerebron/editor/commands' {
|
|
11
|
+
interface Commands<ReturnType = any> {
|
|
12
|
+
/** Toggle a definition list around the selection. */
|
|
13
|
+
toggleDefinitionList: () => ReturnType;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
12
16
|
|
|
13
17
|
export class NodeDefinitionList extends Node {
|
|
14
18
|
override name = 'dl';
|
package/src/NodeDocument.ts
CHANGED
|
@@ -4,6 +4,29 @@ import { CoreEditor, Node } from '@kerebron/editor';
|
|
|
4
4
|
import { CommandFactories, CommandFactory } from '@kerebron/editor/commands';
|
|
5
5
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
6
6
|
|
|
7
|
+
declare module '@kerebron/editor/commands' {
|
|
8
|
+
interface Commands<ReturnType = any> {
|
|
9
|
+
/**
|
|
10
|
+
* Read the document's `meta` attribute.
|
|
11
|
+
*
|
|
12
|
+
* @param cb Called with a structured clone of the current `meta` value.
|
|
13
|
+
*/
|
|
14
|
+
getMeta: (cb: (meta: any) => void) => ReturnType;
|
|
15
|
+
/**
|
|
16
|
+
* Replace the document's `meta` attribute.
|
|
17
|
+
*
|
|
18
|
+
* @param meta New `meta` value.
|
|
19
|
+
*/
|
|
20
|
+
setMeta: (meta: any) => ReturnType;
|
|
21
|
+
/**
|
|
22
|
+
* Update the document's `meta` attribute in place.
|
|
23
|
+
*
|
|
24
|
+
* @param updater Receives the current `meta`, returns the new one.
|
|
25
|
+
*/
|
|
26
|
+
updateMeta: (updater: (meta: unknown) => unknown) => ReturnType;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
7
30
|
export class NodeDocument extends Node {
|
|
8
31
|
override name = 'doc';
|
|
9
32
|
|
package/src/NodeHardBreak.ts
CHANGED
|
@@ -8,6 +8,13 @@ import {
|
|
|
8
8
|
type CommandShortcuts,
|
|
9
9
|
} from '@kerebron/editor/commands';
|
|
10
10
|
|
|
11
|
+
declare module '@kerebron/editor/commands' {
|
|
12
|
+
interface Commands<ReturnType = any> {
|
|
13
|
+
/** Replace the selection with a hard break (`br`) node. */
|
|
14
|
+
setHardBreak: () => ReturnType;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export class NodeHardBreak extends Node {
|
|
12
19
|
override name = 'br';
|
|
13
20
|
requires = ['doc'];
|
package/src/NodeHeading.ts
CHANGED
|
@@ -10,6 +10,23 @@ import {
|
|
|
10
10
|
textblockTypeInputRule,
|
|
11
11
|
} from '@kerebron/editor/plugins/input-rules';
|
|
12
12
|
|
|
13
|
+
declare module '@kerebron/editor/commands' {
|
|
14
|
+
interface Commands<ReturnType = any> {
|
|
15
|
+
/** Set the textblock type to a level-1 heading. */
|
|
16
|
+
setHeading1: () => ReturnType;
|
|
17
|
+
/** Set the textblock type to a level-2 heading. */
|
|
18
|
+
setHeading2: () => ReturnType;
|
|
19
|
+
/** Set the textblock type to a level-3 heading. */
|
|
20
|
+
setHeading3: () => ReturnType;
|
|
21
|
+
/** Set the textblock type to a level-4 heading. */
|
|
22
|
+
setHeading4: () => ReturnType;
|
|
23
|
+
/** Set the textblock type to a level-5 heading. */
|
|
24
|
+
setHeading5: () => ReturnType;
|
|
25
|
+
/** Set the textblock type to a level-6 heading. */
|
|
26
|
+
setHeading6: () => ReturnType;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
13
30
|
const maxLevel = 6;
|
|
14
31
|
|
|
15
32
|
export class NodeHeading extends Node {
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import type { NodeSpec, NodeType } from 'prosemirror-model';
|
|
2
|
+
|
|
2
3
|
import { type CoreEditor, Node } from '@kerebron/editor';
|
|
3
4
|
import type {
|
|
4
5
|
CommandFactories,
|
|
5
6
|
CommandShortcuts,
|
|
6
7
|
} from '@kerebron/editor/commands';
|
|
7
8
|
|
|
9
|
+
declare module '@kerebron/editor/commands' {
|
|
10
|
+
interface Commands<ReturnType = any> {
|
|
11
|
+
/** Replace the selection with a horizontal rule (`hr`) node, scrolling into view. */
|
|
12
|
+
setHorizontalRule: () => ReturnType;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
export class NodeHorizontalRule extends Node {
|
|
9
17
|
override name = 'hr';
|
|
10
18
|
requires = ['doc'];
|
|
@@ -13,6 +13,22 @@ import {
|
|
|
13
13
|
replaceInlineNode,
|
|
14
14
|
} from '@kerebron/editor/plugins/input-rules';
|
|
15
15
|
|
|
16
|
+
declare module '@kerebron/editor/commands' {
|
|
17
|
+
interface Commands<ReturnType = any> {
|
|
18
|
+
/**
|
|
19
|
+
* Replace every `shortcode_inline` node in the document.
|
|
20
|
+
*
|
|
21
|
+
* @param createReplacementNode Builds the replacement node for each match.
|
|
22
|
+
*/
|
|
23
|
+
renderShortCode: (
|
|
24
|
+
createReplacementNode: (
|
|
25
|
+
oldNode: PmNode,
|
|
26
|
+
schema: Schema,
|
|
27
|
+
) => PmNode,
|
|
28
|
+
) => ReturnType;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
export function fixCharacters(text: string) {
|
|
17
33
|
return text
|
|
18
34
|
.replace(/’/g, "'")
|
package/src/NodeParagraph.ts
CHANGED
|
@@ -5,6 +5,13 @@ import {
|
|
|
5
5
|
type CommandShortcuts,
|
|
6
6
|
} from '@kerebron/editor/commands';
|
|
7
7
|
|
|
8
|
+
declare module '@kerebron/editor/commands' {
|
|
9
|
+
interface Commands<ReturnType = any> {
|
|
10
|
+
/** Set the textblock type to a paragraph. */
|
|
11
|
+
setParagraph: () => ReturnType;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export type TextAlign = 'left' | 'center' | 'right' | 'justify' | undefined;
|
|
9
16
|
|
|
10
17
|
export class NodeParagraph extends Node {
|
|
@@ -11,6 +11,13 @@ import {
|
|
|
11
11
|
} from '@kerebron/editor/plugins/input-rules';
|
|
12
12
|
import { toggleList } from './commands.js';
|
|
13
13
|
|
|
14
|
+
declare module '@kerebron/editor/commands' {
|
|
15
|
+
interface Commands<ReturnType = any> {
|
|
16
|
+
/** Toggle a bullet list around the selection. */
|
|
17
|
+
toggleBulletList: () => ReturnType;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
export class NodeBulletList extends Node {
|
|
15
22
|
override name = 'bullet_list';
|
|
16
23
|
requires = ['doc'];
|
|
@@ -11,6 +11,17 @@ import {
|
|
|
11
11
|
} from '@kerebron/editor/utilities';
|
|
12
12
|
import { liftListItem, sinkListItem, splitListItem } from './commands.js';
|
|
13
13
|
|
|
14
|
+
declare module '@kerebron/editor/commands' {
|
|
15
|
+
interface Commands<ReturnType = any> {
|
|
16
|
+
/** Split the current list item at the cursor (Enter). */
|
|
17
|
+
splitListItem: () => ReturnType;
|
|
18
|
+
/** Lift the list item, decreasing nesting (Shift-Tab). */
|
|
19
|
+
liftListItem: () => ReturnType;
|
|
20
|
+
/** Increase nesting of the list item (Tab). */
|
|
21
|
+
sinkListItem: () => ReturnType;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
export class NodeListItem extends Node {
|
|
15
26
|
override name = 'list_item';
|
|
16
27
|
requires = ['doc'];
|
|
@@ -14,8 +14,16 @@ import {
|
|
|
14
14
|
type CommandFactories,
|
|
15
15
|
type CommandShortcuts,
|
|
16
16
|
} from '@kerebron/editor/commands';
|
|
17
|
+
|
|
17
18
|
import { toggleList } from './commands.js';
|
|
18
19
|
|
|
20
|
+
declare module '@kerebron/editor/commands' {
|
|
21
|
+
interface Commands<ReturnType = any> {
|
|
22
|
+
/** Toggle an ordered list around the selection. */
|
|
23
|
+
toggleOrderedList: () => ReturnType;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
export class NodeOrderedList extends Node {
|
|
20
28
|
override name = 'ordered_list';
|
|
21
29
|
requires = ['doc'];
|
|
@@ -10,6 +10,17 @@ import { liftListItem, sinkListItem, splitListItem } from './commands.js';
|
|
|
10
10
|
import { NodeViewConstructor } from '@kerebron/editor/DummyEditorView';
|
|
11
11
|
import { NodeViewTaskItem } from './NodeViewTaskItem.js';
|
|
12
12
|
|
|
13
|
+
declare module '@kerebron/editor/commands' {
|
|
14
|
+
interface Commands<ReturnType = any> {
|
|
15
|
+
/** Split the current task item at the cursor (Enter). */
|
|
16
|
+
splitListItem: () => ReturnType;
|
|
17
|
+
/** Lift the task item, decreasing nesting (Shift-Tab). */
|
|
18
|
+
liftListItem: () => ReturnType;
|
|
19
|
+
/** Increase nesting of the task item (Tab). */
|
|
20
|
+
sinkListItem: () => ReturnType;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
export interface TaskItemOptions {
|
|
14
25
|
onReadOnlyChecked?: (node: PmNode, checked: boolean) => boolean;
|
|
15
26
|
nested: boolean;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import type { NodeSpec
|
|
1
|
+
import type { NodeSpec } from 'prosemirror-model';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Node } from '@kerebron/editor';
|
|
4
4
|
import {
|
|
5
5
|
type CommandFactories,
|
|
6
6
|
type CommandShortcuts,
|
|
7
7
|
} from '@kerebron/editor/commands';
|
|
8
8
|
import { toggleList } from './commands.js';
|
|
9
9
|
|
|
10
|
+
declare module '@kerebron/editor/commands' {
|
|
11
|
+
interface Commands<ReturnType = any> {
|
|
12
|
+
/** Toggle a task list around the selection. */
|
|
13
|
+
toggleTaskList: () => ReturnType;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
10
17
|
export class NodeTaskList extends Node {
|
|
11
18
|
override name = 'task_list';
|
|
12
19
|
requires = ['doc'];
|