@draftably/editor 0.4.0 → 0.5.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/dist/assets/{engine.worker-C6o2x40z.js → engine.worker-BDrPGHQt.js} +1019 -994
- package/dist/element.js +27 -16
- package/dist/index.js +4961 -4823
- package/dist/types/src/components/session-context.d.ts +3 -0
- package/dist/types/src/dsl/translate.d.ts +1 -1
- package/dist/types/src/editor/internal.d.ts +3 -0
- package/dist/types/src/editor/mount.d.ts +13 -6
- package/dist/types/src/model/appearance.d.ts +8 -1
- package/dist/types/src/runtime/color-scheme.d.ts +15 -0
- package/dist/types/src/runtime/host.d.ts +34 -2
- package/dist/types/src/runtime/page-shared.d.ts +1 -1
- package/dist/types/src/runtime/schemes.d.ts +2 -0
- package/dist/types/src/runtime/svg-renderer.d.ts +6 -2
- package/dist/types/src/runtime/types.d.ts +7 -0
- package/dist/types/src/state/active-session.d.ts +3 -0
- package/dist/types/src/state/session/emphasis.d.ts +3 -0
- package/dist/types/src/state/session/index.d.ts +8 -0
- package/package.json +1 -1
package/dist/element.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { mountEditor as E } from "./index.js";
|
|
2
|
-
const A = [
|
|
2
|
+
const A = [
|
|
3
|
+
"link",
|
|
4
|
+
"contextmenu"
|
|
5
|
+
], k = "0.5.0", h = k;
|
|
3
6
|
function b(t, e) {
|
|
4
7
|
if (t === e || typeof t == "function" && typeof e == "function") return !0;
|
|
5
8
|
if (!t || !e || typeof t != "object" || typeof e != "object" || Array.isArray(t) !== Array.isArray(e)) return !1;
|
|
6
|
-
const s = Object.keys(t).filter((
|
|
7
|
-
return s.length ===
|
|
9
|
+
const s = Object.keys(t).filter((n) => t[n] !== void 0), r = Object.keys(e).filter((n) => e[n] !== void 0);
|
|
10
|
+
return s.length === r.length && s.every((n) => b(t[n], e[n]));
|
|
8
11
|
}
|
|
9
12
|
function y(t, e) {
|
|
10
13
|
if (!Object.hasOwn(t, e)) return;
|
|
11
14
|
const s = t[e];
|
|
12
15
|
return delete t[e], s;
|
|
13
16
|
}
|
|
14
|
-
function
|
|
17
|
+
function v(t) {
|
|
15
18
|
const e = customElements.get(t)?.runtimeVersion;
|
|
16
19
|
e !== h && console.warn(
|
|
17
20
|
`<${t}> is already defined by @draftably runtime ${e ?? "unknown"}; this copy (${h}) is not used. Install one copy of the runtime.`
|
|
@@ -46,17 +49,17 @@ function w(t, e, s) {
|
|
|
46
49
|
}
|
|
47
50
|
function M(t, e, s) {
|
|
48
51
|
if (!("preventDefault" in s)) return void c(t, e, s);
|
|
49
|
-
const { preventDefault:
|
|
50
|
-
c(t, e,
|
|
52
|
+
const { preventDefault: r, ...n } = s;
|
|
53
|
+
c(t, e, n) || r();
|
|
51
54
|
}
|
|
52
55
|
function S(t, e, s) {
|
|
53
|
-
const
|
|
56
|
+
const r = t.ownerDocument, n = typeof HTMLSlotElement < "u" && "assign" in HTMLSlotElement.prototype, f = /* @__PURE__ */ new WeakMap();
|
|
54
57
|
let a = /* @__PURE__ */ new Map(), m = [];
|
|
55
58
|
const g = () => {
|
|
56
|
-
if (
|
|
59
|
+
if (n)
|
|
57
60
|
for (const i of m) {
|
|
58
61
|
let o = f.get(i.el);
|
|
59
|
-
o || (o =
|
|
62
|
+
o || (o = r.createElement("slot"), i.el.append(o), f.set(i.el, o)), o.assign(...a.get(i.slot) ?? []);
|
|
60
63
|
}
|
|
61
64
|
}, u = () => {
|
|
62
65
|
const i = [...a.keys()].join(`
|
|
@@ -90,7 +93,7 @@ function S(t, e, s) {
|
|
|
90
93
|
};
|
|
91
94
|
}
|
|
92
95
|
const d = "draft-editor";
|
|
93
|
-
typeof customElements < "u" && (customElements.get(d) ?
|
|
96
|
+
typeof customElements < "u" && (customElements.get(d) ? v(d) : customElements.define(
|
|
94
97
|
d,
|
|
95
98
|
class extends HTMLElement {
|
|
96
99
|
static runtimeVersion = h;
|
|
@@ -121,7 +124,7 @@ typeof customElements < "u" && (customElements.get(d) ? k(d) : customElements.de
|
|
|
121
124
|
this._root = this.ownerDocument.createElement("div"), this._root.style.cssText = "display:flex;flex-direction:column;height:100%;min-height:0", s.append(this._root), this._slotting = S(
|
|
122
125
|
this,
|
|
123
126
|
null,
|
|
124
|
-
(
|
|
127
|
+
(r) => this.editor?.anchor(r)
|
|
125
128
|
);
|
|
126
129
|
}
|
|
127
130
|
_root;
|
|
@@ -165,15 +168,23 @@ typeof customElements < "u" && (customElements.get(d) ? k(d) : customElements.de
|
|
|
165
168
|
}
|
|
166
169
|
});
|
|
167
170
|
} catch (s) {
|
|
168
|
-
const
|
|
169
|
-
this._setStatus("error"), this.setAttribute("data-error",
|
|
171
|
+
const r = w(1, s, "The diagram editor could not start."), n = r.error.diagnostics[0].message;
|
|
172
|
+
this._setStatus("error"), this.setAttribute("data-error", n), c(this, "update", r);
|
|
170
173
|
return;
|
|
171
174
|
}
|
|
172
175
|
this.editor = e;
|
|
173
|
-
for (const s of [
|
|
174
|
-
|
|
176
|
+
for (const s of [
|
|
177
|
+
"update",
|
|
178
|
+
"anchors",
|
|
179
|
+
"diagnostics",
|
|
180
|
+
"camera",
|
|
181
|
+
"select",
|
|
182
|
+
"link",
|
|
183
|
+
"contextmenu"
|
|
184
|
+
])
|
|
185
|
+
e.on(s, (r) => M(this, s, r));
|
|
175
186
|
e.on("anchors", ({ anchors: s }) => this._slotting.setAnchors(s)), e.anchor(this._slotting.names()), e.ready.then(
|
|
176
|
-
() => this.editor === e && this._setStatus("ready"),
|
|
187
|
+
(s) => this.editor === e && this._setStatus(s.status === "error" ? "error" : "ready"),
|
|
177
188
|
() => this.editor === e && this._setStatus("error")
|
|
178
189
|
);
|
|
179
190
|
}
|