sigpro 1.2.40 → 2.0.3
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/Readme.md +172 -84
- package/dist/sigpro.convert.js +34 -0
- package/dist/sigpro.editor.js +1 -1
- package/dist/sigpro.grid.js +39 -39
- package/dist/sigpro.js +1 -1
- package/dist/sigpro.vite.js +6 -4
- package/package.json +8 -35
- package/sigpro.d.ts +257 -130
- package/dist/sigpro.db.js +0 -1
- package/dist/sigpro.locale.js +0 -1
- package/dist/sigpro.router.js +0 -1
- package/dist/sigpro.ui.css +0 -2
- package/dist/sigpro.ui.js +0 -1
- package/sigpro.ui.d.ts +0 -308
package/Readme.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Blazing fast, zero-overhead, vanilla JS renderer with atomic reactivity.
|
|
2
|
-
|
|
3
1
|
# `SigPro`
|
|
4
2
|
|
|
3
|
+
Blazing fast, zero-overhead, vanilla JS renderer with atomic reactivity.
|
|
4
|
+
|
|
5
5
|
[](https://www.npmjs.com/package/sigpro)
|
|
6
|
-

|
|
7
7
|
[](https://github.com/natxocc/sigpro/blob/main/LICENSE)
|
|
8
8
|
|
|
9
9
|
[**Explore the Docs →**](https://sigpro.natxocc.com/#/)
|
|
@@ -16,40 +16,14 @@ After years of building within closed ecosystems like **React, Vue, or Svelte**
|
|
|
16
16
|
|
|
17
17
|
That extra development time and the cognitive load of "learning the framework" instead of "learning the language" is exactly what **SigPro** eliminates. If the final destination is always JS, why not use a Pure JS-based system that drastically simplifies coding with a readable, vanilla, and remarkably fast architecture?
|
|
18
18
|
|
|
19
|
-
* **Atomic Precision:** Powered by
|
|
19
|
+
* **Atomic Precision:** Powered by an **alien-signals**-class push-pull reactive core. State is bound directly to DOM nodes—when a value changes, **only that specific node updates**. No diffing, no virtual tree, no wasted work.
|
|
20
20
|
* **Zero-Hydration Bottlenecks:** No 100KB bundles or complex build steps. SigPro is pure, optimized JavaScript tailored for the browser's native engine.
|
|
21
|
-
* **
|
|
21
|
+
* **Lazy Computation:** `computed()` is lazy and verified with `checkDirty`. Effects don't re-run when a dependency's value didn't actually change.
|
|
22
22
|
* **Build-Tool Agnostic:** Total freedom. Use it with **Vite, Webpack, or Rollup** for enterprise projects, or simply import it via a **`<script>` tag** for rapid prototyping. No tooling required.
|
|
23
|
-
* **
|
|
24
|
-
* **
|
|
25
|
-
* **
|
|
26
|
-
* **
|
|
27
|
-
* **Tree-Shakable:** Optimized for modern bundlers. Import only what you use, or load the full engine for rapid prototyping.
|
|
28
|
-
|
|
29
|
-
-----
|
|
30
|
-
|
|
31
|
-
## Real-World Benchmarks
|
|
32
|
-
|
|
33
|
-
SigPro isn't just "fast on paper." In the industry-standard **JS Framework Benchmark**, it consistently outperforms the most popular libraries by operating at near-native speeds with almost zero memory overhead.
|
|
34
|
-
|
|
35
|
-
### Execution Speed (CPU)
|
|
36
|
-
*Lower is better. Measured in milliseconds (ms).*
|
|
37
|
-
|
|
38
|
-
| Benchmark Test | **SigPro** | SolidJS | Vue 3 | React 18 |
|
|
39
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
40
|
-
| **Surgical Update** (10th row) | **46.8ms** | ~48ms | ~75ms | ~158ms |
|
|
41
|
-
| **Direct Selection** (on click) | **17.5ms** | ~18ms | ~32ms | ~65ms |
|
|
42
|
-
| **Initial Render** (1k rows) | **~35ms** | ~32ms | ~45ms | ~70ms |
|
|
43
|
-
|
|
44
|
-
### Memory Footprint
|
|
45
|
-
*Lower is better. Measured in Megabytes (MB) after 1k rows.*
|
|
46
|
-
|
|
47
|
-
| Metric | **SigPro** | Vanilla JS | Svelte | React |
|
|
48
|
-
| :--- | :--- | :--- | :--- | :--- |
|
|
49
|
-
| **Ready Memory** (Idle) | **1.05 MB** | 1.01 MB | ~2.8 MB | ~10.4 MB |
|
|
50
|
-
| **Run Memory** (1k rows) | **4.90 MB** | 4.25 MB | ~10.2 MB | ~28.5 MB |
|
|
51
|
-
|
|
52
|
-
> **The Verdict:** SigPro delivers **Vanilla-like memory consumption** while maintaining **Surgical reactivity** that rivals (and often beats) SolidJS in granular updates.
|
|
23
|
+
* **Zero-Scale Bloat:** Unlike other frameworks where the bundle grows exponentially, SigPro's footprint remains **flat and predictable**.
|
|
24
|
+
* **Premium DX:** Forget boilerplate imports. SigPro injects an elegant, functional syntax (`div()`, `button()`, `span()`) directly into your scope for a **"Zero-Import"** workflow.
|
|
25
|
+
* **Fully Loaded:** Built-in Hash Routing, native **`localStorage` persistence**, **`provide`/`inject`** dependency injection, **SVG support**, and automatic cleanup of listeners and scopes—all in a single file.
|
|
26
|
+
* **No Memory Leaks:** Scopes cascade idempotently. Event listeners are tracked and removed with the node. Computeds die with their owners.
|
|
53
27
|
|
|
54
28
|
-----
|
|
55
29
|
|
|
@@ -62,21 +36,22 @@ Create reactive, persistent components with a syntax that feels like Vanilla JS,
|
|
|
62
36
|
```
|
|
63
37
|
|
|
64
38
|
```javascript
|
|
65
|
-
import {
|
|
39
|
+
import { signal, computed, mount, exposeTags } from "sigpro";
|
|
40
|
+
|
|
41
|
+
exposeTags();
|
|
66
42
|
|
|
67
43
|
const Counter = () => {
|
|
68
44
|
// Simple signal
|
|
69
|
-
const value =
|
|
45
|
+
const value = signal(100);
|
|
70
46
|
// One-line persistence: state survives page reloads automatically
|
|
71
|
-
const count =
|
|
72
|
-
|
|
73
|
-
const doubleValue =
|
|
47
|
+
const count = local("user-counter-pref",0); // use local() for persistence
|
|
48
|
+
const ref = signal(100);
|
|
49
|
+
const doubleValue = computed(() => value() * ref());
|
|
74
50
|
|
|
75
|
-
// Create fast HTML with pure JS
|
|
76
51
|
return div({ class: "card" }, [
|
|
77
|
-
h1(() => `Count: ${count()}, Reference: ${value()}, Double
|
|
52
|
+
h1(() => `Count: ${count()}, Reference: ${value()}, Double: ${doubleValue()}`),
|
|
78
53
|
p("Atomic updates. Zero re-renders of the parent tree."),
|
|
79
|
-
button({ onclick: () => count(
|
|
54
|
+
button({ onclick: () => count(count() + 1) }, "Increment +1")
|
|
80
55
|
]);
|
|
81
56
|
};
|
|
82
57
|
|
|
@@ -85,56 +60,157 @@ mount(Counter, "#app");
|
|
|
85
60
|
|
|
86
61
|
-----
|
|
87
62
|
|
|
88
|
-
##
|
|
63
|
+
## Core API
|
|
89
64
|
|
|
90
|
-
|
|
91
|
-
| :--- | :--- | :--- | :--- |
|
|
92
|
-
| **Payload (Gzipped)** | **<3KB** | ~30KB - 50KB | ~5KB (Compiled Runtime) |
|
|
93
|
-
| **State Logic** | **Atomic Signals** | Virtual DOM Diffing | Compiler Dirty Bits |
|
|
94
|
-
| **Update Speed** | **Direct Node Access** | Component Re-render | Block Reconciliation |
|
|
95
|
-
| **Native Persistence** | **Included ($)** | Requires Plugins | Manual |
|
|
96
|
-
| **Dependencies** | **Zero** | Many | Build Toolchain |
|
|
97
|
-
| **Lifecycle Mgmt** | **Automatic (Cleanup Root)** | Manual / Hook-based | Manual / Hook-based |
|
|
98
|
-
| **Routing** | **Reactive Hash (Router) + File-based (Vite)** | Virtual Router (External) | File-based / External |
|
|
99
|
-
| **Learning Curve** | **Zero (Vanilla JS)** | Steep (JSX/Templates) | Medium (Directives) |
|
|
65
|
+
### Reactivity
|
|
100
66
|
|
|
101
|
-
|
|
67
|
+
```javascript
|
|
68
|
+
import {
|
|
69
|
+
signal, computed, effect, effectScope,
|
|
70
|
+
batch, untrack, watch, local, provide, inject
|
|
71
|
+
} from "sigpro";
|
|
72
|
+
|
|
73
|
+
const count = signal(0);
|
|
74
|
+
count(); // read
|
|
75
|
+
count(1); // write
|
|
76
|
+
|
|
77
|
+
const double = computed(() => count() * 2);
|
|
78
|
+
double(); // → 2, lazily evaluated
|
|
79
|
+
|
|
80
|
+
// Effect with cleanup
|
|
81
|
+
const stop = effect(() => {
|
|
82
|
+
const v = count();
|
|
83
|
+
console.log(v);
|
|
84
|
+
return () => console.log("cleanup");
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Scoped effects (cascade cleanup for children)
|
|
88
|
+
const dispose = effectScope(() => {
|
|
89
|
+
effect(() => console.log(count()));
|
|
90
|
+
effect(() => console.log(double()));
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Batching: defer flush until the end
|
|
94
|
+
batch(() => {
|
|
95
|
+
count(1);
|
|
96
|
+
count(2);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Watch: skip initial run, receive old/new values
|
|
100
|
+
watch(count, (newval, oldval) => console.log(oldval, "→", newval));
|
|
101
|
+
|
|
102
|
+
// Untrack: read without subscribing
|
|
103
|
+
untrack(() => count());
|
|
102
104
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
│ ├── index.js # → /
|
|
111
|
-
│ ├── about.js # → /about
|
|
112
|
-
│ ├── blog/
|
|
113
|
-
│ │ ├── index.js # → /blog
|
|
114
|
-
│ │ └── [slug].js # → /blog/:slug
|
|
115
|
-
│ └── docs/
|
|
116
|
-
│ └── [...all].js # → /docs/*
|
|
117
|
-
├── 📂 components/ # Reusable components
|
|
118
|
-
└── 📄 main.js # App Entry & Mounting
|
|
105
|
+
// Persistent signal (localStorage-backed, JSON)
|
|
106
|
+
const theme = local("theme", "light");
|
|
107
|
+
theme("dark"); // stored, survives reloads
|
|
108
|
+
|
|
109
|
+
// Dependency injection
|
|
110
|
+
provide("theme", signal("dark"));
|
|
111
|
+
const t = inject("theme"); // nearest provider
|
|
119
112
|
```
|
|
120
113
|
|
|
121
|
-
|
|
114
|
+
### Rendering
|
|
115
|
+
|
|
122
116
|
```javascript
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
import { h, mount, exposeTags } from "sigpro";
|
|
118
|
+
|
|
119
|
+
exposeTags(); // → window.div, window.span, window.button, etc.
|
|
120
|
+
|
|
121
|
+
// Static
|
|
122
|
+
div({ class: "card" }, "Hello");
|
|
123
|
+
|
|
124
|
+
// Reactive props
|
|
125
|
+
div({ class: () => active() ? "card active" : "card" });
|
|
126
|
+
|
|
127
|
+
// Reactive style
|
|
128
|
+
div({ style: () => open() ? "" : "display:none" });
|
|
129
|
+
|
|
130
|
+
// Reactive children
|
|
131
|
+
div({}, () => items().map(i => li({}, i.name)));
|
|
132
|
+
|
|
133
|
+
// Events
|
|
134
|
+
button({ onclick: () => count(count() + 1) }, "+1");
|
|
135
|
+
|
|
136
|
+
// ref
|
|
137
|
+
input({ ref: el => el.focus() });
|
|
126
138
|
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
// innerHTML (reactive)
|
|
140
|
+
div({ html: () => markdown(run().text) });
|
|
141
|
+
|
|
142
|
+
// Two-way binding
|
|
143
|
+
input({ value: () => username(), oninput: e => username(e.target.value)})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### SVG
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
svg({ viewBox: "0 0 24 24" }, [
|
|
150
|
+
path({ d: "M9 12l2 2 4-4", stroke: "currentColor", fill: "none" })
|
|
151
|
+
]);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
SVG tags are detected automatically. `class`, `style`, and every attribute go through `setAttribute` correctly.
|
|
155
|
+
|
|
156
|
+
### Router
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
import { router } from "sigpro";
|
|
160
|
+
|
|
161
|
+
const App = router([
|
|
162
|
+
{ path: "/", component: Home },
|
|
163
|
+
{ path: "/about", component: About },
|
|
164
|
+
{ path: "/blog/:slug", component: BlogPost },
|
|
165
|
+
{ path: "*", component: NotFound }
|
|
166
|
+
]);
|
|
167
|
+
|
|
168
|
+
router.to("/about");
|
|
169
|
+
router.back();
|
|
170
|
+
router.path(); // current path
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### i18n
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
import { addLang, setLocale, t, tt } from "sigpro";
|
|
177
|
+
|
|
178
|
+
addLang({
|
|
179
|
+
en: { hello: "Hello" },
|
|
180
|
+
es: { hello: "Hola" }
|
|
129
181
|
});
|
|
182
|
+
|
|
183
|
+
setLocale("es");
|
|
184
|
+
tt("hello"); // "Hola"
|
|
185
|
+
t("hello")(); // "Hola" (reactive getter)
|
|
130
186
|
```
|
|
131
187
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
188
|
+
### HTTP Helper
|
|
189
|
+
|
|
190
|
+
```javascript
|
|
191
|
+
import { db } from "sigpro";
|
|
192
|
+
|
|
193
|
+
const loading = signal(false);
|
|
194
|
+
const data = await db("/api/users", null, loading);
|
|
195
|
+
|
|
196
|
+
// POST
|
|
197
|
+
await db("/api/save", { name: "Ada" });
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
-----
|
|
201
|
+
|
|
202
|
+
## Performance Without Compromise
|
|
203
|
+
|
|
204
|
+
| Feature | **SigPro** | React / Vue | Svelte |
|
|
205
|
+
| :--- | :--- | :--- | :--- |
|
|
206
|
+
| **Payload (Brotli)** | **~4KB** | ~30KB - 50KB | ~5KB (Compiled Runtime) |
|
|
207
|
+
| **State Logic** | **Push-pull Signals** | Virtual DOM Diffing | Compiler Dirty Bits |
|
|
208
|
+
| **Update Speed** | **Direct Node Access** | Component Re-render | Block Reconciliation |
|
|
209
|
+
| **Native Persistence** | **`local()`** | Requires Plugins | Manual |
|
|
210
|
+
| **Dependencies** | **Zero** | Many | Build Toolchain |
|
|
211
|
+
| **Lifecycle Mgmt** | **Automatic (Scopes + `_cln`)** | Manual / Hook-based | Manual / Hook-based |
|
|
212
|
+
| **Routing** | **Reactive Hash Router** | Virtual Router (External) | File-based / External |
|
|
213
|
+
| **Learning Curve** | **Zero (Vanilla JS)** | Steep (JSX/Templates) | Medium (Directives) |
|
|
138
214
|
|
|
139
215
|
-----
|
|
140
216
|
|
|
@@ -144,7 +220,7 @@ The plugin automatically:
|
|
|
144
220
|
npm install sigpro
|
|
145
221
|
```
|
|
146
222
|
|
|
147
|
-
**With Vite
|
|
223
|
+
**With Vite:**
|
|
148
224
|
```bash
|
|
149
225
|
npm create vite@latest my-app -- --template vanilla
|
|
150
226
|
cd my-app
|
|
@@ -158,6 +234,18 @@ npm install sigpro
|
|
|
158
234
|
|
|
159
235
|
-----
|
|
160
236
|
|
|
237
|
+
## What SigPro Is Not
|
|
238
|
+
|
|
239
|
+
SigPro is **not** a framework with a custom compiler, virtual DOM, or JSX transform. It is:
|
|
240
|
+
|
|
241
|
+
- **Vanilla JS** with a reactive core.
|
|
242
|
+
- **Explicit**: `signal()`, `computed()`, `effect()` — no overloaded operators, no magic argument-type dispatch.
|
|
243
|
+
- **Minimal**: only the primitives needed to build UIs, not a kitchen sink.
|
|
244
|
+
|
|
245
|
+
If you want JSX, file-based routing with auto-generation, or a component lifecycle DSL, SigPro is not that. If you want **the rawest, smallest reactive renderer that stays out of your way**, it is.
|
|
246
|
+
|
|
247
|
+
-----
|
|
248
|
+
|
|
161
249
|
## License
|
|
162
250
|
|
|
163
251
|
MIT © 2026 **SigPro Team**.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var{signal:x}=window.SigPro;function f(s,l="tags"){let a=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected","truespeed"]),p=(o)=>o.replace(/"/g,"\\\""),c=(o)=>{let t=[...o.attributes].map(({name:e,value:n})=>/^on/i.test(e)?`${e}: (e) => { ${n.replace(/\s+/g," ").trim()} }`:a.has(e.toLowerCase())&&(!n||n==e)?`${e}: true`:`${e}: "${p(n)}"`);return t.length?`{ ${t.join(", ")} }`:""},m=(o,t=0)=>{let e=" ".repeat(t);if(o.nodeType==3){let n=o.textContent;return n.trim()?`${e}"${p(n)}"`:""}if(o.nodeType==1){let n=o.tagName.toLowerCase(),d=c(o),i=l==="core"?`h('${n}'`:n,r=[...o.childNodes].map((h)=>m(h,t+1)).filter(Boolean),g=!!d;if(l==="core"){if(!r.length)return g?`${e}${i}, ${d})`:`${e}${i})`;if(r.length===1&&!r[0].includes(`
|
|
2
|
+
`))return g?`${e}${i}, ${d}, ${r[0].trim()})`:`${e}${i}, ${r[0].trim()})`;return g?`${e}${i}, ${d},
|
|
3
|
+
${r.join(`,
|
|
4
|
+
`)}
|
|
5
|
+
${e})`:`${e}${i},
|
|
6
|
+
${r.join(`,
|
|
7
|
+
`)}
|
|
8
|
+
${e})`}else{if(!r.length)return g?`${e}${i}(${d})`:`${e}${i}`;if(r.length===1&&!r[0].includes(`
|
|
9
|
+
`))return g?`${e}${i}(${d}, ${r[0].trim()})`:`${e}${i}(${r[0].trim()})`;return g?`${e}${i}(${d},
|
|
10
|
+
${r.join(`,
|
|
11
|
+
`)}
|
|
12
|
+
${e})`:`${e}${i}(
|
|
13
|
+
${r.join(`,
|
|
14
|
+
`)}
|
|
15
|
+
${e})`}}return""},u=[...new DOMParser().parseFromString(s,"text/html").body.childNodes].map((o)=>m(o)).filter(Boolean);return u.length==1?u[0].trim():`
|
|
16
|
+
${u.join(`,
|
|
17
|
+
`)}
|
|
18
|
+
`}var b=()=>{let s=x(""),l=x(""),a=x("tags"),p=x(""),c=()=>{try{l(f(s(),a()))}catch(t){l("Error: "+t.message)}p(s())},m=()=>{s(""),l(""),a("tags"),p("")},u="width:100%;height:200px;padding:10px;border:1px solid #ccc;border-radius:4px;font-family:monospace;font-size:14px;box-sizing:border-box;resize:vertical",o="padding:8px 16px;border:none;border-radius:4px;cursor:pointer;margin-right:8px;font-size:14px";return div({style:"margin:20px auto;font-family:sans-serif"},h1("HTML → SigPro"),div({style:"margin-bottom:10px"},div({style:"display:flex;gap:20px;flex-wrap:wrap;margin-top:5px"},label({style:"display:flex;align-items:center;gap:6px"},"Core",input({type:"radio",name:"mode",value:"core",checked:()=>a()==="core",onchange:(t)=>{if(t.target.checked)a("core"),c()}}),span("core — h('tag', props, ...)")),label({style:"display:flex;align-items:center;gap:6px"},"Tags",input({type:"radio",name:"mode",value:"tags",checked:()=>a()==="tags",onchange:(t)=>{if(t.target.checked)a("tags"),c()}}),span("tags — tag({ props }, ...)")))),div({style:"margin-top:15px;display:flex;gap:10px"},button({style:"padding:8px 16px;border:none;border-radius:4px;cursor:pointer;margin-right:8px;font-size:14px;background:#3b82f6;color:#fff",onclick:c},"Convert"),button({style:"padding:8px 16px;border:none;border-radius:4px;cursor:pointer;margin-right:8px;font-size:14px;background:#d1d5db",onclick:m},"Clear")),div({style:"display:grid;grid-template-columns:1fr;gap:15px;margin-top:15px;width:100%"},div({style:"border:1px solid #ccc;border-radius:8px;padding:10px;display:flex;flex-direction:column"},label({style:"font-weight:bold;margin-bottom:8px"},"HTML Input"),textarea({style:"width:100%;height:200px;padding:10px;border:1px solid #ccc;border-radius:4px;font-family:monospace;font-size:14px;box-sizing:border-box;resize:vertical",placeholder:"Paste your HTML here...",value:s,oninput:(t)=>{s(t.target.value),c()}})),div({style:"border:1px solid #ccc;border-radius:8px;padding:10px;display:flex;flex-direction:column"},div({style:"display:flex;justify-content:space-between;align-items:center;margin-bottom:8px"},span({style:"font-weight:bold"},"SigPro Output"),button({style:"padding:4px 8px;background:#10b981;color:white;border:none;border-radius:4px;cursor:pointer;font-size:12px",onclick:()=>{navigator.clipboard.writeText(l()),alert("Copied!")}},"Copy")),textarea({style:"width:100%;height:200px;padding:10px;border:1px solid #ccc;border-radius:4px;font-family:monospace;font-size:14px;box-sizing:border-box;resize:vertical;background:#f9fafb",readonly:!0,value:l,placeholder:"Converted code will appear here..."})),div({style:"border:1px solid #ccc;border-radius:8px;padding:10px;display:flex;flex-direction:column"},label({style:"font-weight:bold;margin-bottom:8px"},"Live Preview"),iframe({style:"width:100%;height:200px;border:1px solid #e2e8f0;border-radius:4px;background:white;",srcdoc:()=>{return`
|
|
19
|
+
<!DOCTYPE html>
|
|
20
|
+
<html>
|
|
21
|
+
<head>
|
|
22
|
+
<meta charset="UTF-8">
|
|
23
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
24
|
+
<link href="https://cdn.jsdelivr.net/npm/daisyui@5" rel="stylesheet" type="text/css">
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
26
|
+
<style>
|
|
27
|
+
body { padding: 10px; margin: 0; font-family: sans-serif; }
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
${p()||""}
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
34
|
+
`},sandbox:"allow-same-origin allow-scripts allow-popups allow-forms allow-modals"}))))};window.html2sigpro=f;window.converter=b;
|
package/dist/sigpro.editor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var{$:u,isF:C}=window.SigPro,S=(x)=>{let{value:s,class:z}=x,l=u(0),g=u(""),v=u(0),h=u(0),c=u(0),w=()=>window.getSelection().rangeCount?window.getSelection().getRangeAt(0):0,o,d,R="\uD83D\uDE00 \uD83D\uDE0A \uD83D\uDE09 \uD83E\uDDD0 \uD83D\uDE2E \uD83E\uDD14 \uD83D\uDE05 \uD83D\uDE02 \uD83D\uDE0D \uD83D\uDE18 \uD83E\uDD70 \uD83D\uDC4D \uD83D\uDC4E \uD83D\uDC4C \uD83E\uDD1D \uD83E\uDD1E \uD83D\uDC4B \uD83D\uDC4F \uD83D\uDE4C \uD83D\uDE4F \uD83D\uDCAA ☝️ \uD83D\uDC47 \uD83D\uDC48 \uD83D\uDC49 \uD83D\uDD95 ✅ ⚠️ \uD83D\uDE80 \uD83D\uDCE2 ✉️ ❤️".split(" "),k=()=>{h(h()+1),o&&v(o.innerText.length)},b=()=>{if(o){let e=o.innerHTML;C(s)?s(e):x.onchange?.(e),k()}},r=(e,i=null)=>{if(o?.focus(),d){let n=window.getSelection();n.removeAllRanges(),n.addRange(d)}document.execCommand(e,0,i),d=0,b()},L=(e,i=null)=>{if(h(),!o||l())return 0;try{if(e=="formatBlock"){let n=window.getSelection().getRangeAt(0).commonAncestorContainer;while(n&&n!==o){if(n.tagName===i)return 1;n=n.parentNode}return 0}return document.queryCommandState(e)}catch(n){return 0}},T=(e)=>{if(e){let i=new FileReader;i.onload=(n)=>{let f=e.type.startsWith("image/"),m=n.target.result;r("insertHTML",f?div({style:"display:inline-block;resize:both;overflow:hidden;vertical-align:bottom;width:200px;border:1px dashed #ccc;padding:2px;cursor:pointer",class:"resizable-img-container"},[img({src:m,style:"width:100%;height:100%;object-fit:contain;pointer-events:none"})]):a({href:m,download:e.name,contenteditable:"false",style:"display:inline-flex;align-items:center;gap:5px;padding:4px 8px;border:1px solid #ccc;border-radius:4px;background:#f9f9f9;text-decoration:none;color:#333;font-size:12px;margin:2px;cursor:pointer"},[span({class:"icon-[lucide--paperclip] w-3 h-3"}),e.name]))},i.readAsDataURL(e)}},t=(e,i,n)=>button({type:"button",class:()=>`btn btn-ghost btn-xs ${L(i,n)?"btn-active bg-primary/20":""}`,onclick:()=>typeof i=="function"?i():r(i,n)},[span({class:`icon-[lucide--${e}]`})]);return div({class:`border border-base-300 rounded-box bg-base-100 overflow-hidden flex flex-col ${z||""}`},[div({class:"flex flex-wrap items-center gap-1 p-2 border-b border-base-300 bg-base-200 sticky top-0 z-20"},[div({class:"flex flex-wrap gap-1 flex-1"},[t("bold","bold"),t("italic","italic"),t("underline","underline"),input({type:"color",class:"w-5 h-5 p-0 bg-transparent cursor-pointer",oninput:(e)=>r("foreColor",e.target.value)}),span({class:"w-px h-5 bg-base-300 mx-1"}),t("align-left","justifyLeft"),t("align-center","justifyCenter"),t("align-right","justifyRight"),span({class:"w-px h-5 bg-base-300 mx-1"}),t("list","insertUnorderedList"),t("list-ordered","insertOrderedList"),t("indent-decrease","outdent"),t("indent-increase","indent"),t("quote",()=>r("formatBlock",L("formatBlock","BLOCKQUOTE")?"P":"BLOCKQUOTE"),"BLOCKQUOTE"),span({class:"w-px h-5 bg-base-300 mx-1"}),t("link",()=>{let e=prompt("URL:");e&&r("createLink",e)}),t("paperclip",()=>{let e=document.createElement("input");e.type="file",e.onchange=(i)=>T(i.target.files[0]),e.click()}),div({class:"relative"},[t("smile",()=>{d=w(),c(!c())}),div({class:"absolute top-full left-0 mt-1 p-2 bg-base-100 border shadow-xl rounded-box w-52 z-50 flex flex-wrap gap-1",style:()=>c()?"":"display:none"},R.map((e)=>span({class:"cursor-pointer p-1 text-lg",onclick:()=>{r("insertText",e),c(0)}},e)))]),t("undo-2","undo"),t("redo-2","redo")]),t("code-2",()=>{if(!l())g(o?.innerHTML||"");else if(o)o.innerHTML=g(),b();l(!l())})]),div({class:"relative flex-1 flex flex-col",onclick:()=>c(0)},[div({ref:(e)=>{if(e&&!o)o=e,e.innerHTML=(C(s)?s():s)||"",document.execCommand("defaultParagraphSeparator",0,"br"),e.onclick=(i)=>{let n=i.target.closest(".resizable-img-container");if(n){let f=n.querySelector("img");f&&((m)=>{let p=document.createElement("div");p.style="position:fixed;top:0;left:0;width:100%;height:100%;background:#000e;z-index:9999;display:flex;align-items:center;justify-content:center;cursor:zoom-out",p.onclick=()=>p.remove();let y=document.createElement("img");y.src=m,y.style="max-width:95%;max-height:95%",p.appendChild(y),document.body.appendChild(p)})(f.src)}}},style:()=>`min-height:22rem;${l()?"display:none":""}`,class:"p-4 outline-none text-base-content leading-relaxed [&>div]:m-0 [&>p]:m-0 [&>div]:min-h-[1em] [&_.resizable-img-container]:hover:border-primary [&_blockquote]:border-l-4 [&_blockquote]:border-base-300 [&_blockquote]:pl-4 [&_blockquote]:italic [&_ul]:list-disc [&_ul]:pl-8 [&_ol]:list-decimal [&_ol]:pl-8",contenteditable:"true",oninput:b,onkeydown:(e)=>e.key==="Tab"&&(e.preventDefault(),r("indent")),onkeyup:()=>{k(),d=w()},onmouseup:b,onpaste:(e)=>{e.preventDefault(),r("insertText",e.clipboardData.getData("text/plain"))},ondrop:(e)=>{e.preventDefault(),T(e.dataTransfer.files[0])},ondragover:(e)=>e.preventDefault()}),textarea({class:"w-full flex-1 min-h-[22rem] p-4 font-mono text-sm bg-base-200 border-0",style:()=>l()?"":"display:none",value:g,oninput:(e)=>{if(g(e.target.value),o)o.innerHTML=e.target.value;x.onchange?.(e.target.value)}})]),div({class:"px-3 py-1 border-t text-[10px] text-right opacity-60"},[span(()=>v())])])};export{S as Editor};
|
|
1
|
+
function X({update:e,notify:t,unwatched:i}){return{link:o,unlink:c,propagate:b,checkDirty:T,shallowPropagate:d};function o(n,s,p){let g=s.depsTail;if(g!==void 0&&g.dep===n)return;let r=g!==void 0?g.nextDep:s.deps;if(r!==void 0&&r.dep===n){r.version=p,s.depsTail=r;return}let f=n.subsTail;if(f!==void 0&&f.version===p&&f.sub===s)return;let v=s.depsTail=n.subsTail={version:p,dep:n,sub:s,prevDep:g,nextDep:r,prevSub:f,nextSub:void 0};if(r!==void 0)r.prevDep=v;if(g!==void 0)g.nextDep=v;else s.deps=v;if(f!==void 0)f.nextSub=v;else n.subs=v}function c(n,s=n.sub){let{dep:p,prevDep:g,nextDep:r,nextSub:f,prevSub:v}=n;if(r!==void 0)r.prevDep=g;else s.depsTail=g;if(g!==void 0)g.nextDep=r;else s.deps=r;if(f!==void 0)f.prevSub=v;else p.subsTail=v;if(v!==void 0)v.nextSub=f;else if((p.subs=f)===void 0)i(p);return r}function b(n,s){let p=n.nextSub,g;e:do{let r=n.sub,f=r.flags;if(!(f&60)){if(r.flags=f|32,s)r.flags|=8}else if(!(f&12))f=0;else if(!(f&4))r.flags=f&-9|32;else if(!(f&48)&&u(n,r))r.flags=f|8|32,f&=1;else f=0;if(f&2)t(r);if(f&1){let v=r.subs;if(v!==void 0){let x=(n=v).nextSub;if(x!==void 0)g={value:p,prev:g},p=x;continue}}if((n=p)!==void 0){p=n.nextSub;continue}while(g!==void 0)if(n=g.value,g=g.prev,n!==void 0){p=n.nextSub;continue e}break}while(!0)}function T(n,s){let p,g=0,r=!1;e:do{let f=n.dep,v=f.flags;if(s.flags&16)r=!0;else if((v&17)===17){let x=f.subs;if(e(f)){if(x.nextSub!==void 0)d(x);r=!0}}else if((v&33)===33){p={value:n,prev:p},n=f.deps,s=f,++g;continue}if(!r){let x=n.nextDep;if(x!==void 0){n=x;continue}}while(g--){if(n=p.value,p=p.prev,r){let h=s.subs;if(e(s)){if(h.nextSub!==void 0)d(h);s=n.sub;continue}r=!1}else s.flags&=-33;s=n.sub;let x=n.nextDep;if(x!==void 0){n=x;continue e}}return r&&!!s.flags}while(!0)}function d(n){do{let s=n.sub,p=s.flags;if((p&48)===32){if(s.flags=p|16,(p&6)===2)t(s)}}while((n=n.nextSub)!==void 0)}function u(n,s){let p=s.depsTail;while(p!==void 0){if(p===n)return!0;p=p.prevDep}return!1}}var R=0,_=0,K=0,L=0,E=0,y,S=[],D=[];var{link:P,unlink:M,propagate:z,checkDirty:ee,shallowPropagate:te}=X({update(e){if("getter"in e)return ie(e);if("currentValue"in e)return I(e);return e.flags=1,!0},notify(e){let t=E,i=t;do if(S[t++]=e,e.flags&=-3,e=e.subs?.sub,e===void 0||!(e.flags&2))break;while(!0);E=t;while(i<--t){let o=S[i];S[i++]=S[t],S[t]=o}},unwatched(e){if("getter"in e){if(e.depsTail!==void 0)e.flags=17,F(e)}else if("currentValue"in e);else if("fn"in e)W.call(e);else Q.call(e)}});function k(e){return oe.bind({currentValue:e,pendingValue:e,subs:void 0,subsTail:void 0,flags:1})}function N(e){let t={fn:e,cleanup:void 0,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:6},i=y;if(y=t,i!==void 0)P(t,i,0),i.flags|=64;D.push(new Map);try{++_;let o=t.fn();t.cleanup=typeof o==="function"?o:void 0}finally{--_,y=i,D.pop(),t.flags&=-5}return W.bind(t)}function $(e){let t={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:1},i=y;if(y=t,i!==void 0)P(t,i,0),i.flags|=64;D.push(new Map);try{e()}finally{D.pop(),y=i}return Q.bind(t)}function ie(e){if(e.flags&64){let i=e.depsTail;while(i!==void 0){let{prevDep:o,dep:c}=i;if(!("getter"in c)&&!("currentValue"in c))M(i,e);i=o}}e.depsTail=void 0,e.flags=5;let t=y;y=e;try{++R;let i=e.value;return i!==(e.value=e.getter(i))}finally{y=t,e.flags&=-5,G(e)}}function I(e){return e.flags=1,e.currentValue!==(e.currentValue=e.pendingValue)}function ne(e){let t=e.flags;if(t&16||t&32&&ee(e.deps,e)){if(t&64){let o=e.depsTail;while(o!==void 0){let{prevDep:c,dep:b}=o;if(!("getter"in b)&&!("currentValue"in b))M(o,e);o=c}}if(e.cleanup){if(B(e),!e.flags)return}e.depsTail=void 0,e.flags=6;let i=y;y=e,D.push(new Map);try{++R,++_;let o=e.fn();e.cleanup=typeof o==="function"?o:void 0}finally{--_,y=i,D.pop(),e.flags&=-5,G(e)}}else if(e.deps!==void 0)e.flags=2|t&64}function le(){try{while(L<E){let e=S[L];S[L++]=void 0,ne(e)}}finally{while(L<E){let e=S[L];S[L++]=void 0,e.flags|=10}L=0,E=0}}function oe(...e){if(e.length){if(this.pendingValue!==(this.pendingValue=e[0])){this.flags=17;let t=this.subs;if(t!==void 0){if(z(t,!!_),!K)le()}}}else{if(this.flags&16){if(I(this)){let i=this.subs;if(i!==void 0)te(i)}}let t=y;if(t!==void 0)P(this,t,R);return this.currentValue}}function B(e){let t=e.cleanup;e.cleanup=void 0;let i=y;y=void 0;try{t()}finally{y=i}}function W(){if(Q.call(this),this.cleanup)B(this)}function Q(){this.flags=0,F(this);let e=this.subs;if(e!==void 0)M(e)}function F(e){let t=e.depsTail;while(t!==void 0){let i=t.prevDep;M(t,e),t=i}}function G(e){let t=e.depsTail,i=t!==void 0?t.nextDep:e.deps;while(i!==void 0)i=M(i,e)}var A=typeof document<"u"?document:null,re="http://www.w3.org/2000/svg",ae=new Set("svg path circle rect line polyline polygon g defs text textPath tspan use symbol image marker ellipse foreignObject clipPath mask linearGradient radialGradient pattern filter stop animate animateMotion animateTransform view desc metadata title switch feGaussianBlur feOffset feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feFlood feFuncA feFuncB feFuncG feFuncR feImage feMerge feMergeNode feMorphology fePointLight feSpecularLighting feSpotLight feTile feTurbulence".split(" "));function O(e,t,i,o){if(t==="class"||t==="className"){if(o)if(i==null||i===!1)e.removeAttribute("class");else e.setAttribute("class",i===!0?"":i);else e.className=i??"";return}if(i==null||i===!1){e.removeAttribute(t);return}if(t==="style"&&typeof i==="string"){e.setAttribute("style",i);return}if(o){e.setAttribute(t,i===!0?"":i);return}if(t in e&&typeof e[t]!=="function")e[t]=i;else e.setAttribute(t,i===!0?"":i)}function se(e){let t=[e];while(t.length){let i=t.pop();if(i._stopScope)i._stopScope(),i._stopScope=null;if(i._cln){for(let o of i._cln)o();i._cln=null}for(let o=0;o<i.childNodes.length;o++)t.push(i.childNodes[o])}}function U(e,t={},...i){if(typeof e==="function"){let d,u=$(()=>{d=e(t,i)}),n=(s)=>{if(s instanceof Node)s._stopScope=u;else if(Array.isArray(s))s.forEach(n)};return n(d),d}if(t instanceof Node||Array.isArray(t)||t!==null&&typeof t!=="object"||t===void 0)i=[t,...i],t={};let o=ae.has(e),c=o?A.createElementNS(re,e):A.createElement(e),b,T=!1;for(let d in t){let u=t[d];if(d==="ref"){if(typeof u==="function")u(c);else if(u!=null&&typeof u==="object")u.current=c;continue}if(e==="select"&&d==="value"){b=u;continue}if(d==="html"){if(T=!0,typeof u==="function")N(()=>{c.innerHTML=u()??""});else c.innerHTML=u??"";continue}if(d.startsWith("on")&&typeof u==="function"){let n=d.slice(2).toLowerCase();c.addEventListener(n,u),(c._cln||(c._cln=[])).push(()=>c.removeEventListener(n,u))}else if(typeof u==="function")N(()=>O(c,d,u(),o));else O(c,d,u,o)}if(!T){let d=(u)=>{if(Array.isArray(u)){for(let n of u)d(n);return}if(u==null||u===!1||u===!0)return;if(typeof u==="function"){let n=A.createComment("");c.appendChild(n),N(()=>{let s=u(),p=Array.isArray(s)?s:[s],g=[];for(let r of p){if(r==null||r===!1||r===!0)continue;g.push(r instanceof Node?r:A.createTextNode(String(r)))}for(let r of g)c.insertBefore(r,n);return()=>{for(let r of g)se(r),r.remove()}});return}c.appendChild(u instanceof Node?u:A.createTextNode(String(u)))};d(i)}if(b!==void 0)if(typeof b==="function")N(()=>O(c,"value",b(),o));else O(c,"value",b,o);return c}var fe="a abbr article aside audio b blockquote br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark meter nav object ol optgroup option output p picture pre progress section select slot small source span strong sub summary sup table tbody td template textarea tfoot th thead time tr u ul video",Z=(e=typeof window<"u"?window:null)=>{if(!e)return;for(let t of fe.split(" "))e[t]=(i,...o)=>U(t,i,...o)},V=k(typeof window<"u"?window.location.hash.slice(1)||"/":"/"),ue=k({});if(typeof window<"u")window.addEventListener("hashchange",()=>{V(window.location.hash.slice(1)||"/")});var q=(e)=>()=>{let t=U("div",{class:"router-hook"});return N(()=>{let i=V().split("/").filter(Boolean);return $(()=>{let o=e.find((d)=>{let u=d.path.split("/").filter(Boolean);return u.length===i.length&&u.every((n,s)=>n[0]===":"||n===i[s])})||e.find((d)=>d.path==="*");if(!o){t.replaceChildren();return}let c={};o.path.split("/").filter(Boolean).forEach((d,u)=>{if(d[0]===":")c[d.slice(1)]=i[u]}),ue(c);let b=typeof o.component==="function"?U(o.component,c):o.component,T=b==null?[]:Array.isArray(b)?b:[b];t.replaceChildren(...T)})}),t};q.to=(e)=>{if(typeof window<"u")window.location.hash=e.replace(/^#?\/?/,"#/")};q.back=()=>{if(typeof window<"u")window.history.back()};q.path=()=>V();var ce=k("en");Z();var Y=(e)=>typeof e==="function",ge=(e)=>{let{value:t,class:i}=e,o=k(0),c=k(""),b=k(0),T=k(0),d=k(0),u=()=>window.getSelection().rangeCount?window.getSelection().getRangeAt(0):0,n,s,p="\uD83D\uDE00 \uD83D\uDE0A \uD83D\uDE09 \uD83E\uDDD0 \uD83D\uDE2E \uD83E\uDD14 \uD83D\uDE05 \uD83D\uDE02 \uD83D\uDE0D \uD83D\uDE18 \uD83E\uDD70 \uD83D\uDC4D \uD83D\uDC4E \uD83D\uDC4C \uD83E\uDD1D \uD83E\uDD1E \uD83D\uDC4B \uD83D\uDC4F \uD83D\uDE4C \uD83D\uDE4F \uD83D\uDCAA ☝️ \uD83D\uDC47 \uD83D\uDC48 \uD83D\uDC49 \uD83D\uDD95 ✅ ⚠️ \uD83D\uDE80 \uD83D\uDCE2 ✉️ ❤️".split(" "),g=()=>{T(T()+1),n&&b(n.innerText.length)},r=()=>{if(n){let l=n.innerHTML;Y(t)?t(l):e.onchange?.(l),g()}},f=(l,w=null)=>{if(n?.focus(),s){let m=window.getSelection();m.removeAllRanges(),m.addRange(s)}document.execCommand(l,0,w),s=0,r()},v=(l,w=null)=>{if(T(),!n||o())return 0;try{if(l=="formatBlock"){let m=window.getSelection().getRangeAt(0).commonAncestorContainer;while(m&&m!==n){if(m.tagName===w)return 1;m=m.parentNode}return 0}return document.queryCommandState(l)}catch(m){return 0}},x=(l)=>{if(l){let w=new FileReader;w.onload=(m)=>{let j=l.type.startsWith("image/"),H=m.target.result;f("insertHTML",j?div({style:"display:inline-block;resize:both;overflow:hidden;vertical-align:bottom;width:200px;border:1px dashed #ccc;padding:2px;cursor:pointer",class:"resizable-img-container"},[img({src:H,style:"width:100%;height:100%;object-fit:contain;pointer-events:none"})]):a({href:H,download:l.name,contenteditable:"false",style:"display:inline-flex;align-items:center;gap:5px;padding:4px 8px;border:1px solid #ccc;border-radius:4px;background:#f9f9f9;text-decoration:none;color:#333;font-size:12px;margin:2px;cursor:pointer"},[span({class:"icon-[lucide--paperclip] w-3 h-3"}),l.name]))},w.readAsDataURL(l)}},h=(l,w,m)=>button({type:"button",class:()=>`btn btn-ghost btn-xs ${v(w,m)?"btn-active bg-primary/20":""}`,onclick:()=>typeof w=="function"?w():f(w,m)},[span({class:`icon-[lucide--${l}]`})]);return div({class:`border border-base-300 rounded-box bg-base-100 overflow-hidden flex flex-col ${i||""}`},[div({class:"flex flex-wrap items-center gap-1 p-2 border-b border-base-300 bg-base-200 sticky top-0 z-20"},[div({class:"flex flex-wrap gap-1 flex-1"},[h("bold","bold"),h("italic","italic"),h("underline","underline"),input({type:"color",class:"w-5 h-5 p-0 bg-transparent cursor-pointer",oninput:(l)=>f("foreColor",l.target.value)}),span({class:"w-px h-5 bg-base-300 mx-1"}),h("align-left","justifyLeft"),h("align-center","justifyCenter"),h("align-right","justifyRight"),span({class:"w-px h-5 bg-base-300 mx-1"}),h("list","insertUnorderedList"),h("list-ordered","insertOrderedList"),h("indent-decrease","outdent"),h("indent-increase","indent"),h("quote",()=>f("formatBlock",v("formatBlock","BLOCKQUOTE")?"P":"BLOCKQUOTE"),"BLOCKQUOTE"),span({class:"w-px h-5 bg-base-300 mx-1"}),h("link",()=>{let l=prompt("URL:");l&&f("createLink",l)}),h("paperclip",()=>{let l=document.createElement("input");l.type="file",l.onchange=(w)=>x(w.target.files[0]),l.click()}),div({class:"relative"},[h("smile",()=>{s=u(),d(!d())}),div({class:"absolute top-full left-0 mt-1 p-2 bg-base-100 border shadow-xl rounded-box w-52 z-50 flex flex-wrap gap-1",style:()=>d()?"":"display:none"},p.map((l)=>span({class:"cursor-pointer p-1 text-lg",onclick:()=>{f("insertText",l),d(0)}},l)))]),h("undo-2","undo"),h("redo-2","redo")]),h("code-2",()=>{if(!o())c(n?.innerHTML||"");else if(n)n.innerHTML=c(),r();o(!o())})]),div({class:"relative flex-1 flex flex-col",onclick:()=>d(0)},[div({ref:(l)=>{if(l&&!n)n=l,l.innerHTML=(Y(t)?t():t)||"",document.execCommand("defaultParagraphSeparator",0,"br"),l.onclick=(w)=>{let m=w.target.closest(".resizable-img-container");if(m){let j=m.querySelector("img");j&&((H)=>{let C=document.createElement("div");C.style="position:fixed;top:0;left:0;width:100%;height:100%;background:#000e;z-index:9999;display:flex;align-items:center;justify-content:center;cursor:zoom-out",C.onclick=()=>C.remove();let J=document.createElement("img");J.src=H,J.style="max-width:95%;max-height:95%",C.appendChild(J),document.body.appendChild(C)})(j.src)}}},style:()=>`min-height:22rem;${o()?"display:none":""}`,class:"p-4 outline-none text-base-content leading-relaxed [&>div]:m-0 [&>p]:m-0 [&>div]:min-h-[1em] [&_.resizable-img-container]:hover:border-primary [&_blockquote]:border-l-4 [&_blockquote]:border-base-300 [&_blockquote]:pl-4 [&_blockquote]:italic [&_ul]:list-disc [&_ul]:pl-8 [&_ol]:list-decimal [&_ol]:pl-8",contenteditable:"true",oninput:r,onkeydown:(l)=>l.key==="Tab"&&(l.preventDefault(),f("indent")),onkeyup:()=>{g(),s=u()},onmouseup:r,onpaste:(l)=>{l.preventDefault(),f("insertText",l.clipboardData.getData("text/plain"))},ondrop:(l)=>{l.preventDefault(),x(l.dataTransfer.files[0])},ondragover:(l)=>l.preventDefault()}),textarea({class:"w-full flex-1 min-h-[22rem] p-4 font-mono text-sm bg-base-200 border-0",style:()=>o()?"":"display:none",value:c,oninput:(l)=>{if(c(l.target.value),n)n.innerHTML=l.target.value;e.onchange?.(l.target.value)}})]),div({class:"px-3 py-1 border-t text-[10px] text-right opacity-60"},[span(()=>b())])])};export{ge as Editor};
|