@kerebron/extension-basic-editor 0.5.3 → 0.5.5
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/BasicEditorKit.d.ts.map +1 -1
- package/esm/BasicEditorKit.js +5 -1
- package/esm/BasicEditorKit.js.map +1 -1
- package/esm/ExtensionBasicCodeEditor.d.ts.map +1 -1
- package/esm/ExtensionBasicCodeEditor.js +4 -2
- package/esm/ExtensionBasicCodeEditor.js.map +1 -1
- package/esm/MarkLink.d.ts.map +1 -1
- package/esm/MarkLink.js +3 -1
- package/esm/MarkLink.js.map +1 -1
- package/esm/MarkUnderline.d.ts.map +1 -1
- package/esm/MarkUnderline.js +0 -5
- package/esm/MarkUnderline.js.map +1 -1
- package/esm/NodeBookmark.d.ts.map +1 -1
- package/esm/NodeBookmark.js +5 -1
- package/esm/NodeBookmark.js.map +1 -1
- package/esm/NodeBulletList.d.ts +8 -0
- package/esm/NodeBulletList.d.ts.map +1 -1
- package/esm/NodeBulletList.js +8 -0
- package/esm/NodeBulletList.js.map +1 -1
- package/esm/NodeCodeBlock.js +1 -1
- package/esm/NodeCodeBlock.js.map +1 -1
- package/esm/NodeCommentAnchor.d.ts +15 -0
- package/esm/NodeCommentAnchor.d.ts.map +1 -0
- package/esm/NodeCommentAnchor.js +133 -0
- package/esm/NodeCommentAnchor.js.map +1 -0
- package/esm/NodeHorizontalRule.d.ts.map +1 -1
- package/esm/NodeHorizontalRule.js +2 -1
- package/esm/NodeHorizontalRule.js.map +1 -1
- package/esm/NodeImage.d.ts.map +1 -1
- package/esm/NodeImage.js +2 -0
- package/esm/NodeImage.js.map +1 -1
- package/esm/NodeInlineShortCode.d.ts +1 -3
- package/esm/NodeInlineShortCode.d.ts.map +1 -1
- package/esm/NodeInlineShortCode.js +11 -2
- package/esm/NodeInlineShortCode.js.map +1 -1
- package/esm/NodeOrderedList.d.ts +3 -0
- package/esm/NodeOrderedList.d.ts.map +1 -1
- package/esm/NodeOrderedList.js +3 -0
- package/esm/NodeOrderedList.js.map +1 -1
- package/esm/NodeParagraph.d.ts +1 -0
- package/esm/NodeParagraph.d.ts.map +1 -1
- package/esm/NodeParagraph.js +4 -4
- package/esm/NodeParagraph.js.map +1 -1
- package/esm/pairing/ExtensionPairing.d.ts +7 -0
- package/esm/pairing/ExtensionPairing.d.ts.map +1 -0
- package/esm/pairing/ExtensionPairing.js +11 -0
- package/esm/pairing/ExtensionPairing.js.map +1 -0
- package/esm/pairing/PairNodesPlugin.d.ts +3 -0
- package/esm/pairing/PairNodesPlugin.d.ts.map +1 -0
- package/esm/pairing/PairNodesPlugin.js +45 -0
- package/esm/pairing/PairNodesPlugin.js.map +1 -0
- package/esm/pairing/pairNodes.d.ts +5 -0
- package/esm/pairing/pairNodes.d.ts.map +1 -0
- package/esm/pairing/pairNodes.js +81 -0
- package/esm/pairing/pairNodes.js.map +1 -0
- package/package.json +2 -2
- package/src/BasicEditorKit.ts +5 -1
- package/src/ExtensionBasicCodeEditor.ts +4 -2
- package/src/MarkLink.ts +3 -1
- package/src/MarkUnderline.ts +0 -7
- package/src/NodeBookmark.ts +5 -1
- package/src/NodeBulletList.ts +9 -0
- package/src/NodeCodeBlock.ts +1 -1
- package/src/NodeCommentAnchor.ts +170 -0
- package/src/NodeHorizontalRule.ts +2 -1
- package/src/NodeImage.ts +2 -0
- package/src/NodeInlineShortCode.ts +17 -5
- package/src/NodeOrderedList.ts +3 -0
- package/src/NodeParagraph.ts +5 -5
- package/src/pairing/ExtensionPairing.ts +14 -0
- package/src/pairing/PairNodesPlugin.ts +56 -0
- package/src/pairing/pairNodes.ts +108 -0
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAE5E,qBAAa,aAAc,SAAQ,IAAI;IAC5B,IAAI,SAAe;IAC5B,QAAQ,WAAW;IAEV,WAAW,IAAI,QAAQ;IAgCvB,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAK3D"}
|
package/esm/NodeParagraph.js
CHANGED
|
@@ -7,7 +7,7 @@ export class NodeParagraph extends Node {
|
|
|
7
7
|
content: 'inline*',
|
|
8
8
|
group: 'block',
|
|
9
9
|
attrs: {
|
|
10
|
-
textAlign: { default:
|
|
10
|
+
textAlign: { default: undefined },
|
|
11
11
|
},
|
|
12
12
|
parseDOM: [
|
|
13
13
|
{
|
|
@@ -18,13 +18,13 @@ export class NodeParagraph extends Node {
|
|
|
18
18
|
if (style === 'center' || style === 'right' || style === 'justify') {
|
|
19
19
|
return { textAlign: style };
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return false;
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
],
|
|
25
25
|
toDOM(node) {
|
|
26
|
-
const align = node.attrs.textAlign;
|
|
27
|
-
if (
|
|
26
|
+
const align = node.attrs.textAlign || 'left';
|
|
27
|
+
if (['center', 'right', 'justify'].includes(align)) {
|
|
28
28
|
return ['p', { style: `text-align: ${align}` }, 0];
|
|
29
29
|
}
|
|
30
30
|
return ['p', 0];
|
package/esm/NodeParagraph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeParagraph.js","sourceRoot":"","sources":["../src/NodeParagraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAQzD,MAAM,OAAO,aAAc,SAAQ,IAAI;IAC5B,IAAI,GAAG,WAAW,CAAC;IAC5B,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;IAEV,WAAW;QAClB,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE;gBACL,SAAS,EAAE,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NodeParagraph.js","sourceRoot":"","sources":["../src/NodeParagraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAQzD,MAAM,OAAO,aAAc,SAAQ,IAAI;IAC5B,IAAI,GAAG,WAAW,CAAC;IAC5B,QAAQ,GAAG,CAAC,KAAK,CAAC,CAAC;IAEV,WAAW;QAClB,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,KAAK,EAAE,OAAO;YACd,KAAK,EAAE;gBACL,SAAS,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;aAClC;YACD,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,GAAG;oBACR,QAAQ,CAAC,GAAG;wBACV,MAAM,OAAO,GAAG,GAAkB,CAAC;wBACnC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;wBACtC,IACE,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS,EAC9D,CAAC;4BACD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;wBAC9B,CAAC;wBACD,OAAO,KAAK,CAAC;oBACf,CAAC;iBACF;aACF;YACD,KAAK,CAAC,IAAI;gBACR,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC;gBAC7C,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBACnD,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,eAAe,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAClB,CAAC;SACF,CAAC;IACJ,CAAC;IAEQ,mBAAmB,CAC1B,MAAkB,EAClB,IAAc;QAEd,OAAO;YACL,cAAc,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC;SACjE,CAAC;IACJ,CAAC;IAEQ,oBAAoB;QAC3B,OAAO;YACL,cAAc,EAAE,cAAc;SAC/B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionPairing.d.ts","sourceRoot":"","sources":["../../src/pairing/ExtensionPairing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,IAAI,SAAmB;IAEd,qBAAqB,IAAI,MAAM,EAAE;CAK3C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Extension } from '@kerebron/editor';
|
|
2
|
+
import { createPairingPlugin } from './PairNodesPlugin.js';
|
|
3
|
+
export class ExtensionPairing extends Extension {
|
|
4
|
+
name = 'pairing-nodes';
|
|
5
|
+
getProseMirrorPlugins() {
|
|
6
|
+
return [
|
|
7
|
+
createPairingPlugin(['shortcode_inline']),
|
|
8
|
+
];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ExtensionPairing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionPairing.js","sourceRoot":"","sources":["../../src/pairing/ExtensionPairing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,IAAI,GAAG,eAAe,CAAC;IAEd,qBAAqB;QAC5B,OAAO;YACL,mBAAmB,CAAC,CAAC,kBAAkB,CAAC,CAAC;SAC1C,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PairNodesPlugin.d.ts","sourceRoot":"","sources":["../../src/pairing/PairNodesPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,mBAAmB,CAAC;AAIxD,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,EAAE,gBAmDlD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Plugin } from 'prosemirror-state';
|
|
2
|
+
import { ReplaceAroundStep, ReplaceStep } from 'prosemirror-transform';
|
|
3
|
+
import { buildPairingTransaction } from './pairNodes.js';
|
|
4
|
+
export const createPairingPlugin = (types) => {
|
|
5
|
+
return new Plugin({
|
|
6
|
+
appendTransaction(transactions, oldState, newState) {
|
|
7
|
+
const typesToRebuild = new Set();
|
|
8
|
+
for (const tr of transactions) {
|
|
9
|
+
if (!tr.docChanged)
|
|
10
|
+
continue;
|
|
11
|
+
for (const step of tr.steps) {
|
|
12
|
+
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (step.slice) {
|
|
16
|
+
step.slice.content.descendants((node) => {
|
|
17
|
+
if (types.includes(node.type.name)) {
|
|
18
|
+
typesToRebuild.add(node.type.name);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (step.from != null && step.to != null && step.from !== step.to) {
|
|
23
|
+
oldState.doc.nodesBetween(step.from, step.to, (node) => {
|
|
24
|
+
if (types.includes(node.type.name)) {
|
|
25
|
+
typesToRebuild.add(node.type.name);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (typesToRebuild.size === types.length)
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (typesToRebuild.size === types.length)
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (typesToRebuild.size === 0)
|
|
36
|
+
return null;
|
|
37
|
+
const tr = newState.tr;
|
|
38
|
+
for (const type of typesToRebuild) {
|
|
39
|
+
buildPairingTransaction(newState, type, tr);
|
|
40
|
+
}
|
|
41
|
+
return tr;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=PairNodesPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PairNodesPlugin.js","sourceRoot":"","sources":["../../src/pairing/PairNodesPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAe,EAAE,EAAE;IACrD,OAAO,IAAI,MAAM,CAAC;QAChB,iBAAiB,CACf,YAAoC,EACpC,QAAQ,EACR,QAA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KAAK,KAAK,CAAC,MAAM;oBAAE,MAAM;YAClD,CAAC;YAED,IAAI,cAAc,CAAC,IAAI,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YAE3C,MAAM,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;YACvB,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;gBAClC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YAC9C,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
+
import { CommandFactory } from '@kerebron/editor/commands';
|
|
3
|
+
export declare function buildPairingTransaction(state: EditorState, type: string, tr: Transaction): Transaction | null;
|
|
4
|
+
export declare const pairNodes: CommandFactory;
|
|
5
|
+
//# sourceMappingURL=pairNodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairNodes.d.ts","sourceRoot":"","sources":["../../src/pairing/pairNodes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAa3D,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,sBA0EhB;AAED,eAAO,MAAM,SAAS,EAAE,cAYvB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { NESTING_CLOSING, NESTING_OPENING, NESTING_SELF_CLOSING, } from '@kerebron/editor';
|
|
2
|
+
function generateId() {
|
|
3
|
+
return String(Math.random());
|
|
4
|
+
}
|
|
5
|
+
export function buildPairingTransaction(state, type, tr) {
|
|
6
|
+
const { doc } = state;
|
|
7
|
+
const stackMap = new Map();
|
|
8
|
+
const nodes = [];
|
|
9
|
+
doc.descendants((node, pos) => {
|
|
10
|
+
if (node.type.name === type) {
|
|
11
|
+
nodes.push({ node, pos });
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
let modified = false;
|
|
15
|
+
for (const { node, pos } of nodes) {
|
|
16
|
+
const raw = node.attrs.content?.trim();
|
|
17
|
+
if (!raw)
|
|
18
|
+
continue;
|
|
19
|
+
const match = raw.match(/^[^0-9a-z\/]*(\/?)[\s]*([\w]+)/i);
|
|
20
|
+
const isClosing = match[1] === '/';
|
|
21
|
+
const name = match[2];
|
|
22
|
+
if (!isClosing) {
|
|
23
|
+
if (!stackMap.has(name)) {
|
|
24
|
+
stackMap.set(name, []);
|
|
25
|
+
}
|
|
26
|
+
stackMap.get(name).push({ node, pos });
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const stack = stackMap.get(name);
|
|
30
|
+
if (stack && stack.length > 0) {
|
|
31
|
+
const opening = stack.pop();
|
|
32
|
+
const id = generateId();
|
|
33
|
+
tr.setNodeMarkup(opening.pos, undefined, {
|
|
34
|
+
...opening.node.attrs,
|
|
35
|
+
id,
|
|
36
|
+
nesting: NESTING_OPENING,
|
|
37
|
+
error: undefined,
|
|
38
|
+
});
|
|
39
|
+
tr.setNodeMarkup(pos, undefined, {
|
|
40
|
+
...node.attrs,
|
|
41
|
+
id,
|
|
42
|
+
nesting: NESTING_CLOSING,
|
|
43
|
+
error: undefined,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
tr.setNodeMarkup(pos, undefined, {
|
|
48
|
+
...node.attrs,
|
|
49
|
+
error: 'Closing shortcode without matching opening',
|
|
50
|
+
nesting: NESTING_CLOSING,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
modified = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Any leftover openings are self-closing (no matching close)
|
|
57
|
+
for (const [, stack] of stackMap.entries()) {
|
|
58
|
+
for (const { node, pos } of stack) {
|
|
59
|
+
tr.setNodeMarkup(pos, undefined, {
|
|
60
|
+
...node.attrs,
|
|
61
|
+
nesting: NESTING_SELF_CLOSING,
|
|
62
|
+
id: undefined,
|
|
63
|
+
});
|
|
64
|
+
modified = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return modified ? tr : null;
|
|
68
|
+
}
|
|
69
|
+
export const pairNodes = (type) => {
|
|
70
|
+
return (state, dispatch) => {
|
|
71
|
+
const tr = buildPairingTransaction(state, type, state.tr);
|
|
72
|
+
if (!tr) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (dispatch) {
|
|
76
|
+
dispatch(tr);
|
|
77
|
+
}
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=pairNodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairNodes.js","sourceRoot":"","sources":["../../src/pairing/pairNodes.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,SAAS,UAAU;IACjB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAC/B,CAAC;AAID,MAAM,UAAU,uBAAuB,CACrC,KAAkB,EAClB,IAAY,EACZ,EAAe;IAEf,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;IAEtB,MAAM,QAAQ,GAAmC,IAAI,GAAG,EAAE,CAAC;IAC3D,MAAM,KAAK,GAAsB,EAAE,CAAC;IAEpC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC5B,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QAC5B,CAAC;IACH,C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.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-basic-editor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/BasicEditorKit.js",
|
|
6
6
|
"exports": {
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"assets"
|
|
127
127
|
],
|
|
128
128
|
"dependencies": {
|
|
129
|
-
"@kerebron/editor": "0.5.
|
|
129
|
+
"@kerebron/editor": "0.5.5",
|
|
130
130
|
"prosemirror-history": "1.4.1",
|
|
131
131
|
"prosemirror-model": "1.25.3",
|
|
132
132
|
"prosemirror-state": "1.4.3",
|
package/src/BasicEditorKit.ts
CHANGED
|
@@ -6,8 +6,9 @@ import { ExtensionDropcursor } from './ExtensionDropcursor.js';
|
|
|
6
6
|
import { ExtensionGapcursor } from './ExtensionGapcursor.js';
|
|
7
7
|
import { ExtensionHtml } from './ExtensionHtml.js';
|
|
8
8
|
import { ExtensionMediaUpload } from './ExtensionMediaUpload.js';
|
|
9
|
-
import { ExtensionRemoteSelection } from './remote-selection/ExtensionRemoteSelection.js';
|
|
10
9
|
import { ExtensionTextAlign } from './ExtensionTextAlign.js';
|
|
10
|
+
import { ExtensionRemoteSelection } from './remote-selection/ExtensionRemoteSelection.js';
|
|
11
|
+
import { ExtensionPairing } from './pairing/ExtensionPairing.js';
|
|
11
12
|
|
|
12
13
|
import { MarkLink } from './MarkLink.js';
|
|
13
14
|
import { MarkStrong } from './MarkStrong.js';
|
|
@@ -47,6 +48,7 @@ import { NodeTaskList } from './NodeTaskList.js';
|
|
|
47
48
|
import { NodeTaskItem } from './NodeTaskItem.js';
|
|
48
49
|
import { NodeInlineShortCode } from './NodeInlineShortCode.js';
|
|
49
50
|
import { NodeIframe } from './NodeIframe.js';
|
|
51
|
+
import { NodeCommentAnchor } from './NodeCommentAnchor.js';
|
|
50
52
|
|
|
51
53
|
export class BasicEditorKit implements EditorKit {
|
|
52
54
|
getExtensions(): AnyExtensionOrReq[] {
|
|
@@ -59,6 +61,7 @@ export class BasicEditorKit implements EditorKit {
|
|
|
59
61
|
new ExtensionRemoteSelection(),
|
|
60
62
|
new ExtensionSelection(),
|
|
61
63
|
new ExtensionTextAlign(),
|
|
64
|
+
new ExtensionPairing(),
|
|
62
65
|
new NodeDocument(),
|
|
63
66
|
new NodeText(),
|
|
64
67
|
new NodeParagraph(),
|
|
@@ -86,6 +89,7 @@ export class BasicEditorKit implements EditorKit {
|
|
|
86
89
|
new NodeMath(),
|
|
87
90
|
new NodeInlineShortCode(),
|
|
88
91
|
new NodeIframe(),
|
|
92
|
+
new NodeCommentAnchor(),
|
|
89
93
|
new MarkLink(),
|
|
90
94
|
new MarkItalic(),
|
|
91
95
|
new MarkStrong(),
|
|
@@ -6,15 +6,16 @@ import {
|
|
|
6
6
|
RawTextMapEntry,
|
|
7
7
|
RawTextResult,
|
|
8
8
|
} from '@kerebron/editor';
|
|
9
|
-
import { NodeDocumentCode } from './NodeDocumentCode.js';
|
|
10
9
|
|
|
11
10
|
import { ExtensionSelection } from './ExtensionSelection.js';
|
|
12
11
|
import { ExtensionBaseKeymap } from './ExtensionBaseKeymap.js';
|
|
13
12
|
import { ExtensionDropcursor } from './ExtensionDropcursor.js';
|
|
14
13
|
import { ExtensionGapcursor } from './ExtensionGapcursor.js';
|
|
15
14
|
import { ExtensionHtml } from './ExtensionHtml.js';
|
|
16
|
-
import { NodeText } from './NodeText.js';
|
|
17
15
|
import { ExtensionRemoteSelection } from './remote-selection/ExtensionRemoteSelection.js';
|
|
16
|
+
import { NodeText } from './NodeText.js';
|
|
17
|
+
import { NodeDocumentCode } from './NodeDocumentCode.js';
|
|
18
|
+
import { NodeCodeBlock } from './NodeCodeBlock.js';
|
|
18
19
|
|
|
19
20
|
export class ExtensionBasicCodeEditor extends Extension {
|
|
20
21
|
name = 'basic-code-editor';
|
|
@@ -31,6 +32,7 @@ export class ExtensionBasicCodeEditor extends Extension {
|
|
|
31
32
|
new ExtensionRemoteSelection(),
|
|
32
33
|
new ExtensionSelection(),
|
|
33
34
|
new NodeDocumentCode({ lang }),
|
|
35
|
+
new NodeCodeBlock(),
|
|
34
36
|
new NodeText(),
|
|
35
37
|
];
|
|
36
38
|
}
|
package/src/MarkLink.ts
CHANGED
package/src/MarkUnderline.ts
CHANGED
|
@@ -15,13 +15,6 @@ export class MarkUnderline extends Mark {
|
|
|
15
15
|
{
|
|
16
16
|
tag: 'u',
|
|
17
17
|
},
|
|
18
|
-
{
|
|
19
|
-
style: 'text-decoration',
|
|
20
|
-
consuming: false,
|
|
21
|
-
getAttrs: (
|
|
22
|
-
style,
|
|
23
|
-
) => ((style as string).includes('underline') ? {} : false),
|
|
24
|
-
},
|
|
25
18
|
],
|
|
26
19
|
toDOM() {
|
|
27
20
|
return ['u', 0];
|
package/src/NodeBookmark.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeSpec } from 'prosemirror-model';
|
|
2
2
|
|
|
3
|
-
import { Node } from '@kerebron/editor';
|
|
3
|
+
import { NESTING_SELF_CLOSING, Node } from '@kerebron/editor';
|
|
4
4
|
|
|
5
5
|
export class NodeBookmark extends Node {
|
|
6
6
|
override name = 'node_bookmark';
|
|
@@ -11,8 +11,12 @@ export class NodeBookmark extends Node {
|
|
|
11
11
|
inline: true,
|
|
12
12
|
group: 'inline',
|
|
13
13
|
selectable: false,
|
|
14
|
+
atom: true,
|
|
14
15
|
attrs: {
|
|
15
16
|
id: {},
|
|
17
|
+
nesting: {
|
|
18
|
+
default: NESTING_SELF_CLOSING,
|
|
19
|
+
},
|
|
16
20
|
},
|
|
17
21
|
parseDOM: [],
|
|
18
22
|
toDOM(mark) {
|
package/src/NodeBulletList.ts
CHANGED
|
@@ -14,6 +14,15 @@ export class NodeBulletList extends Node {
|
|
|
14
14
|
override name = 'bullet_list';
|
|
15
15
|
requires = ['doc'];
|
|
16
16
|
|
|
17
|
+
override attributes = {
|
|
18
|
+
toc: {
|
|
19
|
+
default: undefined,
|
|
20
|
+
},
|
|
21
|
+
odtMarginLeft: {
|
|
22
|
+
default: undefined,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
17
26
|
override getNodeSpec(): NodeSpec {
|
|
18
27
|
return {
|
|
19
28
|
content: 'list_item+',
|
package/src/NodeCodeBlock.ts
CHANGED
|
@@ -17,6 +17,7 @@ export class NodeCodeBlock extends Node {
|
|
|
17
17
|
group: 'block',
|
|
18
18
|
code: true,
|
|
19
19
|
defining: true,
|
|
20
|
+
attrs: { lang: { default: undefined } },
|
|
20
21
|
parseDOM: [
|
|
21
22
|
{
|
|
22
23
|
tag: 'pre',
|
|
@@ -42,7 +43,6 @@ export class NodeCodeBlock extends Node {
|
|
|
42
43
|
},
|
|
43
44
|
},
|
|
44
45
|
],
|
|
45
|
-
attrs: { lang: { default: null } },
|
|
46
46
|
toDOM(node) {
|
|
47
47
|
const { lang } = node.attrs;
|
|
48
48
|
return ['pre', { lang }, ['code', 0]];
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { NodeSpec, NodeType } from 'prosemirror-model';
|
|
2
|
+
import { Node as PmNode } from 'prosemirror-model';
|
|
3
|
+
import { Plugin } from 'prosemirror-state';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
type CoreEditor,
|
|
7
|
+
NESTING_CLOSING,
|
|
8
|
+
NESTING_OPENING,
|
|
9
|
+
Node,
|
|
10
|
+
} from '@kerebron/editor';
|
|
11
|
+
import { type CommandFactories } from '@kerebron/editor/commands';
|
|
12
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
13
|
+
import { CommandFactory } from '@kerebron/editor/commands';
|
|
14
|
+
|
|
15
|
+
function collectCommentAnchors(doc: PmNode) {
|
|
16
|
+
const starts = new Map();
|
|
17
|
+
const ends = new Map();
|
|
18
|
+
|
|
19
|
+
doc.descendants((node, pos) => {
|
|
20
|
+
if (node.type.name === 'comment') {
|
|
21
|
+
if (node.attrs.nesting === NESTING_OPENING) {
|
|
22
|
+
starts.set(node.attrs.id, pos);
|
|
23
|
+
}
|
|
24
|
+
if (node.attrs.nesting === NESTING_CLOSING) {
|
|
25
|
+
ends.set(node.attrs.id, pos);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return { starts, ends };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function buildCommentRanges(doc: PmNode) {
|
|
34
|
+
const { starts, ends } = collectCommentAnchors(doc);
|
|
35
|
+
const ranges = [];
|
|
36
|
+
|
|
37
|
+
for (const [id, from] of starts) {
|
|
38
|
+
const to = ends.get(id);
|
|
39
|
+
if (!to || to <= from) continue;
|
|
40
|
+
|
|
41
|
+
ranges.push({
|
|
42
|
+
id,
|
|
43
|
+
from: from + 1, // skip start atom
|
|
44
|
+
to, // end atom position
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return ranges;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function buildDecorations(doc: PmNode) {
|
|
52
|
+
const ranges = buildCommentRanges(doc);
|
|
53
|
+
|
|
54
|
+
return DecorationSet.create(
|
|
55
|
+
doc,
|
|
56
|
+
ranges.map(({ id, from, to }) =>
|
|
57
|
+
Decoration.inline(from, to, {
|
|
58
|
+
class: 'comment-highlight',
|
|
59
|
+
'data-comment-id': id,
|
|
60
|
+
})
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function commentsPlugin(): Plugin {
|
|
66
|
+
return new Plugin({
|
|
67
|
+
state: {
|
|
68
|
+
init(_, { doc }) {
|
|
69
|
+
return buildDecorations(doc);
|
|
70
|
+
},
|
|
71
|
+
apply(tr, oldDecos, oldState, newState) {
|
|
72
|
+
if (!tr.docChanged) return oldDecos;
|
|
73
|
+
return buildDecorations(newState.doc);
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
props: {
|
|
77
|
+
decorations(state) {
|
|
78
|
+
return this.getState(state);
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const addCommentBoundary: CommandFactory = (id) => {
|
|
85
|
+
return (state, dispatch) => {
|
|
86
|
+
const { schema, selection } = state;
|
|
87
|
+
const { from, to } = selection;
|
|
88
|
+
|
|
89
|
+
const commentType = schema.nodes.comment;
|
|
90
|
+
if (!commentType) return false;
|
|
91
|
+
|
|
92
|
+
const startNode = commentType.create({ id, nesting: NESTING_OPENING });
|
|
93
|
+
const endNode = commentType.create({ id, nesting: NESTING_CLOSING });
|
|
94
|
+
|
|
95
|
+
const tr = state.tr;
|
|
96
|
+
|
|
97
|
+
tr.insert(to, endNode);
|
|
98
|
+
tr.insert(from, startNode);
|
|
99
|
+
|
|
100
|
+
// Optional: restore selection
|
|
101
|
+
// tr = tr.setSelection(
|
|
102
|
+
// TextSelection.create(tr.doc, from, to + startNode.nodeSize)
|
|
103
|
+
// );
|
|
104
|
+
|
|
105
|
+
if (dispatch) dispatch(tr);
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export class NodeCommentAnchor extends Node {
|
|
111
|
+
override name = 'comment';
|
|
112
|
+
requires = ['doc'];
|
|
113
|
+
|
|
114
|
+
options = {
|
|
115
|
+
keepMarks: true,
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
override getNodeSpec(): NodeSpec {
|
|
119
|
+
return {
|
|
120
|
+
inline: true,
|
|
121
|
+
group: 'inline',
|
|
122
|
+
selectable: false,
|
|
123
|
+
atom: true,
|
|
124
|
+
attrs: {
|
|
125
|
+
id: {},
|
|
126
|
+
active: {
|
|
127
|
+
default: false,
|
|
128
|
+
},
|
|
129
|
+
nesting: {
|
|
130
|
+
default: NESTING_OPENING,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
parseDOM: [
|
|
134
|
+
{
|
|
135
|
+
tag: 'span[data-comment-id]',
|
|
136
|
+
getAttrs(dom: HTMLElement) {
|
|
137
|
+
return {
|
|
138
|
+
id: dom.getAttribute('data-comment-id'),
|
|
139
|
+
nesting: parseInt(dom.getAttribute('data-nesting') || '1'),
|
|
140
|
+
active: dom.hasAttribute('data-active'),
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
toDOM: (
|
|
146
|
+
node,
|
|
147
|
+
) => ['span', {
|
|
148
|
+
'data-comment-id': node.attrs.id,
|
|
149
|
+
'data-active': node.attrs.active ? 'true' : undefined,
|
|
150
|
+
'data-nesting': node.attrs.nesting,
|
|
151
|
+
}],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
override getCommandFactories(
|
|
156
|
+
editor: CoreEditor,
|
|
157
|
+
type: NodeType,
|
|
158
|
+
): Partial<CommandFactories> {
|
|
159
|
+
return {
|
|
160
|
+
'addComment': (id, active) => addCommentBoundary(id, active),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
override getProseMirrorPlugins(): Plugin[] {
|
|
165
|
+
return [
|
|
166
|
+
commentsPlugin(),
|
|
167
|
+
// dropCursor(this.options),
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/NodeImage.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { Node as PmNode, NodeSpec, NodeType, Schema } from 'prosemirror-model';
|
|
2
2
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
CommandFactories,
|
|
6
|
+
CoreEditor,
|
|
7
|
+
NESTING_SELF_CLOSING,
|
|
8
|
+
Node,
|
|
9
|
+
} from '@kerebron/editor';
|
|
10
|
+
import { Command } from '@kerebron/editor/commands';
|
|
5
11
|
import {
|
|
6
12
|
type InputRule,
|
|
7
13
|
replaceInlineNode,
|
|
8
14
|
} from '@kerebron/editor/plugins/input-rules';
|
|
9
|
-
import { CoreEditor } from '@kerebron/editor';
|
|
10
|
-
import { CommandFactories } from '@kerebron/editor';
|
|
11
|
-
import { Command } from '@kerebron/editor/commands';
|
|
12
15
|
|
|
13
16
|
export function fixCharacters(text: string) {
|
|
14
17
|
return text
|
|
@@ -55,12 +58,21 @@ export class NodeInlineShortCode extends Node {
|
|
|
55
58
|
inline: true,
|
|
56
59
|
group: 'inline',
|
|
57
60
|
selectable: true,
|
|
61
|
+
atom: true,
|
|
58
62
|
attrs: {
|
|
63
|
+
id: {
|
|
64
|
+
default: undefined,
|
|
65
|
+
},
|
|
59
66
|
content: {
|
|
60
67
|
default: '',
|
|
61
68
|
},
|
|
69
|
+
nesting: {
|
|
70
|
+
default: NESTING_SELF_CLOSING,
|
|
71
|
+
},
|
|
72
|
+
error: {
|
|
73
|
+
default: '',
|
|
74
|
+
},
|
|
62
75
|
},
|
|
63
|
-
atom: true,
|
|
64
76
|
parseDOM: [{
|
|
65
77
|
tag: 'span.kb-shortcode-inline',
|
|
66
78
|
getAttrs: (dom) => ({ content: dom.textContent || null }),
|