fix #220 - feat: Add a non-React host example for the Diagram Editor - #288
Conversation
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
✅ Deploy Preview for openworkflow-editor ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| "build:dev": "pnpm clean && tsc -p tsconfig.json && vite build", | ||
| "build:prod": "pnpm lint && pnpm clean && tsc -p tsconfig.json && vite build && pnpm test && pnpm test-e2e", | ||
| "test": "vitest run --passWithNoTests", | ||
| "test": "vitest run", |
There was a problem hiding this comment.
This change is out of scope but we don't need --passWithNoTests anymore
| "build:dev": "pnpm clean && tsc -p tsconfig.json && vite build", | ||
| "build:prod": "pnpm run build:dev && pnpm test", | ||
| "test": "vitest run --passWithNoTests" | ||
| "test": "vitest run" |
There was a problem hiding this comment.
This change is out of scope but we don't need --passWithNoTests anymore
There was a problem hiding this comment.
Pull request overview
Adds a new “vanilla” (non-React host) example that embeds @openworkflowspec/diagram-editor via a Web Component, making it easier for non-React consumers to integrate the Diagram Editor while keeping React encapsulated behind a Custom Element API.
Changes:
- Adds a new
examples/vanilla-web-componentworkspace package with Vite dev server, unit tests (Vitest), and e2e tests (Playwright). - Updates the pnpm workspace to include
examples/*and updates the lockfile accordingly. - Tightens test scripts in existing packages by removing
--passWithNoTests.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Adds examples/* to the pnpm workspace so examples are first-class workspaces. |
| pnpm-lock.yaml | Records the new example importer and its dependencies. |
| packages/open-workflow-diagram-editor/package.json | Changes test script to fail when no tests are found. |
| packages/i18n/package.json | Changes test script to fail when no tests are found. |
| examples/vanilla-web-component/package.json | Defines the new example package scripts, deps, and tooling. |
| examples/vanilla-web-component/index.html | Adds the demo host page that embeds the custom element and loads sample content. |
| examples/vanilla-web-component/src/index.ts | Registers the custom element and imports required editor styles. |
| examples/vanilla-web-component/src/diagram-editor-element.ts | Implements the Custom Element wrapper that mounts/unmounts a React root and renders DiagramEditor. |
| examples/vanilla-web-component/src/sample-workflow.ts | Provides sample Serverless Workflow YAML used by the demo/e2e checks. |
| examples/vanilla-web-component/vite.config.ts | Configures Vite dev server (port 6007) and build behavior for the example. |
| examples/vanilla-web-component/vitest.config.ts | Configures Vitest (jsdom, globals, css, include patterns). |
| examples/vanilla-web-component/playwright.config.ts | Configures Playwright e2e execution against the Vite dev server. |
| examples/vanilla-web-component/tests/diagram-editor-element.test.ts | Adds unit tests validating element registration and prop wiring. |
| examples/vanilla-web-component/tests-e2e/diagram-editor.spec.ts | Adds an e2e smoke test validating the editor renders and shows nodes. |
| examples/vanilla-web-component/tsconfig.json | Adds TS config for the example package. |
| examples/vanilla-web-component/README.md | Documents usage, attributes, and styling requirements of the example. |
| examples/vanilla-web-component/.oxlintrc.json | Inherits repo lint configuration for the example package. |
| examples/vanilla-web-component/.oxfmtrc.json | Inherits repo formatting configuration for the example package. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (2)
examples/vanilla-web-component/README.md:46
- The README’s attributes table lists no default for
locale, but the web component implementation falls back to"en"when the attribute is omitted. This is a documentation mismatch that can confuse consumers of the example.
| `locale` | `string` | - | Language locale for the editor UI |
examples/vanilla-web-component/index.html:32
- CSS property indentation is inconsistent here (the
text-alignline is over-indented compared to the rest of theh1rules), which looks like an accidental formatting error and makes the example harder to read.
h1 {
margin: 16px;
font-size: 1.25rem;
font-weight: 600;
text-align: center;
}
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
| content: this._content, | ||
| locale: this.getAttribute("locale") ?? "en", | ||
| isReadOnly: this.hasAttribute("read-only"), | ||
| colorMode: (this.getAttribute("color-mode") as ColorMode) ?? "system", |
There was a problem hiding this comment.
I think getAttribute returns a string if "" or an unknown value is passed "unknown", both of these means "system" wont get hit as it will either return "" or "unknown" which is not null
There was a problem hiding this comment.
@lornakelly +1 with your point, but thinking a bit I feel like this is more a responsability of the DE, I think in:
This way any wrapper is validated and we don't duplicate the ColorMode values in the Web Component wrapper.
Wdyt?
| } | ||
|
|
||
| private render(): void { | ||
| if (!this._root) return; |
There was a problem hiding this comment.
good to have an additional check here if content is "", in workflowSdk.ts we use text.trim() so can do the same here
if (!this._root || this._content.trim() === "") return;
There was a problem hiding this comment.
This way the host app will not be able to empty the WF, but only replace with a new one.
Is that ok?
cheryl7114
left a comment
There was a problem hiding this comment.
agree with Lorna's comment of the README, other than that looks good
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
…a-non-React-host-example-for-the-Diagram-Editor Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)
packages/open-workflow-diagram-editor/README.md:34
- The README link to the example is a repo-relative path (
../../examples/...). That works on GitHub but will be broken for consumers reading the package README on npm (the published package won’t include the repo’sexamples/folder). Prefer an absolute GitHub URL (or a full URL to the docs site) so the reference works everywhere.
If your application doesn't use React, you can embed the editor as a Web Component.
See the [vanilla Web Component example](../../examples/vanilla-web-component/) for a working setup.
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)
packages/open-workflow-diagram-editor/README.md:34
- The README links to the example via a relative path (
../../examples/...). Since this package publishes onlydist,README.md, andLICENSE(seefilesin package.json), that relative link will be broken on npm/unpkg. Use an absolute GitHub URL so the reference works for consumers reading the published README.
If your application doesn't use React, you can embed the editor as a Web Component.
See the [vanilla Web Component example](../../examples/vanilla-web-component/) for a working setup.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)
packages/open-workflow-diagram-editor/README.md:34
- The README link to the vanilla Web Component example is a monorepo-relative path. That works when browsing the repo on GitHub, but it will be broken for consumers reading the published package README (e.g. on npm). Consider linking to the GitHub URL instead so the example is discoverable outside the monorepo checkout.
If your application doesn't use React, you can embed the editor as a Web Component.
See the [vanilla Web Component example](../../examples/vanilla-web-component/) for a working setup.
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Closes #220
Description
Add an example showing how to use
@openworkflowspec/diagram-editorfrom a non-React framework host application embedding the DE as a Web ComponentHow to test:
From the repository root:
Browse http://localhost:6007
Preview: