@weavour/editor 0.0.0-stage → 0.1.1

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,105 @@
1
- # Temporary Holding Version
1
+ # Weavour editor SDKs
2
+
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`.
37
+
38
+ ## Script tags
39
+
40
+ Use the `dist/editor.js` artifact from a pinned SDK release. It exposes the same
41
+ API as `Weavour.mount(...)`; no framework or npm runtime is required.
42
+ `https://weavour.com/editor.js` remains the hosted compatibility entry point.
43
+ The new application-ready SDK requires the matching hosted iframe rollout;
44
+ see [compatibility](docs/compatibility.md) before switching production clients.
45
+
46
+ ## React
47
+
48
+ ```sh
49
+ npm install @weavour/react
50
+ ```
51
+
52
+ ```tsx
53
+ import { useRef } from 'react';
54
+ import { WeavourEditor, type WeavourEditorRef } from '@weavour/react';
55
+
56
+ export function EmailComposer() {
57
+ const editor = useRef<WeavourEditorRef>(null);
58
+ return <WeavourEditor
59
+ ref={editor}
60
+ editorKey="YOUR_PUBLIC_EDITOR_KEY"
61
+ userId="user-123"
62
+ organizationId="organization-456"
63
+ locale="en"
64
+ style={{ height: 700 }}
65
+ onError={console.error}
66
+ />;
67
+ }
68
+ ```
69
+
70
+ The wrapper cleans up on unmount and supports React 18.3 and 19. Theme, locale,
71
+ merge tags and feature preferences update live. Change the React `key` explicitly
72
+ to switch identity or initial documents, after preserving current work. Callback
73
+ changes do not recreate the iframe. Imports are SSR-safe; mounting runs on the
74
+ client. Next.js examples use a client component boundary.
75
+
76
+ ## Identity and permissions
77
+
78
+ `editorKey` is public. `userId` and optional `organizationId` are declarative
79
+ namespaces inside the customer workspace resolved by that key. They are not
80
+ verified identities: supplying the same IDs grants shared access, including
81
+ modification. Origin restrictions control embedding and do not authenticate users.
82
+ An organization-only mount becomes a personal mount with that organization ID as
83
+ its user ID. A mount with neither ID fails. Never put admin credentials or AI
84
+ provider keys in mount options. Hosted capabilities and quotas are enforced by
85
+ the service, regardless of local preferences.
86
+
87
+ ## Documentation and examples
88
+
89
+ - [API](docs/api.md), [compatibility and migration](docs/compatibility.md),
90
+ [origins and CSP](docs/security.md).
91
+ - [Vanilla](examples/vanilla), [React](examples/react), [Next.js](examples/next).
92
+ - [Contributing](CONTRIBUTING.md), [security reports](SECURITY.md), [changelog](CHANGELOG.md).
93
+
94
+ ## Development
95
+
96
+ Node.js 22.12+ and npm are required. A clean public checkout needs no credentials,
97
+ private code or Weavour account to build and test:
98
+
99
+ ```sh
100
+ npm ci
101
+ npm run verify
102
+ npx playwright install chromium firefox webkit
103
+ npm run test:browser
104
+ ```
2
105
 
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.
@@ -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
+ };