@richhtmleditor/workflows 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # @richhtmleditor/workflows
2
+
3
+ Enterprise approval workflows plugin for Rich HTML Editor. Draft, in-review, changes-requested, approved, and published states with role-based editing permissions, track-changes tools, audit trail, and workflow bar — requires `features.workflows` from [`@richhtmleditor/enterprise`](https://www.npmjs.com/package/@richhtmleditor/enterprise), built on [`@richhtmleditor/core`](https://www.npmjs.com/package/@richhtmleditor/core).
4
+
5
+ **Current release: 1.0.0** — Depends on `@richhtmleditor/core` **^1.0.0**.
6
+
7
+ **Repository:** [github.com/rajkishorsahu89/richhtmleditor](https://github.com/rajkishorsahu89/richhtmleditor)
8
+
9
+ **Demo:** [richhtmleditor.vercel.app](https://richhtmleditor.vercel.app/) — [demo](https://richhtmleditor.vercel.app/demo) · [guide](https://richhtmleditor.vercel.app/guide) · [API](https://richhtmleditor.vercel.app/api). Doc Preview joint demo: [doc-preview-app.vercel.app/demo/enterprise](https://doc-preview-app.vercel.app/demo/enterprise)
10
+
11
+ ### What's in 1.0.0
12
+
13
+ - **`createWorkflowsPlugin`** — workflow toolbar row and status bar
14
+ - **Document states** — `draft` → `in_review` → `approved` → `published` (with `changes_requested`)
15
+ - **Role-based permissions** — viewer, commenter, editor, approver, publisher
16
+ - **Track changes** — mark deletion, accept/reject selection, accept/reject all
17
+ - **Audit trail** — transitions recorded in document metadata and workflow bar
18
+ - **`getWorkflowsHandle`** — programmatic access to role and snapshot
19
+ - **`exportImmutableAudit`** — export tamper-evident audit log
20
+
21
+ > Requires `features.workflows: true`. Demo key: `RHE-ENT-DEMO-2026-FULL`. Pairs with `editor.exportForPreview()` for workflow watermarks.
22
+
23
+ **Keywords:** `richhtmleditor` `enterprise` `workflow` `approval` `track-changes` `permissions`
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ npm install @richhtmleditor/workflows @richhtmleditor/enterprise
29
+ # Requires @richhtmleditor/core (via framework wrapper or direct install).
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ```ts
35
+ import { createEditor } from "@richhtmleditor/core";
36
+ import { createWorkflowsPlugin, getWorkflowsHandle } from "@richhtmleditor/workflows";
37
+ import { resolveEnterpriseFeatures } from "@richhtmleditor/enterprise/browser";
38
+
39
+ const gate = resolveEnterpriseFeatures({ token: "RHE-ENT-DEMO-2026-FULL" });
40
+
41
+ const editor = createEditor({
42
+ element: host,
43
+ toolbar: { preset: "full" },
44
+ features: gate.features,
45
+ plugins: [
46
+ createWorkflowsPlugin({
47
+ actor: "Legal Team",
48
+ role: "editor",
49
+ initialState: "draft",
50
+ onChange: (snapshot) => console.log(snapshot.state, snapshot.audit)
51
+ })
52
+ ]
53
+ });
54
+
55
+ editor.on("workflow:change", (snapshot) => {
56
+ // React to state transitions
57
+ });
58
+
59
+ const handle = getWorkflowsHandle(editor);
60
+ handle?.setRole("approver");
61
+ ```
62
+
63
+ Use toolbar workflow buttons (**Submit for review**, **Approve**, **Publish**, etc.) to transition states. Editing is automatically disabled for viewers, commenters, and published documents.
64
+
65
+ ## Usage — export with workflow watermark
66
+
67
+ ```ts
68
+ const snapshot = getWorkflowsHandle(editor)?.getSnapshot();
69
+
70
+ const preview = editor.exportForPreview({
71
+ workflowState: snapshot?.state ?? "draft",
72
+ includePrintCss: true
73
+ });
74
+ // preview.watermarkText — e.g. "IN REVIEW", "APPROVED · PUBLISHED"
75
+ ```
76
+
77
+ ## API
78
+
79
+ ### `createWorkflowsPlugin(options?)`
80
+
81
+ | Option | Type | Description |
82
+ | --- | --- | --- |
83
+ | `actor` | `string` | Display name for audit entries (default `"Reviewer"`). |
84
+ | `role` | `EditorRole` | Initial role (default `"editor"`). |
85
+ | `initialState` | `DocumentWorkflowState` | Starting state (default `"draft"`). |
86
+ | `initialAudit` | `WorkflowAuditEntry[]` | Pre-load audit log. |
87
+ | `onChange` | `(snapshot: WorkflowSnapshot) => void` | Fired on state or role changes. |
88
+
89
+ ### Document states
90
+
91
+ | State | Label | Editing |
92
+ | --- | --- | --- |
93
+ | `draft` | Draft | Editors+ can edit |
94
+ | `in_review` | In review | Editors+ can edit; track changes active |
95
+ | `changes_requested` | Changes requested | Editors+ can edit |
96
+ | `approved` | Approved | Read-only |
97
+ | `published` | Published | Read-only |
98
+
99
+ ### Roles
100
+
101
+ | Role | Can edit | Can approve | Can publish |
102
+ | --- | --- | --- | --- |
103
+ | `viewer` | No | No | No |
104
+ | `commenter` | No | No | No |
105
+ | `editor` | Yes (draft/review) | No | No |
106
+ | `approver` | Yes (draft/review) | Yes | No |
107
+ | `publisher` | Yes (draft/review) | Yes | Yes |
108
+
109
+ ### Toolbar transitions
110
+
111
+ | Tool ID | Action |
112
+ | --- | --- |
113
+ | `workflowSubmit` | Submit for review (`draft` → `in_review`) |
114
+ | `workflowRequestChanges` | Request changes (`in_review` → `changes_requested`) |
115
+ | `workflowApprove` | Approve (`in_review` / `changes_requested` → `approved`) |
116
+ | `workflowPublish` | Publish (`approved` → `published`) |
117
+ | `workflowReopen` | Reopen draft |
118
+
119
+ ### `getWorkflowsHandle(editor)`
120
+
121
+ | Method | Description |
122
+ | --- | --- |
123
+ | `setRole(role)` | Change the active editor role. |
124
+ | `getSnapshot()` | `{ state, role, audit }` current workflow snapshot. |
125
+
126
+ ### Events
127
+
128
+ | Event | Payload | Description |
129
+ | --- | --- | --- |
130
+ | `workflow:change` | `WorkflowSnapshot` | State or role changed. |
131
+ | `workflow:status` | `WorkflowSnapshot` | Emitted from Workflow status button. |
132
+
133
+ ## Related packages
134
+
135
+ - [`@richhtmleditor/core`](https://www.npmjs.com/package/@richhtmleditor/core) — editor engine, track changes commands, `exportForPreview`.
136
+ - [`@richhtmleditor/enterprise`](https://www.npmjs.com/package/@richhtmleditor/enterprise) — licence gating for `features.workflows`.
137
+ - [`@richhtmleditor/comments`](https://www.npmjs.com/package/@richhtmleditor/comments) — review comments plugin.
138
+ - [`@richhtmleditor/ai`](https://www.npmjs.com/package/@richhtmleditor/ai) — AI authoring plugin.
139
+ - [`@richhtmleditor/angular`](https://www.npmjs.com/package/@richhtmleditor/angular) — Angular wrapper.
140
+ - [`@richhtmleditor/react`](https://www.npmjs.com/package/@richhtmleditor/react) — React wrapper.
141
+
142
+ ## License
143
+
144
+ [MIT](./LICENSE)
@@ -0,0 +1,10 @@
1
+ import type { WorkflowSnapshot } from "./types.js";
2
+ export type ImmutableAuditExport = {
3
+ version: 1;
4
+ exportedAt: string;
5
+ immutable: true;
6
+ workflow: WorkflowSnapshot;
7
+ };
8
+ export declare function exportImmutableAudit(snapshot: WorkflowSnapshot): ImmutableAuditExport;
9
+ export declare function auditExportFileName(state: string): string;
10
+ //# sourceMappingURL=export-audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-audit.d.ts","sourceRoot":"","sources":["../src/export-audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,CAAC,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,oBAAoB,CAWrF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -0,0 +1,16 @@
1
+ export function exportImmutableAudit(snapshot) {
2
+ return {
3
+ version: 1,
4
+ exportedAt: new Date().toISOString(),
5
+ immutable: true,
6
+ workflow: {
7
+ state: snapshot.state,
8
+ role: snapshot.role,
9
+ audit: snapshot.audit.map((entry) => ({ ...entry }))
10
+ }
11
+ };
12
+ }
13
+ export function auditExportFileName(state) {
14
+ return `workflow-audit-${state}-${new Date().toISOString().slice(0, 10)}.json`;
15
+ }
16
+ //# sourceMappingURL=export-audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-audit.js","sourceRoot":"","sources":["../src/export-audit.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,oBAAoB,CAAC,QAA0B;IAC7D,OAAO;QACL,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,SAAS,EAAE,IAAI;QACf,QAAQ,EAAE;YACR,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;SACrD;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,kBAAkB,KAAK,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC;AACjF,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { EditorInstance, EditorPlugin } from "@richhtmleditor/core";
2
+ import type { DocumentWorkflowState, EditorRole, WorkflowAuditEntry, WorkflowSnapshot } from "./types.js";
3
+ export { exportImmutableAudit, auditExportFileName, type ImmutableAuditExport } from "./export-audit.js";
4
+ export { isTrackChangesWorkflowState } from "./track-changes.js";
5
+ export type { DocumentWorkflowState, EditorRole, WorkflowAuditEntry, WorkflowSnapshot } from "./types.js";
6
+ export { ROLE_LABELS, WORKFLOW_STATE_LABELS } from "./types.js";
7
+ export type WorkflowsPluginOptions = {
8
+ actor?: string;
9
+ role?: EditorRole;
10
+ initialState?: DocumentWorkflowState;
11
+ initialAudit?: WorkflowAuditEntry[];
12
+ onChange?: (snapshot: WorkflowSnapshot) => void;
13
+ };
14
+ export type WorkflowsPluginHandle = {
15
+ setRole: (role: EditorRole) => void;
16
+ getSnapshot: () => WorkflowSnapshot;
17
+ };
18
+ export declare function getWorkflowsHandle(editor: EditorInstance): WorkflowsPluginHandle | undefined;
19
+ export declare function createWorkflowsPlugin(options?: WorkflowsPluginOptions): EditorPlugin;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA0B,cAAc,EAAE,YAAY,EAAyB,MAAM,sBAAsB,CAAC;AAExH,OAAO,KAAK,EAEV,qBAAqB,EAErB,UAAU,EAEV,kBAAkB,EAElB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAIjE,YAAY,EAEV,qBAAqB,EAErB,UAAU,EAEV,kBAAkB,EAElB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIhE,MAAM,MAAM,sBAAsB,GAAG;IAEnC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,YAAY,CAAC,EAAE,qBAAqB,CAAC;IAErC,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEpC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAEjD,CAAC;AAIF,MAAM,MAAM,qBAAqB,GAAG;IAElC,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IAEpC,WAAW,EAAE,MAAM,gBAAgB,CAAC;CAErC,CAAC;AAsCF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,qBAAqB,GAAG,SAAS,CAI5F;AAkXD,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,YAAY,CA4NxF"}
package/dist/index.js ADDED
@@ -0,0 +1,316 @@
1
+ import { ROLE_LABELS, WORKFLOW_STATE_LABELS } from "./types.js";
2
+ import { canResolveTrackChanges, isTrackChangesWorkflowState } from "./track-changes.js";
3
+ export { exportImmutableAudit, auditExportFileName } from "./export-audit.js";
4
+ export { isTrackChangesWorkflowState } from "./track-changes.js";
5
+ export { ROLE_LABELS, WORKFLOW_STATE_LABELS } from "./types.js";
6
+ const workflowHandles = new WeakMap();
7
+ export function getWorkflowsHandle(editor) {
8
+ return workflowHandles.get(editor);
9
+ }
10
+ function newId() {
11
+ return `wf-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 7)}`;
12
+ }
13
+ function canEdit(store) {
14
+ if (store.role === "viewer" || store.role === "commenter") {
15
+ return false;
16
+ }
17
+ if (store.state === "approved" || store.state === "published") {
18
+ return false;
19
+ }
20
+ return store.role === "editor" || store.role === "approver" || store.role === "publisher";
21
+ }
22
+ function canResolveTrackChangesRole(store) {
23
+ return store.role === "editor" || store.role === "approver" || store.role === "publisher";
24
+ }
25
+ function canApprove(store) {
26
+ return store.role === "approver" || store.role === "publisher";
27
+ }
28
+ function canPublish(store) {
29
+ return store.role === "publisher";
30
+ }
31
+ const TRANSITIONS = [
32
+ {
33
+ id: "workflowSubmit",
34
+ label: "Submit for review",
35
+ to: "in_review",
36
+ enabled: (s) => s.state === "draft" && (s.role === "editor" || s.role === "publisher")
37
+ },
38
+ {
39
+ id: "workflowRequestChanges",
40
+ label: "Request changes",
41
+ to: "changes_requested",
42
+ note: "Changes requested by reviewer",
43
+ enabled: (s) => s.state === "in_review" && canApprove(s)
44
+ },
45
+ {
46
+ id: "workflowApprove",
47
+ label: "Approve",
48
+ to: "approved",
49
+ enabled: (s) => (s.state === "in_review" || s.state === "changes_requested") && canApprove(s)
50
+ },
51
+ {
52
+ id: "workflowPublish",
53
+ label: "Publish",
54
+ to: "published",
55
+ enabled: (s) => s.state === "approved" && canPublish(s)
56
+ },
57
+ {
58
+ id: "workflowReopen",
59
+ label: "Reopen draft",
60
+ to: "draft",
61
+ enabled: (s) => (s.state === "changes_requested" || s.state === "approved" || s.state === "published") &&
62
+ (s.role === "editor" || s.role === "publisher")
63
+ }
64
+ ];
65
+ function snapshot(store) {
66
+ return { state: store.state, role: store.role, audit: [...store.audit] };
67
+ }
68
+ function metadataFromStore(store) {
69
+ return {
70
+ workflow: {
71
+ state: store.state,
72
+ role: store.role,
73
+ actor: store.actor,
74
+ audit: store.audit.map((entry) => ({ ...entry }))
75
+ }
76
+ };
77
+ }
78
+ function hydrateStoreFromMetadata(store, metadata) {
79
+ const workflow = metadata?.workflow;
80
+ if (!workflow) {
81
+ return;
82
+ }
83
+ if (workflow.state) {
84
+ store.state = workflow.state;
85
+ }
86
+ if (workflow.role) {
87
+ store.role = workflow.role;
88
+ }
89
+ if (workflow.actor) {
90
+ store.actor = workflow.actor;
91
+ }
92
+ if (workflow.audit?.length) {
93
+ store.audit = workflow.audit.map((entry) => ({
94
+ id: entry.id,
95
+ at: entry.at,
96
+ actor: entry.actor,
97
+ role: entry.role,
98
+ action: entry.action,
99
+ fromState: entry.fromState,
100
+ toState: entry.toState,
101
+ note: entry.note
102
+ }));
103
+ }
104
+ }
105
+ function applyTransition(store, transition) {
106
+ const entry = {
107
+ id: newId(),
108
+ at: new Date().toISOString(),
109
+ actor: store.actor,
110
+ role: store.role,
111
+ action: transition.label,
112
+ fromState: store.state,
113
+ toState: transition.to,
114
+ note: transition.note
115
+ };
116
+ store.state = transition.to;
117
+ store.audit.unshift(entry);
118
+ }
119
+ function syncMetadata(editor, store, options) {
120
+ editor.setMetadata(metadataFromStore(store));
121
+ options.onChange?.(snapshot(store));
122
+ }
123
+ function mountWorkflowBar(editor, store, options) {
124
+ const host = editor.element;
125
+ const bar = document.createElement("div");
126
+ bar.className = "de-workflow-bar";
127
+ bar.setAttribute("role", "status");
128
+ bar.setAttribute("aria-live", "polite");
129
+ bar.innerHTML = `
130
+
131
+ <style>
132
+
133
+ .de-workflow-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;padding:8px 12px;
134
+
135
+ border-bottom:1px solid var(--de-border,#e2e8f0);background:color-mix(in srgb,var(--de-border,#e2e8f0) 12%,var(--de-surface,#fff));
136
+
137
+ font:12px/1.4 system-ui,sans-serif}
138
+
139
+ .de-workflow-bar__state{font-weight:700;color:var(--de-text,#0f172a)}
140
+
141
+ .de-workflow-bar__meta{color:var(--de-muted,#64748b)}
142
+
143
+ .de-workflow-bar__audit{flex:1 1 100%;margin:0;padding:0;list-style:none;color:var(--de-muted,#64748b);font-size:11px}
144
+
145
+ .de-workflow-bar__audit li{margin:2px 0 0}
146
+
147
+ .de-workflow-bar--published .de-workflow-bar__state{color:#047857}
148
+
149
+ .de-workflow-bar--review .de-workflow-bar__state{color:#b45309}
150
+
151
+ </style>
152
+
153
+ <span class="de-workflow-bar__state"></span>
154
+
155
+ <span class="de-workflow-bar__meta"></span>
156
+
157
+ <ul class="de-workflow-bar__audit"></ul>
158
+
159
+ `;
160
+ const toolbar = host.querySelector(".de-toolbar");
161
+ if (toolbar?.nextSibling) {
162
+ host.insertBefore(bar, toolbar.nextSibling);
163
+ }
164
+ else {
165
+ host.prepend(bar);
166
+ }
167
+ const stateEl = bar.querySelector(".de-workflow-bar__state");
168
+ const metaEl = bar.querySelector(".de-workflow-bar__meta");
169
+ const auditEl = bar.querySelector(".de-workflow-bar__audit");
170
+ const refresh = () => {
171
+ bar.classList.toggle("de-workflow-bar--published", store.state === "published");
172
+ bar.classList.toggle("de-workflow-bar--review", store.state === "in_review");
173
+ stateEl.textContent = WORKFLOW_STATE_LABELS[store.state];
174
+ metaEl.textContent = `${ROLE_LABELS[store.role]} · ${store.actor}`;
175
+ auditEl.innerHTML = store.audit
176
+ .slice(0, 3)
177
+ .map((entry) => `<li>${new Date(entry.at).toLocaleString()} — ${entry.actor}: ${entry.action} (${WORKFLOW_STATE_LABELS[entry.fromState]} → ${WORKFLOW_STATE_LABELS[entry.toState]})</li>`)
178
+ .join("");
179
+ editor.setEditable(canEdit(store));
180
+ };
181
+ refresh();
182
+ syncMetadata(editor, store, options);
183
+ return { destroy: () => bar.remove(), refresh };
184
+ }
185
+ export function createWorkflowsPlugin(options = {}) {
186
+ const store = {
187
+ state: options.initialState ?? "draft",
188
+ role: options.role ?? "editor",
189
+ actor: options.actor ?? "Reviewer",
190
+ audit: options.initialAudit ? [...options.initialAudit] : []
191
+ };
192
+ let runTransition = null;
193
+ const transitionIcons = {
194
+ workflowSubmit: "workflow-submit",
195
+ workflowRequestChanges: "workflow-changes",
196
+ workflowApprove: "workflow-approve",
197
+ workflowPublish: "workflow-publish",
198
+ workflowReopen: "workflow-reopen"
199
+ };
200
+ const tools = TRANSITIONS.map((transition) => ({
201
+ id: transition.id,
202
+ type: "button",
203
+ label: transition.label,
204
+ icon: transitionIcons[transition.id] ?? "workflow",
205
+ display: "text",
206
+ tooltip: transition.label,
207
+ group: "workflow",
208
+ isEnabled: () => transition.enabled(store),
209
+ onClick: () => runTransition?.(transition.id)
210
+ }));
211
+ tools.push({
212
+ id: "workflowTrackDelete",
213
+ command: "markTrackDelete",
214
+ type: "button",
215
+ label: "Mark deletion",
216
+ icon: "track-delete",
217
+ display: "text",
218
+ tooltip: "Mark selection as deleted (track changes)",
219
+ group: "workflow",
220
+ isEnabled: () => isTrackChangesWorkflowState(store.state) && canEdit(store)
221
+ });
222
+ tools.push({
223
+ id: "workflowAcceptSelection",
224
+ command: "acceptTrackChangeSelection",
225
+ type: "button",
226
+ label: "Accept",
227
+ icon: "track-accept",
228
+ display: "text",
229
+ tooltip: "Accept tracked changes in selection",
230
+ group: "workflow",
231
+ isEnabled: () => canResolveTrackChanges(store.state) && canResolveTrackChangesRole(store)
232
+ });
233
+ tools.push({
234
+ id: "workflowRejectSelection",
235
+ command: "rejectTrackChangeSelection",
236
+ type: "button",
237
+ label: "Reject",
238
+ icon: "track-reject",
239
+ display: "text",
240
+ tooltip: "Reject tracked changes in selection",
241
+ group: "workflow",
242
+ isEnabled: () => canResolveTrackChanges(store.state) && canResolveTrackChangesRole(store)
243
+ });
244
+ tools.push({
245
+ id: "workflowAcceptChanges",
246
+ command: "acceptTrackChanges",
247
+ type: "button",
248
+ label: "Accept all",
249
+ icon: "track-accept",
250
+ display: "text",
251
+ tooltip: "Accept all tracked changes",
252
+ group: "workflow",
253
+ isEnabled: () => canResolveTrackChanges(store.state) && canResolveTrackChangesRole(store)
254
+ });
255
+ tools.push({
256
+ id: "workflowRejectChanges",
257
+ command: "rejectTrackChanges",
258
+ type: "button",
259
+ label: "Reject all",
260
+ icon: "track-reject",
261
+ display: "text",
262
+ tooltip: "Reject all tracked changes",
263
+ group: "workflow",
264
+ isEnabled: () => canResolveTrackChanges(store.state) && canResolveTrackChangesRole(store)
265
+ });
266
+ tools.unshift({
267
+ id: "workflowStatus",
268
+ type: "button",
269
+ label: "Workflow",
270
+ icon: "workflow",
271
+ display: "text",
272
+ tooltip: "Document workflow status",
273
+ group: "workflow",
274
+ isEnabled: () => true,
275
+ onClick: (editor) => {
276
+ editor.emit("workflow:status", snapshot(store));
277
+ }
278
+ });
279
+ return {
280
+ id: "richhtmleditor-workflows",
281
+ tools,
282
+ attach: (editor) => {
283
+ hydrateStoreFromMetadata(store, editor.getMetadata());
284
+ if (!store.audit.length && options.initialAudit?.length) {
285
+ store.audit = [...options.initialAudit];
286
+ }
287
+ const { destroy: destroyBar, refresh: refreshBar } = mountWorkflowBar(editor, store, options);
288
+ const handle = {
289
+ setRole: (role) => {
290
+ store.role = role;
291
+ refreshBar();
292
+ syncMetadata(editor, store, options);
293
+ editor.emit("workflow:change", snapshot(store));
294
+ },
295
+ getSnapshot: () => snapshot(store)
296
+ };
297
+ workflowHandles.set(editor, handle);
298
+ runTransition = (id) => {
299
+ const transition = TRANSITIONS.find((t) => t.id === id);
300
+ if (!transition || !transition.enabled(store)) {
301
+ return;
302
+ }
303
+ applyTransition(store, transition);
304
+ refreshBar();
305
+ syncMetadata(editor, store, options);
306
+ editor.emit("workflow:change", snapshot(store));
307
+ };
308
+ return () => {
309
+ runTransition = null;
310
+ workflowHandles.delete(editor);
311
+ destroyBar();
312
+ };
313
+ }
314
+ };
315
+ }
316
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAA6B,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAgBjE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AA4DhE,MAAM,eAAe,GAAG,IAAI,OAAO,EAAyC,CAAC;AAI7E,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IAEvD,OAAO,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAErC,CAAC;AAID,SAAS,KAAK;IAEZ,OAAO,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAEnF,CAAC;AAID,SAAS,OAAO,CAAC,KAAoB;IAEnC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAE1D,OAAO,KAAK,CAAC;IAEf,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,KAAK,UAAU,IAAI,KAAK,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QAE9D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State | string | undefined): boolean;
3
+ export declare function canResolveTrackChanges(state: DocumentWorkflowState | string | undefined): boolean;
4
+ //# sourceMappingURL=track-changes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"track-changes.d.ts","sourceRoot":"","sources":["../src/track-changes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAEtG;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAOjG"}
@@ -0,0 +1,10 @@
1
+ export function isTrackChangesWorkflowState(state) {
2
+ return state === "in_review" || state === "changes_requested";
3
+ }
4
+ export function canResolveTrackChanges(state) {
5
+ return (state === "in_review" ||
6
+ state === "changes_requested" ||
7
+ state === "approved" ||
8
+ state === "published");
9
+ }
10
+ //# sourceMappingURL=track-changes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"track-changes.js","sourceRoot":"","sources":["../src/track-changes.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,2BAA2B,CAAC,KAAiD;IAC3F,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,mBAAmB,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAiD;IACtF,OAAO,CACL,KAAK,KAAK,WAAW;QACrB,KAAK,KAAK,mBAAmB;QAC7B,KAAK,KAAK,UAAU;QACpB,KAAK,KAAK,WAAW,CACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ export type DocumentWorkflowState = "draft" | "in_review" | "changes_requested" | "approved" | "published";
2
+ export type EditorRole = "viewer" | "commenter" | "editor" | "approver" | "publisher";
3
+ export type WorkflowAuditEntry = {
4
+ id: string;
5
+ at: string;
6
+ actor: string;
7
+ role: EditorRole;
8
+ action: string;
9
+ fromState: DocumentWorkflowState;
10
+ toState: DocumentWorkflowState;
11
+ note?: string;
12
+ };
13
+ export type WorkflowSnapshot = {
14
+ state: DocumentWorkflowState;
15
+ role: EditorRole;
16
+ audit: WorkflowAuditEntry[];
17
+ };
18
+ export declare const WORKFLOW_STATE_LABELS: Record<DocumentWorkflowState, string>;
19
+ export declare const ROLE_LABELS: Record<EditorRole, string>;
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAC7B,OAAO,GACP,WAAW,GACX,mBAAmB,GACnB,UAAU,GACV,WAAW,CAAC;AAEhB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAEtF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,qBAAqB,CAAC;IACjC,OAAO,EAAE,qBAAqB,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,qBAAqB,CAAC;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAMvE,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAMlD,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,15 @@
1
+ export const WORKFLOW_STATE_LABELS = {
2
+ draft: "Draft",
3
+ in_review: "In review",
4
+ changes_requested: "Changes requested",
5
+ approved: "Approved",
6
+ published: "Published"
7
+ };
8
+ export const ROLE_LABELS = {
9
+ viewer: "Viewer",
10
+ commenter: "Commenter",
11
+ editor: "Editor",
12
+ approver: "Approver",
13
+ publisher: "Publisher"
14
+ };
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAC,MAAM,qBAAqB,GAA0C;IAC1E,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,iBAAiB,EAAE,mBAAmB;IACtC,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA+B;IACrD,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;CACvB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@richhtmleditor/workflows",
3
+ "version": "1.0.0",
4
+ "description": "Enterprise approval workflows plugin for Rich HTML Editor.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "prepack": "node ../../scripts/assert-pack-ready.mjs"
22
+ },
23
+ "dependencies": {
24
+ "@richhtmleditor/core": "^1.0.0"
25
+ },
26
+ "keywords": [
27
+ "richhtmleditor",
28
+ "enterprise",
29
+ "workflow",
30
+ "approval",
31
+ "permissions"
32
+ ],
33
+ "license": "MIT",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "engines": {
38
+ "node": ">=18"
39
+ }
40
+ }