@univerjs/docs 1.4.0 → 1.5.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/README.md +12 -46
- package/lib/cjs/facade.js +11 -11
- package/lib/cjs/index.js +126 -126
- package/lib/cjs/{worker-BkTyL8zs.js → protocol-CvmouuxB.js} +14 -352
- package/lib/cjs/worker.js +342 -9
- package/lib/es/facade.js +11 -11
- package/lib/es/index.js +4 -3
- package/lib/es/{worker-Dny9WctR.js → protocol-D1XjAOOp.js} +17 -349
- package/lib/es/worker.js +335 -2
- package/lib/facade.js +11 -11
- package/lib/index.js +4 -3
- package/lib/{worker-Dny9WctR.js → protocol-D1XjAOOp.js} +17 -349
- package/lib/types/index.d.ts +0 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/lib/worker.js +335 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
## Package Overview
|
|
10
10
|
|
|
11
|
-
| Package | UMD global | CSS | Locales | Facade entry |
|
|
12
|
-
| --- | --- | :---: | :---: | :---: |
|
|
13
|
-
| `@univerjs/docs` | `UniverDocs` | No | No | Yes |
|
|
11
|
+
| Package | UMD global | CSS | Locales | Facade entry | Worker entry |
|
|
12
|
+
| --- | --- | :---: | :---: | :---: | :---: |
|
|
13
|
+
| `@univerjs/docs` | `UniverDocs` | No | No | Yes | Yes |
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -20,65 +20,31 @@ pnpm add @univerjs/docs
|
|
|
20
20
|
npm install @univerjs/docs
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Keep all `@univerjs/*` packages on the same version.
|
|
24
|
-
|
|
25
23
|
## Usage
|
|
26
24
|
|
|
25
|
+
Start with the [integration setup](https://docs.univer.ai/) for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
|
|
26
|
+
|
|
27
27
|
```ts
|
|
28
28
|
import { UniverDocsPlugin } from '@univerjs/docs';
|
|
29
29
|
|
|
30
30
|
univer.registerPlugin(UniverDocsPlugin);
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Modern documents (`DocumentFlavor.MODERN`) support collapsing Heading 1 through Heading 5.
|
|
36
|
-
The heading stays visible; its section extends to the next heading of the same or a higher
|
|
37
|
-
level, or the end of its content flow. Each table cell and Modern column has its own heading
|
|
38
|
-
hierarchy. Expanding a parent preserves the collapse flags of its nested headings.
|
|
39
|
-
Traditional documents ignore these flags.
|
|
33
|
+
### Worker usage
|
|
40
34
|
|
|
41
|
-
`
|
|
42
|
-
collapses a heading; `false` or an omitted flag leaves it expanded. Collapsing changes layout
|
|
43
|
-
visibility without deleting the section's text, tables, images, or other snapshot content.
|
|
44
|
-
Saving and reopening a Univer snapshot retains the flag. This contract does not establish
|
|
45
|
-
preservation through Office import or export.
|
|
35
|
+
On the main thread, import `UniverDocsLayoutWorkerPlugin` from `@univerjs/docs`. Register it alongside `UniverDocsPlugin` and set `workerFactory` to a function that creates the layout worker.
|
|
46
36
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`UniverDocsPlugin` registers `SetHeadingCollapsedCommand` (`doc.command.set-heading-collapsed`).
|
|
50
|
-
After registering the plugin and creating the document, execute the registered command through
|
|
51
|
-
the Facade API or `ICommandService`; do not call its handler or mutate the model directly.
|
|
52
|
-
For an existing `univerAPI` instance:
|
|
37
|
+
In the worker entry, import `UniverDocsWorkerPlugin` from `@univerjs/docs/worker`:
|
|
53
38
|
|
|
54
39
|
```ts
|
|
55
|
-
import {
|
|
40
|
+
import { UniverDocsWorkerPlugin } from '@univerjs/docs/worker';
|
|
56
41
|
|
|
57
|
-
|
|
58
|
-
unitId: documentId,
|
|
59
|
-
paragraphId: headingParagraphId,
|
|
60
|
-
collapsed: true,
|
|
61
|
-
});
|
|
42
|
+
univer.registerPlugin(UniverDocsWorkerPlugin);
|
|
62
43
|
```
|
|
63
44
|
|
|
64
|
-
|
|
65
|
-
Use `collapsed: false` to expand. The command returns `false` for a no-op or an invalid target,
|
|
66
|
-
including Traditional or disabled documents, headings hidden by an ancestor, empty sections
|
|
67
|
-
when collapsing, and targets without edit permission.
|
|
68
|
-
|
|
69
|
-
Concurrent paragraph formatting preserves inherited style references and imported numbering metadata;
|
|
70
|
-
a full replacement can still explicitly clear those fields.
|
|
71
|
-
|
|
72
|
-
Collapse state is shared document state, not a personal view preference. The command uses the
|
|
73
|
-
rich-text mutation path for undo/redo and collaboration. Undoing a fold preserves later peer
|
|
74
|
-
character formatting and enclosing field or content-control properties that the fold did not edit.
|
|
75
|
-
A selection hidden by a collapse moves to the visible heading. Worker layout uses the same flags
|
|
76
|
-
after edits, undo/redo, and snapshot recovery; visibility changes rebuild the affected layout and retain the published viewport until
|
|
77
|
-
replacement content is ready. Hidden tables and images are omitted from layout publications,
|
|
78
|
-
while their source data remains in the snapshot. Rejected edits with empty operations do not
|
|
79
|
-
advance the Worker mutation queue or force the next real edit to resnapshot the document.
|
|
45
|
+
## Integration Notes
|
|
80
46
|
|
|
81
|
-
|
|
47
|
+
- Import `@univerjs/docs/facade` when using this package through Univer Facade APIs.
|
|
82
48
|
|
|
83
49
|
## Resources
|
|
84
50
|
|
package/lib/cjs/facade.js
CHANGED
|
@@ -302,14 +302,14 @@ function stripBlockTokens(text) {
|
|
|
302
302
|
return Array.from(text).map((char) => char === _univerjs_core.DataStreamTreeTokenType.PARAGRAPH ? "\n" : char).filter((char) => char !== _univerjs_core.DataStreamTreeTokenType.BLOCK_START && char !== _univerjs_core.DataStreamTreeTokenType.BLOCK_END && char !== _univerjs_core.DataStreamTreeTokenType.SECTION_BREAK).join("").replace(/\n$/, "");
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
// \0@oxc-project+runtime@0.
|
|
305
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
306
306
|
function __decorateParam(paramIndex, decorator) {
|
|
307
307
|
return function(target, key) {
|
|
308
308
|
decorator(target, key, paramIndex);
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
// \0@oxc-project+runtime@0.
|
|
312
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
313
313
|
function __decorate(decorators, target, key, desc) {
|
|
314
314
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
315
315
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1447,7 +1447,7 @@ let FDocumentSection = class FDocumentSection {
|
|
|
1447
1447
|
};
|
|
1448
1448
|
FDocumentSection = __decorate([__decorateParam(2, _univerjs_core.ICommandService), __decorateParam(3, _univerjs_core.IPermissionService)], FDocumentSection);
|
|
1449
1449
|
|
|
1450
|
-
// \0@oxc-project+runtime@0.
|
|
1450
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
1451
1451
|
function _typeof(o) {
|
|
1452
1452
|
"@babel/helpers - typeof";
|
|
1453
1453
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -1457,25 +1457,25 @@ function _typeof(o) {
|
|
|
1457
1457
|
}, _typeof(o);
|
|
1458
1458
|
}
|
|
1459
1459
|
|
|
1460
|
-
// \0@oxc-project+runtime@0.
|
|
1461
|
-
function toPrimitive(t,
|
|
1460
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
1461
|
+
function toPrimitive(t, e) {
|
|
1462
1462
|
if ("object" != _typeof(t) || !t) return t;
|
|
1463
|
-
var
|
|
1464
|
-
if (void 0 !==
|
|
1465
|
-
var i =
|
|
1463
|
+
var r;
|
|
1464
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
1465
|
+
var i = r.call(t, e || "default");
|
|
1466
1466
|
if ("object" != _typeof(i)) return i;
|
|
1467
1467
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1468
1468
|
}
|
|
1469
|
-
return ("string" ===
|
|
1469
|
+
return ("string" === e ? String : Number)(t);
|
|
1470
1470
|
}
|
|
1471
1471
|
|
|
1472
|
-
// \0@oxc-project+runtime@0.
|
|
1472
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
1473
1473
|
function toPropertyKey(t) {
|
|
1474
1474
|
var i = toPrimitive(t, "string");
|
|
1475
1475
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
|
-
// \0@oxc-project+runtime@0.
|
|
1478
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
1479
1479
|
function _defineProperty(e, r, t) {
|
|
1480
1480
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
1481
1481
|
value: t,
|