@kerebron/editor-kits 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/AdvancedEditorKit.js +1 -0
- package/esm/AdvancedEditorKit.js.map +1 -0
- package/esm/CodeEditorKit.js +1 -0
- package/esm/CodeEditorKit.js.map +1 -0
- package/esm/DevAdvancedEditorKit.js +1 -0
- package/esm/DevAdvancedEditorKit.js.map +1 -0
- package/esm/LspEditorKit.js +1 -0
- package/esm/LspEditorKit.js.map +1 -0
- package/esm/YjsEditorKit.js +1 -0
- package/esm/YjsEditorKit.js.map +1 -0
- package/esm/mod.js +1 -0
- package/esm/mod.js.map +1 -0
- package/package.json +17 -13
- package/src/AdvancedEditorKit.ts +30 -0
- package/src/CodeEditorKit.ts +27 -0
- package/src/DevAdvancedEditorKit.ts +32 -0
- package/src/LspEditorKit.ts +84 -0
- package/src/YjsEditorKit.ts +47 -0
- package/src/mod.ts +0 -0
- package/assets/AdvancedEditorKit.css +0 -4
- package/assets/CodeEditorKit.css +0 -2
- package/assets/DevAdvancedEditorKit.css +0 -6
package/esm/AdvancedEditorKit.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdvancedEditorKit.js","sourceRoot":"","sources":["../src/AdvancedEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAqB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,mBAAmB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;YAC/B,qBAAqB;YACrB,MAAM;YACN,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC;SAC/B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevAdvancedEditorKit.js","sourceRoot":"","sources":["../src/DevAdvancedEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IACxC,IAAI,GAAG,qBAAqB,CAAC;IACtC,QAAQ,CAAsB;IAE9B,YAAY,IAA2D;QACrE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,oBAAoB,EAAE;YAC1B,IAAI,iBAAiB,EAAE;YACvB,IAAI,YAAY,EAAE;YAClB,IAAI,eAAe,EAAE;YACrB,IAAI,mBAAmB,EAAE;YACzB,IAAI,mBAAmB,CAAC,IAAI,CAAC;YAC7B,4BAA4B;YAC5B,sBAAsB;YACtB,MAAM;YACN,IAAI,gBAAgB,EAAE;SACvB,CAAC;IACJ,CAAC;CACF"}
|
package/esm/LspEditorKit.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LspEditorKit.js","sourceRoot":"","sources":["../src/LspEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,EA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AkB,CAAC,MAAM,EAAE;YAC9C,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;YACpD,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,UAAU,EAAE,SAAS,CAAC,KAAK;SAC5B,CAAC,CAAC;QAEH,OAAO,IAAI,YAAY,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,YAAY,UAAuB,EAAU,IAAW;QACtD,KAAK,EAAE,CAAC;QADmC,SAAI,GAAJ,IAAI,CAAO;QAGtD,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;SAC5D,CAAC;IACJ,CAAC;CACF"}
|
package/esm/mod.js
CHANGED
package/esm/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/editor-kits",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/mod.js",
|
|
6
6
|
"exports": {
|
|
@@ -27,19 +27,23 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"scripts": {},
|
|
30
|
+
"files": [
|
|
31
|
+
"esm",
|
|
32
|
+
"src"
|
|
33
|
+
],
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@kerebron/editor": "0.4.
|
|
32
|
-
"@kerebron/extension-basic-editor": "0.4.
|
|
33
|
-
"@kerebron/extension-codejar": "0.4.
|
|
34
|
-
"@kerebron/extension-codemirror": "0.4.
|
|
35
|
-
"@kerebron/extension-dev-toolkit": "0.4.
|
|
36
|
-
"@kerebron/extension-lsp": "0.4.
|
|
37
|
-
"@kerebron/extension-markdown": "0.4.
|
|
38
|
-
"@kerebron/extension-menu": "0.4.
|
|
39
|
-
"@kerebron/extension-menu-legacy": "0.4.
|
|
40
|
-
"@kerebron/extension-odt": "0.4.
|
|
41
|
-
"@kerebron/extension-tables": "0.4.
|
|
42
|
-
"@kerebron/extension-yjs": "0.4.
|
|
35
|
+
"@kerebron/editor": "0.4.29",
|
|
36
|
+
"@kerebron/extension-basic-editor": "0.4.29",
|
|
37
|
+
"@kerebron/extension-codejar": "0.4.29",
|
|
38
|
+
"@kerebron/extension-codemirror": "0.4.29",
|
|
39
|
+
"@kerebron/extension-dev-toolkit": "0.4.29",
|
|
40
|
+
"@kerebron/extension-lsp": "0.4.29",
|
|
41
|
+
"@kerebron/extension-markdown": "0.4.29",
|
|
42
|
+
"@kerebron/extension-menu": "0.4.29",
|
|
43
|
+
"@kerebron/extension-menu-legacy": "0.4.29",
|
|
44
|
+
"@kerebron/extension-odt": "0.4.29",
|
|
45
|
+
"@kerebron/extension-tables": "0.4.29",
|
|
46
|
+
"@kerebron/extension-yjs": "0.4.29",
|
|
43
47
|
"lib0": "0.2.109",
|
|
44
48
|
"thememirror": "2.0.1",
|
|
45
49
|
"y-websocket": "3.0.0",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { dracula } from 'thememirror';
|
|
2
|
+
|
|
3
|
+
import { AnyExtensionOrReq, Extension } from '@kerebron/editor';
|
|
4
|
+
import { ExtensionBasicEditor } from '@kerebron/extension-basic-editor/ExtensionBasicEditor';
|
|
5
|
+
import { ExtensionMarkdown } from '@kerebron/extension-markdown';
|
|
6
|
+
import { ExtensionOdt } from '@kerebron/extension-odt';
|
|
7
|
+
import { ExtensionTables } from '@kerebron/extension-tables';
|
|
8
|
+
import { ExtensionDevToolkit } from '@kerebron/extension-dev-toolkit';
|
|
9
|
+
import { ExtensionCustomMenu } from '@kerebron/extension-menu';
|
|
10
|
+
import { ExtensionCodeMirror } from '@kerebron/extension-codemirror';
|
|
11
|
+
|
|
12
|
+
export class AdvancedEditorKit extends Extension {
|
|
13
|
+
override name = 'advanced-editor';
|
|
14
|
+
requires: AnyExtensionOrReq[];
|
|
15
|
+
|
|
16
|
+
constructor(menu?: ConstructorParameters<typeof ExtensionCustomMenu>[0]) {
|
|
17
|
+
super();
|
|
18
|
+
this.requires = [
|
|
19
|
+
new ExtensionBasicEditor(),
|
|
20
|
+
new ExtensionMarkdown(),
|
|
21
|
+
new ExtensionOdt(),
|
|
22
|
+
new ExtensionTables(),
|
|
23
|
+
new ExtensionDevToolkit(),
|
|
24
|
+
new ExtensionCustomMenu(menu),
|
|
25
|
+
new ExtensionCodeMirror({
|
|
26
|
+
theme: [dracula],
|
|
27
|
+
}),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { dracula } from 'thememirror';
|
|
2
|
+
|
|
3
|
+
import { AnyExtensionOrReq, Extension } from '@kerebron/editor';
|
|
4
|
+
import { ExtensionBasicCodeEditor } from '@kerebron/extension-basic-editor/ExtensionBasicCodeEditor';
|
|
5
|
+
import { ExtensionMarkdown } from '@kerebron/extension-markdown';
|
|
6
|
+
import { ExtensionDevToolkit } from '@kerebron/extension-dev-toolkit';
|
|
7
|
+
// import { ExtensionCodeMirror } from '@kerebron/extension-codemirror';
|
|
8
|
+
import { ExtensionCodeJar } from '@kerebron/extension-codejar';
|
|
9
|
+
|
|
10
|
+
export class CodeEditorKit extends Extension {
|
|
11
|
+
override name = 'dev-advanced-editor';
|
|
12
|
+
requires: AnyExtensionOrReq[];
|
|
13
|
+
|
|
14
|
+
constructor(lang: string) {
|
|
15
|
+
super();
|
|
16
|
+
this.requires = [
|
|
17
|
+
new ExtensionBasicCodeEditor({ lang }),
|
|
18
|
+
new ExtensionMarkdown(),
|
|
19
|
+
new ExtensionDevToolkit(),
|
|
20
|
+
// new ExtensionCodeMirror({
|
|
21
|
+
// languageWhitelist: [lang],
|
|
22
|
+
// readOnly: false,
|
|
23
|
+
// }),
|
|
24
|
+
new ExtensionCodeJar({ lang }),
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { dracula } from 'thememirror';
|
|
2
|
+
|
|
3
|
+
import { AnyExtensionOrReq, Extension } from '@kerebron/editor';
|
|
4
|
+
import { ExtensionBasicEditor } from '@kerebron/extension-basic-editor/ExtensionBasicEditor';
|
|
5
|
+
import { ExtensionMarkdown } from '@kerebron/extension-markdown';
|
|
6
|
+
import { ExtensionOdt } from '@kerebron/extension-odt';
|
|
7
|
+
import { ExtensionTables } from '@kerebron/extension-tables';
|
|
8
|
+
import { ExtensionDevToolkit } from '@kerebron/extension-dev-toolkit';
|
|
9
|
+
import { ExtensionMenuLegacy } from '@kerebron/extension-menu-legacy';
|
|
10
|
+
import { ExtensionCodeMirror } from '@kerebron/extension-codemirror';
|
|
11
|
+
import { ExtensionCodeJar } from '@kerebron/extension-codejar';
|
|
12
|
+
|
|
13
|
+
export class DevAdvancedEditorKit extends Extension {
|
|
14
|
+
override name = 'dev-advanced-editor';
|
|
15
|
+
requires: AnyExtensionOrReq[];
|
|
16
|
+
|
|
17
|
+
constructor(menu?: ConstructorParameters<typeof ExtensionMenuLegacy>[0]) {
|
|
18
|
+
super();
|
|
19
|
+
this.requires = [
|
|
20
|
+
new ExtensionBasicEditor(),
|
|
21
|
+
new ExtensionMarkdown(),
|
|
22
|
+
new ExtensionOdt(),
|
|
23
|
+
new ExtensionTables(),
|
|
24
|
+
new ExtensionDevToolkit(),
|
|
25
|
+
new ExtensionMenuLegacy(menu),
|
|
26
|
+
// new ExtensionCodeMirror({
|
|
27
|
+
// theme: [dracula],
|
|
28
|
+
// }),
|
|
29
|
+
new ExtensionCodeJar(),
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Extension } from '@kerebron/editor';
|
|
2
|
+
import type { AnyExtensionOrReq } from '@kerebron/editor';
|
|
3
|
+
|
|
4
|
+
import { LspWebSocketTransport } from '@kerebron/extension-lsp/LspWebSocketTransport';
|
|
5
|
+
import { ExtensionLsp, type LspTransportGetter } from '@kerebron/extension-lsp';
|
|
6
|
+
|
|
7
|
+
import type { Token } from '@kerebron/extension-markdown';
|
|
8
|
+
import { SmartOutput } from '@kerebron/editor/utilities';
|
|
9
|
+
import { Transport } from '@kerebron/extension-lsp';
|
|
10
|
+
|
|
11
|
+
export interface LspEditorKitConfig {
|
|
12
|
+
getLspTransport: LspTransportGetter;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const defaultGetLspTransport: LspTransportGetter = (
|
|
16
|
+
lang: string,
|
|
17
|
+
): Transport | undefined => {
|
|
18
|
+
const protocol = globalThis.location.protocol === 'http:' ? 'ws:' : 'wss:';
|
|
19
|
+
const uri = protocol + '//' + globalThis.location.host + '/lsp';
|
|
20
|
+
|
|
21
|
+
switch (lang) {
|
|
22
|
+
case 'json':
|
|
23
|
+
return new LspWebSocketTransport(uri);
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export class LspEditorKit extends Extension {
|
|
29
|
+
override name = 'lsp-kit';
|
|
30
|
+
requires: AnyExtensionOrReq[];
|
|
31
|
+
|
|
32
|
+
md: string = '';
|
|
33
|
+
|
|
34
|
+
static createFrom(config?: LspEditorKitConfig) {
|
|
35
|
+
return new LspEditorKit(config);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
config: ConstructorParameters<typeof Extension>[0],
|
|
40
|
+
) {
|
|
41
|
+
super(config);
|
|
42
|
+
|
|
43
|
+
const getLspTransport = config?.getLspTransport || defaultGetLspTransport;
|
|
44
|
+
|
|
45
|
+
this.requires = [
|
|
46
|
+
new ExtensionLsp({ getLspTransport: getLspTransport }),
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override created() {
|
|
51
|
+
this.editor.addEventListener('selection', async (ev: CustomEvent) => {
|
|
52
|
+
const selection = ev.detail.selection;
|
|
53
|
+
if (selection) {
|
|
54
|
+
const from = Math.min(selection.$anchor.pos, selection.$head.pos);
|
|
55
|
+
const to = Math.max(selection.$anchor.pos, selection.$head.pos);
|
|
56
|
+
// console.log('lsp.sel', from, to);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
this.editor.addEventListener(
|
|
61
|
+
'transaction',
|
|
62
|
+
async (ev: CustomEvent<any>) => {
|
|
63
|
+
// this.lastValue = ev.detail.transaction.doc;
|
|
64
|
+
const buffer = await this.editor.saveDocument('text/x-markdown');
|
|
65
|
+
this.md = new TextDecoder().decode(buffer);
|
|
66
|
+
// this.$emit('input', this.lastValue);
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
this.editor.addEventListener('md:output', async (ev: CustomEvent<any>) => {
|
|
71
|
+
const output: SmartOutput<Token> = ev.detail.output;
|
|
72
|
+
const mapping = output
|
|
73
|
+
.getMetas()
|
|
74
|
+
.filter((meta) =>
|
|
75
|
+
+(meta?.item?.map?.length) > 0 && meta?.item?.type === 'text'
|
|
76
|
+
)
|
|
77
|
+
.map((meta) => ({
|
|
78
|
+
pmPos: meta.item?.map?.[0] || -1,
|
|
79
|
+
mdPos: meta.pos,
|
|
80
|
+
item: meta.item,
|
|
81
|
+
}));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import * as random from 'lib0/random';
|
|
3
|
+
import { WebsocketProvider } from 'y-websocket';
|
|
4
|
+
|
|
5
|
+
import { Extension } from '@kerebron/editor';
|
|
6
|
+
import type { AnyExtensionOrReq } from '@kerebron/editor';
|
|
7
|
+
import { userColors } from '@kerebron/extension-yjs/userColors';
|
|
8
|
+
import { ExtensionYjs, YjsProvider } from '@kerebron/extension-yjs';
|
|
9
|
+
|
|
10
|
+
export class YjsEditorKit extends Extension {
|
|
11
|
+
override name = 'yjs-editor';
|
|
12
|
+
requires: AnyExtensionOrReq[];
|
|
13
|
+
|
|
14
|
+
static createFrom(ydoc: Y.Doc, roomId: string) {
|
|
15
|
+
const userColor = userColors[random.uint32() % userColors.length];
|
|
16
|
+
if (!roomId) {
|
|
17
|
+
throw new Error('No room id');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const protocol = globalThis.location.protocol === 'http:' ? 'ws:' : 'wss:';
|
|
21
|
+
const wsProvider: YjsProvider = new WebsocketProvider(
|
|
22
|
+
protocol + '//' + globalThis.location.host + '/yjs',
|
|
23
|
+
roomId,
|
|
24
|
+
ydoc,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
wsProvider.on('status', (event) => {
|
|
28
|
+
console.log('wsProvider status', event.status); // logs "connected" or "disconnected"
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
wsProvider.awareness.setLocalStateField('user', {
|
|
32
|
+
name: 'Anonymous ' + Math.floor(Math.random() * 100),
|
|
33
|
+
color: userColor.color,
|
|
34
|
+
colorLight: userColor.light,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return new YjsEditorKit(wsProvider, ydoc);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
constructor(wsProvider: YjsProvider, private ydoc: Y.Doc) {
|
|
41
|
+
super();
|
|
42
|
+
|
|
43
|
+
this.requires = [
|
|
44
|
+
new ExtensionYjs({ ydoc: this.ydoc, provider: wsProvider }),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/mod.ts
ADDED
|
File without changes
|
package/assets/CodeEditorKit.css
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
@import '@kerebron/extension-tables/assets/tables.css';
|
|
2
|
-
/*@import '@kerebron/extension-menu/assets/custom-menu.css';*/
|
|
3
|
-
@import '@kerebron/extension-menu-legacy/assets/menu.css';
|
|
4
|
-
@import '@kerebron/extension-codemirror/assets/codemirror.css';
|
|
5
|
-
@import '@kerebron/extension-codejar/assets/codejar.css';
|
|
6
|
-
@import '@kerebron/extension-autocomplete/assets/autocomplete.css';
|