@beyondwork/docx-react-component 1.0.38 → 1.0.40

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 (85) hide show
  1. package/package.json +41 -31
  2. package/src/api/public-types.ts +305 -6
  3. package/src/core/commands/table-structure-commands.ts +31 -2
  4. package/src/core/commands/text-commands.ts +122 -2
  5. package/src/index.ts +9 -0
  6. package/src/io/docx-session.ts +1 -0
  7. package/src/io/export/serialize-numbering.ts +42 -8
  8. package/src/io/export/serialize-paragraph-formatting.ts +152 -0
  9. package/src/io/export/serialize-run-formatting.ts +90 -0
  10. package/src/io/export/serialize-styles.ts +212 -0
  11. package/src/io/ooxml/parse-fields.ts +10 -3
  12. package/src/io/ooxml/parse-numbering.ts +41 -1
  13. package/src/io/ooxml/parse-paragraph-formatting.ts +188 -0
  14. package/src/io/ooxml/parse-run-formatting.ts +129 -0
  15. package/src/io/ooxml/parse-styles.ts +31 -0
  16. package/src/io/ooxml/xml-attr-helpers.ts +60 -0
  17. package/src/io/ooxml/xml-element.ts +19 -0
  18. package/src/model/canonical-document.ts +83 -3
  19. package/src/runtime/collab/event-types.ts +165 -0
  20. package/src/runtime/collab/index.ts +22 -0
  21. package/src/runtime/collab/remote-cursor-awareness.ts +93 -0
  22. package/src/runtime/collab/runtime-collab-sync.ts +273 -0
  23. package/src/runtime/document-runtime.ts +141 -18
  24. package/src/runtime/layout/docx-font-loader.ts +30 -11
  25. package/src/runtime/layout/index.ts +2 -0
  26. package/src/runtime/layout/inert-layout-facet.ts +3 -0
  27. package/src/runtime/layout/layout-engine-instance.ts +69 -2
  28. package/src/runtime/layout/layout-invalidation.ts +14 -5
  29. package/src/runtime/layout/page-graph.ts +36 -0
  30. package/src/runtime/layout/paginate-paragraph-lines.ts +128 -0
  31. package/src/runtime/layout/paginated-layout-engine.ts +342 -28
  32. package/src/runtime/layout/project-block-fragments.ts +154 -20
  33. package/src/runtime/layout/public-facet.ts +81 -1
  34. package/src/runtime/layout/resolve-page-fields.ts +70 -0
  35. package/src/runtime/layout/resolve-page-previews.ts +185 -0
  36. package/src/runtime/layout/resolved-formatting-state.ts +30 -26
  37. package/src/runtime/layout/table-render-plan.ts +21 -1
  38. package/src/runtime/numbering-prefix.ts +5 -0
  39. package/src/runtime/paragraph-style-resolver.ts +194 -0
  40. package/src/runtime/render/render-kernel.ts +5 -1
  41. package/src/runtime/resolved-numbering-geometry.ts +9 -1
  42. package/src/runtime/surface-projection.ts +129 -9
  43. package/src/runtime/table-schema.ts +11 -0
  44. package/src/runtime/workflow-rail-segments.ts +149 -1
  45. package/src/ui/WordReviewEditor.tsx +302 -5
  46. package/src/ui/editor-command-bag.ts +4 -0
  47. package/src/ui/editor-runtime-boundary.ts +16 -0
  48. package/src/ui/editor-shell-view.tsx +22 -0
  49. package/src/ui/editor-surface-controller.tsx +9 -1
  50. package/src/ui/headless/chrome-registry.ts +34 -5
  51. package/src/ui/headless/scoped-chrome-policy.ts +29 -0
  52. package/src/ui-tailwind/chrome/review-queue-bar.tsx +2 -14
  53. package/src/ui-tailwind/chrome/role-action-sets.ts +14 -8
  54. package/src/ui-tailwind/chrome/tw-mode-dock.tsx +80 -0
  55. package/src/ui-tailwind/chrome/tw-selection-anchor-resolver.ts +7 -10
  56. package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +11 -0
  57. package/src/ui-tailwind/chrome/tw-selection-tool-structure.tsx +11 -0
  58. package/src/ui-tailwind/chrome/tw-table-border-picker.tsx +245 -0
  59. package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +101 -21
  60. package/src/ui-tailwind/chrome/tw-table-grip-layer.tsx +353 -0
  61. package/src/ui-tailwind/chrome-overlay/chrome-overlay-projector.ts +5 -1
  62. package/src/ui-tailwind/chrome-overlay/index.ts +2 -6
  63. package/src/ui-tailwind/chrome-overlay/tw-chrome-overlay.tsx +82 -18
  64. package/src/ui-tailwind/chrome-overlay/tw-scope-card-layer.tsx +133 -0
  65. package/src/ui-tailwind/chrome-overlay/tw-scope-card.tsx +386 -0
  66. package/src/ui-tailwind/chrome-overlay/tw-scope-rail-layer.tsx +140 -69
  67. package/src/ui-tailwind/editor-surface/page-slice-util.ts +15 -0
  68. package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +28 -3
  69. package/src/ui-tailwind/editor-surface/pm-decorations.ts +7 -2
  70. package/src/ui-tailwind/editor-surface/pm-page-break-decorations.ts +389 -0
  71. package/src/ui-tailwind/editor-surface/pm-schema.ts +40 -2
  72. package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +170 -63
  73. package/src/ui-tailwind/editor-surface/remote-cursor-plugin.ts +179 -0
  74. package/src/ui-tailwind/editor-surface/tw-page-block-view.tsx +559 -0
  75. package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +224 -78
  76. package/src/ui-tailwind/editor-surface/tw-table-bands.css +61 -0
  77. package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +19 -0
  78. package/src/ui-tailwind/index.ts +6 -5
  79. package/src/ui-tailwind/theme/editor-theme.css +108 -15
  80. package/src/ui-tailwind/toolbar/tw-role-action-region.tsx +122 -1
  81. package/src/ui-tailwind/toolbar/tw-toolbar.tsx +36 -3
  82. package/src/ui-tailwind/tw-review-workspace.tsx +207 -54
  83. package/src/runtime/collab-review-sync.ts +0 -254
  84. package/src/ui-tailwind/chrome-overlay/tw-workspace-view-switcher.tsx +0 -95
  85. package/src/ui-tailwind/editor-surface/pm-collab-plugins.ts +0 -40
@@ -1,95 +0,0 @@
1
- /**
2
- * TwWorkspaceViewSwitcher — floating dock that sits at the bottom of the
3
- * chrome overlay. Mirrors the "WORKFLOW VIEW" bottom bar in image copy.png.
4
- *
5
- * Per runtime-rendering-and-chrome-phase.md §6.3, the dock is a
6
- * `DraggableFloat`-compatible surface that lives inside the `ChromeOverlay`
7
- * plane. Today it ships the preset selector + the canonical workflow
8
- * actions (review / comment / approve) so consumers can wire them without
9
- * waiting for the full DraggableFloat primitive.
10
- */
11
-
12
- import * as React from "react";
13
-
14
- export type WorkspaceView = "draft" | "layout" | "review" | "workflow";
15
-
16
- export interface WorkspaceViewAction {
17
- id: string;
18
- label: string;
19
- icon: string;
20
- onClick?: () => void;
21
- disabled?: boolean;
22
- }
23
-
24
- export interface TwWorkspaceViewSwitcherProps {
25
- activeView: WorkspaceView;
26
- onViewChange?: (view: WorkspaceView) => void;
27
- actions?: readonly WorkspaceViewAction[];
28
- "data-testid"?: string;
29
- }
30
-
31
- const DEFAULT_VIEW_ORDER: readonly WorkspaceView[] = [
32
- "draft",
33
- "layout",
34
- "review",
35
- "workflow",
36
- ];
37
-
38
- const VIEW_LABELS: Record<WorkspaceView, string> = {
39
- draft: "DRAFT",
40
- layout: "LAYOUT",
41
- review: "REVIEW",
42
- workflow: "WORKFLOW VIEW",
43
- };
44
-
45
- export const TwWorkspaceViewSwitcher: React.FC<TwWorkspaceViewSwitcherProps> = ({
46
- activeView,
47
- onViewChange,
48
- actions,
49
- "data-testid": testId,
50
- }) => {
51
- return (
52
- <div
53
- className="wre-workspace-dock pointer-events-auto absolute left-1/2 bottom-6 z-10 -translate-x-1/2 flex items-center gap-2 rounded-full border border-border/70 bg-canvas/95 px-4 py-2 shadow-lg backdrop-blur"
54
- data-testid={testId ?? "workspace-view-switcher"}
55
- role="toolbar"
56
- aria-label="Workspace view"
57
- >
58
- {DEFAULT_VIEW_ORDER.map((view) => (
59
- <button
60
- key={view}
61
- type="button"
62
- className={`wre-workspace-dock-view-btn inline-flex items-center gap-1 rounded-full px-3 py-1 text-[11px] font-semibold uppercase tracking-[0.14em] ${
63
- view === activeView
64
- ? "wre-workspace-dock-view-btn-active bg-primary text-white"
65
- : "text-secondary hover:text-primary"
66
- }`}
67
- aria-pressed={view === activeView}
68
- onClick={onViewChange ? () => onViewChange(view) : undefined}
69
- disabled={!onViewChange}
70
- >
71
- <span aria-hidden="true" className="wre-workspace-dock-icon h-3 w-3" />
72
- {VIEW_LABELS[view]}
73
- </button>
74
- ))}
75
- {actions && actions.length > 0 ? (
76
- <div className="wre-workspace-dock-sep mx-1 h-5 w-px bg-border" />
77
- ) : null}
78
- {actions?.map((action) => (
79
- <button
80
- key={action.id}
81
- type="button"
82
- className="wre-workspace-dock-action inline-flex h-7 w-7 items-center justify-center rounded-full text-secondary hover:bg-surface hover:text-primary disabled:opacity-40"
83
- aria-label={action.label}
84
- disabled={action.disabled}
85
- onClick={action.onClick}
86
- data-action-id={action.id}
87
- >
88
- <span aria-hidden="true" className={`wre-workspace-dock-icon wre-workspace-dock-icon-${action.icon}`} />
89
- </button>
90
- ))}
91
- </div>
92
- );
93
- };
94
-
95
- export default TwWorkspaceViewSwitcher;
@@ -1,40 +0,0 @@
1
- import { type Plugin } from "prosemirror-state";
2
- import { keymap } from "prosemirror-keymap";
3
- import { columnResizing, tableEditing } from "prosemirror-tables";
4
- import { yCursorPlugin, ySyncPlugin, yUndoPlugin, undo, redo } from "y-prosemirror";
5
- import type { Awareness } from "y-protocols/awareness";
6
- import type { Doc as YDoc } from "yjs";
7
-
8
- import {
9
- createSelectionSyncPlugin,
10
- type SelectionSyncCallbacks,
11
- } from "./pm-command-bridge";
12
-
13
- export interface CollabPluginOptions {
14
- ydoc: YDoc;
15
- awareness?: Awareness;
16
- selectionCallbacks: SelectionSyncCallbacks;
17
- }
18
-
19
- export function createCollabPlugins(options: CollabPluginOptions): Plugin[] {
20
- const yXmlFragment = options.ydoc.getXmlFragment("prosemirror");
21
-
22
- const plugins: Plugin[] = [
23
- ySyncPlugin(yXmlFragment),
24
- yUndoPlugin(),
25
- keymap({
26
- "Mod-z": undo,
27
- "Mod-y": redo,
28
- "Shift-Mod-z": redo,
29
- }),
30
- createSelectionSyncPlugin(options.selectionCallbacks),
31
- tableEditing(),
32
- columnResizing(),
33
- ];
34
-
35
- if (options.awareness) {
36
- plugins.splice(1, 0, yCursorPlugin(options.awareness));
37
- }
38
-
39
- return plugins;
40
- }