@kerebron/editor-kits 0.4.27 → 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.
@@ -0,0 +1,8 @@
1
+ import { AnyExtensionOrReq, Extension } from '@kerebron/editor';
2
+ import { ExtensionCustomMenu } from '@kerebron/extension-menu';
3
+ export declare class AdvancedEditorKit extends Extension {
4
+ name: string;
5
+ requires: AnyExtensionOrReq[];
6
+ constructor(menu?: ConstructorParameters<typeof ExtensionCustomMenu>[0]);
7
+ }
8
+ //# sourceMappingURL=AdvancedEditorKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdvancedEditorKit.d.ts","sourceRoot":"","sources":["../src/AdvancedEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,qBAAa,iBAAkB,SAAQ,SAAS;IACrC,IAAI,SAAqB;IAClC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAElB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAcxE"}
@@ -0,0 +1,28 @@
1
+ import { dracula } from 'thememirror';
2
+ import { Extension } from '@kerebron/editor';
3
+ import { ExtensionBasicEditor } from '@kerebron/extension-basic-editor/ExtensionBasicEditor';
4
+ import { ExtensionMarkdown } from '@kerebron/extension-markdown';
5
+ import { ExtensionOdt } from '@kerebron/extension-odt';
6
+ import { ExtensionTables } from '@kerebron/extension-tables';
7
+ import { ExtensionDevToolkit } from '@kerebron/extension-dev-toolkit';
8
+ import { ExtensionCustomMenu } from '@kerebron/extension-menu';
9
+ import { ExtensionCodeMirror } from '@kerebron/extension-codemirror';
10
+ export class AdvancedEditorKit extends Extension {
11
+ name = 'advanced-editor';
12
+ requires;
13
+ constructor(menu) {
14
+ super();
15
+ this.requires = [
16
+ new ExtensionBasicEditor(),
17
+ new ExtensionMarkdown(),
18
+ new ExtensionOdt(),
19
+ new ExtensionTables(),
20
+ new ExtensionDevToolkit(),
21
+ new ExtensionCustomMenu(menu),
22
+ new ExtensionCodeMirror({
23
+ theme: [dracula],
24
+ }),
25
+ ];
26
+ }
27
+ }
28
+ //# sourceMappingURL=AdvancedEditorKit.js.map
@@ -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,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IACrC,IAAI,GAAG,iBAAiB,CAAC;IAClC,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,IAAI,mBAAmB,CAAC;gBACtB,KAAK,EAAE,CAAC,OAAO,CAAC;aACjB,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import { AnyExtensionOrReq, Extension } from '@kerebron/editor';
2
+ export declare class CodeEditorKit extends Extension {
3
+ name: string;
4
+ requires: AnyExtensionOrReq[];
5
+ constructor(lang: string);
6
+ }
7
+ //# sourceMappingURL=CodeEditorKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditorKit.d.ts","sourceRoot":"","sources":["../src/CodeEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAOhE,qBAAa,aAAc,SAAQ,SAAS;IACjC,IAAI,SAAyB;IACtC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAElB,IAAI,EAAE,MAAM;CAazB"}
@@ -0,0 +1,24 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import { ExtensionBasicCodeEditor } from '@kerebron/extension-basic-editor/ExtensionBasicCodeEditor';
3
+ import { ExtensionMarkdown } from '@kerebron/extension-markdown';
4
+ import { ExtensionDevToolkit } from '@kerebron/extension-dev-toolkit';
5
+ // import { ExtensionCodeMirror } from '@kerebron/extension-codemirror';
6
+ import { ExtensionCodeJar } from '@kerebron/extension-codejar';
7
+ export class CodeEditorKit extends Extension {
8
+ name = 'dev-advanced-editor';
9
+ requires;
10
+ constructor(lang) {
11
+ super();
12
+ this.requires = [
13
+ new ExtensionBasicCodeEditor({ lang }),
14
+ new ExtensionMarkdown(),
15
+ new ExtensionDevToolkit(),
16
+ // new ExtensionCodeMirror({
17
+ // languageWhitelist: [lang],
18
+ // readOnly: false,
19
+ // }),
20
+ new ExtensionCodeJar({ lang }),
21
+ ];
22
+ }
23
+ }
24
+ //# sourceMappingURL=CodeEditorKit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditorKit.js","sourceRoot":"","sources":["../src/CodeEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,wEAAwE;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,MAAM,OAAO,aAAc,SAAQ,SAAS;IACjC,IAAI,GAAG,qBAAqB,CAAC;IACtC,QAAQ,CAAsB;IAE9B,YAAY,IAAY;QACtB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,wBAAwB,CAAC,EAAE,IAAI,EAAE,CAAC;YACtC,IAAI,iBAAiB,EAAE;YACvB,IAAI,mBAAmB,EAAE;YACzB,4BAA4B;YAC5B,+BAA+B;YAC/B,qBAAqB;YACrB,MAAM;YACN,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC;SAC/B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ import { AnyExtensionOrReq, Extension } from '@kerebron/editor';
2
+ import { ExtensionMenuLegacy } from '@kerebron/extension-menu-legacy';
3
+ export declare class DevAdvancedEditorKit extends Extension {
4
+ name: string;
5
+ requires: AnyExtensionOrReq[];
6
+ constructor(menu?: ConstructorParameters<typeof ExtensionMenuLegacy>[0]);
7
+ }
8
+ //# sourceMappingURL=DevAdvancedEditorKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevAdvancedEditorKit.d.ts","sourceRoot":"","sources":["../src/DevAdvancedEditorKit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAItE,qBAAa,oBAAqB,SAAQ,SAAS;IACxC,IAAI,SAAyB;IACtC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;gBAElB,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC;CAexE"}
@@ -0,0 +1,28 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import { ExtensionBasicEditor } from '@kerebron/extension-basic-editor/ExtensionBasicEditor';
3
+ import { ExtensionMarkdown } from '@kerebron/extension-markdown';
4
+ import { ExtensionOdt } from '@kerebron/extension-odt';
5
+ import { ExtensionTables } from '@kerebron/extension-tables';
6
+ import { ExtensionDevToolkit } from '@kerebron/extension-dev-toolkit';
7
+ import { ExtensionMenuLegacy } from '@kerebron/extension-menu-legacy';
8
+ import { ExtensionCodeJar } from '@kerebron/extension-codejar';
9
+ export class DevAdvancedEditorKit extends Extension {
10
+ name = 'dev-advanced-editor';
11
+ requires;
12
+ constructor(menu) {
13
+ super();
14
+ this.requires = [
15
+ new ExtensionBasicEditor(),
16
+ new ExtensionMarkdown(),
17
+ new ExtensionOdt(),
18
+ new ExtensionTables(),
19
+ new ExtensionDevToolkit(),
20
+ new ExtensionMenuLegacy(menu),
21
+ // new ExtensionCodeMirror({
22
+ // theme: [dracula],
23
+ // }),
24
+ new ExtensionCodeJar(),
25
+ ];
26
+ }
27
+ }
28
+ //# sourceMappingURL=DevAdvancedEditorKit.js.map
@@ -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"}
@@ -0,0 +1,15 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import type { AnyExtensionOrReq } from '@kerebron/editor';
3
+ import { type LspTransportGetter } from '@kerebron/extension-lsp';
4
+ export interface LspEditorKitConfig {
5
+ getLspTransport: LspTransportGetter;
6
+ }
7
+ export declare class LspEditorKit extends Extension {
8
+ name: string;
9
+ requires: AnyExtensionOrReq[];
10
+ md: string;
11
+ static createFrom(config?: LspEditorKitConfig): LspEditorKit;
12
+ constructor(config: ConstructorParameters<typeof Extension>[0]);
13
+ created(): void;
14
+ }
15
+ //# sourceMappingURL=LspEditorKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LspEditorKit.d.ts","sourceRoot":"","sources":["../src/LspEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAMhF,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,kBAAkB,CAAC;CACrC;AAeD,qBAAa,YAAa,SAAQ,SAAS;IAChC,IAAI,SAAa;IAC1B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAE9B,EAAE,EAAE,MAAM,CAAM;IAEhB,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,kBAAkB;gBAK3C,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC;IAW3C,OAAO;CAkCjB"}
@@ -0,0 +1,55 @@
1
+ import { Extension } from '@kerebron/editor';
2
+ import { LspWebSocketTransport } from '@kerebron/extension-lsp/LspWebSocketTransport';
3
+ import { ExtensionLsp } from '@kerebron/extension-lsp';
4
+ const defaultGetLspTransport = (lang) => {
5
+ const protocol = globalThis.location.protocol === 'http:' ? 'ws:' : 'wss:';
6
+ const uri = protocol + '//' + globalThis.location.host + '/lsp';
7
+ switch (lang) {
8
+ case 'json':
9
+ return new LspWebSocketTransport(uri);
10
+ }
11
+ return undefined;
12
+ };
13
+ export class LspEditorKit extends Extension {
14
+ name = 'lsp-kit';
15
+ requires;
16
+ md = '';
17
+ static createFrom(config) {
18
+ return new LspEditorKit(config);
19
+ }
20
+ constructor(config) {
21
+ super(config);
22
+ const getLspTransport = config?.getLspTransport || defaultGetLspTransport;
23
+ this.requires = [
24
+ new ExtensionLsp({ getLspTransport: getLspTransport }),
25
+ ];
26
+ }
27
+ created() {
28
+ this.editor.addEventListener('selection', async (ev) => {
29
+ const selection = ev.detail.selection;
30
+ if (selection) {
31
+ const from = Math.min(selection.$anchor.pos, selection.$head.pos);
32
+ const to = Math.max(selection.$anchor.pos, selection.$head.pos);
33
+ // console.log('lsp.sel', from, to);
34
+ }
35
+ });
36
+ this.editor.addEventListener('transaction', async (ev) => {
37
+ // this.lastValue = ev.detail.transaction.doc;
38
+ const buffer = await this.editor.saveDocument('text/x-markdown');
39
+ this.md = new TextDecoder().decode(buffer);
40
+ // this.$emit('input', this.lastValue);
41
+ });
42
+ this.editor.addEventListener('md:output', async (ev) => {
43
+ const output = ev.detail.output;
44
+ const mapping = output
45
+ .getMetas()
46
+ .filter((meta) => +(meta?.item?.map?.length) > 0 && meta?.item?.type === 'text')
47
+ .map((meta) => ({
48
+ pmPos: meta.item?.map?.[0] || -1,
49
+ mdPos: meta.pos,
50
+ item: meta.item,
51
+ }));
52
+ });
53
+ }
54
+ }
55
+ //# sourceMappingURL=LspEditorKit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LspEditorKit.js","sourceRoot":"","sources":["../src/LspEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,YAAY,EAA2B,MAAM,yBAAyB,CAAC;AAUhF,MAAM,sBAAsB,GAAuB,CACjD,IAAY,EACW,EAAE;IACzB,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3E,MAAM,GAAG,GAAG,QAAQ,GAAG,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,MAAM,CAAC;IAEhE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,MAAM;YACT,OAAO,IAAI,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,OAAO,YAAa,SAAQ,SAAS;IAChC,IAAI,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAsB;IAE9B,EAAE,GAAW,EAAE,CAAC;IAEhB,MAAM,CAAC,UAAU,CAAC,MAA2B;QAC3C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,YACE,MAAkD;QAElD,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,MAAM,eAA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I,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,KAAK,MAAM,CAC9D;iBACA,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACd,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAChC,KAAK,EAAE,IAAI,CAAC,GAAG;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC,CAAC,CAAC;QACR,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import * as Y from 'yjs';
2
+ import { Extension } from '@kerebron/editor';
3
+ import type { AnyExtensionOrReq } from '@kerebron/editor';
4
+ import { YjsProvider } from '@kerebron/extension-yjs';
5
+ export declare class YjsEditorKit extends Extension {
6
+ private ydoc;
7
+ name: string;
8
+ requires: AnyExtensionOrReq[];
9
+ static createFrom(ydoc: Y.Doc, roomId: string): YjsEditorKit;
10
+ constructor(wsProvider: YjsProvider, ydoc: Y.Doc);
11
+ }
12
+ //# sourceMappingURL=YjsEditorKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YjsEditorKit.d.ts","sourceRoot":"","sources":["../src/YjsEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAgB,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEpE,qBAAa,YAAa,SAAQ,SAAS;IA8BJ,OAAO,CAAC,IAAI;IA7BxC,IAAI,SAAgB;IAC7B,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAE9B,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM;gBA0BjC,UAAU,EAAE,WAAW,EAAU,IAAI,EAAE,CAAC,CAAC,GAAG;CAOzD"}
@@ -0,0 +1,35 @@
1
+ import * as random from 'lib0/random';
2
+ import { WebsocketProvider } from 'y-websocket';
3
+ import { Extension } from '@kerebron/editor';
4
+ import { userColors } from '@kerebron/extension-yjs/userColors';
5
+ import { ExtensionYjs } from '@kerebron/extension-yjs';
6
+ export class YjsEditorKit extends Extension {
7
+ ydoc;
8
+ name = 'yjs-editor';
9
+ requires;
10
+ static createFrom(ydoc, roomId) {
11
+ const userColor = userColors[random.uint32() % userColors.length];
12
+ if (!roomId) {
13
+ throw new Error('No room id');
14
+ }
15
+ const protocol = globalThis.location.protocol === 'http:' ? 'ws:' : 'wss:';
16
+ const wsProvider = new WebsocketProvider(protocol + '//' + globalThis.location.host + '/yjs', roomId, ydoc);
17
+ wsProvider.on('status', (event) => {
18
+ console.log('wsProvider status', event.status); // logs "connected" or "disconnected"
19
+ });
20
+ wsProvider.awareness.setLocalStateField('user', {
21
+ name: 'Anonymous ' + Math.floor(Math.random() * 100),
22
+ color: userColor.color,
23
+ colorLight: userColor.light,
24
+ });
25
+ return new YjsEditorKit(wsProvider, ydoc);
26
+ }
27
+ constructor(wsProvider, ydoc) {
28
+ super();
29
+ this.ydoc = ydoc;
30
+ this.requires = [
31
+ new ExtensionYjs({ ydoc: this.ydoc, provider: wsProvider }),
32
+ ];
33
+ }
34
+ }
35
+ //# sourceMappingURL=YjsEditorKit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YjsEditorKit.js","sourceRoot":"","sources":["../src/YjsEditorKit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AA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J,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.d.ts ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":""}
package/esm/mod.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=mod.js.map
package/esm/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/editor-kits",
3
- "version": "0.4.27",
3
+ "version": "0.4.29",
4
4
  "license": "MIT",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -27,20 +27,23 @@
27
27
  }
28
28
  },
29
29
  "scripts": {},
30
- "files": [],
30
+ "files": [
31
+ "esm",
32
+ "src"
33
+ ],
31
34
  "dependencies": {
32
- "@kerebron/editor": "0.4.27",
33
- "@kerebron/extension-basic-editor": "0.4.27",
34
- "@kerebron/extension-codejar": "0.4.27",
35
- "@kerebron/extension-codemirror": "0.4.27",
36
- "@kerebron/extension-dev-toolkit": "0.4.27",
37
- "@kerebron/extension-lsp": "0.4.27",
38
- "@kerebron/extension-markdown": "0.4.27",
39
- "@kerebron/extension-menu": "0.4.27",
40
- "@kerebron/extension-menu-legacy": "0.4.27",
41
- "@kerebron/extension-odt": "0.4.27",
42
- "@kerebron/extension-tables": "0.4.27",
43
- "@kerebron/extension-yjs": "0.4.27",
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",
44
47
  "lib0": "0.2.109",
45
48
  "thememirror": "2.0.1",
46
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