@portone/docx-editor 0.1.1 → 0.2.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +17 -5
  3. package/dist/DocxEditor.d.ts +34 -10
  4. package/dist/DocxEditor.js +69 -24
  5. package/dist/core.d.ts +2 -0
  6. package/dist/core.js +2 -0
  7. package/dist/docx/commentOnlyChange.d.ts +45 -0
  8. package/dist/docx/commentOnlyChange.js +145 -0
  9. package/dist/docx/comments/constants.d.ts +8 -0
  10. package/dist/docx/comments/constants.js +6 -0
  11. package/dist/docx/comments/contentTypes.d.ts +7 -0
  12. package/dist/docx/comments/contentTypes.js +38 -0
  13. package/dist/docx/comments/model.d.ts +2 -0
  14. package/dist/docx/comments/model.js +3 -0
  15. package/dist/docx/comments/people.d.ts +39 -0
  16. package/dist/docx/comments/people.js +198 -0
  17. package/dist/docx/comments/reading.d.ts +16 -1
  18. package/dist/docx/comments/reading.js +15 -5
  19. package/dist/docx/comments/writing.d.ts +4 -1
  20. package/dist/docx/comments/writing.js +12 -32
  21. package/dist/docx/importParagraph.js +1 -0
  22. package/dist/editor/commands/breakCommands.js +4 -1
  23. package/dist/editor/commands/canRunCommand.d.ts +3 -2
  24. package/dist/editor/commands/canRunCommand.js +1 -1
  25. package/dist/editor/commands/comments/editing.js +6 -4
  26. package/dist/editor/commands/comments/model.d.ts +9 -0
  27. package/dist/editor/commands/comments/reading.d.ts +7 -0
  28. package/dist/editor/commands/comments/reading.js +14 -0
  29. package/dist/editor/commands/formatting/editing.js +6 -1
  30. package/dist/editor/commands/historyCommands.js +14 -6
  31. package/dist/editor/commands/index.d.ts +7 -1
  32. package/dist/editor/commands/index.js +4 -0
  33. package/dist/editor/commands/linkCommands.js +2 -0
  34. package/dist/editor/commands/lockCommands.js +2 -0
  35. package/dist/editor/commands/tabCommands.js +2 -1
  36. package/dist/editor/createEditor.d.ts +13 -3
  37. package/dist/editor/createEditor.js +21 -7
  38. package/dist/editor/insertImage.js +4 -1
  39. package/dist/editor/insertTable.js +2 -1
  40. package/dist/editor/paragraphEdits.d.ts +2 -0
  41. package/dist/editor/paragraphEdits.js +2 -0
  42. package/dist/editor/plugins/documentProtection.d.ts +21 -0
  43. package/dist/editor/plugins/documentProtection.js +44 -0
  44. package/dist/editor/plugins/imagePaste.js +4 -1
  45. package/dist/editor/plugins/keymap.d.ts +11 -1
  46. package/dist/editor/plugins/keymap.js +24 -4
  47. package/dist/editor/plugins/lockedContent.d.ts +4 -2
  48. package/dist/editor/plugins/lockedContent.js +1 -1
  49. package/dist/editor/plugins/tableContextMenu.js +2 -1
  50. package/dist/editor/plugins/textContextMenu.js +6 -1
  51. package/dist/index.d.ts +2 -0
  52. package/dist/schema/docxSchema.js +5 -0
  53. package/dist/schema/locks.d.ts +31 -3
  54. package/dist/schema/locks.js +54 -3
  55. package/dist/schema/protection.d.ts +77 -0
  56. package/dist/schema/protection.js +170 -0
  57. package/dist/schema/protectionState.d.ts +20 -0
  58. package/dist/schema/protectionState.js +37 -0
  59. package/dist/table/cellFormatting.js +3 -1
  60. package/dist/table/commands.js +1 -1
  61. package/dist/table/merge.js +2 -2
  62. package/dist/ui/CommentsPanel.d.ts +3 -3
  63. package/dist/ui/CommentsPanel.js +26 -18
  64. package/dist/ui/LinkCard.d.ts +1 -2
  65. package/dist/ui/LinkCard.js +3 -4
  66. package/dist/ui/TextMenu.js +15 -10
  67. package/package.json +2 -2
@@ -7,6 +7,5 @@ export interface LinkCardProps {
7
7
  view: EditorView;
8
8
  state: EditorState;
9
9
  link: ActiveLinkSpan;
10
- readOnly?: boolean;
11
10
  }
12
- export declare function LinkCard({ view, state, link, readOnly, }: LinkCardProps): ReactElement | null;
11
+ export declare function LinkCard({ view, state, link, }: LinkCardProps): ReactElement | null;
@@ -49,8 +49,7 @@ function useEscape(onEscape) {
49
49
  function LinkCard({
50
50
  view,
51
51
  state,
52
- link,
53
- readOnly = false
52
+ link
54
53
  }) {
55
54
  const box = useRef(null);
56
55
  const [hidden, setHidden] = useState(false);
@@ -94,7 +93,7 @@ function LinkCard({
94
93
  children: /* @__PURE__ */ jsx(ExternalLink, { size: ICON_SIZE, "aria-hidden": "true" })
95
94
  }
96
95
  ),
97
- !readOnly && openLinkPanel(state) && /* @__PURE__ */ jsx(
96
+ openLinkPanel(state) && /* @__PURE__ */ jsx(
98
97
  "button",
99
98
  {
100
99
  type: "button",
@@ -106,7 +105,7 @@ function LinkCard({
106
105
  children: /* @__PURE__ */ jsx(Pencil, { size: ICON_SIZE, "aria-hidden": "true" })
107
106
  }
108
107
  ),
109
- !readOnly && removeLink(state) && /* @__PURE__ */ jsx(
108
+ removeLink(state) && /* @__PURE__ */ jsx(
110
109
  "button",
111
110
  {
112
111
  type: "button",
@@ -21,6 +21,7 @@ import { insertClipboardData } from "../editor/externalClipboard.js";
21
21
  import {
22
22
  closeTextMenu
23
23
  } from "../editor/plugins/textContextMenu.js";
24
+ import { editsShut } from "../schema/protectionState.js";
24
25
  import { editorClassNames } from "../styles/classNames.js";
25
26
  import { usePanelAtPoint } from "./panelPlacement.js";
26
27
  import { commandRunner } from "./runCommand.js";
@@ -103,8 +104,16 @@ function TextMenu({
103
104
  const keys = useMenuKeyboard({ menu: box, onClose: close });
104
105
  const selected = !state.selection.empty;
105
106
  const shut = selectionTouchesLocked(state);
107
+ const bodyOpen = !editsShut(state);
108
+ const copy = {
109
+ label: "Copy",
110
+ icon: Copy,
111
+ hint: `${MOD}C`,
112
+ enabled: selected,
113
+ run: () => clipboardCommand(view, "copy")
114
+ };
106
115
  const groups = [
107
- [
116
+ bodyOpen ? [
108
117
  {
109
118
  label: "Cut",
110
119
  icon: Scissors,
@@ -112,13 +121,7 @@ function TextMenu({
112
121
  enabled: selected && !shut,
113
122
  run: () => clipboardCommand(view, "cut")
114
123
  },
115
- {
116
- label: "Copy",
117
- icon: Copy,
118
- hint: `${MOD}C`,
119
- enabled: selected,
120
- run: () => clipboardCommand(view, "copy")
121
- },
124
+ copy,
122
125
  {
123
126
  label: "Paste",
124
127
  icon: ClipboardPaste,
@@ -134,7 +137,7 @@ function TextMenu({
134
137
  enabled: selected && !shut,
135
138
  run: () => run(deleteSelection)
136
139
  }
137
- ]
140
+ ] : [copy]
138
141
  ];
139
142
  groups.push([
140
143
  {
@@ -144,7 +147,9 @@ function TextMenu({
144
147
  run: () => onAddComment?.()
145
148
  }
146
149
  ]);
147
- if (allowLocking) groups.push([lockItem(selectionLock(state), run)]);
150
+ if (allowLocking && bodyOpen) {
151
+ groups.push([lockItem(selectionLock(state), run)]);
152
+ }
148
153
  const choose = (item) => {
149
154
  if (!item.enabled) return;
150
155
  item.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@portone/docx-editor",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A simple DOCX editor for React, built directly on OOXML.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -79,7 +79,7 @@
79
79
  "@playwright/test": "^1.62.1",
80
80
  "@types/node": "^26.2.0",
81
81
  "@types/react": "19.2.18",
82
- "@types/react-dom": "19.2.4",
82
+ "@types/react-dom": "19.2.5",
83
83
  "@vitejs/plugin-react": "^6.0.5",
84
84
  "esbuild": "^0.28.1",
85
85
  "jsdom": "^30.0.1",