@univerjs/docs 1.1.0 → 1.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/README.md +50 -0
- package/lib/cjs/index.js +748 -676
- package/lib/es/index.js +748 -677
- package/lib/index.js +748 -677
- package/lib/types/commands/commands/set-heading-collapsed.command.d.ts +22 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/utils/section-columns.d.ts +2 -1
- package/lib/umd/index.js +2 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -30,6 +30,56 @@ import { UniverDocsPlugin } from '@univerjs/docs';
|
|
|
30
30
|
univer.registerPlugin(UniverDocsPlugin);
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
## Heading collapse in Modern documents
|
|
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.
|
|
40
|
+
|
|
41
|
+
`IParagraph.headingCollapsed` is an optional boolean in the document snapshot. Only `true`
|
|
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.
|
|
46
|
+
|
|
47
|
+
### Change collapse state with a command
|
|
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:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { SetHeadingCollapsedCommand } from '@univerjs/docs';
|
|
56
|
+
|
|
57
|
+
const changed = await univerAPI.executeCommand(SetHeadingCollapsedCommand.id, {
|
|
58
|
+
unitId: documentId,
|
|
59
|
+
paragraphId: headingParagraphId,
|
|
60
|
+
collapsed: true,
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Pass the document's unit ID, the heading's stable paragraph ID, and the desired boolean state.
|
|
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.
|
|
80
|
+
|
|
81
|
+
See [the editor interaction details](../docs-ui/README.md#heading-collapse) for the Canvas control.
|
|
82
|
+
|
|
33
83
|
## Resources
|
|
34
84
|
|
|
35
85
|
- [Documentation](https://docs.univer.ai)
|