@kerebron/editor-kits 0.6.7 → 0.7.0
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/YjsEditorKit.d.ts +2 -3
- package/esm/YjsEditorKit.d.ts.map +1 -1
- package/esm/YjsEditorKit.js +6 -11
- package/esm/YjsEditorKit.js.map +1 -1
- package/package.json +13 -14
- package/src/YjsEditorKit.ts +7 -11
package/esm/YjsEditorKit.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { AnyExtensionOrReq, EditorKit } from '@kerebron/editor';
|
|
2
2
|
export declare class YjsEditorKit implements EditorKit {
|
|
3
3
|
url: string;
|
|
4
|
-
userName: string;
|
|
5
4
|
name: string;
|
|
6
|
-
static createFrom(
|
|
7
|
-
constructor(url: string
|
|
5
|
+
static createFrom(url?: string): YjsEditorKit;
|
|
6
|
+
constructor(url: string);
|
|
8
7
|
getExtensions(): AnyExtensionOrReq[];
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=YjsEditorKit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YjsEditorKit.d.ts","sourceRoot":"","sources":["../src/YjsEditorKit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AASrE,qBAAa,YAAa,YAAW,SAAS;IAczB,GAAG,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"YjsEditorKit.d.ts","sourceRoot":"","sources":["../src/YjsEditorKit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AASrE,qBAAa,YAAa,YAAW,SAAS;IAczB,GAAG,EAAE,MAAM;IAb9B,IAAI,SAAgB;IAEpB,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM;gBAWX,GAAG,EAAE,MAAM;IAG9B,aAAa,IAAI,iBAAiB,EAAE;CAiBrC"}
|
package/esm/YjsEditorKit.js
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
|
-
import { WebsocketProvider } from '
|
|
2
|
+
import { WebsocketProvider } from '@kerebron/extension-yjs/WebsocketProvider';
|
|
3
3
|
import { ExtensionYjs, } from '@kerebron/extension-yjs';
|
|
4
4
|
import { MarkYChange } from '@kerebron/extension-yjs/MarkYChange';
|
|
5
5
|
export class YjsEditorKit {
|
|
6
6
|
url;
|
|
7
|
-
userName;
|
|
8
7
|
name = 'yjs-editor';
|
|
9
|
-
static createFrom(
|
|
8
|
+
static createFrom(url) {
|
|
10
9
|
if (!url) {
|
|
11
10
|
const protocol = globalThis.location.protocol === 'http:'
|
|
12
11
|
? 'ws:'
|
|
13
12
|
: 'wss:';
|
|
14
13
|
url = protocol + '//' + globalThis.location.host + '/yjs';
|
|
15
14
|
}
|
|
16
|
-
return new YjsEditorKit(url
|
|
15
|
+
return new YjsEditorKit(url);
|
|
17
16
|
}
|
|
18
|
-
constructor(url
|
|
17
|
+
constructor(url) {
|
|
19
18
|
this.url = url;
|
|
20
|
-
this.userName = userName;
|
|
21
19
|
}
|
|
22
20
|
getExtensions() {
|
|
23
|
-
const
|
|
21
|
+
const createYjsProvider = (roomId) => {
|
|
24
22
|
const ydoc = new Y.Doc();
|
|
25
23
|
const wsProvider = new WebsocketProvider(this.url, roomId, ydoc);
|
|
26
|
-
wsProvider.on('status', (event) => {
|
|
27
|
-
console.log('wsProvider status', event.status); // logs "connected" or "disconnected"
|
|
28
|
-
});
|
|
29
24
|
return [wsProvider, ydoc];
|
|
30
25
|
};
|
|
31
26
|
return [
|
|
32
27
|
new MarkYChange(),
|
|
33
|
-
new ExtensionYjs({
|
|
28
|
+
new ExtensionYjs({ createYjsProvider }),
|
|
34
29
|
];
|
|
35
30
|
}
|
|
36
31
|
}
|
package/esm/YjsEditorKit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YjsEditorKit.js","sourceRoot":"","sources":["../src/YjsEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"YjsEditorKit.js","sourceRoot":"","sources":["../src/YjsEditorKit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAG9E,OAAO,EAEL,YAAY,GAEb,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,MAAM,OAAO,YAAY;IAcJ;IAbnB,IAAI,GAAG,YAAY,CAAC;IAEpB,MAAM,CAAC,UAAU,CAAC,GAAY;QAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,QAAQ,KAAK,OAAO;gBACvD,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,MAAM,CAAC;YACX,GAAG,GAAG,QAAQ,GAAG,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,MAAM,CAAC;QAC5D,CAAC;QAED,OAAO,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,YAAmB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAC9B,CAAC;IAED,aAAa;QACX,MAAM,iBAAiB,GAAsB,CAAC,MAAc,EAAE,EAAE;YAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;YACzB,MAAM,UAAU,GAAgB,IAAI,iBAAiB,CACnD,IAAI,CAAC,GAAG,EACR,MAAM,EACN,IAAI,CACL,CAAC;YAEF,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;QAEF,OAAO;YACL,IAAI,WAAW,EAAE;YACjB,IAAI,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;SACxC,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/editor-kits",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/mod.js",
|
|
6
6
|
"exports": {
|
|
@@ -33,20 +33,19 @@
|
|
|
33
33
|
"assets"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@kerebron/editor": "0.
|
|
37
|
-
"@kerebron/extension-basic-editor": "0.
|
|
38
|
-
"@kerebron/extension-codejar": "0.
|
|
39
|
-
"@kerebron/extension-codemirror": "0.
|
|
40
|
-
"@kerebron/extension-dev-toolkit": "0.
|
|
41
|
-
"@kerebron/extension-lsp": "0.
|
|
42
|
-
"@kerebron/extension-markdown": "0.
|
|
43
|
-
"@kerebron/extension-menu": "0.
|
|
44
|
-
"@kerebron/extension-menu-legacy": "0.
|
|
45
|
-
"@kerebron/extension-odt": "0.
|
|
46
|
-
"@kerebron/extension-tables": "0.
|
|
47
|
-
"@kerebron/extension-yjs": "0.
|
|
36
|
+
"@kerebron/editor": "0.7.0",
|
|
37
|
+
"@kerebron/extension-basic-editor": "0.7.0",
|
|
38
|
+
"@kerebron/extension-codejar": "0.7.0",
|
|
39
|
+
"@kerebron/extension-codemirror": "0.7.0",
|
|
40
|
+
"@kerebron/extension-dev-toolkit": "0.7.0",
|
|
41
|
+
"@kerebron/extension-lsp": "0.7.0",
|
|
42
|
+
"@kerebron/extension-markdown": "0.7.0",
|
|
43
|
+
"@kerebron/extension-menu": "0.7.0",
|
|
44
|
+
"@kerebron/extension-menu-legacy": "0.7.0",
|
|
45
|
+
"@kerebron/extension-odt": "0.7.0",
|
|
46
|
+
"@kerebron/extension-tables": "0.7.0",
|
|
47
|
+
"@kerebron/extension-yjs": "0.7.0",
|
|
48
48
|
"thememirror": "2.0.1",
|
|
49
|
-
"y-websocket": "3.0.0",
|
|
50
49
|
"yjs": "13.6.24"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
package/src/YjsEditorKit.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
|
-
import { WebsocketProvider } from '
|
|
2
|
+
import { WebsocketProvider } from '@kerebron/extension-yjs/WebsocketProvider';
|
|
3
3
|
|
|
4
4
|
import type { AnyExtensionOrReq, EditorKit } from '@kerebron/editor';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
CreateYjsProvider,
|
|
7
7
|
ExtensionYjs,
|
|
8
8
|
YjsProvider,
|
|
9
9
|
} from '@kerebron/extension-yjs';
|
|
@@ -13,7 +13,7 @@ import { MarkYChange } from '@kerebron/extension-yjs/MarkYChange';
|
|
|
13
13
|
export class YjsEditorKit implements EditorKit {
|
|
14
14
|
name = 'yjs-editor';
|
|
15
15
|
|
|
16
|
-
static createFrom(
|
|
16
|
+
static createFrom(url?: string) {
|
|
17
17
|
if (!url) {
|
|
18
18
|
const protocol = globalThis.location.protocol === 'http:'
|
|
19
19
|
? 'ws:'
|
|
@@ -21,14 +21,14 @@ export class YjsEditorKit implements EditorKit {
|
|
|
21
21
|
url = protocol + '//' + globalThis.location.host + '/yjs';
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
return new YjsEditorKit(url
|
|
24
|
+
return new YjsEditorKit(url);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
constructor(public url: string
|
|
27
|
+
constructor(public url: string) {
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
getExtensions(): AnyExtensionOrReq[] {
|
|
31
|
-
const
|
|
31
|
+
const createYjsProvider: CreateYjsProvider = (roomId: string) => {
|
|
32
32
|
const ydoc = new Y.Doc();
|
|
33
33
|
const wsProvider: YjsProvider = new WebsocketProvider(
|
|
34
34
|
this.url,
|
|
@@ -36,16 +36,12 @@ export class YjsEditorKit implements EditorKit {
|
|
|
36
36
|
ydoc,
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
-
wsProvider.on('status', (event) => {
|
|
40
|
-
console.log('wsProvider status', event.status); // logs "connected" or "disconnected"
|
|
41
|
-
});
|
|
42
|
-
|
|
43
39
|
return [wsProvider, ydoc];
|
|
44
40
|
};
|
|
45
41
|
|
|
46
42
|
return [
|
|
47
43
|
new MarkYChange(),
|
|
48
|
-
new ExtensionYjs({
|
|
44
|
+
new ExtensionYjs({ createYjsProvider }),
|
|
49
45
|
];
|
|
50
46
|
}
|
|
51
47
|
}
|