@kerebron/extension-basic-editor 0.4.28 → 0.4.29
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/ExtensionBaseKeymap.js +1 -0
- package/esm/ExtensionBaseKeymap.js.map +1 -0
- package/esm/ExtensionBasicCodeEditor.js +1 -0
- package/esm/ExtensionBasicCodeEditor.js.map +1 -0
- package/esm/ExtensionBasicEditor.js +1 -0
- package/esm/ExtensionBasicEditor.js.map +1 -0
- package/esm/ExtensionDropcursor.js +1 -0
- package/esm/ExtensionDropcursor.js.map +1 -0
- package/esm/ExtensionGapcursor.js +1 -0
- package/esm/ExtensionGapcursor.js.map +1 -0
- package/esm/ExtensionHistory.js +1 -0
- package/esm/ExtensionHistory.js.map +1 -0
- package/esm/ExtensionHtml.js +1 -0
- package/esm/ExtensionHtml.js.map +1 -0
- package/esm/ExtensionMediaUpload.js +1 -0
- package/esm/ExtensionMediaUpload.js.map +1 -0
- package/esm/ExtensionSelection.js +1 -0
- package/esm/ExtensionSelection.js.map +1 -0
- package/esm/ExtensionTextAlign.js +1 -0
- package/esm/ExtensionTextAlign.js.map +1 -0
- package/esm/MarkBookmark.js +1 -0
- package/esm/MarkBookmark.js.map +1 -0
- package/esm/MarkChange.js +1 -0
- package/esm/MarkChange.js.map +1 -0
- package/esm/MarkCode.js +1 -0
- package/esm/MarkCode.js.map +1 -0
- package/esm/MarkHighlight.js +1 -0
- package/esm/MarkHighlight.js.map +1 -0
- package/esm/MarkItalic.js +1 -0
- package/esm/MarkItalic.js.map +1 -0
- package/esm/MarkLink.js +1 -0
- package/esm/MarkLink.js.map +1 -0
- package/esm/MarkStrike.js +1 -0
- package/esm/MarkStrike.js.map +1 -0
- package/esm/MarkStrong.js +1 -0
- package/esm/MarkStrong.js.map +1 -0
- package/esm/MarkSubscript.js +1 -0
- package/esm/MarkSubscript.js.map +1 -0
- package/esm/MarkSuperscript.js +1 -0
- package/esm/MarkSuperscript.js.map +1 -0
- package/esm/MarkTextColor.js +1 -0
- package/esm/MarkTextColor.js.map +1 -0
- package/esm/MarkUnderline.js +1 -0
- package/esm/MarkUnderline.js.map +1 -0
- package/esm/NodeAside.js +1 -0
- package/esm/NodeAside.js.map +1 -0
- package/esm/NodeBlockquote.js +1 -0
- package/esm/NodeBlockquote.js.map +1 -0
- package/esm/NodeBookmark.js +1 -0
- package/esm/NodeBookmark.js.map +1 -0
- package/esm/NodeBulletList.js +1 -0
- package/esm/NodeBulletList.js.map +1 -0
- package/esm/NodeCodeBlock.js +1 -0
- package/esm/NodeCodeBlock.js.map +1 -0
- package/esm/NodeDefinitionDesc.js +1 -0
- package/esm/NodeDefinitionDesc.js.map +1 -0
- package/esm/NodeDefinitionList.js +1 -0
- package/esm/NodeDefinitionList.js.map +1 -0
- package/esm/NodeDefinitionTerm.js +1 -0
- package/esm/NodeDefinitionTerm.js.map +1 -0
- package/esm/NodeDocument.js +1 -0
- package/esm/NodeDocument.js.map +1 -0
- package/esm/NodeDocumentCode.js +1 -0
- package/esm/NodeDocumentCode.js.map +1 -0
- package/esm/NodeFrontmatter.js +1 -0
- package/esm/NodeFrontmatter.js.map +1 -0
- package/esm/NodeHardBreak.js +1 -0
- package/esm/NodeHardBreak.js.map +1 -0
- package/esm/NodeHeading.js +1 -0
- package/esm/NodeHeading.js.map +1 -0
- package/esm/NodeHorizontalRule.js +1 -0
- package/esm/NodeHorizontalRule.js.map +1 -0
- package/esm/NodeImage.js +1 -0
- package/esm/NodeImage.js.map +1 -0
- package/esm/NodeInlineShortCode.js +1 -0
- package/esm/NodeInlineShortCode.js.map +1 -0
- package/esm/NodeListItem.js +1 -0
- package/esm/NodeListItem.js.map +1 -0
- package/esm/NodeMath.js +1 -0
- package/esm/NodeMath.js.map +1 -0
- package/esm/NodeOrderedList.js +1 -0
- package/esm/NodeOrderedList.js.map +1 -0
- package/esm/NodeParagraph.js +1 -0
- package/esm/NodeParagraph.js.map +1 -0
- package/esm/NodeTaskItem.js +1 -0
- package/esm/NodeTaskItem.js.map +1 -0
- package/esm/NodeTaskList.js +1 -0
- package/esm/NodeTaskList.js.map +1 -0
- package/esm/NodeText.js +1 -0
- package/esm/NodeText.js.map +1 -0
- package/esm/NodeVideo.js +1 -0
- package/esm/NodeVideo.js.map +1 -0
- package/esm/remote-selection/ExtensionRemoteSelection.js +1 -0
- package/esm/remote-selection/ExtensionRemoteSelection.js.map +1 -0
- package/esm/remote-selection/remoteSelectionPlugin.js +1 -0
- package/esm/remote-selection/remoteSelectionPlugin.js.map +1 -0
- package/package.json +6 -2
- package/src/ExtensionBaseKeymap.ts +64 -0
- package/src/ExtensionBasicCodeEditor.ts +82 -0
- package/src/ExtensionBasicEditor.ts +97 -0
- package/src/ExtensionDropcursor.ts +221 -0
- package/src/ExtensionGapcursor.ts +278 -0
- package/src/ExtensionHistory.ts +48 -0
- package/src/ExtensionHtml.ts +158 -0
- package/src/ExtensionMediaUpload.ts +258 -0
- package/src/ExtensionSelection.ts +379 -0
- package/src/ExtensionTextAlign.ts +50 -0
- package/src/MarkBookmark.ts +20 -0
- package/src/MarkChange.ts +17 -0
- package/src/MarkCode.ts +35 -0
- package/src/MarkHighlight.ts +38 -0
- package/src/MarkItalic.ts +41 -0
- package/src/MarkLink.ts +32 -0
- package/src/MarkStrike.ts +38 -0
- package/src/MarkStrong.ts +52 -0
- package/src/MarkSubscript.ts +42 -0
- package/src/MarkSuperscript.ts +42 -0
- package/src/MarkTextColor.ts +29 -0
- package/src/MarkUnderline.ts +47 -0
- package/src/NodeAside.ts +19 -0
- package/src/NodeBlockquote.ts +51 -0
- package/src/NodeBookmark.ts +23 -0
- package/src/NodeBulletList.ts +51 -0
- package/src/NodeCodeBlock.ts +60 -0
- package/src/NodeDefinitionDesc.ts +19 -0
- package/src/NodeDefinitionList.ts +46 -0
- package/src/NodeDefinitionTerm.ts +19 -0
- package/src/NodeDocument.ts +22 -0
- package/src/NodeDocumentCode.ts +33 -0
- package/src/NodeFrontmatter.ts +19 -0
- package/src/NodeHardBreak.ts +92 -0
- package/src/NodeHeading.ts +76 -0
- package/src/NodeHorizontalRule.ts +43 -0
- package/src/NodeImage.ts +36 -0
- package/src/NodeInlineShortCode.ts +55 -0
- package/src/NodeListItem.ts +320 -0
- package/src/NodeMath.ts +109 -0
- package/src/NodeOrderedList.ts +79 -0
- package/src/NodeParagraph.ts +60 -0
- package/src/NodeTaskItem.ts +190 -0
- package/src/NodeTaskList.ts +38 -0
- package/src/NodeText.ts +12 -0
- package/src/NodeVideo.ts +44 -0
- package/src/remote-selection/ExtensionRemoteSelection.ts +45 -0
- package/src/remote-selection/remoteSelectionPlugin.ts +157 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeTaskItem.js","sourceRoot":"","sources":["../src/NodeTaskItem.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,mBAAmB,CAAC;AAK3B;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAOnD,MAAM,OAAO,YAAa,SAAQ,IAAI;IAIE;IAH7B,IAAI,GAAG,WAAW,CAAC;IAC5B,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;IAEnB,YAAsC,SAAmC,EAAE;QACzE,KAAK,CAAC,MAAM,CAAC,CAAC;QADsB,WAAM,GAAN,MAAM,CAA+B;IAE3E,CAAC;IAEQ,WAAW;QAClB,OAAO;YACL,KAAK,EAAE;gBACL,OAAO,EAAE;oBACP,OAAO,EAAE,KAAK;iBACf;aACF;YACD,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,YAAY;YAC/D,QAAQ,EAAE,CAAC;oBACT,GAAG,EAAE,kBAAkB;oBACvB,QAA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M,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC;SACjE,CAAC;IACJ,CAAC;IAEQ,oBAAoB;QAC3B,OAAO;YACL,cAAc,EAAE,gBAAgB;SACjC,CAAC;IACJ,CAAC;CACF"}
|
package/esm/NodeText.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeText.js","sourceRoot":"","sources":["../src/NodeText.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,OAAO,QAAS,SAAQ,IAAI;IACvB,IAAI,GAAG,MAAM,CAAC;IAEd,WAAW;QAClB,OAAO;YACL,KAAK,EAAE,QAAQ;SAChB,CAAC;IACJ,CAAC;CACF"}
|
package/esm/NodeVideo.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeVideo.js","sourceRoot":"","sources":["../src/NodeVideo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,OAAO,SAAU,SAAQ,IAAI;IACxB,IAAI,GAAG,OAAO,CAAC;IACxB,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;IAEV,WAAW;QAClB,OAAO;YACL,KAAK,EAAE;gBACL,GAAG,EAAE,EAAE;gBACP,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;gBACxB,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;gBAC3B,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;gBACxB,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;aAC1B;YACD,KAAK,EAAE,OAAO;YACd,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,YAAY;oBACjB,QAAQ,CAAC,GAAgB;wBACvB,OAAO;4BACL,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC;4BAC5B,K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AQ,CAAC,KAAK,CAAC,CAAC;YAClD,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-basic-editor",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/ExtensionBasicEditor.js",
|
|
6
6
|
"exports": {
|
|
@@ -111,8 +111,12 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"scripts": {},
|
|
114
|
+
"files": [
|
|
115
|
+
"esm",
|
|
116
|
+
"src"
|
|
117
|
+
],
|
|
114
118
|
"dependencies": {
|
|
115
|
-
"@kerebron/editor": "0.4.
|
|
119
|
+
"@kerebron/editor": "0.4.29",
|
|
116
120
|
"prosemirror-history": "1.4.1",
|
|
117
121
|
"prosemirror-model": "1.25.3",
|
|
118
122
|
"prosemirror-state": "1.4.3",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Extension } from '@kerebron/editor';
|
|
2
|
+
import { type CommandShortcuts } from '@kerebron/editor/commands';
|
|
3
|
+
|
|
4
|
+
/// A basic keymap containing bindings not specific to any schema.
|
|
5
|
+
/// Binds the following keys (when multiple commands are listed, they
|
|
6
|
+
/// are chained with [`chainCommands`](#commands.chainCommands)):
|
|
7
|
+
///
|
|
8
|
+
/// * **Enter** to `newlineInCode`, `createParagraphNear`, `liftEmptyBlock`, `splitBlock`
|
|
9
|
+
/// * **Mod-Enter** to `exitCode`
|
|
10
|
+
/// * **Backspace** and **Mod-Backspace** to `deleteSelection`, `joinBackward`, `selectNodeBackward`
|
|
11
|
+
/// * **Delete** and **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`
|
|
12
|
+
/// * **Mod-Delete** to `deleteSelection`, `joinForward`, `selectNodeForward`
|
|
13
|
+
/// * **Mod-a** to `selectAll`
|
|
14
|
+
const pcBaseKeymap: { [key: string]: string } = {
|
|
15
|
+
'Mod-Enter': 'exitCode',
|
|
16
|
+
'Backspace': 'backspace',
|
|
17
|
+
'Mod-Backspace': 'backspace',
|
|
18
|
+
'Shift-Backspace': 'backspace',
|
|
19
|
+
'Delete': 'del',
|
|
20
|
+
'Mod-Delete': 'del',
|
|
21
|
+
'Mod-a': 'selectAll',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/// A copy of `pcBaseKeymap` that also binds **Ctrl-h** like Backspace,
|
|
25
|
+
/// **Ctrl-d** like Delete, **Alt-Backspace** like Ctrl-Backspace, and
|
|
26
|
+
/// **Ctrl-Alt-Backspace**, **Alt-Delete**, and **Alt-d** like
|
|
27
|
+
/// Ctrl-Delete.
|
|
28
|
+
const macBaseKeymap: { [key: string]: string } = {
|
|
29
|
+
...pcBaseKeymap,
|
|
30
|
+
'Ctrl-h': pcBaseKeymap['Backspace'],
|
|
31
|
+
'Alt-Backspace': pcBaseKeymap['Mod-Backspace'],
|
|
32
|
+
'Ctrl-d': pcBaseKeymap['Delete'],
|
|
33
|
+
'Ctrl-Alt-Backspace': pcBaseKeymap['Mod-Delete'],
|
|
34
|
+
'Alt-Delete': pcBaseKeymap['Mod-Delete'],
|
|
35
|
+
'Alt-d': pcBaseKeymap['Mod-Delete'],
|
|
36
|
+
'Ctrl-a': 'selectTextblockStart',
|
|
37
|
+
'Ctrl-e': 'selectTextblockEnd',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const mac = /(Mac|iPhone|iPod|iPad)/i.test(navigator?.platform);
|
|
41
|
+
|
|
42
|
+
const baseKeymap: { [key: string]: string } = mac
|
|
43
|
+
? macBaseKeymap
|
|
44
|
+
: pcBaseKeymap;
|
|
45
|
+
|
|
46
|
+
export class ExtensionBaseKeymap extends Extension {
|
|
47
|
+
name = 'base-keymap';
|
|
48
|
+
|
|
49
|
+
override getKeyboardShortcuts(): Partial<CommandShortcuts> {
|
|
50
|
+
const shortcuts: CommandShortcuts = {
|
|
51
|
+
'Enter': 'enter',
|
|
52
|
+
'Alt-ArrowUp': 'joinUp',
|
|
53
|
+
'Alt-ArrowDown': 'joinDown',
|
|
54
|
+
'Mod-BracketLeft': 'lift',
|
|
55
|
+
'Escape': 'selectParentNode',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
for (const key in baseKeymap) {
|
|
59
|
+
shortcuts[key] = baseKeymap[key];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return shortcuts;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AnyExtensionOrReq,
|
|
5
|
+
Extension,
|
|
6
|
+
RawTextMapEntry,
|
|
7
|
+
RawTextResult,
|
|
8
|
+
} from '@kerebron/editor';
|
|
9
|
+
import { NodeDocumentCode } from './NodeDocumentCode.js';
|
|
10
|
+
|
|
11
|
+
import { ExtensionSelection } from './ExtensionSelection.js';
|
|
12
|
+
import { ExtensionBaseKeymap } from './ExtensionBaseKeymap.js';
|
|
13
|
+
import { ExtensionDropcursor } from './ExtensionDropcursor.js';
|
|
14
|
+
import { ExtensionGapcursor } from './ExtensionGapcursor.js';
|
|
15
|
+
import { ExtensionHtml } from './ExtensionHtml.js';
|
|
16
|
+
import { NodeText } from './NodeText.js';
|
|
17
|
+
import { ExtensionRemoteSelection } from './remote-selection/ExtensionRemoteSelection.js';
|
|
18
|
+
|
|
19
|
+
export class ExtensionBasicCodeEditor extends Extension {
|
|
20
|
+
name = 'basic-code-editor';
|
|
21
|
+
requires: AnyExtensionOrReq[];
|
|
22
|
+
|
|
23
|
+
constructor({ lang }: { lang: string }) {
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
this.requires = [
|
|
27
|
+
new ExtensionBaseKeymap(),
|
|
28
|
+
new ExtensionDropcursor(),
|
|
29
|
+
new ExtensionGapcursor(),
|
|
30
|
+
new ExtensionHtml(),
|
|
31
|
+
new ExtensionRemoteSelection(),
|
|
32
|
+
new ExtensionSelection(),
|
|
33
|
+
new NodeDocumentCode({ lang }),
|
|
34
|
+
new NodeText(),
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toRawText(doc: Node): RawTextResult {
|
|
39
|
+
const topNodeType = this.editor.schema.topNodeType;
|
|
40
|
+
const spec = topNodeType.spec;
|
|
41
|
+
const singleNodeDoc = spec.content?.indexOf('*') === -1;
|
|
42
|
+
|
|
43
|
+
if (!singleNodeDoc) {
|
|
44
|
+
throw new Error('Not a single node doc');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (doc.children.length !== 1) {
|
|
48
|
+
throw new Error('Not a single node doc');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const codeBlock = doc.children[0];
|
|
52
|
+
|
|
53
|
+
const content = codeBlock.content.content
|
|
54
|
+
.map((node) => node.text)
|
|
55
|
+
.join('');
|
|
56
|
+
|
|
57
|
+
const lines = content.split('\n');
|
|
58
|
+
|
|
59
|
+
const rawTextMap: Array<RawTextMapEntry> = [];
|
|
60
|
+
|
|
61
|
+
let nodeIdx = 1;
|
|
62
|
+
let targetPos = 0;
|
|
63
|
+
let targetRow = 0;
|
|
64
|
+
for (const line of lines) {
|
|
65
|
+
rawTextMap.push({
|
|
66
|
+
nodeIdx: nodeIdx,
|
|
67
|
+
targetRow,
|
|
68
|
+
targetCol: 0,
|
|
69
|
+
targetPos,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
targetRow++;
|
|
73
|
+
targetPos += line.length + 1;
|
|
74
|
+
nodeIdx += line.length + 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
content,
|
|
79
|
+
rawTextMap,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Extension } from '@kerebron/editor';
|
|
2
|
+
import { ExtensionSelection } from './ExtensionSelection.js';
|
|
3
|
+
import { ExtensionBaseKeymap } from './ExtensionBaseKeymap.js';
|
|
4
|
+
import { ExtensionDropcursor } from './ExtensionDropcursor.js';
|
|
5
|
+
import { ExtensionGapcursor } from './ExtensionGapcursor.js';
|
|
6
|
+
import { ExtensionHtml } from './ExtensionHtml.js';
|
|
7
|
+
import { ExtensionMediaUpload } from './ExtensionMediaUpload.js';
|
|
8
|
+
import { ExtensionRemoteSelection } from './remote-selection/ExtensionRemoteSelection.js';
|
|
9
|
+
import { ExtensionTextAlign } from './ExtensionTextAlign.js';
|
|
10
|
+
|
|
11
|
+
import { MarkLink } from './MarkLink.js';
|
|
12
|
+
import { MarkStrong } from './MarkStrong.js';
|
|
13
|
+
import { MarkItalic } from './MarkItalic.js';
|
|
14
|
+
import { MarkUnderline } from './MarkUnderline.js';
|
|
15
|
+
import { MarkStrike } from './MarkStrike.js';
|
|
16
|
+
import { MarkCode } from './MarkCode.js';
|
|
17
|
+
import { MarkChange } from './MarkChange.js';
|
|
18
|
+
import { MarkBookmark } from './MarkBookmark.js';
|
|
19
|
+
import { MarkTextColor } from './MarkTextColor.js';
|
|
20
|
+
import { MarkHighlight } from './MarkHighlight.js';
|
|
21
|
+
import { MarkSuperscript } from './MarkSuperscript.js';
|
|
22
|
+
import { MarkSubscript } from './MarkSubscript.js';
|
|
23
|
+
|
|
24
|
+
import { NodeDocument } from './NodeDocument.js';
|
|
25
|
+
import { NodeText } from './NodeText.js';
|
|
26
|
+
import { NodeCodeBlock } from './NodeCodeBlock.js';
|
|
27
|
+
import { NodeBookmark } from './NodeBookmark.js';
|
|
28
|
+
import { NodeParagraph } from './NodeParagraph.js';
|
|
29
|
+
import { NodeHardBreak } from './NodeHardBreak.js';
|
|
30
|
+
import { NodeHorizontalRule } from './NodeHorizontalRule.js';
|
|
31
|
+
import { NodeOrderedList } from './NodeOrderedList.js';
|
|
32
|
+
import { NodeBulletList } from './NodeBulletList.js';
|
|
33
|
+
import { NodeListItem } from './NodeListItem.js';
|
|
34
|
+
import { NodeImage } from './NodeImage.js';
|
|
35
|
+
import { NodeVideo } from './NodeVideo.js';
|
|
36
|
+
import { NodeBlockquote } from './NodeBlockquote.js';
|
|
37
|
+
import { NodeAside } from './NodeAside.js';
|
|
38
|
+
import { NodeHeading } from './NodeHeading.js';
|
|
39
|
+
import { NodeMath } from './NodeMath.js';
|
|
40
|
+
import { NodeDefinitionList } from './NodeDefinitionList.js';
|
|
41
|
+
import { NodeDefinitionTerm } from './NodeDefinitionTerm.js';
|
|
42
|
+
import { NodeDefinitionDesc } from './NodeDefinitionDesc.js';
|
|
43
|
+
import { NodeFrontmatter } from './NodeFrontmatter.js';
|
|
44
|
+
import { NodeTaskList } from './NodeTaskList.js';
|
|
45
|
+
import { NodeTaskItem } from './NodeTaskItem.js';
|
|
46
|
+
import { NodeInlineShortCode } from './NodeInlineShortCode.js';
|
|
47
|
+
|
|
48
|
+
export class ExtensionBasicEditor extends Extension {
|
|
49
|
+
name = 'basic-editor';
|
|
50
|
+
requires = [
|
|
51
|
+
new ExtensionBaseKeymap(),
|
|
52
|
+
new ExtensionDropcursor(),
|
|
53
|
+
new ExtensionGapcursor(),
|
|
54
|
+
new ExtensionHtml(),
|
|
55
|
+
new ExtensionMediaUpload(),
|
|
56
|
+
new ExtensionRemoteSelection(),
|
|
57
|
+
new ExtensionSelection(),
|
|
58
|
+
new ExtensionTextAlign(),
|
|
59
|
+
new NodeDocument(),
|
|
60
|
+
new NodeText(),
|
|
61
|
+
new NodeParagraph(),
|
|
62
|
+
new NodeHardBreak(),
|
|
63
|
+
new NodeCodeBlock(),
|
|
64
|
+
new NodeBookmark(),
|
|
65
|
+
new NodeHorizontalRule(),
|
|
66
|
+
new NodeOrderedList(),
|
|
67
|
+
new NodeBulletList(),
|
|
68
|
+
new NodeListItem(),
|
|
69
|
+
new NodeTaskList(),
|
|
70
|
+
new NodeTaskItem(),
|
|
71
|
+
new NodeDefinitionList(),
|
|
72
|
+
new NodeDefinitionTerm(),
|
|
73
|
+
new NodeDefinitionDesc(),
|
|
74
|
+
new NodeTaskList(),
|
|
75
|
+
new NodeTaskItem(),
|
|
76
|
+
new NodeFrontmatter(),
|
|
77
|
+
new NodeImage(),
|
|
78
|
+
new NodeVideo(),
|
|
79
|
+
new NodeBlockquote(),
|
|
80
|
+
new NodeAside(),
|
|
81
|
+
new NodeHeading(),
|
|
82
|
+
new NodeMath(),
|
|
83
|
+
new NodeInlineShortCode(),
|
|
84
|
+
new MarkLink(),
|
|
85
|
+
new MarkItalic(),
|
|
86
|
+
new MarkStrong(),
|
|
87
|
+
new MarkUnderline(),
|
|
88
|
+
new MarkStrike(),
|
|
89
|
+
new MarkCode(),
|
|
90
|
+
new MarkChange(),
|
|
91
|
+
new MarkBookmark(),
|
|
92
|
+
new MarkTextColor(),
|
|
93
|
+
new MarkHighlight(),
|
|
94
|
+
new MarkSuperscript(),
|
|
95
|
+
new MarkSubscript(),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { EditorState, Plugin } from 'prosemirror-state';
|
|
2
|
+
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import { dropPoint } from 'prosemirror-transform';
|
|
4
|
+
|
|
5
|
+
import { Extension } from '@kerebron/editor';
|
|
6
|
+
|
|
7
|
+
interface DropCursorOptions {
|
|
8
|
+
/// The color of the cursor. Defaults to `black`. Use `false` to apply no color and rely only on class.
|
|
9
|
+
color?: string | false;
|
|
10
|
+
|
|
11
|
+
/// The precise width of the cursor in pixels. Defaults to 1.
|
|
12
|
+
width?: number;
|
|
13
|
+
|
|
14
|
+
/// A CSS class name to add to the cursor element.
|
|
15
|
+
class?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// Create a plugin that, when added to a ProseMirror instance,
|
|
19
|
+
/// causes a decoration to show up at the drop position when something
|
|
20
|
+
/// is dragged over the editor.
|
|
21
|
+
///
|
|
22
|
+
/// Nodes may add a `disableDropCursor` property to their spec to
|
|
23
|
+
/// control the showing of a drop cursor inside them. This may be a
|
|
24
|
+
/// boolean or a function, which will be called with a view and a
|
|
25
|
+
/// position, and should return a boolean.
|
|
26
|
+
export function dropCursor(options: DropCursorOptions = {}): Plugin {
|
|
27
|
+
return new Plugin({
|
|
28
|
+
view(editorView) {
|
|
29
|
+
return new DropCursorView(editorView, options);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class DropCursorView {
|
|
35
|
+
width: number;
|
|
36
|
+
color: string | undefined;
|
|
37
|
+
class: string | undefined;
|
|
38
|
+
cursorPos: number | null = null;
|
|
39
|
+
element: HTMLElement | null = null;
|
|
40
|
+
timeout: number = -1;
|
|
41
|
+
handlers: { name: string; handler: (event: Event) => void }[];
|
|
42
|
+
|
|
43
|
+
constructor(readonly editorView: EditorView, options: DropCursorOptions) {
|
|
44
|
+
this.width = options.width ?? 1;
|
|
45
|
+
this.color = options.color === false
|
|
46
|
+
? undefined
|
|
47
|
+
: (options.color || 'black');
|
|
48
|
+
this.class = options.class;
|
|
49
|
+
|
|
50
|
+
this.handlers = ['dragover', 'dragend', 'drop', 'dragleave'].map((name) => {
|
|
51
|
+
let handler = (e: Event) => {
|
|
52
|
+
(this as any)[name](e);
|
|
53
|
+
};
|
|
54
|
+
editorView.dom.addEventListener(name, handler);
|
|
55
|
+
return { name, handler };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
destroy() {
|
|
60
|
+
this.handlers.forEach(({ name, handler }) =>
|
|
61
|
+
this.editorView.dom.removeEventListener(name, handler)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
update(editorView: EditorView, prevState: EditorState) {
|
|
66
|
+
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
|
|
67
|
+
if (this.cursorPos > editorView.state.doc.content.size) {
|
|
68
|
+
this.setCursor(null);
|
|
69
|
+
} else this.updateOverlay();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setCursor(pos: number | null) {
|
|
74
|
+
if (pos == this.cursorPos) return;
|
|
75
|
+
this.cursorPos = pos;
|
|
76
|
+
if (pos == null) {
|
|
77
|
+
this.element!.parentNode!.removeChild(this.element!);
|
|
78
|
+
this.element = null;
|
|
79
|
+
} else {
|
|
80
|
+
this.updateOverlay();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
updateOverlay() {
|
|
85
|
+
let $pos = this.editorView.state.doc.resolve(this.cursorPos!);
|
|
86
|
+
let isBlock = !$pos.parent.inlineContent, rect;
|
|
87
|
+
let editorDOM = this.editorView.dom,
|
|
88
|
+
editorRect = editorDOM.getBoundingClientRect();
|
|
89
|
+
let scaleX = editorRect.width / editorDOM.offsetWidth,
|
|
90
|
+
scaleY = editorRect.height / editorDOM.offsetHeight;
|
|
91
|
+
if (isBlock) {
|
|
92
|
+
let before = $pos.nodeBefore, after = $pos.nodeAfter;
|
|
93
|
+
if (before || after) {
|
|
94
|
+
let node = this.editorView.nodeDOM(
|
|
95
|
+
this.cursorPos! - (before ? before.nodeSize : 0),
|
|
96
|
+
);
|
|
97
|
+
if (node) {
|
|
98
|
+
let nodeRect = (node as HTMLElement).getBoundingClientRect();
|
|
99
|
+
let top = before ? nodeRect.bottom : nodeRect.top;
|
|
100
|
+
if (before && after) {
|
|
101
|
+
top = (top +
|
|
102
|
+
(this.editorView.nodeDOM(this.cursorPos!) as HTMLElement)
|
|
103
|
+
.getBoundingClientRect().top) / 2;
|
|
104
|
+
}
|
|
105
|
+
let halfWidth = (this.width / 2) * scaleY;
|
|
106
|
+
rect = {
|
|
107
|
+
left: nodeRect.left,
|
|
108
|
+
right: nodeRect.right,
|
|
109
|
+
top: top - halfWidth,
|
|
110
|
+
bottom: top + halfWidth,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (!rect) {
|
|
116
|
+
let coords = this.editorView.coordsAtPos(this.cursorPos!);
|
|
117
|
+
let halfWidth = (this.width / 2) * scaleX;
|
|
118
|
+
rect = {
|
|
119
|
+
left: coords.left - halfWidth,
|
|
120
|
+
right: coords.left + halfWidth,
|
|
121
|
+
top: coords.top,
|
|
122
|
+
bottom: coords.bottom,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let parent = this.editorView.dom.offsetParent as HTMLElement;
|
|
127
|
+
if (!this.element) {
|
|
128
|
+
this.element = parent.appendChild(document.createElement('div'));
|
|
129
|
+
if (this.class) this.element.className = this.class;
|
|
130
|
+
this.element.style.cssText =
|
|
131
|
+
'position: absolute; z-index: 50; pointer-events: none;';
|
|
132
|
+
if (this.color) {
|
|
133
|
+
this.element.style.backgroundColor = this.color;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
this.element.classList.toggle('prosemirror-dropcursor-block', isBlock);
|
|
137
|
+
this.element.classList.toggle('prosemirror-dropcursor-inline', !isBlock);
|
|
138
|
+
let parentLeft, parentTop;
|
|
139
|
+
if (
|
|
140
|
+
!parent ||
|
|
141
|
+
parent == document.body && getComputedStyle(parent).position == 'static'
|
|
142
|
+
) {
|
|
143
|
+
parentLeft = -pageXOffset;
|
|
144
|
+
parentTop = -pageYOffset;
|
|
145
|
+
} else {
|
|
146
|
+
let rect = parent.getBoundingClientRect();
|
|
147
|
+
let parentScaleX = rect.width / parent.offsetWidth,
|
|
148
|
+
parentScaleY = rect.height / parent.offsetHeight;
|
|
149
|
+
parentLeft = rect.left - parent.scrollLeft * parentScaleX;
|
|
150
|
+
parentTop = rect.top - parent.scrollTop * parentScaleY;
|
|
151
|
+
}
|
|
152
|
+
this.element.style.left = (rect.left - parentLeft) / scaleX + 'px';
|
|
153
|
+
this.element.style.top = (rect.top - parentTop) / scaleY + 'px';
|
|
154
|
+
this.element.style.width = (rect.right - rect.left) / scaleX + 'px';
|
|
155
|
+
this.element.style.height = (rect.bottom - rect.top) / scaleY + 'px';
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
scheduleRemoval(timeout: number) {
|
|
159
|
+
clearTimeout(this.timeout);
|
|
160
|
+
this.timeout = setTimeout(() => this.setCursor(null), timeout);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
dragover(event: DragEvent) {
|
|
164
|
+
if (!this.editorView.editable) return;
|
|
165
|
+
let pos = this.editorView.posAtCoords({
|
|
166
|
+
left: event.clientX,
|
|
167
|
+
top: event.clientY,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
let node = pos && pos.inside >= 0 &&
|
|
171
|
+
this.editorView.state.doc.nodeAt(pos.inside);
|
|
172
|
+
let disableDropCursor = node && node.type.spec.disableDropCursor;
|
|
173
|
+
let disabled = typeof disableDropCursor == 'function'
|
|
174
|
+
? disableDropCursor(this.editorView, pos!, event)
|
|
175
|
+
: disableDropCursor;
|
|
176
|
+
|
|
177
|
+
if (pos && !disabled) {
|
|
178
|
+
let target = pos.pos;
|
|
179
|
+
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
180
|
+
let point = dropPoint(
|
|
181
|
+
this.editorView.state.doc,
|
|
182
|
+
target,
|
|
183
|
+
this.editorView.dragging.slice,
|
|
184
|
+
);
|
|
185
|
+
if (point != null) target = point;
|
|
186
|
+
}
|
|
187
|
+
this.setCursor(target);
|
|
188
|
+
this.scheduleRemoval(5000);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
dragend() {
|
|
193
|
+
this.scheduleRemoval(20);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
drop() {
|
|
197
|
+
this.scheduleRemoval(20);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
dragleave(event: DragEvent) {
|
|
201
|
+
if (!this.editorView.dom.contains((event as any).relatedTarget)) {
|
|
202
|
+
this.setCursor(null);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export class ExtensionDropcursor extends Extension {
|
|
208
|
+
name = 'dropcursor';
|
|
209
|
+
|
|
210
|
+
options = {
|
|
211
|
+
color: 'currentColor',
|
|
212
|
+
width: 1,
|
|
213
|
+
class: undefined,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
override getProseMirrorPlugins(): Plugin[] {
|
|
217
|
+
return [
|
|
218
|
+
dropCursor(this.options),
|
|
219
|
+
];
|
|
220
|
+
}
|
|
221
|
+
}
|