@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
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { docxSchema } from "../../../schema/index.js";
|
|
13
13
|
import { editShut, openStretches } from "../../../schema/guards.js";
|
|
14
14
|
import { documentFormatting } from "../../documentStyles.js";
|
|
15
|
+
import { paragraphPlacementAt } from "../../paragraphPlacement.js";
|
|
15
16
|
import {
|
|
16
17
|
activePieces,
|
|
17
18
|
caretPiece,
|
|
@@ -21,7 +22,11 @@ import {
|
|
|
21
22
|
function editedMark(state, target, edit) {
|
|
22
23
|
const context = documentFormatting(state);
|
|
23
24
|
const rPr = text(target.mark?.attrs.rPr);
|
|
24
|
-
const paragraph = resolveParagraph(
|
|
25
|
+
const paragraph = resolveParagraph(
|
|
26
|
+
target.pPr,
|
|
27
|
+
context,
|
|
28
|
+
paragraphPlacementAt(state.doc, target.from)
|
|
29
|
+
);
|
|
25
30
|
const next = editRunProps(
|
|
26
31
|
{ rPr, format: target.format },
|
|
27
32
|
inheritedRunFormat(rPr, paragraph, context),
|
|
@@ -56,8 +56,8 @@ export { insertLineBreak, insertPageBreak } from "./breakCommands";
|
|
|
56
56
|
* question takes are not exported anywhere.
|
|
57
57
|
*/
|
|
58
58
|
export { canRunCommand } from "./canRunCommand";
|
|
59
|
-
export type { CommentAuthor, DocumentComment, DocumentCommentReply, NewComment, } from "./commentCommands";
|
|
60
|
-
export { addComment, addCommentReply, canAddComment, canEditComment, documentComments, removeComment, removeCommentReply, selectComment, setCommentResolved, updateComment, updateCommentReply, } from "./commentCommands";
|
|
59
|
+
export type { CommentAuthor, CommentRange, DocumentComment, DocumentCommentReply, NewComment, } from "./commentCommands";
|
|
60
|
+
export { addComment, addCommentReply, canAddComment, canEditComment, documentComments, removeComment, removeCommentReply, selectComment, setCommentBody, setCommentResolved, updateComment, updateCommentReply, } from "./commentCommands";
|
|
61
61
|
/**
|
|
62
62
|
* Whether the document as it stands can be written back, and every reason it could not, each
|
|
63
63
|
* with the code `exportDocx` would throw it under. `canExport` is what an export control is
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
removeComment,
|
|
26
26
|
removeCommentReply,
|
|
27
27
|
selectComment,
|
|
28
|
+
setCommentBody,
|
|
28
29
|
setCommentResolved,
|
|
29
30
|
updateComment,
|
|
30
31
|
updateCommentReply
|
|
@@ -158,6 +159,7 @@ export {
|
|
|
158
159
|
selectComment,
|
|
159
160
|
selectionLock,
|
|
160
161
|
selectionTouchesLocked,
|
|
162
|
+
setCommentBody,
|
|
161
163
|
setCommentResolved,
|
|
162
164
|
setFontFamily,
|
|
163
165
|
setFontSize,
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* All they do is change a paragraph's place in a list (its numbering id and level).
|
|
5
5
|
* Editing the formatting fragments belongs to `docx/paraProps`, and the list's appearance
|
|
6
6
|
* belongs to `numbering/`.
|
|
7
|
-
*
|
|
7
|
+
* Starting a list records its definition on the document node in the same transaction, and the
|
|
8
|
+
* export writes that definition into numbering.xml.
|
|
8
9
|
*/
|
|
9
10
|
import type { Node as PMNode } from "prosemirror-model";
|
|
10
11
|
import type { Command, EditorState } from "prosemirror-state";
|
|
@@ -24,6 +25,8 @@ export declare function listLevelChange(numbering: Numbering, node: PMNode, delt
|
|
|
24
25
|
export declare const increaseListLevel: Command;
|
|
25
26
|
/** Moves a list item one level back up, which is not the paragraph's own indent. What Shift+Tab does */
|
|
26
27
|
export declare const decreaseListLevel: Command;
|
|
28
|
+
/** Every numbering id a paragraph of this document wears */
|
|
29
|
+
export declare function numIdsIn(doc: PMNode): Set<number>;
|
|
27
30
|
/**
|
|
28
31
|
* Takes the selected paragraphs out of the list.
|
|
29
32
|
* Only the hanging indentation the marker sat in goes with it; an indentation the paragraph had
|
|
@@ -31,8 +34,14 @@ export declare const decreaseListLevel: Command;
|
|
|
31
34
|
*/
|
|
32
35
|
export declare const removeFromList: Command;
|
|
33
36
|
/**
|
|
34
|
-
* The kind of list
|
|
35
|
-
*
|
|
37
|
+
* The kind of this list position, which the number format of its level decides.
|
|
38
|
+
* Null where nothing defines the list, which is a position whose kind cannot be told and so is
|
|
39
|
+
* neither of the two buttons.
|
|
40
|
+
*/
|
|
41
|
+
export declare function listKindOf(numbering: Numbering, ref: NumberingRef): ListKind | null;
|
|
42
|
+
/**
|
|
43
|
+
* The kind of list the selected paragraphs belong to. Null when they are not a list, when nothing
|
|
44
|
+
* defines the list they are in, or when the kinds are mixed.
|
|
36
45
|
* It reads the paragraphs a lock leaves open, the same ones `editParagraphs` writes to: counting a
|
|
37
46
|
* locked paragraph that stays out of the list would keep the answer mixed, so the button would make
|
|
38
47
|
* a list a second time instead of taking it off.
|
|
@@ -5,12 +5,18 @@ import {
|
|
|
5
5
|
} from "../../docx/paraProps.js";
|
|
6
6
|
import { toParagraphFormat } from "../../model/format.js";
|
|
7
7
|
import {
|
|
8
|
+
listsWorn,
|
|
9
|
+
NEW_LISTS_ATTR,
|
|
10
|
+
newListsValue
|
|
11
|
+
} from "../../numbering/listRegistry.js";
|
|
12
|
+
import {
|
|
13
|
+
allocateList,
|
|
8
14
|
listFor,
|
|
9
|
-
listKindOf,
|
|
10
15
|
MAX_ILVL,
|
|
11
|
-
|
|
16
|
+
templateList
|
|
12
17
|
} from "../../numbering/listTemplate.js";
|
|
13
18
|
import { docxSchema } from "../../schema/index.js";
|
|
19
|
+
import { documentFormatting } from "../documentStyles.js";
|
|
14
20
|
import {
|
|
15
21
|
editableParagraphs,
|
|
16
22
|
editParagraphs,
|
|
@@ -24,18 +30,25 @@ import {
|
|
|
24
30
|
function listRefOf(node) {
|
|
25
31
|
return toParagraphFormat(node.attrs.format)?.numbering ?? null;
|
|
26
32
|
}
|
|
27
|
-
function changeParagraphs(state, dispatch, plan
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
function changeParagraphs(state, dispatch, plan, extras = {
|
|
34
|
+
alongside: pruneLists(documentNumbering(state).added)
|
|
35
|
+
}) {
|
|
36
|
+
return editParagraphs(
|
|
37
|
+
state,
|
|
38
|
+
dispatch,
|
|
39
|
+
(node) => {
|
|
40
|
+
const change = plan(node);
|
|
41
|
+
return change && withListNumbering(paragraphPPr(node), change);
|
|
42
|
+
},
|
|
43
|
+
extras
|
|
44
|
+
);
|
|
32
45
|
}
|
|
33
46
|
function indentForLevel(numbering, node, ref) {
|
|
34
47
|
const format = toParagraphFormat(node.attrs.format);
|
|
35
48
|
if (format?.indentStartPt === void 0 && format?.indentLeftPt === void 0) {
|
|
36
49
|
return { kind: "keep" };
|
|
37
50
|
}
|
|
38
|
-
const indent = listFor(numbering, ref.numId)
|
|
51
|
+
const indent = listFor(numbering, ref.numId)?.levels.get(ref.ilvl)?.indent;
|
|
39
52
|
return indent ? { kind: "level", indent } : { kind: "keep" };
|
|
40
53
|
}
|
|
41
54
|
function listLevelChange(numbering, node, delta) {
|
|
@@ -58,24 +71,50 @@ function levelShift(delta) {
|
|
|
58
71
|
}
|
|
59
72
|
var increaseListLevel = levelShift(1);
|
|
60
73
|
var decreaseListLevel = levelShift(-1);
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
|
|
74
|
+
function numIdsIn(doc) {
|
|
75
|
+
const worn = /* @__PURE__ */ new Set();
|
|
76
|
+
doc.descendants((node) => {
|
|
64
77
|
if (node.type !== docxSchema.nodes.paragraph) return true;
|
|
65
78
|
const ref = listRefOf(node);
|
|
66
|
-
if (ref)
|
|
79
|
+
if (ref) worn.add(ref.numId);
|
|
67
80
|
return false;
|
|
68
81
|
});
|
|
69
|
-
return
|
|
82
|
+
return worn;
|
|
83
|
+
}
|
|
84
|
+
function recordLists(tr, lists) {
|
|
85
|
+
tr.setDocAttribute(
|
|
86
|
+
NEW_LISTS_ATTR,
|
|
87
|
+
newListsValue(listsWorn(lists, numIdsIn(tr.doc)))
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function pruneLists(lists) {
|
|
91
|
+
return (tr) => {
|
|
92
|
+
if (listsWorn(lists, numIdsIn(tr.doc)) !== lists) recordLists(tr, lists);
|
|
93
|
+
};
|
|
70
94
|
}
|
|
71
95
|
function startList(kind) {
|
|
72
96
|
return (state, dispatch) => {
|
|
73
97
|
if (!canStartNewList(state)) return false;
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
98
|
+
const started = allocateList(
|
|
99
|
+
documentNumbering(state),
|
|
100
|
+
numIdsIn(state.doc),
|
|
101
|
+
templateList(kind)
|
|
102
|
+
);
|
|
103
|
+
return changeParagraphs(
|
|
104
|
+
state,
|
|
105
|
+
dispatch,
|
|
106
|
+
(node) => ({
|
|
107
|
+
numbering: { numId: started.numId, ilvl: listRefOf(node)?.ilvl ?? 0 },
|
|
108
|
+
indent: { kind: "keep" }
|
|
109
|
+
}),
|
|
110
|
+
{
|
|
111
|
+
formatting: {
|
|
112
|
+
...documentFormatting(state),
|
|
113
|
+
numbering: started.numbering
|
|
114
|
+
},
|
|
115
|
+
alongside: (tr) => recordLists(tr, started.numbering.added)
|
|
116
|
+
}
|
|
117
|
+
);
|
|
79
118
|
};
|
|
80
119
|
}
|
|
81
120
|
var removeFromList = (state, dispatch) => changeParagraphs(
|
|
@@ -83,16 +122,16 @@ var removeFromList = (state, dispatch) => changeParagraphs(
|
|
|
83
122
|
dispatch,
|
|
84
123
|
(node) => listRefOf(node) ? { numbering: null, indent: { kind: "clearHanging" } } : null
|
|
85
124
|
);
|
|
86
|
-
function
|
|
87
|
-
const level = listFor(numbering, ref.numId)
|
|
88
|
-
if (!level) return
|
|
125
|
+
function listKindOf(numbering, ref) {
|
|
126
|
+
const level = listFor(numbering, ref.numId)?.levels.get(ref.ilvl);
|
|
127
|
+
if (!level) return null;
|
|
89
128
|
return level.format === "bullet" ? "bullet" : "numbered";
|
|
90
129
|
}
|
|
91
130
|
function activeListKind(state) {
|
|
92
131
|
const numbering = documentNumbering(state);
|
|
93
132
|
const kinds = editableParagraphs(state).map(({ node }) => {
|
|
94
133
|
const ref = listRefOf(node);
|
|
95
|
-
return ref === null ? null :
|
|
134
|
+
return ref === null ? null : listKindOf(numbering, ref);
|
|
96
135
|
});
|
|
97
136
|
const first = kinds[0] ?? null;
|
|
98
137
|
return kinds.every((kind) => kind === first) ? first : null;
|
|
@@ -107,14 +146,19 @@ function isInList(state) {
|
|
|
107
146
|
(spot) => listRefOf(spot.node) !== null
|
|
108
147
|
);
|
|
109
148
|
}
|
|
110
|
-
var leaveListAtLineStart = (state, dispatch) => editParagraphs(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
149
|
+
var leaveListAtLineStart = (state, dispatch) => editParagraphs(
|
|
150
|
+
state,
|
|
151
|
+
dispatch,
|
|
152
|
+
(node) => {
|
|
153
|
+
if (!listRefOf(node)) return null;
|
|
154
|
+
const unlisted = withListNumbering(paragraphPPr(node), {
|
|
155
|
+
numbering: null,
|
|
156
|
+
indent: { kind: "clearHanging" }
|
|
157
|
+
});
|
|
158
|
+
return unlisted && withLeftIndent(unlisted.pPr, 0);
|
|
159
|
+
},
|
|
160
|
+
{ alongside: pruneLists(documentNumbering(state).added) }
|
|
161
|
+
);
|
|
118
162
|
var leaveEmptyListItem = (state, dispatch) => {
|
|
119
163
|
const { empty, $from } = state.selection;
|
|
120
164
|
const paragraph = $from.parent;
|
|
@@ -130,8 +174,10 @@ export {
|
|
|
130
174
|
increaseListLevel,
|
|
131
175
|
isInList,
|
|
132
176
|
leaveEmptyListItem,
|
|
177
|
+
listKindOf,
|
|
133
178
|
listLevelChange,
|
|
134
179
|
listRefOf,
|
|
180
|
+
numIdsIn,
|
|
135
181
|
removeFromList,
|
|
136
182
|
toggleBulletList,
|
|
137
183
|
toggleNumberedList
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
/** Document-level readers for imported footnotes and endnotes. */
|
|
2
2
|
import type { EditorState } from "prosemirror-state";
|
|
3
|
+
import { DecorationSet } from "prosemirror-view";
|
|
3
4
|
import type { NoteKind } from "../../docx/notes";
|
|
4
5
|
export interface DocumentNote {
|
|
5
|
-
kind: NoteKind;
|
|
6
|
-
id: string;
|
|
7
|
-
label: string;
|
|
8
|
-
text: string;
|
|
9
|
-
referencePos: number;
|
|
6
|
+
readonly kind: NoteKind;
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
readonly referencePos: number;
|
|
10
11
|
}
|
|
12
|
+
interface NoteProjection {
|
|
13
|
+
notes: readonly DocumentNote[];
|
|
14
|
+
/**
|
|
15
|
+
* The body of each note on the marker pointing at it, which is the tooltip a reader gets without
|
|
16
|
+
* looking away from the line. It is drawn rather than written on the node, because what a note
|
|
17
|
+
* says is a story on the document and not an attr of the reference.
|
|
18
|
+
*/
|
|
19
|
+
tooltips: DecorationSet;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Which notes the document refers to is the document's to decide, so the list is worked out once
|
|
23
|
+
* per edit (`editor/plugins/documentProjection`) rather than once per render of the panel under
|
|
24
|
+
* the page.
|
|
25
|
+
*/
|
|
26
|
+
export declare const noteProjection: import("../plugins/documentProjection").DocumentProjection<NoteProjection>;
|
|
11
27
|
/** The distinct notes referenced by the main document story, in first-reference order. */
|
|
12
28
|
export declare function documentNotes(state: EditorState): readonly DocumentNote[];
|
|
29
|
+
export {};
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
// src/editor/commands/noteQueries.ts
|
|
2
|
+
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
3
|
+
import { storyKey, storyOf, storyText } from "../../docx/story.js";
|
|
4
|
+
import { documentProjection } from "../plugins/documentProjection.js";
|
|
2
5
|
function stringAttr(value) {
|
|
3
6
|
return typeof value === "string" ? value : null;
|
|
4
7
|
}
|
|
5
|
-
function
|
|
8
|
+
function noteKindOf(node) {
|
|
9
|
+
return node.attrs.kind === "endnote" ? "endnote" : "footnote";
|
|
10
|
+
}
|
|
11
|
+
function noteText(doc, kind, id) {
|
|
12
|
+
return storyText(storyOf(doc, storyKey(kind, id)));
|
|
13
|
+
}
|
|
14
|
+
function deriveNotes(doc) {
|
|
6
15
|
const notes = [];
|
|
16
|
+
const tooltips = [];
|
|
7
17
|
const seen = /* @__PURE__ */ new Set();
|
|
8
|
-
|
|
18
|
+
doc.descendants((node, pos) => {
|
|
9
19
|
if (node.type.name !== "noteReference") return true;
|
|
10
20
|
const id = stringAttr(node.attrs.id);
|
|
11
21
|
if (id === null) return true;
|
|
12
|
-
const kind = node
|
|
22
|
+
const kind = noteKindOf(node);
|
|
23
|
+
const text = noteText(doc, kind, id);
|
|
24
|
+
if (text !== "") {
|
|
25
|
+
tooltips.push(Decoration.node(pos, pos + node.nodeSize, { title: text }));
|
|
26
|
+
}
|
|
13
27
|
const key = `${kind}:${id}`;
|
|
14
28
|
if (seen.has(key)) return true;
|
|
15
29
|
seen.add(key);
|
|
@@ -17,13 +31,27 @@ function documentNotes(state) {
|
|
|
17
31
|
kind,
|
|
18
32
|
id,
|
|
19
33
|
label: stringAttr(node.attrs.label) ?? "?",
|
|
20
|
-
text
|
|
34
|
+
text,
|
|
21
35
|
referencePos: pos
|
|
22
36
|
});
|
|
23
37
|
return true;
|
|
24
38
|
});
|
|
25
|
-
return notes;
|
|
39
|
+
return { notes, tooltips: DecorationSet.create(doc, tooltips) };
|
|
40
|
+
}
|
|
41
|
+
var noteProjection = documentProjection(
|
|
42
|
+
"docxEditorNotes",
|
|
43
|
+
deriveNotes,
|
|
44
|
+
{
|
|
45
|
+
// The set the last edit derived. Written as a method so that `this` is the plugin holding it
|
|
46
|
+
decorations(state) {
|
|
47
|
+
return this.getState(state)?.tooltips;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
function documentNotes(state) {
|
|
52
|
+
return noteProjection.read(state).notes;
|
|
26
53
|
}
|
|
27
54
|
export {
|
|
28
|
-
documentNotes
|
|
55
|
+
documentNotes,
|
|
56
|
+
noteProjection
|
|
29
57
|
};
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
paragraphPPr,
|
|
20
20
|
selectedParagraphs
|
|
21
21
|
} from "../paragraphEdits.js";
|
|
22
|
+
import { paragraphPlacementAt } from "../paragraphPlacement.js";
|
|
22
23
|
function alignOf(node) {
|
|
23
24
|
return toParagraphFormat(node.attrs.format)?.align ?? "left";
|
|
24
25
|
}
|
|
@@ -78,7 +79,11 @@ function setParagraphStyle(styleId) {
|
|
|
78
79
|
if (styleIdOf(pPr) === styleId) return [];
|
|
79
80
|
const props = withParagraphStyle(pPr, styleId);
|
|
80
81
|
if (!props) return [];
|
|
81
|
-
const paragraph = resolveParagraph(
|
|
82
|
+
const paragraph = resolveParagraph(
|
|
83
|
+
props.pPr,
|
|
84
|
+
context,
|
|
85
|
+
paragraphPlacementAt(state.doc, spot.pos)
|
|
86
|
+
);
|
|
82
87
|
return [
|
|
83
88
|
{
|
|
84
89
|
spot,
|
|
@@ -14,15 +14,17 @@ import {
|
|
|
14
14
|
DEFAULT_FONT_FALLBACKS
|
|
15
15
|
} from "../styles/fontStack.js";
|
|
16
16
|
import { documentDefaultsStyle } from "../styles/inlineStyle.js";
|
|
17
|
+
import { docxClipboard } from "./clipboard/plugin.js";
|
|
18
|
+
import { noteProjection } from "./commands/noteQueries.js";
|
|
17
19
|
import {
|
|
18
20
|
documentOf,
|
|
19
21
|
editorDocument,
|
|
20
22
|
editorDocumentOf,
|
|
21
23
|
NO_DOCUMENT
|
|
22
24
|
} from "./editorDocument.js";
|
|
23
|
-
import { externalClipboard } from "./externalClipboard.js";
|
|
24
25
|
import { imageFiles } from "./imageFiles.js";
|
|
25
26
|
import { columnResize } from "./plugins/columnResize.js";
|
|
27
|
+
import { commentComposer } from "./plugins/commentComposer.js";
|
|
26
28
|
import { commentDecorations } from "./plugins/commentDecorations.js";
|
|
27
29
|
import {
|
|
28
30
|
displayDerivation,
|
|
@@ -80,17 +82,22 @@ function createEditorState(doc, options = {}) {
|
|
|
80
82
|
// above, is what takes such a conversion back
|
|
81
83
|
listInputRules(),
|
|
82
84
|
dropCursor(),
|
|
83
|
-
//
|
|
85
|
+
// Images get the first reading. The clipboard then handles only empty readings and text
|
|
86
|
+
// fallbacks; tableEditing owns insertion into a cell selection for every nonempty slice.
|
|
84
87
|
imageFiles(),
|
|
85
88
|
imagePaste(),
|
|
86
|
-
|
|
89
|
+
docxClipboard(),
|
|
87
90
|
// A press that grabs a table edge must be intercepted before a cell-selection drag starts.
|
|
88
91
|
// For DOM events the plugin registered first wins, so both resizers precede `tableEditing`.
|
|
89
92
|
columnResize(),
|
|
90
93
|
rowResize(),
|
|
91
94
|
tableEditing(),
|
|
92
95
|
// Comment anchors live in the model; this paints their ranges without changing document XML.
|
|
96
|
+
// The list beside the page, the lookup the comment commands ask, and these ranges are the
|
|
97
|
+
// one walk this plugin holds (`plugins/commentDecorations`)
|
|
93
98
|
commentDecorations(),
|
|
99
|
+
// What the notes under the page are, worked out from the document the same way
|
|
100
|
+
noteProjection.plugin,
|
|
94
101
|
// Adjacent text tabs still need separate DOM ranges for layout and pointer selection.
|
|
95
102
|
tabDecorations(),
|
|
96
103
|
tabPointer(),
|
|
@@ -103,6 +110,9 @@ function createEditorState(doc, options = {}) {
|
|
|
103
110
|
// or fall together with the menus the editor draws. The text menu stands ahead of the table
|
|
104
111
|
// menu, and hands a click with nothing selected inside a cell back to it
|
|
105
112
|
...contextMenus ? [textContextMenu(), tableContextMenu()] : [],
|
|
113
|
+
// Holds the stretch of text the built-in comment composer was opened over. It reads the
|
|
114
|
+
// protection above it, so it stands after the plugin that holds one
|
|
115
|
+
commentComposer(),
|
|
106
116
|
numberingMarkers(),
|
|
107
117
|
// Values only go in when page display is turned on
|
|
108
118
|
pageDecorations()
|
|
@@ -112,7 +122,7 @@ function createEditorState(doc, options = {}) {
|
|
|
112
122
|
function editorStateForSession(opened, options = {}) {
|
|
113
123
|
return createEditorState(opened.doc, {
|
|
114
124
|
...options,
|
|
115
|
-
document: editorDocumentOf(opened.session)
|
|
125
|
+
document: editorDocumentOf(opened.session, opened.doc)
|
|
116
126
|
});
|
|
117
127
|
}
|
|
118
128
|
var sheetStyles = /* @__PURE__ */ new WeakMap();
|
|
@@ -19,10 +19,25 @@ export declare function documentDefaults(state: EditorState): DocumentDefaults;
|
|
|
19
19
|
/** The paragraph styles this document defines. Empty when the editor does not know them */
|
|
20
20
|
export declare function documentParagraphStyles(state: EditorState): ParagraphStyleOption[];
|
|
21
21
|
/**
|
|
22
|
-
* The paper the
|
|
23
|
-
* the
|
|
22
|
+
* The paper the sheet is drawn on: the first section's, since one sheet is drawn at one paper
|
|
23
|
+
* (`page/pageLayout`). A document the editor knows no paper for is drawn on the same A4 every
|
|
24
|
+
* document was drawn on before the geometry was read.
|
|
25
|
+
*
|
|
26
|
+
* Anything deciding a value for one spot in the document - the width of a table put there, the
|
|
27
|
+
* height a pasted image is fitted to - asks `sectionGeometryAt` instead, since a later section may
|
|
28
|
+
* be written on another paper.
|
|
24
29
|
*/
|
|
25
30
|
export declare function documentGeometry(state: EditorState): PageGeometry;
|
|
31
|
+
/**
|
|
32
|
+
* The paper the block at this position is written on: the paper of the section that block belongs
|
|
33
|
+
* to (`docx/sections`), which is the width a table inserted or resized there is fitted to.
|
|
34
|
+
*
|
|
35
|
+
* The section table is read off the document rather than off the snapshot the state carries: a
|
|
36
|
+
* section is where the document says it is, and the snapshot holds the first section's paper
|
|
37
|
+
* alone. Reading it walks every block, so a caller drawing a whole document asks once and looks
|
|
38
|
+
* its positions up (`page/pageLayout`) rather than calling this per block.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sectionGeometryAt(state: EditorState, pos: number): PageGeometry;
|
|
26
41
|
/** The document-wide interval between automatic tab stops, in points. */
|
|
27
42
|
export declare function documentDefaultTabStopPt(state: EditorState): number;
|
|
28
43
|
/**
|
|
@@ -32,5 +47,12 @@ export declare function documentDefaultTabStopPt(state: EditorState): number;
|
|
|
32
47
|
* itself asks for it rather than taking the A4 width `fittedExtent` falls back to.
|
|
33
48
|
*/
|
|
34
49
|
export declare function documentBodyWidthPx(state: EditorState): number;
|
|
35
|
-
/**
|
|
36
|
-
|
|
50
|
+
/**
|
|
51
|
+
* The height one page of body content occupies at this position, in pixels: the height the paper
|
|
52
|
+
* of the section that block sits in leaves.
|
|
53
|
+
*
|
|
54
|
+
* It is the height an image taller than the page is shrunk to when it is pasted there, so a tall
|
|
55
|
+
* image dropped into a section on shorter paper is fitted to that section rather than to the
|
|
56
|
+
* sheet's own.
|
|
57
|
+
*/
|
|
58
|
+
export declare function sectionBodyHeightPx(state: EditorState, pos: number): number;
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
bodyWidth,
|
|
5
5
|
twipsToPx
|
|
6
6
|
} from "../docx/pageGeometry.js";
|
|
7
|
+
import { sectionAt } from "../docx/sections.js";
|
|
7
8
|
import { documentOf } from "./editorDocument.js";
|
|
8
9
|
function documentFormatting(state) {
|
|
9
10
|
return documentOf(state).formatting;
|
|
@@ -17,21 +18,25 @@ function documentParagraphStyles(state) {
|
|
|
17
18
|
function documentGeometry(state) {
|
|
18
19
|
return documentOf(state).geometry;
|
|
19
20
|
}
|
|
21
|
+
function sectionGeometryAt(state, pos) {
|
|
22
|
+
return sectionAt(state.doc, pos).props.geometry;
|
|
23
|
+
}
|
|
20
24
|
function documentDefaultTabStopPt(state) {
|
|
21
25
|
return documentOf(state).defaultTabStopPt;
|
|
22
26
|
}
|
|
23
27
|
function documentBodyWidthPx(state) {
|
|
24
28
|
return bodyWidth(documentGeometry(state)).px;
|
|
25
29
|
}
|
|
26
|
-
function
|
|
27
|
-
return twipsToPx(bodyHeightTwips(
|
|
30
|
+
function sectionBodyHeightPx(state, pos) {
|
|
31
|
+
return twipsToPx(bodyHeightTwips(sectionGeometryAt(state, pos)));
|
|
28
32
|
}
|
|
29
33
|
export {
|
|
30
|
-
documentBodyHeightPx,
|
|
31
34
|
documentBodyWidthPx,
|
|
32
35
|
documentDefaultTabStopPt,
|
|
33
36
|
documentDefaults,
|
|
34
37
|
documentFormatting,
|
|
35
38
|
documentGeometry,
|
|
36
|
-
documentParagraphStyles
|
|
39
|
+
documentParagraphStyles,
|
|
40
|
+
sectionBodyHeightPx,
|
|
41
|
+
sectionGeometryAt
|
|
37
42
|
};
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* behalf, and `editorDocumentOf` is the one place a session is read into editor values: a screen
|
|
8
8
|
* and a test that open the same document hold the same values.
|
|
9
9
|
*/
|
|
10
|
+
import type { Node as PMNode } from "prosemirror-model";
|
|
10
11
|
import { type EditorState, Plugin } from "prosemirror-state";
|
|
11
12
|
import { type FormattingContext, type ParagraphStyleOption } from "../docx/formatting";
|
|
12
13
|
import { type PageGeometry } from "../docx/pageGeometry";
|
|
@@ -22,8 +23,8 @@ export interface EditorDocument {
|
|
|
22
23
|
/** The styles the document defines for the style picker to offer */
|
|
23
24
|
readonly paragraphStyles: ParagraphStyleOption[];
|
|
24
25
|
/**
|
|
25
|
-
* Whether the
|
|
26
|
-
* A state built without opening a document assumes
|
|
26
|
+
* Whether the definition of a new list has somewhere to go, which is what the commands that
|
|
27
|
+
* start one ask. A state built without opening a document assumes it has and behaves as every
|
|
27
28
|
* state did before the question was asked.
|
|
28
29
|
*/
|
|
29
30
|
readonly canStartNewList: boolean;
|
|
@@ -39,15 +40,15 @@ export interface EditorDocument {
|
|
|
39
40
|
/** What a state built without an opened document answers: the same as nothing being written down */
|
|
40
41
|
export declare const NO_DOCUMENT: EditorDocument;
|
|
41
42
|
/** The one place an opened document is read into the values the editor holds */
|
|
42
|
-
export declare function editorDocumentOf(session: SessionStore): EditorDocument;
|
|
43
|
+
export declare function editorDocumentOf(session: SessionStore, doc: PMNode): EditorDocument;
|
|
43
44
|
/** The document the state was built for. `NO_DOCUMENT` for a state built without one */
|
|
44
45
|
export declare function documentOf(state: EditorState): EditorDocument;
|
|
45
46
|
/**
|
|
46
47
|
* Holds the snapshot for the lifetime of the state.
|
|
47
48
|
*
|
|
48
|
-
* It is derived again only where a document-level edit could have been recorded
|
|
49
|
-
*
|
|
50
|
-
* cached against that identity.
|
|
49
|
+
* It is derived again only where a document-level edit could have been recorded - the attrs of the
|
|
50
|
+
* document node, which is where such an edit is written - so an ordinary edit and a selection move
|
|
51
|
+
* both leave the same object behind, allowing the sheet's style to be cached against that identity.
|
|
51
52
|
*/
|
|
52
53
|
export declare function editorDocument(document: EditorDocument): Plugin<EditorDocument>;
|
|
53
54
|
/** The comment ids the opened document already spent, which a new comment may not take */
|
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
NO_DOCUMENT_DEFAULTS,
|
|
6
6
|
NO_FORMATTING
|
|
7
7
|
} from "../docx/formatting.js";
|
|
8
|
+
import { canDefineNewList } from "../docx/newLists.js";
|
|
8
9
|
import { A4_PORTRAIT } from "../docx/pageGeometry.js";
|
|
10
|
+
import { NEW_LISTS_ATTR, newListsOf } from "../numbering/listRegistry.js";
|
|
9
11
|
var NO_IDS = /* @__PURE__ */ new Set();
|
|
10
12
|
var NO_PARAGRAPH_STYLES = [];
|
|
11
13
|
var NO_DOCUMENT = {
|
|
@@ -29,13 +31,20 @@ function reservedParaIds(session) {
|
|
|
29
31
|
}
|
|
30
32
|
return paraIds;
|
|
31
33
|
}
|
|
32
|
-
function
|
|
34
|
+
function formattingWithNewLists(formatting, doc) {
|
|
35
|
+
const added = newListsOf(doc.attrs[NEW_LISTS_ATTR]);
|
|
36
|
+
if (added.size === 0 && formatting.numbering.added.size === 0) {
|
|
37
|
+
return formatting;
|
|
38
|
+
}
|
|
39
|
+
return { ...formatting, numbering: { ...formatting.numbering, added } };
|
|
40
|
+
}
|
|
41
|
+
function editorDocumentOf(session, doc) {
|
|
33
42
|
return {
|
|
34
43
|
session,
|
|
35
|
-
formatting: session.formatting,
|
|
44
|
+
formatting: formattingWithNewLists(session.formatting, doc),
|
|
36
45
|
defaults: session.defaults,
|
|
37
46
|
paragraphStyles: session.paragraphStyles,
|
|
38
|
-
canStartNewList: session
|
|
47
|
+
canStartNewList: canDefineNewList(session),
|
|
39
48
|
geometry: session.geometry,
|
|
40
49
|
defaultTabStopPt: session.defaultTabStopPt,
|
|
41
50
|
reservedCommentIds: new Set(session.comments.byId.keys()),
|
|
@@ -46,15 +55,18 @@ var editorDocumentKey = new PluginKey("docxEditorDocument");
|
|
|
46
55
|
function documentOf(state) {
|
|
47
56
|
return editorDocumentKey.getState(state) ?? NO_DOCUMENT;
|
|
48
57
|
}
|
|
49
|
-
function
|
|
50
|
-
return
|
|
58
|
+
function derived(current, doc) {
|
|
59
|
+
return current.session === null ? {
|
|
60
|
+
...current,
|
|
61
|
+
formatting: formattingWithNewLists(current.formatting, doc)
|
|
62
|
+
} : editorDocumentOf(current.session, doc);
|
|
51
63
|
}
|
|
52
64
|
function editorDocument(document) {
|
|
53
65
|
return new Plugin({
|
|
54
66
|
key: editorDocumentKey,
|
|
55
67
|
state: {
|
|
56
68
|
init: () => document,
|
|
57
|
-
apply: (tr, current, old) =>
|
|
69
|
+
apply: (tr, current, old) => tr.doc.attrs === old.doc.attrs ? current : derived(current, tr.doc)
|
|
58
70
|
}
|
|
59
71
|
});
|
|
60
72
|
}
|
|
@@ -65,8 +65,8 @@ export declare function insertImageFiles(view: EditorView, files: readonly File[
|
|
|
65
65
|
/**
|
|
66
66
|
* The plugin that takes image files pasted or dropped onto the paper.
|
|
67
67
|
*
|
|
68
|
-
* It
|
|
69
|
-
*
|
|
68
|
+
* It runs before clipboard fallback and table insertion (see the order in `createEditor.ts`).
|
|
69
|
+
* A paste that chose plain text leaves any accompanying image file alone.
|
|
70
70
|
* An event carrying no image file is passed on untouched, so text keeps coming in exactly
|
|
71
71
|
* as it did.
|
|
72
72
|
*/
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
pxToEmu,
|
|
11
11
|
toImageSrc
|
|
12
12
|
} from "../ooxml/image.js";
|
|
13
|
+
import { plainTextPaste } from "./clipboard/parser.js";
|
|
13
14
|
import { documentBodyWidthPx } from "./documentStyles.js";
|
|
14
15
|
import { insertImage } from "./insertImage.js";
|
|
15
16
|
import { moveCaretToDrop } from "./plugins/dropCaret.js";
|
|
@@ -140,6 +141,7 @@ function imageFiles() {
|
|
|
140
141
|
return new Plugin({
|
|
141
142
|
props: {
|
|
142
143
|
handlePaste(view, event) {
|
|
144
|
+
if (plainTextPaste(view, event)) return false;
|
|
143
145
|
const files = imageFilesIn(event.clipboardData);
|
|
144
146
|
if (files.length === 0) return false;
|
|
145
147
|
void insertImageFiles(view, files);
|
|
@@ -13,6 +13,6 @@ export interface TableSize {
|
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Inserts a table of empty cells and moves the caret into the first cell.
|
|
16
|
-
* The table is as wide as one line of body text on the paper the
|
|
16
|
+
* The table is as wide as one line of body text on the paper of the section it goes into
|
|
17
17
|
*/
|
|
18
18
|
export declare function insertTable({ rows, columns }: TableSize): Command;
|