proposal-studio 0.1.2
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 +26 -0
- package/README.md +199 -0
- package/dist/editor-document.html +684 -0
- package/dist/proposal-studio.cjs +968 -0
- package/dist/proposal-studio.d.ts +90 -0
- package/dist/proposal-studio.esm.js +945 -0
- package/dist/proposal-studio.global.js +970 -0
- package/dist/proposal-studio.global.min.js +684 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mani
|
|
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.
|
|
22
|
+
|
|
23
|
+
NOTE: This package loads the Froala WYSIWYG editor from a CDN at runtime for
|
|
24
|
+
rich-text editing. Froala is a commercial product; production use may require a
|
|
25
|
+
Froala license obtained separately from https://froala.com. This MIT license
|
|
26
|
+
covers only the custom-form-editor code, not the third-party Froala editor.
|
package/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# proposal-studio
|
|
2
|
+
|
|
3
|
+
A **framework-agnostic** visual form / proposal / brochure editor, shipped as a
|
|
4
|
+
standard **Web Component** (`<proposal-studio>`). Drag-and-drop blocks, rich-text
|
|
5
|
+
editing, tables, repeaters, vector shapes, multi-page PDF layout, templates and
|
|
6
|
+
real-time collaboration — all in one custom element.
|
|
7
|
+
|
|
8
|
+
Because it is a Web Component, it works **natively in every framework**:
|
|
9
|
+
|
|
10
|
+
| Environment | Supported |
|
|
11
|
+
| ---------------------- | --------- |
|
|
12
|
+
| Angular 7 → 22+ | ✅ |
|
|
13
|
+
| React 16 → 19 | ✅ |
|
|
14
|
+
| Vue 2.7 / 3 | ✅ |
|
|
15
|
+
| Svelte / SolidJS | ✅ |
|
|
16
|
+
| Plain HTML (no build) | ✅ |
|
|
17
|
+
|
|
18
|
+
This is the **complete editor UI** — top toolbar, left component palette
|
|
19
|
+
(Templates / History), the canvas, and the right Properties / Data Binding /
|
|
20
|
+
Style panels — bundled into one self-contained document. The whole thing runs
|
|
21
|
+
inside an isolated, same-origin `iframe`, so its internal Angular runtime /
|
|
22
|
+
jQuery / Froala / globals **never collide** with your host app (which can be a
|
|
23
|
+
different Angular version, React, Vue, …), and you can mount **multiple
|
|
24
|
+
editors** on one page.
|
|
25
|
+
|
|
26
|
+
> **Sizing:** the editor is a full app with its own internal scrolling, so give
|
|
27
|
+
> it a height — e.g. `<proposal-studio style="height:90vh">`. It defaults to
|
|
28
|
+
> `720px` if you don't.
|
|
29
|
+
>
|
|
30
|
+
> **Bundle size:** ~1.3 MB (≈300 KB gzipped) because it ships the full editor
|
|
31
|
+
> application. It loads lazily inside the iframe and never touches your app's
|
|
32
|
+
> bundle.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install proposal-studio
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or use it straight from a CDN, no build step:
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<script src="https://unpkg.com/proposal-studio"></script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> **Internet note:** rich-text editing loads Froala + Font Awesome + jQuery from
|
|
49
|
+
> a CDN at runtime. The editor needs network access on first paint. Froala is a
|
|
50
|
+
> commercial product — see [Licensing](#licensing).
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick start (plain HTML)
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<proposal-studio id="editor" style="display:block;min-height:600px"></proposal-studio>
|
|
58
|
+
|
|
59
|
+
<script type="module">
|
|
60
|
+
import 'proposal-studio';
|
|
61
|
+
|
|
62
|
+
const editor = document.getElementById('editor');
|
|
63
|
+
editor.addEventListener('ready', () => {
|
|
64
|
+
editor.loadTemplate('<h1>Hello 👋</h1><p>Edit me.</p>');
|
|
65
|
+
});
|
|
66
|
+
editor.addEventListener('change', (e) => {
|
|
67
|
+
console.log('html length:', e.detail.html.length);
|
|
68
|
+
});
|
|
69
|
+
</script>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## React
|
|
73
|
+
|
|
74
|
+
```jsx
|
|
75
|
+
import { useEffect, useRef } from 'react';
|
|
76
|
+
import 'proposal-studio';
|
|
77
|
+
|
|
78
|
+
export function Editor({ value, onChange }) {
|
|
79
|
+
const ref = useRef(null);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
const el = ref.current;
|
|
82
|
+
const h = (e) => onChange?.(e.detail.html);
|
|
83
|
+
el.addEventListener('change', h);
|
|
84
|
+
el.whenReady().then(() => value && el.setHtml(value));
|
|
85
|
+
return () => el.removeEventListener('change', h);
|
|
86
|
+
}, [value, onChange]);
|
|
87
|
+
return <proposal-studio ref={ref} style={{ display: 'block', minHeight: 600 }} />;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Vue 3
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<template><proposal-studio ref="el" /></template>
|
|
95
|
+
<script setup>
|
|
96
|
+
import { ref, onMounted } from 'vue';
|
|
97
|
+
import 'proposal-studio';
|
|
98
|
+
const el = ref(null);
|
|
99
|
+
onMounted(() => el.value.addEventListener('change', (e) => console.log(e.detail.html)));
|
|
100
|
+
</script>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
In `vite.config.js`, mark it a custom element:
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
vue({ template: { compilerOptions: { isCustomElement: (t) => t === 'proposal-studio' } } })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Angular (7 → 22+)
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
113
|
+
import 'proposal-studio';
|
|
114
|
+
|
|
115
|
+
@Component({
|
|
116
|
+
standalone: true, // omit on Angular 7–14
|
|
117
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA], // the one required line
|
|
118
|
+
template: `<proposal-studio (change)="onChange($event)"></proposal-studio>`,
|
|
119
|
+
})
|
|
120
|
+
export class EditorComponent {
|
|
121
|
+
onChange(e: Event) { console.log((e as CustomEvent).detail.html); }
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
On Angular 7–14 add `CUSTOM_ELEMENTS_SCHEMA` to your `@NgModule` instead.
|
|
126
|
+
|
|
127
|
+
See [`examples/`](./examples) for complete, copy-pasteable wrappers for each
|
|
128
|
+
framework.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## API
|
|
133
|
+
|
|
134
|
+
### Properties
|
|
135
|
+
|
|
136
|
+
| Property | Type | Description |
|
|
137
|
+
| ----------------- | ----------------- | -------------------------------------------- |
|
|
138
|
+
| `value` | `string` | Get/set the canvas HTML. |
|
|
139
|
+
| `ready` | `boolean` | `true` once the engine has booted. |
|
|
140
|
+
| `contentWindow` | `Window \| null` | The editor iframe window (same-origin). |
|
|
141
|
+
| `contentDocument` | `Document \| null`| The editor iframe document. |
|
|
142
|
+
|
|
143
|
+
### Methods
|
|
144
|
+
|
|
145
|
+
| Method | Description |
|
|
146
|
+
| ----------------------- | ------------------------------------------------------- |
|
|
147
|
+
| `whenReady()` | `Promise<this>` that resolves when the editor is ready. |
|
|
148
|
+
| `getHtml()` | Current canvas HTML. |
|
|
149
|
+
| `setHtml(html)` | Replace canvas content (queued if called before ready). |
|
|
150
|
+
| `loadTemplate(html)` | Alias of `setHtml`. |
|
|
151
|
+
| `post(message)` | Low-level: post a message to the editor iframe. |
|
|
152
|
+
| `focus()` | Focus the editor canvas. |
|
|
153
|
+
|
|
154
|
+
### Events (all `CustomEvent`)
|
|
155
|
+
|
|
156
|
+
| Event | `detail` | Fired when |
|
|
157
|
+
| --------- | ------------------------------ | ------------------------------------- |
|
|
158
|
+
| `ready` | `{ editor }` | the engine has booted |
|
|
159
|
+
| `change` | `{ html }` | canvas content changes |
|
|
160
|
+
| `resize` | `{ height }` | the editor reports a new height |
|
|
161
|
+
| `message` | the raw iframe message object | any internal message (advanced use) |
|
|
162
|
+
|
|
163
|
+
### Attributes
|
|
164
|
+
|
|
165
|
+
| Attribute | Default | Description |
|
|
166
|
+
| ------------- | ------- | ------------------------------------------------- |
|
|
167
|
+
| `height` | — | Fixed/initial height (`"800"` or any CSS length). |
|
|
168
|
+
| `auto-height` | `true` | Auto-grow to fit content; set `"false"` to lock. |
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Build from source / contribute
|
|
173
|
+
|
|
174
|
+
The editor is the monorepo's Angular app (`src/app/`) driving the pure-JS canvas
|
|
175
|
+
engine (`public/custom-form/`). The build:
|
|
176
|
+
|
|
177
|
+
1. runs `ng build` (the Angular app → `dist/custom-form/browser/`),
|
|
178
|
+
2. inlines the canvas engine into one self-contained document (the canvas
|
|
179
|
+
iframe's `srcdoc`),
|
|
180
|
+
3. inlines the Angular build + that canvas doc into one portable "outer"
|
|
181
|
+
document, and
|
|
182
|
+
4. bundles the `<proposal-studio>` element (esm / cjs / global / `.d.ts`).
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
cd packages/proposal-studio
|
|
186
|
+
npm run build # reuses an existing Angular build if present
|
|
187
|
+
PS_NG_BUILD=1 npm run build # force a fresh `ng build` first
|
|
188
|
+
npm test # headless browser sanity check (full UI boots)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Edit the Angular UI under `src/app/` or the canvas engine under
|
|
192
|
+
`public/custom-form/js/`, then re-run the build. PRs welcome.
|
|
193
|
+
|
|
194
|
+
## Licensing
|
|
195
|
+
|
|
196
|
+
This package is MIT licensed. It loads the **Froala** WYSIWYG editor from a CDN
|
|
197
|
+
at runtime for rich-text editing; Froala is a commercial product and production
|
|
198
|
+
use may require a license from <https://froala.com>. The MIT license here covers
|
|
199
|
+
only the `proposal-studio` code, not third-party Froala/jQuery/Font Awesome.
|