@portone/docx-editor 0.3.0 → 0.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/CHANGELOG.md +205 -0
- package/assets/editor.png +0 -0
- package/dist/DocxEditor.d.ts +1 -1
- package/dist/DocxEditor.js +45 -25
- package/dist/core.d.ts +1 -1
- package/dist/docx/cloning.js +4 -9
- package/dist/docx/commentOnlyChange.d.ts +5 -3
- package/dist/docx/comments/grammar.d.ts +27 -10
- package/dist/docx/comments/grammar.js +18 -67
- package/dist/docx/comments/model.d.ts +5 -6
- package/dist/docx/comments/model.js +0 -9
- package/dist/docx/comments/parts.d.ts +16 -10
- package/dist/docx/comments/parts.js +65 -13
- package/dist/docx/comments/people.d.ts +11 -3
- package/dist/docx/comments/people.js +20 -6
- package/dist/docx/comments/policy.js +7 -1
- package/dist/docx/comments/reading.d.ts +4 -2
- package/dist/docx/comments/reading.js +1 -14
- package/dist/docx/comments/writing.js +78 -35
- package/dist/docx/exportDocx.js +30 -18
- package/dist/docx/exportRefs.d.ts +8 -3
- package/dist/docx/exportRefs.js +2 -1
- package/dist/docx/fidelity.js +24 -10
- package/dist/docx/fields.d.ts +42 -0
- package/dist/docx/fields.js +76 -0
- package/dist/docx/formatting/attrs.d.ts +20 -2
- package/dist/docx/formatting/attrs.js +57 -2
- package/dist/docx/formatting/context.d.ts +10 -2
- package/dist/docx/formatting/context.js +23 -5
- package/dist/docx/formatting/resolve.d.ts +10 -4
- package/dist/docx/formatting/resolve.js +31 -11
- package/dist/docx/formatting/styles.d.ts +25 -2
- package/dist/docx/formatting/styles.js +84 -3
- package/dist/docx/headersFooters.d.ts +89 -20
- package/dist/docx/headersFooters.js +163 -172
- package/dist/docx/hyperlink.d.ts +14 -4
- package/dist/docx/hyperlink.js +4 -1
- package/dist/docx/importDocx.d.ts +1 -1
- package/dist/docx/importDocx.js +135 -74
- package/dist/docx/importParagraph.d.ts +16 -4
- package/dist/docx/importParagraph.js +87 -93
- package/dist/docx/importPolicy.d.ts +70 -0
- package/dist/docx/importPolicy.js +190 -0
- package/dist/docx/importPreserved.d.ts +30 -0
- package/dist/docx/importPreserved.js +54 -0
- package/dist/docx/importTable.d.ts +2 -2
- package/dist/docx/importTable.js +107 -66
- package/dist/docx/invariants.js +42 -31
- package/dist/docx/newLists.d.ts +30 -0
- package/dist/docx/newLists.js +24 -1
- package/dist/docx/notes.d.ts +6 -1
- package/dist/docx/notes.js +6 -16
- package/dist/docx/numberingPlanner.d.ts +6 -3
- package/dist/docx/numberingPlanner.js +38 -7
- package/dist/docx/pageGeometry.d.ts +5 -14
- package/dist/docx/pageGeometry.js +0 -12
- package/dist/docx/protectionPolicy.d.ts +13 -5
- package/dist/docx/protectionPolicy.js +32 -22
- package/dist/docx/scan.d.ts +18 -8
- package/dist/docx/scan.js +17 -11
- package/dist/docx/sections.d.ts +126 -0
- package/dist/docx/sections.js +207 -0
- package/dist/docx/serializeBlock.d.ts +13 -4
- package/dist/docx/serializeBlock.js +16 -18
- package/dist/docx/serializeParagraph.d.ts +4 -0
- package/dist/docx/serializeParagraph.js +1 -0
- package/dist/docx/serializePreserved.d.ts +14 -0
- package/dist/docx/serializePreserved.js +24 -0
- package/dist/docx/serializeStory.d.ts +17 -0
- package/dist/docx/serializeStory.js +17 -0
- package/dist/docx/serializeTable.js +10 -13
- package/dist/docx/session.d.ts +24 -7
- package/dist/docx/session.js +37 -6
- package/dist/docx/story.d.ts +140 -0
- package/dist/docx/story.js +237 -0
- package/dist/docx/storyProjection.js +6 -1
- package/dist/docx/tableFormatting/conditions.d.ts +76 -0
- package/dist/docx/tableFormatting/conditions.js +196 -0
- package/dist/docx/tableFormatting/editing.d.ts +7 -3
- package/dist/docx/tableFormatting/editing.js +4 -5
- package/dist/docx/tableFormatting/reading.d.ts +49 -19
- package/dist/docx/tableFormatting/reading.js +109 -35
- package/dist/docx/tableFormatting.d.ts +1 -0
- package/dist/docx/tableFormatting.js +1 -0
- package/dist/docx/tableTemplate.js +12 -12
- package/dist/editor/clipboard/htmlReader.d.ts +30 -0
- package/dist/editor/clipboard/htmlReader.js +302 -0
- package/dist/editor/clipboard/internalChannel.d.ts +57 -0
- package/dist/editor/clipboard/internalChannel.js +58 -0
- package/dist/editor/clipboard/normalizers.d.ts +99 -0
- package/dist/editor/clipboard/normalizers.js +199 -0
- package/dist/editor/clipboard/parser.d.ts +34 -0
- package/dist/editor/clipboard/parser.js +58 -0
- package/dist/editor/clipboard/plugin.d.ts +21 -0
- package/dist/editor/clipboard/plugin.js +320 -0
- package/dist/editor/clipboard/readContext.d.ts +24 -0
- package/dist/editor/clipboard/readContext.js +19 -0
- package/dist/editor/clipboard/readers.d.ts +33 -0
- package/dist/editor/clipboard/readers.js +37 -0
- package/dist/editor/commands/comments/editing.d.ts +26 -6
- package/dist/editor/commands/comments/editing.js +175 -105
- package/dist/editor/commands/comments/model.d.ts +34 -17
- package/dist/editor/commands/comments/model.js +11 -0
- package/dist/editor/commands/comments/reading.d.ts +5 -3
- package/dist/editor/commands/comments/reading.js +8 -58
- package/dist/editor/commands/formatting/propertyCommands.js +6 -1
- package/dist/editor/commands/index.d.ts +2 -2
- package/dist/editor/commands/index.js +2 -0
- package/dist/editor/commands/listCommands.d.ts +12 -3
- package/dist/editor/commands/listCommands.js +76 -30
- package/dist/editor/commands/noteQueries.d.ts +22 -5
- package/dist/editor/commands/noteQueries.js +34 -6
- package/dist/editor/commands/paragraphCommands.js +6 -1
- package/dist/editor/createEditor.js +14 -4
- package/dist/editor/documentStyles.d.ts +26 -4
- package/dist/editor/documentStyles.js +9 -4
- package/dist/editor/editorDocument.d.ts +7 -6
- package/dist/editor/editorDocument.js +18 -6
- package/dist/editor/imageFiles.d.ts +2 -2
- package/dist/editor/imageFiles.js +2 -0
- package/dist/editor/insertTable.d.ts +1 -1
- package/dist/editor/insertTable.js +2 -2
- package/dist/editor/paragraphEdits.d.ts +16 -1
- package/dist/editor/paragraphEdits.js +13 -5
- package/dist/editor/paragraphPlacement.d.ts +11 -0
- package/dist/editor/paragraphPlacement.js +18 -0
- package/dist/editor/plainText.d.ts +12 -0
- package/dist/editor/plainText.js +2 -1
- package/dist/editor/plugins/columnResize.js +6 -3
- package/dist/editor/plugins/commentComposer.d.ts +28 -0
- package/dist/editor/plugins/commentComposer.js +46 -0
- package/dist/editor/plugins/commentDecorations.d.ts +29 -2
- package/dist/editor/plugins/commentDecorations.js +89 -15
- package/dist/editor/plugins/documentProjection.d.ts +31 -0
- package/dist/editor/plugins/documentProjection.js +22 -0
- package/dist/editor/plugins/imagePaste.js +20 -10
- package/dist/editor/plugins/linkPanel.d.ts +7 -3
- package/dist/editor/plugins/linkPanel.js +13 -27
- package/dist/editor/plugins/numberingDecorations.d.ts +10 -4
- package/dist/editor/plugins/numberingDecorations.js +43 -2
- package/dist/editor/plugins/panelState.d.ts +67 -0
- package/dist/editor/plugins/panelState.js +54 -0
- package/dist/editor/plugins/paragraphDisplay.js +9 -3
- package/dist/editor/plugins/tableContextMenu.d.ts +1 -1
- package/dist/editor/plugins/tableContextMenu.js +30 -47
- package/dist/editor/plugins/tableDisplay.js +19 -5
- package/dist/editor/plugins/textContextMenu.d.ts +1 -1
- package/dist/editor/plugins/textContextMenu.js +30 -47
- package/dist/model/format.d.ts +50 -0
- package/dist/model/format.js +65 -0
- package/dist/numbering/listRegistry.d.ts +37 -0
- package/dist/numbering/listRegistry.js +112 -0
- package/dist/numbering/listTemplate.d.ts +26 -17
- package/dist/numbering/listTemplate.js +66 -20
- package/dist/numbering/markers.d.ts +15 -6
- package/dist/numbering/markers.js +26 -59
- package/dist/numbering/parseNumbering.d.ts +70 -5
- package/dist/numbering/parseNumbering.js +100 -26
- package/dist/numbering/spellers.d.ts +15 -0
- package/dist/numbering/spellers.js +96 -0
- package/dist/numbering/writeNumbering.d.ts +5 -3
- package/dist/numbering/writeNumbering.js +15 -15
- package/dist/ooxml/conformance.d.ts +28 -0
- package/dist/ooxml/conformance.js +20 -0
- package/dist/ooxml/errors.d.ts +5 -5
- package/dist/ooxml/fragment.d.ts +11 -0
- package/dist/ooxml/fragment.js +14 -4
- package/dist/ooxml/image.d.ts +3 -4
- package/dist/ooxml/image.js +50 -5
- package/dist/ooxml/names.d.ts +15 -0
- package/dist/ooxml/names.js +10 -1
- package/dist/ooxml/partSplice.d.ts +1 -1
- package/dist/ooxml/partSplice.js +10 -3
- package/dist/ooxml/props.d.ts +8 -0
- package/dist/ooxml/props.js +14 -4
- package/dist/ooxml/rangeMarkers.d.ts +5 -0
- package/dist/ooxml/rangeMarkers.js +24 -0
- package/dist/ooxml/xml.d.ts +8 -9
- package/dist/ooxml/xml.js +6 -6
- package/dist/page/PageGuides.d.ts +8 -4
- package/dist/page/PageGuides.js +13 -37
- package/dist/page/pageLayout.d.ts +62 -13
- package/dist/page/pageLayout.js +91 -37
- package/dist/page/usePageLayout.d.ts +14 -11
- package/dist/page/usePageLayout.js +21 -29
- package/dist/schema/attrRoles.js +44 -19
- package/dist/schema/docxSchema.d.ts +9 -1
- package/dist/schema/docxSchema.js +220 -139
- package/dist/schema/editGuard.d.ts +1 -1
- package/dist/schema/guards.js +2 -2
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/preservedFragments.d.ts +12 -0
- package/dist/schema/preservedFragments.js +38 -0
- package/dist/schema/preservedGuards.d.ts +9 -7
- package/dist/schema/preservedGuards.js +112 -11
- package/dist/schema/protection.d.ts +34 -5
- package/dist/schema/protection.js +42 -14
- package/dist/schema/rendering.js +3 -1
- package/dist/schema/stories.d.ts +49 -0
- package/dist/schema/stories.js +78 -0
- package/dist/styles/classNames.d.ts +16 -7
- package/dist/styles/classNames.js +16 -7
- package/dist/styles.css +90 -30
- package/dist/table/cellFormatting.js +1 -2
- package/dist/table/gridBorders.d.ts +11 -15
- package/dist/table/gridBorders.js +32 -18
- package/dist/table/resize.d.ts +5 -3
- package/dist/ui/CommentsPanel.d.ts +1 -3
- package/dist/ui/CommentsPanel.js +24 -15
- package/dist/ui/NotesPanel.js +2 -2
- package/dist/ui/TextMenu.d.ts +1 -3
- package/dist/ui/TextMenu.js +10 -6
- package/dist/ui/comments/CommentComposer.d.ts +6 -1
- package/dist/ui/comments/CommentComposer.js +26 -3
- package/package.json +1 -1
- package/dist/editor/externalClipboard.d.ts +0 -11
- package/dist/editor/externalClipboard.js +0 -456
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,210 @@
|
|
|
1
1
|
# @portone/docx-editor
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#105](https://github.com/portone-io/docx-editor/pull/105) [`efe7dbf`](https://github.com/portone-io/docx-editor/commit/efe7dbf6f2cb260ee912dbaed4c518c11b3527b7) Thanks [@Deea222](https://github.com/Deea222)! - Keep markup the editor cannot model where it stood, instead of standing the paragraph around it down.
|
|
8
|
+
|
|
9
|
+
Opening a document used to walk a handful of element names and give up on the rest, and giving up
|
|
10
|
+
travelled outward until a whole paragraph became an "Unsupported content" placeholder. A word
|
|
11
|
+
processor writes a `w:lastRenderedPageBreak` on every page it lays out, so a real document opened
|
|
12
|
+
with one locked paragraph per page.
|
|
13
|
+
|
|
14
|
+
Every level of the document now has a preservation rule of its own. A run child stays inside its
|
|
15
|
+
run, a paragraph child beside the runs, a block stays a block, and only a marker or a wrapper
|
|
16
|
+
standing between the rows or the cells of a table - where there is no node to keep it in - still
|
|
17
|
+
stands the table down. What is left shows as a small box naming the element it stands for, or as
|
|
18
|
+
nothing where the file drew nothing, and the paragraph around it stays editable.
|
|
19
|
+
|
|
20
|
+
- A field code and its drawn result, a tracked insertion or deletion, a symbol, a positional tab
|
|
21
|
+
and a content control the editor could not take apart are visible where they stand.
|
|
22
|
+
- Bookmarks, permission ranges, the markers of a moved passage and the pieces of a field cannot be
|
|
23
|
+
removed by an edit; a tracked-change container, a simple field and a symbol can be selected and
|
|
24
|
+
deleted whole.
|
|
25
|
+
- `documentFidelity` and the `notes` of `importDocx` now report `preserved-run-content`, and no
|
|
26
|
+
longer report `paragraph-demoted` for a document being opened.
|
|
27
|
+
- New node `rawRunContent`, and `rawInline` gains the attrs `element`, `display`, `text` and
|
|
28
|
+
`guarded`. A plugin reading the document model sees both.
|
|
29
|
+
- A footnote body, a comment body and a header now read a `w:cr` and a `w:noBreakHyphen` the way
|
|
30
|
+
the document body does.
|
|
31
|
+
|
|
32
|
+
- [#106](https://github.com/portone-io/docx-editor/pull/106) [`f2871cd`](https://github.com/portone-io/docx-editor/commit/f2871cd5535780c10574906c9dceb2b3ecc4715c) Thanks [@Deea222](https://github.com/Deea222)! - The comment composer keeps the text it was opened over while the document is edited elsewhere, and closes when that text is deleted or the mode turns read-only. The comment is written on that text rather than on whatever is selected when the writer submits.
|
|
33
|
+
|
|
34
|
+
Opening the composer no longer scrolls the document back to its first page.
|
|
35
|
+
|
|
36
|
+
`addComment` and `canAddComment` take an optional `{ from, to }` range as their last argument, which a composer of your own can hold across edits the same way; the current selection is still used when none is given.
|
|
37
|
+
|
|
38
|
+
- [#116](https://github.com/portone-io/docx-editor/pull/116) [`4d9964d`](https://github.com/portone-io/docx-editor/commit/4d9964d59ce66ce52dac06b86968b8ee20dc4f2d) Thanks [@Deea222](https://github.com/Deea222)! - Comment bodies keep their formatting when edited, and `setCommentBody` accepts a formatted body.
|
|
39
|
+
|
|
40
|
+
**Breaking:** the `commentReference` node loses its `text`, `commentXml` and `imported` attrs and
|
|
41
|
+
the `noteReference` node loses its `text` attr, together with the `data-comment-text`,
|
|
42
|
+
`data-comment-xml`, `data-comment-imported` and `data-note-text` attributes that carried them into
|
|
43
|
+
the DOM. A plugin that matched any of those reads what a comment or a note says through
|
|
44
|
+
`documentComments` and `documentNotes` instead, which answer as they always did.
|
|
45
|
+
|
|
46
|
+
**Breaking:** `DocumentComment`, `DocumentCommentReply` and `DocumentNote` declare every field
|
|
47
|
+
`readonly`. They are the editor's own records, worked out once per edit and handed out rather than
|
|
48
|
+
copied, so a caller that was writing into one copies it first.
|
|
49
|
+
|
|
50
|
+
A side story - a comment's body, a footnote's - is now read the way the document body is: the same
|
|
51
|
+
block readers, the same verbatim slices, one document of the editor's own schema per story. It
|
|
52
|
+
stands on the document node under `doc.attrs.stories`, so an edit to it rides a transaction and
|
|
53
|
+
lands in the history, and everything the edit did not touch is written back as the bytes it arrived
|
|
54
|
+
as. Editing a comment used to flatten its body to plain text and rewrite it as one run, which lost
|
|
55
|
+
its bold, its paragraph style and its second paragraph.
|
|
56
|
+
|
|
57
|
+
`setCommentBody(id, body)` is a new command on `./commands`. It takes a `doc` node of `docxSchema`,
|
|
58
|
+
which is what a composer of your own builds a formatted body as; `updateComment(id, text)` stays
|
|
59
|
+
what it was for a body that is only text.
|
|
60
|
+
|
|
61
|
+
Dropping those attrs is what the story replaces them with: what a comment or a note says is no
|
|
62
|
+
longer written on the node marking where it stands, so nothing has to keep the two in step, a copy
|
|
63
|
+
of the node no longer carries the body along with it, and neither reaches the clipboard.
|
|
64
|
+
|
|
65
|
+
- [#108](https://github.com/portone-io/docx-editor/pull/108) [`d783e24`](https://github.com/portone-io/docx-editor/commit/d783e2485eaf6bbbacc3498202019ab053f4e7da) Thanks [@Deea222](https://github.com/Deea222)! - Keep a table whose markers stand between its rows or its cells, and stand every block the editor
|
|
66
|
+
cannot model as one kind of placeholder.
|
|
67
|
+
|
|
68
|
+
**Breaking:** the `docxRaw` and `bookmarkBlock` node types no longer exist. Both were placeholders
|
|
69
|
+
for a block nobody could read, differing only in where the block stood and whether anything of it
|
|
70
|
+
was drawn, and `rawBlock` is now the one node for all of them. A plugin that matched either name
|
|
71
|
+
matches `rawBlock` instead and reads `display` (`"chip"` for a placeholder box, `"hidden"` for a
|
|
72
|
+
marker that draws nothing) and `guarded` to tell them apart. The class names
|
|
73
|
+
`docx-editor-bookmark-block`, `docx-editor-raw-xml` and `docx-editor-table` are gone with them;
|
|
74
|
+
every placeholder now draws as `docx-editor-raw-block`.
|
|
75
|
+
|
|
76
|
+
- A bookmark spanning a table column stands under the row rather than inside a cell, and used to
|
|
77
|
+
cost the whole table its structure. Such a table now opens as a table, and the marker goes back
|
|
78
|
+
exactly where it stood. A marker following a cell that only continues a vertical merge is the
|
|
79
|
+
remaining exception, since that cell is created fresh on export.
|
|
80
|
+
- `documentFidelity` and the `notes` of `importDocx` no longer report `table-demoted` for a table
|
|
81
|
+
whose only unread markup is a marker.
|
|
82
|
+
- A placeholder can now be moved between the body and a table cell and still export.
|
|
83
|
+
- `table` and `tableRow` gain a `leadingXml` attr, `tableRow` and `tableCell` a `trailingXml` attr:
|
|
84
|
+
the markers each carries between its children.
|
|
85
|
+
|
|
86
|
+
Table markers remain protected against deletion, duplication and reordering, including markers
|
|
87
|
+
whose ranges cross into a cell paragraph. Export checks read those fragments in document order.
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- [#109](https://github.com/portone-io/docx-editor/pull/109) [`05e9431`](https://github.com/portone-io/docx-editor/commit/05e9431c5ba773fa9f751860cbf34760b191d91a) Thanks [@Deea222](https://github.com/Deea222)! - Cache comment and note lists between document edits. Public readers continue to return independent comment, reply, and note records, so changes to their results cannot alter the editor's cached data.
|
|
92
|
+
|
|
93
|
+
- [#118](https://github.com/portone-io/docx-editor/pull/118) [`7de8870`](https://github.com/portone-io/docx-editor/commit/7de8870596bf4b311ab4b9fe4f19fb1291d37dbb) Thanks [@Deea222](https://github.com/Deea222)! - Every section now previews the headers and footers it names. A document whose second section
|
|
94
|
+
selects a header of its own used to draw the first section's on every page, because only the first
|
|
95
|
+
section's references were ever resolved.
|
|
96
|
+
|
|
97
|
+
A header and a footer body is read the way the document body is: the same block readers, the same
|
|
98
|
+
verbatim slices, one story per part on the document node beside the comment and footnote stories.
|
|
99
|
+
The plain-text walker each of them used to have is gone, so a `w:cr`, a no-break hyphen and a field
|
|
100
|
+
read the same in a header as they do anywhere else, and a `PAGE` or `NUMPAGES` field is now found by
|
|
101
|
+
pairing the field characters it is written between rather than by scanning the text they surround.
|
|
102
|
+
|
|
103
|
+
A header story the editor rewrote is written back into its own part, around the two ends that part
|
|
104
|
+
arrived with, and every part nobody rewrote is repacked as the bytes it came as. Editing a header is
|
|
105
|
+
not offered in the editor yet; this is the model and the export path underneath it.
|
|
106
|
+
|
|
107
|
+
- [#115](https://github.com/portone-io/docx-editor/pull/115) [`9c5331d`](https://github.com/portone-io/docx-editor/commit/9c5331d543b3238f9859c60f5821e7b94fe52bba) Thanks [@Deea222](https://github.com/Deea222)! - Copying and pasting inside the same document now keeps what it was copied as: paragraph and character formatting, tabs, breaks, images, links, and whole tables, instead of the part an HTML reader could make out. Copying a grid of cells and pasting it over selected cells fills them in place. Comment markers, bookmarks, and note references are not copied, so cutting and pasting them back drops them. A pasted list whose numbering the document no longer defines is given a number that it does, keeping the bullets or numbers it was copied with; a list arriving from another document or application is renumbered by the reader that reads it. Content copied from another document, including a second editor on the same page, still comes in through that reader.
|
|
108
|
+
|
|
109
|
+
- [#119](https://github.com/portone-io/docx-editor/pull/119) [`9b4b3fc`](https://github.com/portone-io/docx-editor/commit/9b4b3fc72ca51b89adf81063ca7fb2fb2c126e3f) Thanks [@Deea222](https://github.com/Deea222)! - Page boundaries and table widths now follow the paper of the section a block sits in. A document
|
|
110
|
+
whose second section is landscape used to be paginated as though the whole of it were the first
|
|
111
|
+
section's portrait paper, and a table put in that section was divided into the upright body width
|
|
112
|
+
and could not be widened past it.
|
|
113
|
+
|
|
114
|
+
Each page is now as tall as the body its own section leaves, a section break starts a new page
|
|
115
|
+
unless it is marked continuous, and a table is fitted to the body width of the section it is
|
|
116
|
+
inserted or dragged in. An image pasted into a section is fitted to the height that section's paper
|
|
117
|
+
leaves. A page number still carries on across a section boundary rather than restarting where the
|
|
118
|
+
section asks.
|
|
119
|
+
|
|
120
|
+
One sheet is still drawn at one width, the first section's, because nothing draws two paper widths
|
|
121
|
+
on one sheet. A landscape section is therefore paginated on landscape pages but drawn on the
|
|
122
|
+
sheet's width, and a table wider than the sheet's body is drawn shrunk to fit it while the document
|
|
123
|
+
keeps the width it was given. An even-page or odd-page start is preserved and exported untouched
|
|
124
|
+
but drawn as an ordinary new page.
|
|
125
|
+
|
|
126
|
+
- [#110](https://github.com/portone-io/docx-editor/pull/110) [`272cd5c`](https://github.com/portone-io/docx-editor/commit/272cd5c55098ef4c62e352fc9837b3db807c1439) Thanks [@Deea222](https://github.com/Deea222)! - Keep a picture's extension lists intact when the image is resized.
|
|
127
|
+
|
|
128
|
+
A picture written by Word often carries extension lists - the small records a word processor
|
|
129
|
+
attaches to a picture to remember things the format has no field for, such as which application
|
|
130
|
+
created it or what resolution to keep it at. Resizing such an image used to overwrite the name of
|
|
131
|
+
any empty record with the image's new size, which left the document with content Word reads as
|
|
132
|
+
invalid. Only the two sizes an image is drawn from are rewritten now, and every extension record
|
|
133
|
+
goes back out exactly as it came in.
|
|
134
|
+
|
|
135
|
+
Size updates follow the picture’s own XML paths, so an extension’s nested transforms and size
|
|
136
|
+
records stay unchanged too. Size attributes retain their quoting and surrounding markup.
|
|
137
|
+
|
|
138
|
+
- [#112](https://github.com/portone-io/docx-editor/pull/112) [`0327d4d`](https://github.com/portone-io/docx-editor/commit/0327d4dabe1de5814d440bf21f89cf5e5d1308b9) Thanks [@Deea222](https://github.com/Deea222)! - Give a document's sections a model of their own. Every `w:sectPr` is now read once - its paper and
|
|
139
|
+
margins, the header and footer stories it selects, whether the first page differs, and the page
|
|
140
|
+
number it starts at - instead of being read twice by two readers that looked for it differently.
|
|
141
|
+
|
|
142
|
+
The section that closes the body rides on the document node as `sectPr` rather than in the
|
|
143
|
+
preserved tail. It is written straight back out, so an untouched document still exports byte for
|
|
144
|
+
byte, and a submission that rewrites the paper it is written on is refused by
|
|
145
|
+
`onlyCommentsChangedBy` as it was before.
|
|
146
|
+
|
|
147
|
+
Pressing Enter in the last paragraph of a section continues to leave the break on the later half,
|
|
148
|
+
now on the same reading of `w:pPr` the rest of the package uses.
|
|
149
|
+
|
|
150
|
+
- [#111](https://github.com/portone-io/docx-editor/pull/111) [`4357635`](https://github.com/portone-io/docx-editor/commit/435763591d456ec26f6466b5e69ecc226a20f743) Thanks [@Deea222](https://github.com/Deea222)! - Take a comment added to a document whose author shares your display name, instead of refusing the whole save.
|
|
151
|
+
A document an older Word wrote has no people part, so its comments name an author and nobody in particular.
|
|
152
|
+
Adding a comment under one of those names no longer records a person for it, which had handed the comments already there to whoever commented next, and `onlyCommentsChangedBy` now takes such a comment back rather than reading it as a forged author.
|
|
153
|
+
Every comment carrying a shared name, the new one included, stays everyone's to edit.
|
|
154
|
+
This also protects comments preserved outside the editable story: their authors are not assigned to a new commenter, and the verifier rejects a people record that would claim them.
|
|
155
|
+
|
|
156
|
+
- [#113](https://github.com/portone-io/docx-editor/pull/113) [`e61185e`](https://github.com/portone-io/docx-editor/commit/e61185e645b06ce5091e59b08c5926fcaf71da16) Thanks [@Deea222](https://github.com/Deea222)! - Pasting text over selected table cells now fills every selected cell instead of only the first. Pasting the clipboard's plain text (Ctrl/Cmd+Shift+V) ignores accompanying HTML and images. Right-click Paste passes the clipboard's HTML and text through the same handlers as Ctrl/Cmd+V, including image loading and text fallback. Unreadable clipboard content leaves the selection intact when there is no usable text fallback.
|
|
157
|
+
|
|
158
|
+
- [#117](https://github.com/portone-io/docx-editor/pull/117) [`faf4081`](https://github.com/portone-io/docx-editor/commit/faf4081b43cbfd111985b1aa124e0e90b4136fc9) Thanks [@Deea222](https://github.com/Deea222)! - A hyperlink whose text is already underlined, which is how a word processor writes one, is drawn with one line under it rather than two. The editor's own link line is still drawn under a link the document leaves unstyled.
|
|
159
|
+
|
|
160
|
+
- [#106](https://github.com/portone-io/docx-editor/pull/106) [`f2871cd`](https://github.com/portone-io/docx-editor/commit/f2871cd5535780c10574906c9dceb2b3ecc4715c) Thanks [@Deea222](https://github.com/Deea222)! - Reject invalid comment range positions without throwing or adding a comment at a rounded position.
|
|
161
|
+
|
|
162
|
+
## 0.4.0
|
|
163
|
+
|
|
164
|
+
### Minor Changes
|
|
165
|
+
|
|
166
|
+
- [#102](https://github.com/portone-io/docx-editor/pull/102) [`4258530`](https://github.com/portone-io/docx-editor/commit/4258530aaf391ba546a282f73dff7b45f7063829) Thanks [@Deea222](https://github.com/Deea222)! - Draw the table styles and list numbering a document defines, and let a document that never held a list take one.
|
|
167
|
+
|
|
168
|
+
A table style is now displayed part by part: the header row, the closing row, the first and last column, the corners and the banded rows take the shading, the lines and the text formatting the style dresses them with (`w:tblStylePr`), and `w:tblLook` decides which of those parts a table takes.
|
|
169
|
+
The bands are as many rows or columns wide as the style says (`w:tblStyleRowBandSize`, `w:tblStyleColBandSize`), and the header row and the closing row are not banded with the rest.
|
|
170
|
+
Text already in a cell follows its new position after a row edit, and the conditional-formatting markup a document arrived with goes back out untouched.
|
|
171
|
+
|
|
172
|
+
A list that takes its numbers from a numbering style now draws them.
|
|
173
|
+
Such a list holds no numbers of its own: it names a style (`w:numStyleLink`), the style names a list, and that list's definition is where the numbers are, which is how Word writes a list built from its gallery.
|
|
174
|
+
Alongside decimal, bullets, upper and lower letters and lower Roman numerals, a list may now count in upper Roman numerals, decimal numbers with a leading zero, Ganada, Korean digits and the Chinese counting system; a format past those is still shown with decimal numbers.
|
|
175
|
+
Each level is drawn the way it asks to be: where its counting starts over (`w:lvlRestart`), whether the numbers in its text are all spelled as decimals (`w:isLgl`), what stands between its number and the paragraph text (`w:suff`), and where the number sits in the room kept for it (`w:lvlJc`).
|
|
176
|
+
A marker is also drawn in the character formatting its own level writes down (`lvl/rPr`), so bold, italic, color, size and typeface reach the number and never the text of the paragraph it stands in front of.
|
|
177
|
+
All of this is read; the numbering part goes back out exactly as it arrived.
|
|
178
|
+
|
|
179
|
+
A new list no longer needs the document to have arrived with a numbering part.
|
|
180
|
+
The export writes `word/numbering.xml`, relates it from the main part and declares it in the content types, so a document that never held a list can take one; the list commands, which used to report that they did not apply in such a document, now do.
|
|
181
|
+
If an existing numbering relationship points to a missing part, the new definition is written at that location so the document can find the list when it is reopened.
|
|
182
|
+
|
|
183
|
+
A new or pasted list is exported with the definition it was started with, rather than a format inferred from its numbering IDs, and undo restores that registration along with the edit.
|
|
184
|
+
A list whose definition is missing or unsupported is refused as `unsupported-content`, and a package with no `[Content_Types].xml` for the new numbering part to be declared in is refused as `missing-content-types`; `exportProblems` reports either ahead of the write.
|
|
185
|
+
List and abstract definition IDs stay distinct in a document already using the largest safely representable integer, and a value that cannot be written faithfully is rejected rather than silently changed or discarded.
|
|
186
|
+
|
|
187
|
+
An ECMA-376 Strict package is refused with the new `unsupported-conformance` code, and a document whose main part root does not bind `w` to Transitional WordprocessingML is refused as `unsupported-content`.
|
|
188
|
+
Word saves neither by default, and both used to open far enough to fail later and obscurely: a Strict package as `missing-part`, and a document under another prefix as a `malformed-xml` about bookmarks on its first edit.
|
|
189
|
+
A write needing a prefix already bound to a different namespace is refused instead of silently giving new markup the wrong meaning, and a new hyperlink relationship attribute is checked for a declaration that shadows the root binding.
|
|
190
|
+
The comment and hyperlink writers now have the part's root declare the prefix they write under rather than declaring it on every element written, and editing an existing numbering or comment extension part that uses another prefix adds the writer's declaration at the root, so an untouched document still exports byte for byte and the exported XML stays readable.
|
|
191
|
+
|
|
192
|
+
`DocxImportErrorCode` gains `unsupported-conformance`.
|
|
193
|
+
`DocxExportErrorCode` loses `missing-numbering-part`, since nothing can reach it any more, and that is a compile error for a `switch` over the code written to be exhaustive; drop the branch.
|
|
194
|
+
`missing-content-types` now also covers the numbering part a new list is defined in.
|
|
195
|
+
On `./core`, `Numbering` gains `added`, and the new `NewList` and `NewListLevel` types describe the definitions the editor registered.
|
|
196
|
+
Level maps are read-only, and a registered definition carries a restart, legal numbering and a suffix, while marker run formatting and custom tab stops stay outside what can be registered.
|
|
197
|
+
|
|
198
|
+
### Patch Changes
|
|
199
|
+
|
|
200
|
+
- [#101](https://github.com/portone-io/docx-editor/pull/101) [`1b6c723`](https://github.com/portone-io/docx-editor/commit/1b6c723982eed9c10656d57aca1d496e6baad5ec) Thanks [@Deea222](https://github.com/Deea222)! - Stop drawing the page number on the corner of each page.
|
|
201
|
+
|
|
202
|
+
The page guides laid a small grey number inside the top right corner of every page, over the paper the text sits on.
|
|
203
|
+
It is gone, and the guides now draw the gaps between pages and the header and footer stories alone.
|
|
204
|
+
A document that prints its own page number through a `PAGE` field in a header or footer is unaffected: that number is the document's, not the editor's.
|
|
205
|
+
|
|
206
|
+
The `docx-editor-page-badge` class the number carried is no longer emitted, so a rule of your own written against it in the published stylesheet no longer matches anything.
|
|
207
|
+
|
|
3
208
|
## 0.3.0
|
|
4
209
|
|
|
5
210
|
### Minor Changes
|
package/assets/editor.png
CHANGED
|
Binary file
|
package/dist/DocxEditor.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { EditorView } from "prosemirror-view";
|
|
|
12
12
|
import { type CSSProperties, type ReactNode } from "react";
|
|
13
13
|
import { type DocxSource } from "./docx/importDocx";
|
|
14
14
|
import { type ExportProblem } from "./docx/invariants";
|
|
15
|
-
import {
|
|
15
|
+
import type { CommentAuthor } from "./editor/commands/commentCommands";
|
|
16
16
|
import { DocxImportError } from "./ooxml/errors";
|
|
17
17
|
import type { EditableComments } from "./schema/protection";
|
|
18
18
|
import type { FontFallbacks } from "./styles/fontStack";
|
package/dist/DocxEditor.js
CHANGED
|
@@ -9,22 +9,27 @@ import {
|
|
|
9
9
|
useState
|
|
10
10
|
} from "react";
|
|
11
11
|
import { exportDocx } from "./docx/exportDocx.js";
|
|
12
|
+
import { variantsFor } from "./docx/headersFooters.js";
|
|
12
13
|
import { importDocx } from "./docx/importDocx.js";
|
|
13
14
|
import { exportProblems } from "./docx/invariants.js";
|
|
14
|
-
import {
|
|
15
|
-
documentComments
|
|
16
|
-
} from "./editor/commands/commentCommands.js";
|
|
15
|
+
import { sectionIn, sectionsOf } from "./docx/sections.js";
|
|
17
16
|
import { activeLinkSpan } from "./editor/commands/linkCommands.js";
|
|
18
17
|
import { createEditorView, editorStateForSession } from "./editor/createEditor.js";
|
|
18
|
+
import {
|
|
19
|
+
closeCommentComposer,
|
|
20
|
+
isCommentComposerOpen
|
|
21
|
+
} from "./editor/plugins/commentComposer.js";
|
|
22
|
+
import { commentProjection } from "./editor/plugins/commentDecorations.js";
|
|
19
23
|
import { setProtection } from "./editor/plugins/documentProtection.js";
|
|
20
24
|
import { isLinkPanelOpen } from "./editor/plugins/linkPanel.js";
|
|
21
25
|
import { tableMenuAnchor } from "./editor/plugins/tableContextMenu.js";
|
|
22
26
|
import { textMenuAnchor } from "./editor/plugins/textContextMenu.js";
|
|
23
27
|
import { DocxImportError } from "./ooxml/errors.js";
|
|
24
28
|
import { PageGuides } from "./page/PageGuides.js";
|
|
25
|
-
import { A4_PAGE_PIXELS, pagePixels } from "./page/pageLayout.js";
|
|
29
|
+
import { A4_PAGE_PIXELS, pagePixels, sectionPixels } from "./page/pageLayout.js";
|
|
26
30
|
import { usePageLayout } from "./page/usePageLayout.js";
|
|
27
31
|
import { editingProtection, protectionOf } from "./schema/protectionState.js";
|
|
32
|
+
import { storyNodeOf } from "./schema/stories.js";
|
|
28
33
|
import { editorClassNames } from "./styles/classNames.js";
|
|
29
34
|
import { CommentsPanel } from "./ui/CommentsPanel.js";
|
|
30
35
|
import { LinkCard } from "./ui/LinkCard.js";
|
|
@@ -36,6 +41,9 @@ import { Toolbar } from "./ui/Toolbar.js";
|
|
|
36
41
|
import { useFitWidthZoom } from "./ui/useFitWidthZoom.js";
|
|
37
42
|
import { normalizeZoom } from "./ui/zoom.js";
|
|
38
43
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
44
|
+
function runOn(view, command) {
|
|
45
|
+
command(view.state, (transaction) => view.dispatch(transaction));
|
|
46
|
+
}
|
|
39
47
|
function affordancesOf(mode) {
|
|
40
48
|
switch (mode.kind) {
|
|
41
49
|
case "readOnly":
|
|
@@ -115,6 +123,7 @@ var IMPORT_REJECTION_REASON = {
|
|
|
115
123
|
"missing-part": "This document is missing the part that holds its body.",
|
|
116
124
|
"missing-body": "This document has no body.",
|
|
117
125
|
"malformed-xml": "The XML inside this document cannot be read.",
|
|
126
|
+
"unsupported-conformance": "This document is saved in a format this editor cannot open. Save it as a Word document and try again.",
|
|
118
127
|
"unsupported-content": "This document holds content that could not be kept as it is."
|
|
119
128
|
};
|
|
120
129
|
function ImportRejection({ error }) {
|
|
@@ -160,7 +169,6 @@ function DocxEditorSurface({
|
|
|
160
169
|
);
|
|
161
170
|
const viewRef = useRef(null);
|
|
162
171
|
const [live, setLive] = useState(null);
|
|
163
|
-
const [commentComposerOpen, setCommentComposerOpen] = useState(false);
|
|
164
172
|
const [commentsOpen, setCommentsOpen] = useState(false);
|
|
165
173
|
const [uncontrolledZoom, setUncontrolledZoom] = useState(
|
|
166
174
|
() => normalizeZoom(defaultZoom)
|
|
@@ -216,7 +224,6 @@ function DocxEditorSurface({
|
|
|
216
224
|
const authorId = author?.id ?? null;
|
|
217
225
|
const mounted = live !== null;
|
|
218
226
|
useLayoutEffect(() => {
|
|
219
|
-
if (protection === "readOnly") setCommentComposerOpen(false);
|
|
220
227
|
const view = viewRef.current;
|
|
221
228
|
if (!view || !mounted) return;
|
|
222
229
|
const held = protectionOf(view.state);
|
|
@@ -230,40 +237,58 @@ function DocxEditorSurface({
|
|
|
230
237
|
useImperativeHandle(ref, () => {
|
|
231
238
|
const view = viewRef.current;
|
|
232
239
|
if (!view || opened?.status !== "opened") return null;
|
|
233
|
-
const
|
|
240
|
+
const session2 = opened.session;
|
|
234
241
|
return {
|
|
235
242
|
view,
|
|
236
|
-
exportBytes: () => exportDocx(view.state.doc,
|
|
237
|
-
exportProblems: () => exportProblems(view.state.doc,
|
|
243
|
+
exportBytes: () => exportDocx(view.state.doc, session2),
|
|
244
|
+
exportProblems: () => exportProblems(view.state.doc, session2)
|
|
238
245
|
};
|
|
239
246
|
}, [opened]);
|
|
247
|
+
const doc = live?.state.doc ?? null;
|
|
248
|
+
const session = opened?.status === "opened" ? opened.session : null;
|
|
249
|
+
const sections = useMemo(
|
|
250
|
+
() => doc === null ? null : sectionsOf(doc),
|
|
251
|
+
[doc]
|
|
252
|
+
);
|
|
253
|
+
const sectionPapers = useMemo(
|
|
254
|
+
() => sections === null ? void 0 : sectionPixels(sections),
|
|
255
|
+
[sections]
|
|
256
|
+
);
|
|
240
257
|
const overlay = usePageLayout({
|
|
241
258
|
view: live?.view ?? null,
|
|
242
259
|
layer: layerRef,
|
|
243
260
|
enabled: showPageGuides,
|
|
244
261
|
revision: live?.state.doc,
|
|
245
|
-
|
|
262
|
+
sections: sectionPapers
|
|
246
263
|
});
|
|
264
|
+
const headersFootersFor = useMemo(() => {
|
|
265
|
+
if (doc === null || session === null || sections === null) return void 0;
|
|
266
|
+
const shown = sections.map(
|
|
267
|
+
(section) => variantsFor(
|
|
268
|
+
section,
|
|
269
|
+
session.headerFooterStories,
|
|
270
|
+
(key) => storyNodeOf(doc, key)
|
|
271
|
+
)
|
|
272
|
+
);
|
|
273
|
+
return (face) => shown[sectionIn(sections, doc, face.pos).index] ?? null;
|
|
274
|
+
}, [doc, session, sections]);
|
|
247
275
|
if (opened?.status === "rejected") {
|
|
248
276
|
return renderImportError ? renderImportError(opened.error) : /* @__PURE__ */ jsx(ImportRejection, { error: opened.error });
|
|
249
277
|
}
|
|
250
278
|
const bodyOpen = live !== null && editingProtection(live.state) === "none";
|
|
251
|
-
const commentsOpenToWrite = live !== null && editingProtection(live.state) !== "readOnly";
|
|
252
279
|
const textAnchor = live ? textMenuAnchor(live.state) : null;
|
|
253
280
|
const tableAnchor = live && !textAnchor ? tableMenuAnchor(live.state) : null;
|
|
254
281
|
const linkAtCursor = live && !live.view.composing && !isLinkPanelOpen(live.state) ? activeLinkSpan(live.state) : null;
|
|
255
|
-
const comments = live?.state === void 0 ? [] :
|
|
282
|
+
const comments = live?.state === void 0 ? [] : commentProjection.read(live.state).comments;
|
|
256
283
|
const hasUnresolvedComments = comments.some((comment) => !comment.resolved);
|
|
257
|
-
const
|
|
258
|
-
const showComments = live !== null && (commentsOpen ||
|
|
284
|
+
const composerOpen = live !== null && isCommentComposerOpen(live.state);
|
|
285
|
+
const showComments = live !== null && (commentsOpen || composerOpen || hasUnresolvedComments);
|
|
259
286
|
const commentsPanel = live && showComments && /* @__PURE__ */ jsx(
|
|
260
287
|
CommentsPanel,
|
|
261
288
|
{
|
|
262
289
|
view: live.view,
|
|
263
290
|
state: live.state,
|
|
264
|
-
composerOpen: effectiveComposerOpen,
|
|
265
291
|
author,
|
|
266
|
-
closeComposer: () => setCommentComposerOpen(false),
|
|
267
292
|
scrollContainer: rootRef.current,
|
|
268
293
|
allCommentsOpen: commentsOpen
|
|
269
294
|
}
|
|
@@ -283,10 +308,8 @@ function DocxEditorSurface({
|
|
|
283
308
|
presets,
|
|
284
309
|
commentsOpen,
|
|
285
310
|
onToggleComments: () => {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return !open;
|
|
289
|
-
});
|
|
311
|
+
if (commentsOpen) runOn(live.view, closeCommentComposer);
|
|
312
|
+
setCommentsOpen(!commentsOpen);
|
|
290
313
|
},
|
|
291
314
|
zoom: selectedZoom,
|
|
292
315
|
onZoomChange: changeZoom
|
|
@@ -322,7 +345,7 @@ function DocxEditorSurface({
|
|
|
322
345
|
PageGuides,
|
|
323
346
|
{
|
|
324
347
|
overlay,
|
|
325
|
-
|
|
348
|
+
headersFootersFor
|
|
326
349
|
}
|
|
327
350
|
),
|
|
328
351
|
live && opened?.status === "opened" && /* @__PURE__ */ jsx(NotesPanel, { state: live.state, pageWidth: page.pageWidth })
|
|
@@ -351,10 +374,7 @@ function DocxEditorSurface({
|
|
|
351
374
|
view: live.view,
|
|
352
375
|
state: live.state,
|
|
353
376
|
anchor: textAnchor,
|
|
354
|
-
allowLocking: locking
|
|
355
|
-
onAddComment: () => {
|
|
356
|
-
setCommentComposerOpen(true);
|
|
357
|
-
}
|
|
377
|
+
allowLocking: locking
|
|
358
378
|
}
|
|
359
379
|
),
|
|
360
380
|
live && tableAnchor && /* @__PURE__ */ jsx(
|
package/dist/core.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export type { DocxSession } from "./docx/session";
|
|
|
27
27
|
export { documentNumbering, documentPartPath } from "./docx/session";
|
|
28
28
|
export type { CellFormat, CellVerticalAlign, DocumentDefaults, HighlightName, LineSpacing, NumberingRef, ParagraphAlign, ParagraphFormat, RowFormat, RowHeight, RunFormat, TableFormat, TableWidth, TableWidthType, UnderlineKind, VerticalAlign, } from "./model/format";
|
|
29
29
|
export { toCellFormat, toParagraphFormat, toRowFormat, toRunFormat, toTableFormat, toTableWidth, } from "./model/format";
|
|
30
|
-
export type { LevelIndent, NumberFormat, Numbering, NumberingLevel, NumberingList, NumberingOptions, } from "./numbering/parseNumbering";
|
|
30
|
+
export type { LevelAlign, LevelIndent, LevelSuffix, NewList, NewListLevel, NumberFormat, Numbering, NumberingLevel, NumberingList, NumberingOptions, NumberingStyleLinks, ReadLevelRun, } from "./numbering/parseNumbering";
|
|
31
31
|
export { parseNumbering } from "./numbering/parseNumbering";
|
|
32
32
|
export type { DocxExportErrorCode, DocxImportErrorCode, } from "./ooxml/errors";
|
|
33
33
|
export { DocxExportError, DocxImportError } from "./ooxml/errors";
|
package/dist/docx/cloning.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/docx/cloning.ts
|
|
2
2
|
import { attrsText, withoutAttrs } from "../ooxml/element.js";
|
|
3
|
-
import { parseProps, renderProps, setChild } from "../ooxml/props.js";
|
|
4
3
|
import { parseAttrs } from "../ooxml/tagScan.js";
|
|
4
|
+
import { withoutSectionBreak } from "./sections.js";
|
|
5
5
|
var carried = (value) => value;
|
|
6
6
|
var defaulted = () => void 0;
|
|
7
7
|
var PARAGRAPH_ID_ATTRS = ["paraId", "textId"];
|
|
@@ -13,13 +13,8 @@ function withoutParagraphIds(value) {
|
|
|
13
13
|
if (kept.length === attrs.length) return value;
|
|
14
14
|
return kept.length === 0 ? null : attrsText(kept);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
const props = parseProps(value);
|
|
19
|
-
if (props === null) return value;
|
|
20
|
-
const without = setChild(props, "sectPr", null);
|
|
21
|
-
if (without.children.length === props.children.length) return value;
|
|
22
|
-
return renderProps(without) || null;
|
|
16
|
+
function droppingSectionBreak(value) {
|
|
17
|
+
return typeof value === "string" ? withoutSectionBreak(value) : value;
|
|
23
18
|
}
|
|
24
19
|
var INHERITED_CELL_ATTRS = ["tcAttrs", "tcPr", "tcW", "format"];
|
|
25
20
|
var INHERITED_ROW_ATTRS = ["trAttrs", "trPr", "format"];
|
|
@@ -48,7 +43,7 @@ var CLONE_POLICIES = {
|
|
|
48
43
|
// A paragraph-level `w:sectPr` ends the section it stands in, so it belongs to whichever
|
|
49
44
|
// paragraph ends up last in that section: the second half of a split, and no half of a copy,
|
|
50
45
|
// which is lifted out of the section it was taken from.
|
|
51
|
-
pPr: (value, side) => side === "after" ? value :
|
|
46
|
+
pPr: (value, side) => side === "after" ? value : droppingSectionBreak(value),
|
|
52
47
|
// What names the block this paragraph was opened from. Only the half still standing where
|
|
53
48
|
// that block stood may go on claiming it; `docx/exportDocx` writes the original bytes back
|
|
54
49
|
// for whatever claims one.
|
|
@@ -34,9 +34,11 @@ export type CommentOnlyVerdict = {
|
|
|
34
34
|
* has to read as it did, comments aside. Those three parts are read entry by entry instead
|
|
35
35
|
* (`./comments/policy`), since a comment edit is free to rewrite them and something has to say
|
|
36
36
|
* what it may have written there. A comment carrying no recorded identity is everyone's to
|
|
37
|
-
* edit here as it is in the editor (`schema/protection`)
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* edit here as it is in the editor (`schema/protection`). A comment that appeared carries this
|
|
38
|
+
* identity, or none under a name an original comment already carried unattributed, including a
|
|
39
|
+
* preserved comment outside the editable story. A file can claim any author, so an addition under
|
|
40
|
+
* any other name must carry the requester's identity. An identity already recorded is nobody's
|
|
41
|
+
* to rewrite, and a new identity cannot claim an original unattributed comment.
|
|
40
42
|
*
|
|
41
43
|
* `editableComments: "all"` judges the file of an editor opened for a moderator, where every
|
|
42
44
|
* comment was theirs to edit; an identity is nobody's to rewrite under either setting.
|
|
@@ -22,13 +22,38 @@ export declare const COMMENT_EX_ATTRIBUTES: ReadonlySet<string>;
|
|
|
22
22
|
* everything it writes.
|
|
23
23
|
*/
|
|
24
24
|
export declare function declarationWritten(attr: Attr): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether this element and everything inside it declares only namespaces this package writes.
|
|
27
|
+
*
|
|
28
|
+
* A declaration decides what every name under it means, so a block rebinding a prefix says one
|
|
29
|
+
* thing to this reader and another to Word, and is a place to put bytes nothing looks at.
|
|
30
|
+
*/
|
|
31
|
+
export declare function declarationsWritten(el: Element): boolean;
|
|
25
32
|
/**
|
|
26
33
|
* Whether the element carries no attribute outside this set, and declares no namespace outside
|
|
27
34
|
* what the writer declares.
|
|
28
35
|
*/
|
|
29
36
|
export declare function attributesWithin(el: Element, allowed: ReadonlySet<string>): boolean;
|
|
30
|
-
/**
|
|
31
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Whether the element holds elements and nothing else.
|
|
39
|
+
*
|
|
40
|
+
* The writer puts no whitespace, comment or stray text between the pieces of a body, so an entry
|
|
41
|
+
* carrying any is one it did not write, and a reading that passed over them would leave a place to
|
|
42
|
+
* put bytes nothing looks at.
|
|
43
|
+
*/
|
|
44
|
+
export declare function holdsElementsOnly(el: Element): boolean;
|
|
45
|
+
/** XML layout whitespace, which is the one text carrying no payload wherever it stands */
|
|
46
|
+
export declare function isLayoutText(node: Node): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the element holds elements and the whitespace a producer laid them out over.
|
|
49
|
+
*
|
|
50
|
+
* A block is sliced with the whitespace standing ahead of it (`docx/scan`), so the writer hands a
|
|
51
|
+
* block it left untouched back with the layout it arrived in, and an entry from a part written
|
|
52
|
+
* over several lines carries that layout between its blocks. Whitespace is the only text this
|
|
53
|
+
* passes over: a comment, a processing instruction or a stretch of real text is a place to put
|
|
54
|
+
* bytes nothing looks at, and none of them is anything the writer puts out.
|
|
55
|
+
*/
|
|
56
|
+
export declare function holdsElementsAndLayout(el: Element): boolean;
|
|
32
57
|
/**
|
|
33
58
|
* The paragraph a thread key belongs on, which is the last one of the body.
|
|
34
59
|
*
|
|
@@ -61,20 +86,12 @@ export declare function arrivedEntries(partXml: string | null): ReadonlyMap<stri
|
|
|
61
86
|
* declares it on its root along with the compatibility markup that goes with it (`./writing`).
|
|
62
87
|
*/
|
|
63
88
|
export declare function withThreadKey(commentXml: string, paraId: string, arrived: Element | null): string;
|
|
64
|
-
/**
|
|
65
|
-
* The text of a comment written in that shape, and null for an entry holding anything else: a
|
|
66
|
-
* field, a second run, markup a producer wrapped it in, an attribute this editor does not write.
|
|
67
|
-
*
|
|
68
|
-
* An entry that arrived and was not edited is compared as it stands rather than read here, so
|
|
69
|
-
* saying no to a shape this editor would not have written turns down only a rewrite.
|
|
70
|
-
*/
|
|
71
89
|
/** Whether this editor's writer could have put out this thread state */
|
|
72
90
|
export declare function wellFormedCommentExtension(entry: Element): boolean;
|
|
73
91
|
/** Whether this editor's writer could have put out this recorded identity */
|
|
74
92
|
export declare function wellFormedPerson(entry: Element): boolean;
|
|
75
93
|
/** The identity a recorded person stands for, and null for an entry recording none */
|
|
76
94
|
export declare function recordedIdentity(person: Element): string | null;
|
|
77
|
-
export declare function readStrictCommentBody(comment: Element): string | null;
|
|
78
95
|
/** The thread state of one comment, as this editor writes it into the extended part */
|
|
79
96
|
export declare function renderCommentExtension(comment: CommentReferenceData | CommentReplyData): string;
|
|
80
97
|
/**
|