@kerebron/extension-yjs 0.3.0 → 0.3.2
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/LICENSE +23 -0
- package/README.md +67 -0
- package/esm/editor/src/CoreEditor.d.ts.map +1 -1
- package/esm/editor/src/CoreEditor.js +3 -1
- package/esm/editor/src/Extension.d.ts.map +1 -1
- package/esm/editor/src/ExtensionManager.d.ts +1 -1
- package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
- package/esm/editor/src/nodeToTreeString.d.ts +8 -2
- package/esm/editor/src/nodeToTreeString.d.ts.map +1 -1
- package/esm/editor/src/nodeToTreeString.js +27 -11
- package/esm/editor/src/types.d.ts +1 -1
- package/esm/editor/src/types.d.ts.map +1 -1
- package/esm/editor/src/utilities/SmartOutput.d.ts +39 -0
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -0
- package/esm/editor/src/utilities/SmartOutput.js +213 -0
- package/esm/extension-yjs/src/ExtensionYjs.d.ts.map +1 -1
- package/esm/extension-yjs/src/ExtensionYjs.js +1 -1
- package/esm/extension-yjs/src/convertUtils.d.ts +59 -0
- package/esm/extension-yjs/src/convertUtils.d.ts.map +1 -0
- package/esm/extension-yjs/src/convertUtils.js +88 -0
- package/esm/extension-yjs/src/lib.d.ts +15 -0
- package/esm/extension-yjs/src/lib.d.ts.map +1 -0
- package/esm/extension-yjs/src/lib.js +24 -101
- package/esm/extension-yjs/src/ySyncPlugin.d.ts +36 -29
- package/esm/extension-yjs/src/ySyncPlugin.d.ts.map +1 -1
- package/esm/extension-yjs/src/ySyncPlugin.js +89 -71
- package/esm/extension-yjs/src/yUndoPlugin.d.ts.map +1 -1
- package/esm/extension-yjs/src/yUndoPlugin.js +18 -15
- package/esm/package.json +3 -0
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Permission is hereby granted, free of charge, to any
|
|
2
|
+
person obtaining a copy of this software and associated
|
|
3
|
+
documentation files (the "Software"), to deal in the
|
|
4
|
+
Software without restriction, including without
|
|
5
|
+
limitation the rights to use, copy, modify, merge,
|
|
6
|
+
publish, distribute, sublicense, and/or sell copies of
|
|
7
|
+
the Software, and to permit persons to whom the Software
|
|
8
|
+
is furnished to do so, subject to the following
|
|
9
|
+
conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice
|
|
12
|
+
shall be included in all copies or substantial portions
|
|
13
|
+
of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
16
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
17
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
18
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
19
|
+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
22
|
+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
23
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Kerebron - Prosemirror based online editor kit
|
|
2
|
+
|
|
3
|
+
## Watch a Demo
|
|
4
|
+
|
|
5
|
+
<a href="https://youtube.com/shorts/OdJjhAPj-wA?feature=share" target="_blank">
|
|
6
|
+
<img src="https://github.com/user-attachments/assets/b63ec84a-0ed2-4f98-920c-76f6d3215168" alt="Alt Text" width="200">
|
|
7
|
+
</a>
|
|
8
|
+
|
|
9
|
+
## Playground Demo
|
|
10
|
+
|
|
11
|
+
[playground](https://demo.kerebron.com) - be nice.
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Using vanilla Prosemirror modules is often impossible because of
|
|
16
|
+
incompatibilities.
|
|
17
|
+
|
|
18
|
+
Kerebron forks several prosemirror projects into one monorepo in order to keep
|
|
19
|
+
them in sync.
|
|
20
|
+
|
|
21
|
+
Project is inspired on https://tiptap.dev/, but instead of building wrapper
|
|
22
|
+
around a wrapper it borrows concept of extension and command manager.
|
|
23
|
+
|
|
24
|
+
It has simplified tooling (deno), fewer dependencies and resulting in lower
|
|
25
|
+
number of output npm modules.
|
|
26
|
+
|
|
27
|
+
**Work in progress**
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
To start example server:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
deno task -f server-deno-hono start
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Examples
|
|
38
|
+
|
|
39
|
+
TODO
|
|
40
|
+
|
|
41
|
+
## Build
|
|
42
|
+
|
|
43
|
+
### Build static examples
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
deno task -r build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### NPM packages are generated using DNT
|
|
50
|
+
|
|
51
|
+
- https://deno.com/blog/publish-esm-cjs-module-dnt - the easiest way to publish
|
|
52
|
+
a hybrid npm module for ESM and CommonJS
|
|
53
|
+
- https://github.com/denoland/dnt
|
|
54
|
+
- https://gaubee.com/article/Publishing-Your-Deno-Project-as-a-Monorepo-using-dnt/
|
|
55
|
+
|
|
56
|
+
To generate npm packages
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
deno -A ./build/build_npm.ts
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Run through docker
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
docker build . -t editor-test
|
|
66
|
+
docker run -it -p 8000:8000 -v $PWD:/usr/src/app editor-test
|
|
67
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/src/CoreEditor.ts"],"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) {
|
|
131
|
-
let doc = createNodeFromObject(content, this.schema
|
|
131
|
+
let doc = createNodeFromObject(content, this.schema, {
|
|
132
|
+
errorOnInvalidContent: true,
|
|
133
|
+
});
|
|
132
134
|
doc = ensureDocSchema(doc, this.schema);
|
|
133
135
|
this.state = EditorState.create({
|
|
134
136
|
doc,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,
|
|
1
|
+
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,WAAW,eAAe;IAE9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7C,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,8BAAsB,SAAS;IAIV,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC;IAH7D,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEO,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAGlE,aAAa,IAAI,SAAS,EAAE;IAI5B,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAInE,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIlE,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAI5E,SAAS,CAAC,IAAI,EAAE,UAAU;CAE3B"}
|
|
@@ -25,7 +25,7 @@ export declare class ExtensionManager {
|
|
|
25
25
|
converters: Record<string, Converter>;
|
|
26
26
|
private debug;
|
|
27
27
|
constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor);
|
|
28
|
-
getExtension(name: string):
|
|
28
|
+
getExtension<T extends Extension>(name: string): T | undefined;
|
|
29
29
|
private getPlugins;
|
|
30
30
|
private setupExtensions;
|
|
31
31
|
getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionManager.d.ts","sourceRoot":"","sources":["../../../src/editor/src/ExtensionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,C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|
1
|
-
import { Node } from 'prosemirror-model';
|
|
2
|
-
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
import { SmartOutput } from './utilities/SmartOutput.js';
|
|
3
|
+
export interface NodeAndPos {
|
|
4
|
+
node: Node;
|
|
5
|
+
pos: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function nodeToTreeStringOutput(output: SmartOutput<NodeAndPos>, node: Node | Node[] | readonly Node[], level?: number, currentPos?: number): SmartOutput<NodeAndPos> | undefined;
|
|
8
|
+
export declare function nodeToTreeString(node: Node | Node[] | readonly Node[]): string;
|
|
3
9
|
export declare function debugNode(node: Node | Node[]): void;
|
|
4
10
|
//# sourceMappingURL=nodeToTreeString.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAYzD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,EAC/B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,uCAmEf;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,UAIrE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAE5C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SmartOutput } from './utilities/SmartOutput.js';
|
|
1
2
|
function trimText(str, maxLen = 20) {
|
|
2
3
|
str = str.replaceAll('\n', '\\n');
|
|
3
4
|
if (str.length <= maxLen) {
|
|
@@ -5,19 +6,19 @@ function trimText(str, maxLen = 20) {
|
|
|
5
6
|
}
|
|
6
7
|
return str.slice(0, maxLen) + '...';
|
|
7
8
|
}
|
|
8
|
-
export function
|
|
9
|
+
export function nodeToTreeStringOutput(output, node, level = 0, currentPos = 0) {
|
|
9
10
|
let delim = '';
|
|
10
11
|
for (let i = 0; i < level; i++) {
|
|
11
12
|
delim += ' ';
|
|
12
13
|
}
|
|
13
|
-
let output = '';
|
|
14
14
|
if (Array.isArray(node)) {
|
|
15
15
|
for (const child of node) {
|
|
16
|
-
output
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
output.log(delim, { node: child, pos: currentPos });
|
|
17
|
+
nodeToTreeStringOutput(output, child, level + 1, currentPos);
|
|
18
|
+
// .replace(/\s+$/gm, '') +
|
|
19
|
+
// '\n'
|
|
19
20
|
}
|
|
20
|
-
return
|
|
21
|
+
return;
|
|
21
22
|
}
|
|
22
23
|
// https://prosemirror.net/docs/guide/#doc.indexing
|
|
23
24
|
let line = '';
|
|
@@ -33,7 +34,7 @@ export function nodeToTreeString(node, level = 0, currentPos = 0) {
|
|
|
33
34
|
if (node.content) {
|
|
34
35
|
line += `fragment.size: ${node.content.size}, `;
|
|
35
36
|
}
|
|
36
|
-
output
|
|
37
|
+
output.log((delim + line) + '\n', { node, pos: currentPos });
|
|
37
38
|
let marksLine = '';
|
|
38
39
|
if (node.marks) {
|
|
39
40
|
for (const mark of node.marks) {
|
|
@@ -41,18 +42,33 @@ export function nodeToTreeString(node, level = 0, currentPos = 0) {
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
if (marksLine) {
|
|
44
|
-
output
|
|
45
|
+
output.log((delim + ' ' + marksLine) + '\n', {
|
|
46
|
+
node,
|
|
47
|
+
pos: currentPos,
|
|
48
|
+
});
|
|
45
49
|
}
|
|
46
50
|
if (node.text) {
|
|
47
|
-
output
|
|
51
|
+
output.log((delim + ' "' + trimText(node.text) + '"') + '\n', {
|
|
52
|
+
node,
|
|
53
|
+
pos: currentPos,
|
|
54
|
+
});
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
57
|
node.forEach((child, offset) => {
|
|
51
|
-
output +=
|
|
52
|
-
|
|
58
|
+
// output +=
|
|
59
|
+
nodeToTreeStringOutput(output, child, level + 1, currentPos + offset + 1);
|
|
60
|
+
// .replace(
|
|
61
|
+
// /\s+$/gm,
|
|
62
|
+
// '',
|
|
63
|
+
// ) + '\n'; // + (node.isLeaf ? 1 : 2)
|
|
53
64
|
});
|
|
54
65
|
return output;
|
|
55
66
|
}
|
|
67
|
+
export function nodeToTreeString(node) {
|
|
68
|
+
const output = new SmartOutput();
|
|
69
|
+
nodeToTreeStringOutput(output, node);
|
|
70
|
+
return output.toString();
|
|
71
|
+
}
|
|
56
72
|
export function debugNode(node) {
|
|
57
73
|
console.debug(nodeToTreeString(node));
|
|
58
74
|
}
|
|
@@ -8,7 +8,7 @@ export type AnyExtensionOrReq = AnyExtension | {
|
|
|
8
8
|
};
|
|
9
9
|
export type Content = JSONContent | JSONContent[] | null;
|
|
10
10
|
export interface EditorOptions {
|
|
11
|
-
element:
|
|
11
|
+
element: HTMLElement;
|
|
12
12
|
content: Content;
|
|
13
13
|
parseOptions: ParseOptions;
|
|
14
14
|
extensions: AnyExtensionOrReq[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/editor/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA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ACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,EAAE,CAAC;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,CAAC,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,CAAC,CAAC;CACtC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface OutputMeta<K> {
|
|
2
|
+
rowPos: number;
|
|
3
|
+
colPos: number;
|
|
4
|
+
item: K;
|
|
5
|
+
}
|
|
6
|
+
interface Mapping {
|
|
7
|
+
sourceNo: number;
|
|
8
|
+
sourceRowPos: number;
|
|
9
|
+
sourceColPos: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SourceMap {
|
|
12
|
+
'version': 3;
|
|
13
|
+
'file': string;
|
|
14
|
+
'sourceRoot': string;
|
|
15
|
+
'sources': Array<string>;
|
|
16
|
+
'sourcesContent': Array<string>;
|
|
17
|
+
'names': Array<string>;
|
|
18
|
+
'mappings': string;
|
|
19
|
+
}
|
|
20
|
+
export declare class SmartOutput<K> {
|
|
21
|
+
private _rowPos;
|
|
22
|
+
private _colPos;
|
|
23
|
+
private chunks;
|
|
24
|
+
private metas;
|
|
25
|
+
log(text: string, item: K): void;
|
|
26
|
+
get chunkPos(): number;
|
|
27
|
+
rollback(pos: number): void;
|
|
28
|
+
get rowPos(): number;
|
|
29
|
+
get colPos(): number;
|
|
30
|
+
endsWith(text: string): boolean;
|
|
31
|
+
toString(): string;
|
|
32
|
+
getSourceMap(mapper: (item: K, rowPos: number, colPos: number) => Mapping | void): SourceMap;
|
|
33
|
+
}
|
|
34
|
+
/** @param {string} string */
|
|
35
|
+
export declare function decode(string: any): number[];
|
|
36
|
+
/** @param {number | number[]} value */
|
|
37
|
+
export declare function encode(value: any): string;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=SmartOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartOutput.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/SmartOutput.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAED,UAAU,OAAO;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,CAAC,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW,CAAC,CAAC;IACxB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IAEpB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,KAAK,CAA4B;IAEzC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAiBzB,IAAI,QAAQ,WAEX;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM;IAKpB,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAET;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM;IAIrB,QAAQ;IAIR,YAAY,CACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,GAClE,SAAS;CAuDb;AA0DD,6BAA6B;AAC7B,wBAAgB,MAAM,CAAC,MAAM,KAAA,YAqC5B;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,KAAK,KAAA,UAW3B"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export class SmartOutput {
|
|
2
|
+
constructor() {
|
|
3
|
+
Object.defineProperty(this, "_rowPos", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: 0
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(this, "_colPos", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: 0
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "chunks", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: []
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(this, "metas", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: []
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
log(text, item) {
|
|
29
|
+
this.chunks.push(text);
|
|
30
|
+
this.metas.push({
|
|
31
|
+
colPos: this._colPos,
|
|
32
|
+
rowPos: this._rowPos,
|
|
33
|
+
item,
|
|
34
|
+
});
|
|
35
|
+
const lines = text.split('\n');
|
|
36
|
+
if (lines.length === 1) {
|
|
37
|
+
this._colPos += lines[lines.length - 1].length;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this._rowPos += lines.length - 1;
|
|
41
|
+
this._colPos = lines[lines.length - 1].length;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
get chunkPos() {
|
|
45
|
+
return this.chunks.length;
|
|
46
|
+
}
|
|
47
|
+
rollback(pos) {
|
|
48
|
+
this.chunks.splice(pos);
|
|
49
|
+
this.metas.splice(pos);
|
|
50
|
+
}
|
|
51
|
+
get rowPos() {
|
|
52
|
+
return this._rowPos;
|
|
53
|
+
}
|
|
54
|
+
get colPos() {
|
|
55
|
+
return this._colPos;
|
|
56
|
+
}
|
|
57
|
+
endsWith(text) {
|
|
58
|
+
return this.chunks.join('').endsWith(text);
|
|
59
|
+
}
|
|
60
|
+
toString() {
|
|
61
|
+
return this.chunks.join('');
|
|
62
|
+
}
|
|
63
|
+
getSourceMap(mapper) {
|
|
64
|
+
const mappingRows = [];
|
|
65
|
+
let lastRow = -1;
|
|
66
|
+
let lastCol = -1;
|
|
67
|
+
for (const meta of this.metas) {
|
|
68
|
+
while (meta.rowPos >= mappingRows.length) {
|
|
69
|
+
mappingRows.push([]);
|
|
70
|
+
}
|
|
71
|
+
if (lastRow != meta.rowPos || lastCol != meta.colPos) {
|
|
72
|
+
const currentRow = mappingRows[meta.rowPos];
|
|
73
|
+
const mapping = mapper(meta.item, meta.rowPos, meta.colPos);
|
|
74
|
+
if (mapping) {
|
|
75
|
+
currentRow.push([
|
|
76
|
+
meta.colPos,
|
|
77
|
+
mapping.sourceNo,
|
|
78
|
+
mapping.sourceRowPos,
|
|
79
|
+
mapping.sourceColPos,
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
lastRow = meta.rowPos;
|
|
84
|
+
lastCol = meta.colPos;
|
|
85
|
+
}
|
|
86
|
+
const mappings = mappingRows
|
|
87
|
+
.map((row) => row.map((group) => encode(group))
|
|
88
|
+
.join(','))
|
|
89
|
+
.join(';');
|
|
90
|
+
mappingRows.forEach((row, rowNo) => {
|
|
91
|
+
// console.log('g', rowNo, row);
|
|
92
|
+
row.forEach((group) => {
|
|
93
|
+
const enc = encode(group);
|
|
94
|
+
// console.log('g', rowNo, group, enc, decode(enc));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
version: 3,
|
|
99
|
+
file: '',
|
|
100
|
+
sourceRoot: '',
|
|
101
|
+
sources: [],
|
|
102
|
+
sourcesContent: [],
|
|
103
|
+
names: [],
|
|
104
|
+
mappings,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
109
|
+
function toVLQ(value) {
|
|
110
|
+
const vlq = [];
|
|
111
|
+
const isNegative = value < 0;
|
|
112
|
+
value = Math.abs(value);
|
|
113
|
+
if (value === 0) {
|
|
114
|
+
vlq.push(0);
|
|
115
|
+
return vlq;
|
|
116
|
+
}
|
|
117
|
+
while (value > 0) {
|
|
118
|
+
let digit = value & 0x1F;
|
|
119
|
+
value >>= 5;
|
|
120
|
+
if (value > 0) {
|
|
121
|
+
digit |= 0x20;
|
|
122
|
+
}
|
|
123
|
+
vlq.push(digit);
|
|
124
|
+
if (vlq.length === 1) {
|
|
125
|
+
digit = isNegative ? (digit | 0x1) : (digit & ~0x1);
|
|
126
|
+
vlq[0] = digit;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return vlq;
|
|
130
|
+
}
|
|
131
|
+
function encodeVLQ(input) {
|
|
132
|
+
const numbers = Array.isArray(input) ? input : [input];
|
|
133
|
+
let result = '';
|
|
134
|
+
for (const num of numbers) {
|
|
135
|
+
const vlq = toVLQ(num);
|
|
136
|
+
for (const digit of vlq) {
|
|
137
|
+
result += BASE64_CHARS[digit];
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
/** @type {Record<string, number>} */
|
|
143
|
+
let char_to_integer = {};
|
|
144
|
+
/** @type {Record<number, string>} */
|
|
145
|
+
let integer_to_char = {};
|
|
146
|
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
|
147
|
+
.split('')
|
|
148
|
+
.forEach(function (char, i) {
|
|
149
|
+
char_to_integer[char] = i;
|
|
150
|
+
integer_to_char[i] = char;
|
|
151
|
+
});
|
|
152
|
+
/** @param {string} string */
|
|
153
|
+
export function decode(string) {
|
|
154
|
+
/** @type {number[]} */
|
|
155
|
+
let result = [];
|
|
156
|
+
let shift = 0;
|
|
157
|
+
let value = 0;
|
|
158
|
+
for (let i = 0; i < string.length; i += 1) {
|
|
159
|
+
let integer = char_to_integer[string[i]];
|
|
160
|
+
if (integer === undefined) {
|
|
161
|
+
throw new Error('Invalid character (' + string[i] + ')');
|
|
162
|
+
}
|
|
163
|
+
const has_continuation_bit = integer & 32;
|
|
164
|
+
integer &= 31;
|
|
165
|
+
value += integer << shift;
|
|
166
|
+
if (has_continuation_bit) {
|
|
167
|
+
shift += 5;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const should_negate = value & 1;
|
|
171
|
+
value >>>= 1;
|
|
172
|
+
if (should_negate) {
|
|
173
|
+
result.push(value === 0 ? -0x80000000 : -value);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
result.push(value);
|
|
177
|
+
}
|
|
178
|
+
// reset
|
|
179
|
+
value = shift = 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/** @param {number | number[]} value */
|
|
185
|
+
export function encode(value) {
|
|
186
|
+
if (typeof value === 'number') {
|
|
187
|
+
return encode_integer(value);
|
|
188
|
+
}
|
|
189
|
+
let result = '';
|
|
190
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
191
|
+
result += encode_integer(value[i]);
|
|
192
|
+
}
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
/** @param {number} num */
|
|
196
|
+
function encode_integer(num) {
|
|
197
|
+
let result = '';
|
|
198
|
+
if (num < 0) {
|
|
199
|
+
num = (-num << 1) | 1;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
num <<= 1;
|
|
203
|
+
}
|
|
204
|
+
do {
|
|
205
|
+
let clamped = num & 31;
|
|
206
|
+
num >>>= 5;
|
|
207
|
+
if (num > 0) {
|
|
208
|
+
clamped |= 32;
|
|
209
|
+
}
|
|
210
|
+
result += integer_to_char[clamped];
|
|
211
|
+
} while (num > 0);
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionYjs.d.ts","sourceRoot":"","sources":["../../../src/extension-yjs/src/ExtensionYjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ExtensionYjs.d.ts","sourceRoot":"","sources":["../../../src/extension-yjs/src/ExtensionYjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,kCAAkC,CAAC;AAM1C,qBAAa,YAAa,SAAQ,SAAS;IACzC,IAAI,SAAS;IACb,GAAG,EAAE,GAAG,CAAC;IAGA,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAOhD,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAOjD,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;CAY7E"}
|
|
@@ -2,7 +2,7 @@ import { Extension } from '../../editor/src/mod.js';
|
|
|
2
2
|
import { ySyncPlugin } from './ySyncPlugin.js';
|
|
3
3
|
import { yCursorPlugin } from './yCursorPlugin.js';
|
|
4
4
|
import { redo, undo, yUndoPlugin } from './yUndoPlugin.js';
|
|
5
|
-
import { initProseMirrorDoc } from './
|
|
5
|
+
import { initProseMirrorDoc } from './convertUtils.js';
|
|
6
6
|
export class ExtensionYjs extends Extension {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { Fragment, Node, type Schema } from 'prosemirror-model';
|
|
3
|
+
import { BindingMetadata } from './ySyncPlugin.js';
|
|
4
|
+
export declare const createEmptyMeta: () => BindingMetadata;
|
|
5
|
+
/**
|
|
6
|
+
* Utility function for converting an Y.Fragment to a ProseMirror fragment.
|
|
7
|
+
*/
|
|
8
|
+
export declare const yXmlFragmentToProseMirrorFragment: (yXmlFragment: Y.XmlFragment, schema: Schema) => Fragment;
|
|
9
|
+
/**
|
|
10
|
+
* Utility function for converting an Y.Fragment to a ProseMirror node.
|
|
11
|
+
*/
|
|
12
|
+
export declare const yXmlFragmentToProseMirrorRootNode: (yXmlFragment: Y.XmlFragment, schema: Schema) => Node;
|
|
13
|
+
/**
|
|
14
|
+
* The initial ProseMirror content should be supplied by Yjs. This function transforms a Y.Fragment
|
|
15
|
+
* to a ProseMirror Doc node and creates a mapping that is used by the sync plugin.
|
|
16
|
+
*
|
|
17
|
+
* @todo deprecate mapping property
|
|
18
|
+
*/
|
|
19
|
+
export declare const initProseMirrorDoc: (yXmlFragment: Y.XmlFragment, schema: Schema) => {
|
|
20
|
+
doc: Node;
|
|
21
|
+
meta: BindingMetadata;
|
|
22
|
+
mapping: Map<Y.AbstractType<any>, Node | Node[]>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Utility method to convert a Prosemirror Doc Node into a Y.Doc.
|
|
26
|
+
*
|
|
27
|
+
* This can be used when importing existing content to Y.Doc for the first time,
|
|
28
|
+
* note that this should not be used to rehydrate a Y.Doc from a database once
|
|
29
|
+
* collaboration has begun as all history will be lost
|
|
30
|
+
*/
|
|
31
|
+
export declare function prosemirrorToYDoc(doc: Node, xmlFragment?: string): Y.Doc;
|
|
32
|
+
/**
|
|
33
|
+
* Utility method to update an empty Y.XmlFragment with content from a Prosemirror Doc Node.
|
|
34
|
+
*
|
|
35
|
+
* This can be used when importing existing content to Y.Doc for the first time,
|
|
36
|
+
* note that this should not be used to rehydrate a Y.Doc from a database once
|
|
37
|
+
* collaboration has begun as all history will be lost
|
|
38
|
+
*
|
|
39
|
+
* Note: The Y.XmlFragment does not need to be part of a Y.Doc document at the time that this
|
|
40
|
+
* method is called, but it must be added before any other operations are performed on it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function prosemirrorToYXmlFragment(doc: Node, xmlFragment: Y.XmlFragment): Y.XmlFragment;
|
|
43
|
+
/**
|
|
44
|
+
* Utility method to convert Prosemirror compatible JSON into a Y.Doc.
|
|
45
|
+
*
|
|
46
|
+
* This can be used when importing existing content to Y.Doc for the first time,
|
|
47
|
+
* note that this should not be used to rehydrate a Y.Doc from a database once
|
|
48
|
+
* collaboration has begun as all history will be lost
|
|
49
|
+
*/
|
|
50
|
+
export declare function prosemirrorJSONToYDoc(schema: Schema, state: any, xmlFragment?: string): Y.Doc;
|
|
51
|
+
/**
|
|
52
|
+
* Utility method to convert Prosemirror compatible JSON to a Y.XmlFragment
|
|
53
|
+
*
|
|
54
|
+
* This can be used when importing existing content to Y.Doc for the first time,
|
|
55
|
+
* note that this should not be used to rehydrate a Y.Doc from a database once
|
|
56
|
+
* collaboration has begun as all history will be lost
|
|
57
|
+
*/
|
|
58
|
+
export declare function prosemirrorJSONToYXmlFragment(schema: Schema, state: any, xmlFragment: Y.XmlFragment): Y.XmlFragment;
|
|
59
|
+
//# sourceMappingURL=convertUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertUtils.d.ts","sourceRoot":"","sources":["../../../src/extension-yjs/src/convertUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACL,eAAe,EAIhB,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,eAAe,QAAO,eAGjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iCAAiC,GAC5C,cAAc,CAAC,CAAC,WAAW,EAC3B,QAAQ,MAAM,aAUf,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,GAC5C,cAAc,CAAC,CAAC,WAAW,EAC3B,QAAQ,MAAM,SAKb,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,cAAc,CAAC,CAAC,WAAW,EAC3B,QAAQ,MAAM;;;;CAef,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,IAAI,EACT,WAAW,GAAE,MAAsB,GAClC,CAAC,CAAC,GAAG,CAUP;AAED;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,IAAI,EACT,WAAW,EAAE,CAAC,CAAC,WAAW,GACzB,CAAC,CAAC,WAAW,CAOf;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,GAAG,EACV,WAAW,GAAE,MAAsB,GAClC,CAAC,CAAC,GAAG,CAGP;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,GAAG,EACV,WAAW,EAAE,CAAC,CAAC,WAAW,GACzB,CAAC,CAAC,WAAW,CAGf"}
|