Skip to content

fix #220 - feat: Add a non-React host example for the Diagram Editor - #288

Open
fantonangeli wants to merge 10 commits into
open-workflow-specification:mainfrom
fantonangeli:issue-220-feat-Add-a-non-React-host-example-for-the-Diagram-Editor
Open

fix #220 - feat: Add a non-React host example for the Diagram Editor#288
fantonangeli wants to merge 10 commits into
open-workflow-specification:mainfrom
fantonangeli:issue-220-feat-Add-a-non-React-host-example-for-the-Diagram-Editor

Conversation

@fantonangeli

Copy link
Copy Markdown
Member

Closes #220

Description

Add an example showing how to use @openworkflowspec/diagram-editor from a non-React framework host application embedding the DE as a Web Component

How to test:

From the repository root:

pnpm install
pnpm --filter @openworkflowspec/vanilla-web-component-example start

Browse http://localhost:6007

Preview:

image

Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Copilot AI review requested due to automatic review settings July 30, 2026 09:11
@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for openworkflow-editor ready!

Name Link
🔨 Latest commit 92526f0
🔍 Latest deploy log https://app.netlify.com/projects/openworkflow-editor/deploys/6a6b7a007988d700081eb171
😎 Deploy Preview https://deploy-preview-288--openworkflow-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is out of scope but we don't need --passWithNoTests anymore

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-component workspace 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.

Comment thread examples/vanilla-web-component/src/index.ts Outdated
Comment thread examples/vanilla-web-component/src/diagram-editor-element.ts
Comment thread examples/vanilla-web-component/README.md
Comment thread examples/vanilla-web-component/tests/diagram-editor-element.test.ts
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Copilot AI review requested due to automatic review settings July 30, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-align line is over-indented compared to the rest of the h1 rules), 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>
Copilot AI review requested due to automatic review settings July 30, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

content: this._content,
locale: this.getAttribute("locale") ?? "en",
isReadOnly: this.hasAttribute("read-only"),
colorMode: (this.getAttribute("color-mode") as ColorMode) ?? "system",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lornakelly +1 with your point, but thinking a bit I feel like this is more a responsability of the DE, I think in:

colorMode === "system" ? getSystemColorMode() : colorMode,

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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way the host app will not be able to empty the WF, but only replace with a new one.
Is that ok?

Comment thread examples/vanilla-web-component/README.md

@cheryl7114 cheryl7114 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with Lorna's comment of the README, other than that looks good

Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>
Copilot AI review requested due to automatic review settings July 30, 2026 16:06
…a-non-React-host-example-for-the-Diagram-Editor

Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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’s examples/ 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.

Copilot AI review requested due to automatic review settings July 30, 2026 16:09
Signed-off-by: fantonangeli <fabrizio.antonangeli@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 only dist, README.md, and LICENSE (see files in 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.

Copilot AI review requested due to automatic review settings July 30, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings July 30, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add a non-React host example for the Diagram Editor

4 participants