@pluv/crdt-yjs 0.1.3 → 0.3.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +27 -0
- package/README.md +18 -3
- package/dist/index.d.ts +31 -19
- package/dist/index.js +33 -3
- package/dist/index.mjs +29 -2
- package/package.json +8 -8
- package/src/doc.ts +3 -3
- package/src/index.ts +6 -1
- package/src/object.ts +1 -1
- package/src/types.ts +4 -1
- package/src/xmlElement.ts +19 -0
- package/src/xmlFragment.ts +16 -0
- package/src/xmlText.ts +5 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/crdt-yjs@0.
|
|
2
|
+
> @pluv/crdt-yjs@0.3.0 build /home/runner/work/pluv/pluv/packages/crdt-yjs
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v6.
|
|
7
|
+
[34mCLI[39m tsup v6.6.3
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m4.69 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 54ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m3.50 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 55ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1551ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m3.09 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @pluv/crdt-yjs
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 327a6ef: renamed y.unstable\_\_object to y.object
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 8bf62cb: bumped dependencies
|
|
12
|
+
- 7e52685: Bumped dependencies
|
|
13
|
+
- b1cb325: Updated dependencies
|
|
14
|
+
- 8e97fb2: Updated dependencies
|
|
15
|
+
- Updated dependencies [8bf62cb]
|
|
16
|
+
- Updated dependencies [7e52685]
|
|
17
|
+
- Updated dependencies [8e97fb2]
|
|
18
|
+
- @pluv/types@0.1.3
|
|
19
|
+
|
|
20
|
+
## 0.2.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- 6858682: Added support for yjs xml types including XmlElement, XmlFragment and XmlText
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- @pluv/types@0.1.2
|
|
29
|
+
|
|
3
30
|
## 0.1.3
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
<img src="https://img.shields.io/badge/docs-coming%20soon!-blue" alt="Docs coming soon!" />
|
|
27
27
|
</p>
|
|
28
28
|
|
|
29
|
-
<
|
|
29
|
+
<p align="center">
|
|
30
|
+
<img src="https://github.com/pluv-io/pluv/blob/master/assets/demo-events.gif?raw=true" alt="Demo" />
|
|
31
|
+
</p>
|
|
30
32
|
|
|
31
33
|
## `@pluv/crdt-yjs`
|
|
32
34
|
|
|
@@ -52,6 +54,11 @@ pnpm add @pluv/crdt-yjs yjs
|
|
|
52
54
|
|
|
53
55
|
```ts
|
|
54
56
|
import { createClient, y } from "@pluv/client";
|
|
57
|
+
import type {
|
|
58
|
+
Array as YArray,
|
|
59
|
+
Map as YMap,
|
|
60
|
+
XmlFragment as YXmlFragment,
|
|
61
|
+
} from "yjs";
|
|
55
62
|
import { z } from "zod";
|
|
56
63
|
// Import the PluvIO instance as a type from your server file
|
|
57
64
|
import { type io } from "./server";
|
|
@@ -61,13 +68,21 @@ const client = createClient<typeof io>({ /* client config here */ });
|
|
|
61
68
|
type Presence = {};
|
|
62
69
|
|
|
63
70
|
interface Storage {
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
editor: YXmlFragment;
|
|
72
|
+
groceryList: YMap<string, number>;
|
|
73
|
+
messages: YArray<{ name: string; message: string }>;
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
// Create a room to join
|
|
69
77
|
const room = client.createRoom<Presence, Storage>("my-room", {
|
|
70
78
|
initialStorage: () => ({
|
|
79
|
+
editor: y.xmlFragment({
|
|
80
|
+
children: [
|
|
81
|
+
y.xmlElement("paragraph", {
|
|
82
|
+
children: [y.xmlText("Hello World!")],
|
|
83
|
+
}),
|
|
84
|
+
]
|
|
85
|
+
}),
|
|
71
86
|
groceryList: y.map([
|
|
72
87
|
["apricots", 2],
|
|
73
88
|
["bread", 3],
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
import { Array, AbstractType,
|
|
1
|
+
import { Array, Map, AbstractType, Text, XmlElement, XmlFragment, XmlText, Doc, Transaction } from 'yjs';
|
|
2
2
|
export { AbstractType, Array, Map, Text } from 'yjs';
|
|
3
|
-
import {
|
|
3
|
+
import { JsonPrimitive } from '@pluv/types';
|
|
4
4
|
|
|
5
5
|
declare const array: <T extends unknown>(value?: readonly T[]) => Array<T>;
|
|
6
6
|
|
|
7
|
+
type unstable__YObjectValue = Record<string, NonNullable<JsonPrimitive> | AbstractType<any>>;
|
|
8
|
+
type unstable__YObject<T extends unstable__YObjectValue> = Map<T[keyof T]> & {
|
|
9
|
+
__$type: T;
|
|
10
|
+
};
|
|
11
|
+
declare const object: <T extends unstable__YObjectValue = {}>(value: T) => unstable__YObject<T>;
|
|
12
|
+
|
|
13
|
+
type InferYjsDocJson<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer ITypes> ? {
|
|
14
|
+
[P in keyof ITypes]: InferYjsSharedTypeJson<ITypes[P]>;
|
|
15
|
+
} : never;
|
|
16
|
+
type InferYjsDocSharedType<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsDocSharedTypes<TDoc>[TKey];
|
|
17
|
+
type InferYjsDocSharedTypeJson<TDoc extends YjsDoc<any>, TKey extends keyof InferYjsDocSharedTypes<TDoc> = keyof InferYjsDocSharedTypes<TDoc>> = InferYjsSharedTypeJson<InferYjsDocSharedTypes<TDoc>[TKey]>;
|
|
18
|
+
type InferYjsDocSharedTypes<TDoc extends YjsDoc<any>> = TDoc extends YjsDoc<infer ITypes> ? ITypes : never;
|
|
19
|
+
type InferYjsSharedTypeJson<TShared extends unknown> = TShared extends AbstractType<any> ? TShared extends Array<infer IItem> ? readonly InferYjsSharedTypeJson<IItem>[] : TShared extends unstable__YObject<infer IObject> ? {
|
|
20
|
+
[P in keyof IObject]: InferYjsSharedTypeJson<IObject[P]>;
|
|
21
|
+
} : TShared extends Map<infer IItem> ? Record<string, InferYjsSharedTypeJson<IItem>> : TShared extends Text | XmlElement | XmlFragment | XmlText ? string : never : TShared;
|
|
22
|
+
|
|
7
23
|
declare class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
8
24
|
value: Doc;
|
|
9
25
|
private get _storage();
|
|
@@ -14,7 +30,7 @@ declare class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
|
14
30
|
get<TKey extends keyof T>(key: TKey): T[TKey];
|
|
15
31
|
getSharedTypes(): T;
|
|
16
32
|
subscribe(fn: (update: string, origin: string, doc: Doc, transaction: Transaction) => void): () => void;
|
|
17
|
-
toJSON():
|
|
33
|
+
toJSON(): InferYjsDocJson<this>;
|
|
18
34
|
static fromUint8Array(u8a: Uint8Array): string;
|
|
19
35
|
static toUint8Array(str: string): Uint8Array;
|
|
20
36
|
}
|
|
@@ -22,22 +38,18 @@ declare const doc: <T extends Record<string, AbstractType<any>> = {}>(value?: T
|
|
|
22
38
|
|
|
23
39
|
declare const map: <T extends unknown>(value?: readonly (readonly [key: string, value: T])[]) => Map<T>;
|
|
24
40
|
|
|
25
|
-
type unstable__YObjectValue = Record<string, NonNullable<JsonPrimitive> | AbstractType<any>>;
|
|
26
|
-
type unstable__YObject<T extends unstable__YObjectValue> = Map<T[keyof T]> & {
|
|
27
|
-
__$type: T;
|
|
28
|
-
};
|
|
29
|
-
declare const unstable__object: <T extends unstable__YObjectValue = {}>(value: T) => unstable__YObject<T>;
|
|
30
|
-
|
|
31
41
|
declare const text: (value?: string) => Text;
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
interface XmlElementParams {
|
|
44
|
+
children?: readonly (XmlElement | XmlText)[];
|
|
45
|
+
}
|
|
46
|
+
declare const xmlElement: (name: string, params?: XmlElementParams) => XmlElement;
|
|
47
|
+
|
|
48
|
+
interface XmlFragmentParams {
|
|
49
|
+
children?: readonly (XmlElement | XmlText)[];
|
|
50
|
+
}
|
|
51
|
+
declare const xmlFragment: (params?: XmlFragmentParams) => XmlFragment;
|
|
52
|
+
|
|
53
|
+
declare const xmlText: (value?: string) => XmlText;
|
|
42
54
|
|
|
43
|
-
export { InferYjsDocJson, InferYjsDocSharedType, InferYjsDocSharedTypeJson, InferYjsDocSharedTypes, InferYjsSharedTypeJson, YjsDoc, array, doc, map, text, unstable__YObject,
|
|
55
|
+
export { InferYjsDocJson, InferYjsDocSharedType, InferYjsDocSharedTypeJson, InferYjsDocSharedTypes, InferYjsSharedTypeJson, XmlElementParams, XmlFragmentParams, YjsDoc, array, doc, map, object, text, unstable__YObject, xmlElement, xmlFragment, xmlText };
|
package/dist/index.js
CHANGED
|
@@ -41,8 +41,11 @@ __export(src_exports, {
|
|
|
41
41
|
array: () => array,
|
|
42
42
|
doc: () => doc,
|
|
43
43
|
map: () => map,
|
|
44
|
+
object: () => object,
|
|
44
45
|
text: () => text,
|
|
45
|
-
|
|
46
|
+
xmlElement: () => xmlElement,
|
|
47
|
+
xmlFragment: () => xmlFragment,
|
|
48
|
+
xmlText: () => xmlText
|
|
46
49
|
});
|
|
47
50
|
module.exports = __toCommonJS(src_exports);
|
|
48
51
|
|
|
@@ -119,7 +122,7 @@ var map = (value = []) => {
|
|
|
119
122
|
|
|
120
123
|
// src/object.ts
|
|
121
124
|
var import_yjs4 = require("yjs");
|
|
122
|
-
var
|
|
125
|
+
var object = (value) => {
|
|
123
126
|
return new import_yjs4.Map(Object.entries(value));
|
|
124
127
|
};
|
|
125
128
|
|
|
@@ -128,12 +131,39 @@ var import_yjs5 = require("yjs");
|
|
|
128
131
|
var text = (value = "") => {
|
|
129
132
|
return new import_yjs5.Text(value);
|
|
130
133
|
};
|
|
134
|
+
|
|
135
|
+
// src/xmlElement.ts
|
|
136
|
+
var import_yjs6 = require("yjs");
|
|
137
|
+
var xmlElement = (name, params = {}) => {
|
|
138
|
+
const { children = [] } = params;
|
|
139
|
+
const element = new import_yjs6.XmlElement(name);
|
|
140
|
+
element.push(children.slice());
|
|
141
|
+
return element;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/xmlFragment.ts
|
|
145
|
+
var import_yjs7 = require("yjs");
|
|
146
|
+
var xmlFragment = (params = {}) => {
|
|
147
|
+
const { children = [] } = params;
|
|
148
|
+
const fragment = new import_yjs7.XmlFragment();
|
|
149
|
+
fragment.push(children.slice());
|
|
150
|
+
return fragment;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/xmlText.ts
|
|
154
|
+
var import_yjs8 = require("yjs");
|
|
155
|
+
var xmlText = (value = "") => {
|
|
156
|
+
return new import_yjs8.XmlText(value);
|
|
157
|
+
};
|
|
131
158
|
// Annotate the CommonJS export names for ESM import in node:
|
|
132
159
|
0 && (module.exports = {
|
|
133
160
|
YjsDoc,
|
|
134
161
|
array,
|
|
135
162
|
doc,
|
|
136
163
|
map,
|
|
164
|
+
object,
|
|
137
165
|
text,
|
|
138
|
-
|
|
166
|
+
xmlElement,
|
|
167
|
+
xmlFragment,
|
|
168
|
+
xmlText
|
|
139
169
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -91,7 +91,7 @@ var map = (value = []) => {
|
|
|
91
91
|
|
|
92
92
|
// src/object.ts
|
|
93
93
|
import { Map as YMap2 } from "yjs";
|
|
94
|
-
var
|
|
94
|
+
var object = (value) => {
|
|
95
95
|
return new YMap2(Object.entries(value));
|
|
96
96
|
};
|
|
97
97
|
|
|
@@ -100,11 +100,38 @@ import { Text as YText } from "yjs";
|
|
|
100
100
|
var text = (value = "") => {
|
|
101
101
|
return new YText(value);
|
|
102
102
|
};
|
|
103
|
+
|
|
104
|
+
// src/xmlElement.ts
|
|
105
|
+
import { XmlElement as YXmlElement } from "yjs";
|
|
106
|
+
var xmlElement = (name, params = {}) => {
|
|
107
|
+
const { children = [] } = params;
|
|
108
|
+
const element = new YXmlElement(name);
|
|
109
|
+
element.push(children.slice());
|
|
110
|
+
return element;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/xmlFragment.ts
|
|
114
|
+
import { XmlFragment as YXmlFragment } from "yjs";
|
|
115
|
+
var xmlFragment = (params = {}) => {
|
|
116
|
+
const { children = [] } = params;
|
|
117
|
+
const fragment = new YXmlFragment();
|
|
118
|
+
fragment.push(children.slice());
|
|
119
|
+
return fragment;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/xmlText.ts
|
|
123
|
+
import { XmlText as YXmlText } from "yjs";
|
|
124
|
+
var xmlText = (value = "") => {
|
|
125
|
+
return new YXmlText(value);
|
|
126
|
+
};
|
|
103
127
|
export {
|
|
104
128
|
YjsDoc,
|
|
105
129
|
array,
|
|
106
130
|
doc,
|
|
107
131
|
map,
|
|
132
|
+
object,
|
|
108
133
|
text,
|
|
109
|
-
|
|
134
|
+
xmlElement,
|
|
135
|
+
xmlFragment,
|
|
136
|
+
xmlText
|
|
110
137
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/crdt-yjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "yjs for @pluv/io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"js-base64": "^3.7.
|
|
21
|
-
"@pluv/types": "^0.1.
|
|
20
|
+
"js-base64": "^3.7.5",
|
|
21
|
+
"@pluv/types": "^0.1.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"yjs": "^13.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"tsup": "^6.
|
|
28
|
-
"typescript": "^4.9.
|
|
29
|
-
"yjs": "^13.5.
|
|
30
|
-
"@pluv/tsconfig": "^0.1.
|
|
31
|
-
"eslint-config-pluv": "^0.1.
|
|
27
|
+
"tsup": "^6.6.3",
|
|
28
|
+
"typescript": "^4.9.5",
|
|
29
|
+
"yjs": "^13.5.49",
|
|
30
|
+
"@pluv/tsconfig": "^0.1.3",
|
|
31
|
+
"eslint-config-pluv": "^0.1.4"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/doc.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { JsonObject } from "@pluv/types";
|
|
2
1
|
import { fromUint8Array, toUint8Array } from "js-base64";
|
|
3
2
|
import type { AbstractType, Map as YMap, Transaction } from "yjs";
|
|
4
3
|
import { applyUpdate, Doc as YDoc, encodeStateAsUpdate } from "yjs";
|
|
4
|
+
import type { InferYjsDocJson } from "./types";
|
|
5
5
|
|
|
6
6
|
export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
7
7
|
public value: YDoc = new YDoc();
|
|
@@ -70,8 +70,8 @@ export class YjsDoc<T extends Record<string, AbstractType<any>> = {}> {
|
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
public toJSON():
|
|
74
|
-
return this._storage.toJSON()
|
|
73
|
+
public toJSON(): InferYjsDocJson<this> {
|
|
74
|
+
return this._storage.toJSON() as InferYjsDocJson<this>;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
public static fromUint8Array(u8a: Uint8Array): string {
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,13 @@ export { array } from "./array";
|
|
|
3
3
|
export { doc, YjsDoc } from "./doc";
|
|
4
4
|
export { map } from "./map";
|
|
5
5
|
export type { unstable__YObject } from "./object";
|
|
6
|
-
export {
|
|
6
|
+
export { object } from "./object";
|
|
7
7
|
export { text } from "./text";
|
|
8
|
+
export type { XmlElementParams } from "./xmlElement";
|
|
9
|
+
export { xmlElement } from "./xmlElement";
|
|
10
|
+
export type { XmlFragmentParams } from "./xmlFragment";
|
|
11
|
+
export { xmlFragment } from "./xmlFragment";
|
|
12
|
+
export { xmlText } from "./xmlText";
|
|
8
13
|
export type {
|
|
9
14
|
InferYjsDocJson,
|
|
10
15
|
InferYjsDocSharedType,
|
package/src/object.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type unstable__YObject<T extends unstable__YObjectValue> = YMap<
|
|
|
11
11
|
T[keyof T]
|
|
12
12
|
> & { __$type: T };
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const object = <T extends unstable__YObjectValue = {}>(
|
|
15
15
|
value: T
|
|
16
16
|
): unstable__YObject<T> => {
|
|
17
17
|
return new YMap(Object.entries(value)) as unstable__YObject<T>;
|
package/src/types.ts
CHANGED
|
@@ -3,6 +3,9 @@ import type {
|
|
|
3
3
|
Array as YArray,
|
|
4
4
|
Map as YMap,
|
|
5
5
|
Text as YText,
|
|
6
|
+
XmlElement as YXmlElement,
|
|
7
|
+
XmlFragment as YXmlFragment,
|
|
8
|
+
XmlText as YXmlText,
|
|
6
9
|
} from "yjs";
|
|
7
10
|
import type { YjsDoc } from "./doc";
|
|
8
11
|
import type { unstable__YObject } from "./object";
|
|
@@ -34,7 +37,7 @@ export type InferYjsSharedTypeJson<TShared extends unknown> =
|
|
|
34
37
|
? { [P in keyof IObject]: InferYjsSharedTypeJson<IObject[P]> }
|
|
35
38
|
: TShared extends YMap<infer IItem>
|
|
36
39
|
? Record<string, InferYjsSharedTypeJson<IItem>>
|
|
37
|
-
: TShared extends YText
|
|
40
|
+
: TShared extends YText | YXmlElement | YXmlFragment | YXmlText
|
|
38
41
|
? string
|
|
39
42
|
: never
|
|
40
43
|
: TShared;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { XmlText as YXmlText } from "yjs";
|
|
2
|
+
import { XmlElement as YXmlElement } from "yjs";
|
|
3
|
+
|
|
4
|
+
export interface XmlElementParams {
|
|
5
|
+
children?: readonly (YXmlElement | YXmlText)[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const xmlElement = (
|
|
9
|
+
name: string,
|
|
10
|
+
params: XmlElementParams = {}
|
|
11
|
+
): YXmlElement => {
|
|
12
|
+
const { children = [] } = params;
|
|
13
|
+
|
|
14
|
+
const element = new YXmlElement(name);
|
|
15
|
+
|
|
16
|
+
element.push(children.slice());
|
|
17
|
+
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { XmlElement as YXmlElement, XmlText as YXmlText } from "yjs";
|
|
2
|
+
import { XmlFragment as YXmlFragment } from "yjs";
|
|
3
|
+
|
|
4
|
+
export interface XmlFragmentParams {
|
|
5
|
+
children?: readonly (YXmlElement | YXmlText)[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const xmlFragment = (params: XmlFragmentParams = {}): YXmlFragment => {
|
|
9
|
+
const { children = [] } = params;
|
|
10
|
+
|
|
11
|
+
const fragment = new YXmlFragment();
|
|
12
|
+
|
|
13
|
+
fragment.push(children.slice());
|
|
14
|
+
|
|
15
|
+
return fragment;
|
|
16
|
+
};
|