@weavour/editor 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Weavour contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,114 @@
1
- # Temporary Holding Version
1
+ # Weavour editor SDKs
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Embed the hosted Weavour email editor in your application. Your application owns
4
+ its users and sends the exported emails. The SDKs are MIT licensed; the hosted
5
+ editor, rendering implementation and services are proprietary.
6
+
7
+ - `@weavour/editor`: JavaScript/TypeScript and classic script-tag integrations.
8
+ - `@weavour/react`: React component using the same core and hosted iframe.
9
+
10
+ ## JavaScript / TypeScript
11
+
12
+ ```sh
13
+ npm install @weavour/editor
14
+ ```
15
+
16
+ ```ts
17
+ import { mount } from '@weavour/editor';
18
+
19
+ const editor = mount('#email-editor', {
20
+ editorKey: 'YOUR_PUBLIC_EDITOR_KEY',
21
+ userId: 'user-123',
22
+ organizationId: 'organization-456',
23
+ locale: 'en',
24
+ onDocumentChange(email) { /* Persist the complete versioned envelope. */ },
25
+ onError(error) { console.error(error); },
26
+ });
27
+ await editor.ready;
28
+ const { html, text, subject, preheader } = await editor.exportHTML();
29
+ // Your application sends the email.
30
+ // Before leaving, optionally await editor.flushAutosave(), then:
31
+ editor.destroy();
32
+ ```
33
+
34
+ Supply an element with an explicit height, for example 700px. The SDK appends a
35
+ full-width, full-height titled iframe and preserves other container children.
36
+ The default iframe is `https://weavour.com/editor`. Local integration can set
37
+ `editorUrl: 'http://localhost:8788/editor'` and
38
+ `apiUrl: 'http://localhost:8787'` explicitly.
39
+
40
+ ## Script tags
41
+
42
+ Use the `dist/editor.js` artifact from a pinned SDK release. It exposes the same
43
+ API as `Weavour.mount(...)`; no framework or npm runtime is required.
44
+ `https://weavour.com/editor.js` remains the hosted compatibility entry point.
45
+ The new application-ready SDK requires the matching hosted iframe rollout;
46
+ see [compatibility](docs/compatibility.md) before switching production clients.
47
+
48
+ ## React
49
+
50
+ ```sh
51
+ npm install @weavour/react
52
+ ```
53
+
54
+ ```tsx
55
+ import { useRef } from 'react';
56
+ import { WeavourEditor, type WeavourEditorRef } from '@weavour/react';
57
+
58
+ export function EmailComposer() {
59
+ const editor = useRef<WeavourEditorRef>(null);
60
+ return <WeavourEditor
61
+ ref={editor}
62
+ editorKey="YOUR_PUBLIC_EDITOR_KEY"
63
+ userId="user-123"
64
+ organizationId="organization-456"
65
+ locale="en"
66
+ style={{ height: 700 }}
67
+ onError={console.error}
68
+ />;
69
+ }
70
+ ```
71
+
72
+ The wrapper cleans up on unmount and supports React 18.3 and 19. Theme, locale,
73
+ merge tags and feature preferences update live. Change the React `key` explicitly
74
+ to switch identity or initial documents, after preserving current work. Callback
75
+ changes do not recreate the iframe. Imports are SSR-safe; mounting runs on the
76
+ client. Next.js examples use a client component boundary.
77
+
78
+ ## Identity and permissions
79
+
80
+ `editorKey` is public. `userId` and optional `organizationId` are declarative
81
+ namespaces inside the customer workspace resolved by that key. They are not
82
+ verified identities: supplying the same IDs grants shared access, including
83
+ modification. Origin restrictions control embedding and do not authenticate users.
84
+ An organization-only mount becomes a personal mount with that organization ID as
85
+ its user ID. A mount with neither ID fails. Never put admin credentials or AI
86
+ provider keys in mount options. Hosted capabilities and quotas are enforced by
87
+ the service, regardless of local preferences.
88
+
89
+ ## Documentation and examples
90
+
91
+ - [API](docs/api.md), [compatibility and migration](docs/compatibility.md),
92
+ [origins and CSP](docs/security.md).
93
+ - [Vanilla](examples/vanilla), [React](examples/react), [Next.js](examples/next).
94
+ - [Contributing](CONTRIBUTING.md), [security reports](SECURITY.md), [changelog](CHANGELOG.md).
95
+
96
+ ## Development
97
+
98
+ Node.js 22.12+ and npm are required. A clean public checkout needs no credentials,
99
+ private code or Weavour account to build and test:
100
+
101
+ ```sh
102
+ npm ci
103
+ npm run verify
104
+ npx playwright install chromium firefox webkit
105
+ npm run test:browser
106
+ ```
107
+
108
+ GitHub Actions runs package checks and tests on **every push and pull request**,
109
+ using Node 22/24 and React 18/19, plus Chromium, Firefox and WebKit browser checks.
110
+ Browser tests use a small mock iframe, not a copy of the hosted editor. Real
111
+ hosted integrations require a configured public editor key and allowed origin.
112
+
113
+ See [release instructions](docs/releases.md) for npm trusted publishing and
114
+ private hosted-editor promotion. Installing this SDK does not self-host the editor.
@@ -0,0 +1,6 @@
1
+ import type { EditorSDK } from './types.js';
2
+ declare global {
3
+ interface Window {
4
+ Weavour?: EditorSDK;
5
+ }
6
+ }
package/dist/core.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type { EditorSDK, SDKOptions } from './types.js';
2
+ export declare function createSDK(settings?: SDKOptions): EditorSDK;
@@ -0,0 +1,2 @@
1
+ export declare const editorBlockIds: readonly ["text", "heading", "button", "image", "video", "gif", "timer", "menu", "social", "unsubscribe", "list", "html", "space", "divider", "section", "columns"];
2
+ export type EditorBlockId = typeof editorBlockIds[number];
@@ -0,0 +1,30 @@
1
+ export type EditorTheme = {
2
+ mode?: 'light' | 'dark';
3
+ primaryColor?: string;
4
+ backgroundColor?: string;
5
+ surfaceColor?: string;
6
+ shellColor?: string;
7
+ inputColor?: string;
8
+ textColor?: string;
9
+ mutedColor?: string;
10
+ borderColor?: string;
11
+ cornerRadius?: number;
12
+ density?: 'comfortable' | 'compact';
13
+ fontFamily?: string;
14
+ };
15
+ export declare function resolveEditorTheme(input?: EditorTheme): Required<EditorTheme>;
16
+ export declare function colorContrast(first: string, second: string): number;
17
+ export declare function readableForeground(background: string): "#ffffff" | "#111111" | "#000000";
18
+ export declare function editorSurfacePalette(background: string, theme: EditorTheme): {
19
+ text: string;
20
+ muted: string;
21
+ danger: string;
22
+ focus: string;
23
+ hover: string;
24
+ selected: string;
25
+ accessory: string;
26
+ accessoryText: string;
27
+ accessoryFocus: string;
28
+ border: string;
29
+ colorScheme: string;
30
+ };