@linkurious/ogma-annotations 2.1.2 → 2.1.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/dist/{Polygon-BsnVN6js.js → Polygon-C9ZkyU-t.js} +210 -196
- package/dist/index.js +9 -9
- package/dist/index.mjs +4980 -4528
- package/dist/types/Control-BiYdzv0K.d.ts +1609 -0
- package/dist/types/index.d.ts +271 -1913
- package/dist/types/ui.d.ts +742 -1423
- package/dist/ui-styles.css +308 -46
- package/dist/ui.js +17 -17
- package/dist/ui.mjs +572 -166
- package/package.json +10 -7
package/dist/ui.mjs
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { RgbaBase as
|
|
5
|
-
import { j as
|
|
6
|
-
const
|
|
7
|
-
class
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var R = (i, t, e) => t in i ? _(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var r = (i, t, e) => R(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { RgbaBase as z } from "vanilla-colorful/lib/entrypoints/rgba";
|
|
5
|
+
import { j as w, s as g, t as $, i as B, v as E, h as S, K as m, aN as F, D as x, an as M, ai as P, F as W, u as V, L as q, al as L, aM as U } from "./Polygon-C9ZkyU-t.js";
|
|
6
|
+
const k = "rgba-color-picker";
|
|
7
|
+
class Y extends z {
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return customElements.get(
|
|
9
|
+
function N() {
|
|
10
|
+
return customElements.get(k) || customElements.define(k, Y), document.createElement(k);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
12
|
+
const j = [
|
|
13
13
|
{ value: "#f5f5f5", style: "--circle-color: #f5f5f5;" },
|
|
14
14
|
{ value: "#EDE6FF", style: "--circle-color: #EDE6FF;" },
|
|
15
15
|
{
|
|
16
16
|
value: "transparent",
|
|
17
17
|
style: "--circle-color: white; border: 2px dashed #ccc;"
|
|
18
18
|
}
|
|
19
|
-
],
|
|
19
|
+
], C = [
|
|
20
20
|
{ value: "sans-serif", label: "Sans Serif", icon: "type" },
|
|
21
21
|
{ value: "serif", label: "Serif", icon: "italic" },
|
|
22
22
|
{ value: "monospace", label: "Monospace", icon: "code" }
|
|
23
|
-
],
|
|
23
|
+
], G = [
|
|
24
24
|
{ value: "none", label: "None", icon: "x" },
|
|
25
25
|
{ value: "arrow", label: "Open Arrow", icon: "arrow-left" },
|
|
26
26
|
{ value: "arrow-plain", label: "Filled Arrow", icon: "play" },
|
|
27
27
|
{ value: "halo-dot", label: "Halo Dot", icon: "circle-dot" },
|
|
28
28
|
{ value: "dot", label: "Dot", icon: "dot" }
|
|
29
|
-
],
|
|
29
|
+
], X = [
|
|
30
30
|
{ value: "plain", icon: "circle" },
|
|
31
31
|
{ value: "dashed", icon: "circle-dashed" }
|
|
32
|
-
],
|
|
33
|
-
function
|
|
34
|
-
return `rgba(${
|
|
32
|
+
], J = ["#0099FF", "#FF7523", "#44AA99"];
|
|
33
|
+
function D(i) {
|
|
34
|
+
return `rgba(${i.r}, ${i.g}, ${i.b}, ${i.a})`;
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
return { colors: [...
|
|
36
|
+
const K = 3;
|
|
37
|
+
function Z() {
|
|
38
|
+
return { colors: [...J], activeIndex: 0 };
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const e =
|
|
42
|
-
return e === -1 ? { colors: [t, ...
|
|
40
|
+
function Q(i, t) {
|
|
41
|
+
const e = i.colors.indexOf(t);
|
|
42
|
+
return e === -1 ? { colors: [t, ...i.colors].slice(0, K), activeIndex: 0 } : { colors: i.colors, activeIndex: e };
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const tt = {
|
|
45
45
|
"chevron-down": '<path d="m6 9 6 6 6-6"/>',
|
|
46
46
|
x: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
47
47
|
"arrow-left": '<path d="m12 19-7-7 7-7"/><path d="M19 12H5"/>',
|
|
@@ -53,6 +53,8 @@ const W = {
|
|
|
53
53
|
"circle-dashed": '<path d="M10.1 2.182a10 10 0 0 1 3.8 0"/><path d="M13.9 21.818a10 10 0 0 1-3.8 0"/><path d="M17.609 3.721a10 10 0 0 1 2.69 2.7"/><path d="M2.182 13.9a10 10 0 0 1 0-3.8"/><path d="M20.279 17.609a10 10 0 0 1-2.7 2.69"/><path d="M21.818 10.1a10 10 0 0 1 0 3.8"/><path d="M3.721 6.391a10 10 0 0 1 2.7-2.69"/><path d="M6.391 20.279a10 10 0 0 1-2.69-2.7"/>',
|
|
54
54
|
type: '<path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/>',
|
|
55
55
|
italic: '<line x1="19" x2="10" y1="4" y2="4"/><line x1="14" x2="5" y1="20" y2="20"/><line x1="15" x2="9" y1="4" y2="20"/>',
|
|
56
|
+
bold: '<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"/>',
|
|
57
|
+
user: '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>',
|
|
56
58
|
code: '<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>',
|
|
57
59
|
trash: '<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>',
|
|
58
60
|
undo: '<path d="M3 7v6h6"/><path d="M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"/>',
|
|
@@ -68,74 +70,100 @@ const W = {
|
|
|
68
70
|
"rotate-ccw": '<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/>',
|
|
69
71
|
minimize: '<path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/>'
|
|
70
72
|
};
|
|
71
|
-
function
|
|
72
|
-
return `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${
|
|
73
|
+
function b(i, t = 18) {
|
|
74
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${tt[i]}</svg>`;
|
|
73
75
|
}
|
|
74
|
-
const
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
const et = 150;
|
|
77
|
+
function O(i, { onShow: t, onHide: e, hideWhenNotEditable: o = !0 }) {
|
|
78
|
+
const n = (p) => !o || i.isAnnotationEditable(p);
|
|
79
|
+
let s = null, a = null, d = null, h = null;
|
|
80
|
+
const c = () => {
|
|
81
|
+
h !== null && (clearTimeout(h), h = null);
|
|
82
|
+
}, l = () => {
|
|
83
|
+
if (c(), s) {
|
|
84
|
+
const p = s;
|
|
85
|
+
s = null, n(p.id) ? (a = p, t(p)) : u();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!a && d != null) {
|
|
89
|
+
const p = i.getAnnotation(d);
|
|
90
|
+
p && n(p.id) && (a = p, t(p));
|
|
91
|
+
}
|
|
92
|
+
}, u = () => {
|
|
93
|
+
c(), s = null, a = null, e();
|
|
94
|
+
}, y = (p) => {
|
|
95
|
+
if (c(), p.ids.length === 1) {
|
|
96
|
+
const f = i.getAnnotation(p.ids[0]);
|
|
97
|
+
if (!f) return;
|
|
98
|
+
if (d = p.ids[0], s = f, i.isDrawing()) {
|
|
99
|
+
i.once("cancelDrawing", l), i.once("completeDrawing", l);
|
|
87
100
|
return;
|
|
88
101
|
}
|
|
89
|
-
|
|
102
|
+
h = setTimeout(l, et);
|
|
90
103
|
} else
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
n(), o = null, e();
|
|
104
|
+
d = null, u();
|
|
105
|
+
}, v = () => u(), A = (p) => {
|
|
106
|
+
const f = s ?? a;
|
|
107
|
+
f && !p.ids.includes(f.id) || (d = null, u());
|
|
96
108
|
};
|
|
97
|
-
return
|
|
98
|
-
|
|
109
|
+
return i.on("select", y), i.on("click", l), i.on("dragend", l), i.on("dragstart", v), i.on("unselect", A), () => {
|
|
110
|
+
c(), i.off("select", y), i.off("click", l), i.off("dragend", l), i.off("dragstart", v), i.off("unselect", A), i.off("cancelDrawing", l), i.off("completeDrawing", l);
|
|
99
111
|
};
|
|
100
112
|
}
|
|
101
|
-
const
|
|
102
|
-
|
|
113
|
+
const ot = "right", nt = "vertical", st = [
|
|
114
|
+
"arrow",
|
|
115
|
+
"text",
|
|
116
|
+
"box",
|
|
117
|
+
"comment",
|
|
118
|
+
"polygon"
|
|
119
|
+
];
|
|
120
|
+
function it(i) {
|
|
121
|
+
return w(i) ? "arrow" : g(i) ? "text" : $(i) ? "box" : B(i) ? "comment" : E(i) ? "polygon" : null;
|
|
122
|
+
}
|
|
123
|
+
class kt {
|
|
103
124
|
constructor(t) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
r(this, "control");
|
|
126
|
+
r(this, "panel");
|
|
127
|
+
r(this, "panelBody");
|
|
128
|
+
r(this, "mode", null);
|
|
129
|
+
r(this, "currentAnnotation", null);
|
|
130
|
+
r(this, "currentColor", "#0099FF");
|
|
131
|
+
r(this, "recent", Z());
|
|
132
|
+
r(this, "colorCircles", []);
|
|
133
|
+
r(this, "colorPickerOverlay", null);
|
|
134
|
+
r(this, "colorPicker", null);
|
|
135
|
+
r(this, "detachVisibility");
|
|
136
|
+
r(this, "documentClickHandler");
|
|
137
|
+
r(this, "enabledTypes");
|
|
138
|
+
r(this, "hide", () => {
|
|
117
139
|
this.panel.style.display = "none", this.closeColorPicker(), this.currentAnnotation = null, this.mode = null;
|
|
118
140
|
});
|
|
119
|
-
this.control = t.control;
|
|
141
|
+
this.control = t.control, this.enabledTypes = t.enabledTypes ?? st;
|
|
120
142
|
const e = t.container ?? document.body;
|
|
121
|
-
this.panel = document.createElement("div"), this.panel.className = "annotation-panel", this.panel.style.display = "none", this.panel.dataset.placement = t.placement ??
|
|
143
|
+
this.panel = document.createElement("div"), this.panel.className = "annotation-panel", this.panel.style.display = "none", this.panel.dataset.placement = t.placement ?? ot, this.panel.dataset.orientation = t.orientation ?? nt, this.panelBody = document.createElement("div"), this.panelBody.className = "panel-body", this.panel.appendChild(this.panelBody), e.appendChild(this.panel), this.detachVisibility = O(this.control, {
|
|
122
144
|
onShow: (o) => {
|
|
145
|
+
const n = it(o);
|
|
146
|
+
if (!n || !this.enabledTypes.includes(n)) {
|
|
147
|
+
this.hide();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
123
150
|
this.setAnnotation(o), this.show();
|
|
124
151
|
},
|
|
125
|
-
onHide: this.hide
|
|
152
|
+
onHide: this.hide,
|
|
153
|
+
hideWhenNotEditable: t.hideWhenNotEditable
|
|
126
154
|
}), ["click", "mousedown", "mousemove"].forEach(
|
|
127
|
-
(o) => this.panel.addEventListener(o, (
|
|
155
|
+
(o) => this.panel.addEventListener(o, (n) => n.stopPropagation())
|
|
128
156
|
), this.documentClickHandler = (o) => {
|
|
129
|
-
this.colorPickerOverlay && !this.colorPickerOverlay.contains(o.target) && !this.colorCircles.some((
|
|
157
|
+
this.colorPickerOverlay && !this.colorPickerOverlay.contains(o.target) && !this.colorCircles.some((n) => n.contains(o.target)) && this.closeColorPicker(), this.panelBody.querySelectorAll(".custom-select").forEach((n) => n.classList.remove("open"));
|
|
130
158
|
}, document.addEventListener("click", this.documentClickHandler);
|
|
131
159
|
}
|
|
132
160
|
setAnnotation(t) {
|
|
133
|
-
this.currentAnnotation = t,
|
|
161
|
+
this.currentAnnotation = t, w(t) ? (this.mode = "arrow", this.renderArrow(t)) : g(t) || $(t) || B(t) ? (this.mode = "text", this.renderText(t)) : E(t) && (this.mode = "polygon", this.renderPolygon(t));
|
|
134
162
|
}
|
|
135
163
|
renderArrow(t) {
|
|
136
164
|
const e = t.properties.style || {};
|
|
137
165
|
this.updateColorFromAnnotation(
|
|
138
|
-
e.strokeColor ||
|
|
166
|
+
e.strokeColor || S.strokeColor
|
|
139
167
|
), this.panelBody.innerHTML = `
|
|
140
168
|
${this.section("Color", this.colorSelector())}
|
|
141
169
|
${this.section(
|
|
@@ -145,20 +173,20 @@ class Z {
|
|
|
145
173
|
${this.extremitySelector("tail", t)}
|
|
146
174
|
</div>`
|
|
147
175
|
)}
|
|
148
|
-
${this.slider("Stroke width", "line-width", e.strokeWidth ||
|
|
176
|
+
${this.slider("Stroke width", "line-width", e.strokeWidth || S.strokeWidth, 1, 20)}
|
|
149
177
|
${this.lineTypeButtons(e.strokeType || "plain")}
|
|
150
178
|
`, this.bind();
|
|
151
179
|
}
|
|
152
180
|
renderText(t) {
|
|
153
181
|
const e = t.properties.style || {};
|
|
154
|
-
this.updateColorFromAnnotation(e.color ||
|
|
155
|
-
const o = typeof e.fontSize == "number" ? e.fontSize : typeof
|
|
182
|
+
this.updateColorFromAnnotation(e.color || m.color);
|
|
183
|
+
const o = typeof e.fontSize == "number" ? e.fontSize : typeof m.fontSize == "number" ? m.fontSize : 18;
|
|
156
184
|
this.panelBody.innerHTML = `
|
|
157
185
|
${this.section("Color", this.colorSelector())}
|
|
158
|
-
${this.section("Background", this.backgroundSelector(e.background ||
|
|
159
|
-
${this.section("Font", `<div class="custom-select-section">${this.fontSelector(e.font ||
|
|
186
|
+
${this.section("Background", this.backgroundSelector(e.background || m.background))}
|
|
187
|
+
${this.section("Font", `<div class="custom-select-section">${this.fontSelector(e.font || m.font)}</div>`)}
|
|
160
188
|
${this.slider("Font size", "font-size", o, 8, 72)}
|
|
161
|
-
${this.slider("Stroke width", "line-width", e.strokeWidth ||
|
|
189
|
+
${this.slider("Stroke width", "line-width", e.strokeWidth || m.strokeWidth, 1, 20)}
|
|
162
190
|
${this.lineTypeButtons(e.strokeType || "plain")}
|
|
163
191
|
`, this.bind();
|
|
164
192
|
}
|
|
@@ -176,7 +204,7 @@ class Z {
|
|
|
176
204
|
return `<div class="section-header"><h3>${t}</h3></div>${e}`;
|
|
177
205
|
}
|
|
178
206
|
icon(t, e = !1) {
|
|
179
|
-
return e ? `<span style="display:inline-flex;transform:rotate(180deg)">${
|
|
207
|
+
return e ? `<span style="display:inline-flex;transform:rotate(180deg)">${b(t)}</span>` : b(t);
|
|
180
208
|
}
|
|
181
209
|
colorSelector() {
|
|
182
210
|
return `<div class="color-selector">${this.recent.colors.map(
|
|
@@ -188,7 +216,7 @@ class Z {
|
|
|
188
216
|
).join("")}</div>`;
|
|
189
217
|
}
|
|
190
218
|
backgroundSelector(t) {
|
|
191
|
-
return `<div class="color-selector">${
|
|
219
|
+
return `<div class="color-selector">${j.map(
|
|
192
220
|
({ value: e, style: o }) => `
|
|
193
221
|
<button class="color-circle ${e === t ? "color-circle-primary" : ""}" data-background-color="${e}">
|
|
194
222
|
<div class="color-inner" style="${o}"></div>
|
|
@@ -197,45 +225,45 @@ class Z {
|
|
|
197
225
|
).join("")}</div>`;
|
|
198
226
|
}
|
|
199
227
|
fontSelector(t) {
|
|
200
|
-
const e =
|
|
228
|
+
const e = C.find((o) => o.value === t) || C[0];
|
|
201
229
|
return this.dropdown(
|
|
202
230
|
"font",
|
|
203
231
|
e,
|
|
204
|
-
|
|
232
|
+
C.map((o) => ({ ...o, selected: o.value === t }))
|
|
205
233
|
);
|
|
206
234
|
}
|
|
207
235
|
extremitySelector(t, e) {
|
|
208
|
-
var
|
|
209
|
-
const o = ((
|
|
210
|
-
...
|
|
211
|
-
icon:
|
|
212
|
-
selected:
|
|
213
|
-
rotate:
|
|
214
|
-
})),
|
|
215
|
-
return `<div class="extremity-wrapper"><label>${t}</label>${this.dropdown(t,
|
|
216
|
-
}
|
|
217
|
-
dropdown(t, e, o,
|
|
218
|
-
return `<div class="custom-select" data-type="${t}" ${
|
|
236
|
+
var a;
|
|
237
|
+
const o = ((a = e.properties.style) == null ? void 0 : a[t]) || "none", n = G.map((d) => ({
|
|
238
|
+
...d,
|
|
239
|
+
icon: d.value === "arrow" && t === "tail" ? "arrow-left" : d.value === "arrow" ? "arrow-right" : d.icon,
|
|
240
|
+
selected: d.value === o,
|
|
241
|
+
rotate: d.value === "arrow-plain" && t === "tail"
|
|
242
|
+
})), s = n.find((d) => d.selected) || n[0];
|
|
243
|
+
return `<div class="extremity-wrapper"><label>${t}</label>${this.dropdown(t, s, n, `data-end="${t}"`)}</div>`;
|
|
244
|
+
}
|
|
245
|
+
dropdown(t, e, o, n = "") {
|
|
246
|
+
return `<div class="custom-select" data-type="${t}" ${n}>
|
|
219
247
|
<div class="custom-select-trigger">
|
|
220
248
|
${this.icon(e.icon, e.rotate)}
|
|
221
249
|
<span>${e.label}</span>
|
|
222
250
|
${this.icon("chevron-down")}
|
|
223
251
|
</div>
|
|
224
252
|
<div class="custom-select-options">${o.map(
|
|
225
|
-
(
|
|
226
|
-
<div class="custom-select-option ${
|
|
227
|
-
${this.icon(
|
|
228
|
-
<span>${
|
|
253
|
+
(s) => `
|
|
254
|
+
<div class="custom-select-option ${s.selected ? "selected" : ""}" data-value="${s.value}" data-icon="${s.icon}" data-rotate="${s.rotate ? "1" : ""}" title="${s.label}">
|
|
255
|
+
${this.icon(s.icon, s.rotate)}
|
|
256
|
+
<span>${s.label}</span>
|
|
229
257
|
</div>
|
|
230
258
|
`
|
|
231
259
|
).join("")}</div>
|
|
232
260
|
</div>`;
|
|
233
261
|
}
|
|
234
|
-
slider(t, e, o,
|
|
262
|
+
slider(t, e, o, n, s) {
|
|
235
263
|
return `${this.section(
|
|
236
264
|
t,
|
|
237
265
|
`<div class="slider-section">
|
|
238
|
-
<input type="range" id="${e}-slider" class="slider" min="${
|
|
266
|
+
<input type="range" id="${e}-slider" class="slider" min="${n}" max="${s}" value="${o}">
|
|
239
267
|
<div class="slider-value"><span id="${e}-value">${o}</span></div>
|
|
240
268
|
</div>`
|
|
241
269
|
)}`;
|
|
@@ -243,7 +271,7 @@ class Z {
|
|
|
243
271
|
lineTypeButtons(t) {
|
|
244
272
|
return `${this.section(
|
|
245
273
|
"Line type",
|
|
246
|
-
`<div class="linetype-section">${
|
|
274
|
+
`<div class="linetype-section">${X.map(
|
|
247
275
|
({ value: e, icon: o }) => `
|
|
248
276
|
<button class="linetype-button ${t === e ? "active" : ""}" data-linetype="${e}" title="${e}">
|
|
249
277
|
${this.icon(o)}
|
|
@@ -259,8 +287,8 @@ class Z {
|
|
|
259
287
|
), this.colorCircles.forEach((t, e) => {
|
|
260
288
|
t.addEventListener("click", (o) => {
|
|
261
289
|
o.stopPropagation();
|
|
262
|
-
const
|
|
263
|
-
this.recent = { ...this.recent, activeIndex: e }, this.currentColor = this.recent.colors[e], this.updateColorCircles(),
|
|
290
|
+
const n = this.recent.activeIndex === e && t.classList.contains("color-circle-primary");
|
|
291
|
+
this.recent = { ...this.recent, activeIndex: e }, this.currentColor = this.recent.colors[e], this.updateColorCircles(), n ? this.toggleColorPicker(t) : this.mode === "arrow" ? this.updateStyle({ strokeColor: this.currentColor }) : this.mode === "text" && this.updateStyle({ strokeColor: this.currentColor });
|
|
264
292
|
});
|
|
265
293
|
}), this.updateColorCircles(), this.panelBody.querySelectorAll("[data-background-color]").forEach((t) => {
|
|
266
294
|
t.addEventListener(
|
|
@@ -273,19 +301,19 @@ class Z {
|
|
|
273
301
|
), o = t.querySelectorAll(
|
|
274
302
|
".custom-select-option"
|
|
275
303
|
);
|
|
276
|
-
e.addEventListener("click", (
|
|
277
|
-
|
|
278
|
-
|
|
304
|
+
e.addEventListener("click", (n) => {
|
|
305
|
+
n.stopPropagation(), this.panelBody.querySelectorAll(".custom-select").forEach((s) => {
|
|
306
|
+
s !== t && s.classList.remove("open");
|
|
279
307
|
}), t.classList.toggle("open");
|
|
280
|
-
}), o.forEach((
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
o.forEach((
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
const u = t.dataset.type,
|
|
288
|
-
u === "font" ? this.updateStyle({ font:
|
|
308
|
+
}), o.forEach((n) => {
|
|
309
|
+
n.addEventListener("click", (s) => {
|
|
310
|
+
s.stopPropagation();
|
|
311
|
+
const a = n.dataset.value;
|
|
312
|
+
o.forEach((v) => v.classList.remove("selected")), n.classList.add("selected");
|
|
313
|
+
const d = n.dataset.icon, h = n.dataset.rotate === "1", c = n.querySelector("span").textContent || "", l = e.querySelector("svg, span[style]");
|
|
314
|
+
l && (l.outerHTML = this.icon(d, h)), e.querySelector("span").textContent = c, t.classList.remove("open");
|
|
315
|
+
const u = t.dataset.type, y = t.dataset.end;
|
|
316
|
+
u === "font" ? this.updateStyle({ font: a }) : y === "head" ? this.updateStyle({ head: a }) : y === "tail" && this.updateStyle({ tail: a });
|
|
289
317
|
});
|
|
290
318
|
});
|
|
291
319
|
}), ["line-width", "font-size"].forEach((t) => {
|
|
@@ -293,10 +321,10 @@ class Z {
|
|
|
293
321
|
`#${t}-slider`
|
|
294
322
|
), o = this.panelBody.querySelector(`#${t}-value`);
|
|
295
323
|
e && o && e.addEventListener("input", () => {
|
|
296
|
-
const
|
|
297
|
-
o.textContent =
|
|
298
|
-
this.mode === "text" ? { strokeWidth:
|
|
299
|
-
) : t === "font-size" && this.updateStyle({ fontSize:
|
|
324
|
+
const n = parseInt(e.value, 10);
|
|
325
|
+
o.textContent = n.toString(), t === "line-width" ? this.updateStyle(
|
|
326
|
+
this.mode === "text" ? { strokeWidth: n, strokeColor: this.currentColor } : { strokeWidth: n }
|
|
327
|
+
) : t === "font-size" && this.updateStyle({ fontSize: n });
|
|
300
328
|
});
|
|
301
329
|
}), this.panelBody.querySelectorAll(".linetype-button").forEach((t) => {
|
|
302
330
|
t.addEventListener("click", () => {
|
|
@@ -307,7 +335,7 @@ class Z {
|
|
|
307
335
|
}
|
|
308
336
|
// Color management
|
|
309
337
|
updateColorFromAnnotation(t) {
|
|
310
|
-
this.recent =
|
|
338
|
+
this.recent = Q(this.recent, t), this.currentColor = t;
|
|
311
339
|
}
|
|
312
340
|
updateColorCircles() {
|
|
313
341
|
this.colorCircles.forEach((t, e) => {
|
|
@@ -322,10 +350,10 @@ class Z {
|
|
|
322
350
|
this.closeColorPicker();
|
|
323
351
|
return;
|
|
324
352
|
}
|
|
325
|
-
this.colorPickerOverlay = document.createElement("div"), this.colorPickerOverlay.className = "color-picker-overlay", document.body.appendChild(this.colorPickerOverlay), this.colorPicker =
|
|
353
|
+
this.colorPickerOverlay = document.createElement("div"), this.colorPickerOverlay.className = "color-picker-overlay", document.body.appendChild(this.colorPickerOverlay), this.colorPicker = N(), this.colorPicker.color = F(this.currentColor), this.colorPickerOverlay.appendChild(this.colorPicker);
|
|
326
354
|
const e = t.getBoundingClientRect();
|
|
327
355
|
this.colorPickerOverlay.style.right = `${window.innerWidth - e.right}px`, this.colorPickerOverlay.style.top = `${e.bottom + 10}px`, this.colorPicker.addEventListener("color-changed", (o) => {
|
|
328
|
-
this.currentColor =
|
|
356
|
+
this.currentColor = D(o.detail.value), this.recent.colors[this.recent.activeIndex] = this.currentColor, this.updateColorCircles(), this.mode === "arrow" ? this.updateStyle({ strokeColor: this.currentColor }) : this.mode === "text" ? this.updateStyle({ color: this.currentColor }) : this.mode === "polygon" && this.updateStyle({ strokeColor: this.currentColor });
|
|
329
357
|
});
|
|
330
358
|
}
|
|
331
359
|
closeColorPicker() {
|
|
@@ -333,7 +361,7 @@ class Z {
|
|
|
333
361
|
}
|
|
334
362
|
// Unified update method
|
|
335
363
|
updateStyle(t) {
|
|
336
|
-
this.currentAnnotation && (
|
|
364
|
+
this.currentAnnotation && (w(this.currentAnnotation) ? this.control.updateStyle(this.currentAnnotation.id, t) : E(this.currentAnnotation) ? this.control.updateStyle(this.currentAnnotation.id, t) : this.control.updateStyle(this.currentAnnotation.id, t));
|
|
337
365
|
}
|
|
338
366
|
// Layout
|
|
339
367
|
setPlacement(t) {
|
|
@@ -350,7 +378,7 @@ class Z {
|
|
|
350
378
|
this.closeColorPicker(), this.detachVisibility(), document.removeEventListener("click", this.documentClickHandler), this.panel.remove();
|
|
351
379
|
}
|
|
352
380
|
}
|
|
353
|
-
const
|
|
381
|
+
const rt = "bottom", lt = "horizontal", T = [
|
|
354
382
|
"arrow",
|
|
355
383
|
"comment",
|
|
356
384
|
"sticky-note",
|
|
@@ -358,26 +386,26 @@ const j = "bottom", J = "horizontal", A = [
|
|
|
358
386
|
"text",
|
|
359
387
|
"polygon"
|
|
360
388
|
];
|
|
361
|
-
class
|
|
389
|
+
class Ct {
|
|
362
390
|
constructor(t) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
391
|
+
r(this, "control");
|
|
392
|
+
r(this, "root");
|
|
393
|
+
r(this, "activeButton", null);
|
|
394
|
+
r(this, "undoButton");
|
|
395
|
+
r(this, "redoButton");
|
|
396
|
+
r(this, "handleDrawingEnd", () => this.setActiveMode(null));
|
|
397
|
+
r(this, "handleHistory", () => this.updateUndoRedo());
|
|
370
398
|
this.control = t.control;
|
|
371
399
|
const e = t.container ?? document.body;
|
|
372
|
-
this.root = document.createElement("div"), this.root.className = "annotation-toolbar", this.root.dataset.placement = t.placement ??
|
|
373
|
-
(
|
|
400
|
+
this.root = document.createElement("div"), this.root.className = "annotation-toolbar oa-toolbar oa-toolbar-bar", this.root.dataset.placement = t.placement ?? rt, this.root.dataset.orientation = t.orientation ?? lt, e.appendChild(this.root), ["click", "mousedown", "mousemove"].forEach(
|
|
401
|
+
(a) => this.root.addEventListener(a, (d) => d.stopPropagation())
|
|
374
402
|
);
|
|
375
|
-
const o = t.enabledTypes ??
|
|
376
|
-
|
|
377
|
-
(
|
|
403
|
+
const o = t.enabledTypes ?? T, n = t.styles ?? {};
|
|
404
|
+
T.filter((a) => o.includes(a)).forEach(
|
|
405
|
+
(a) => this.root.appendChild(this.drawingButton(a, n))
|
|
378
406
|
), o.length > 0 && this.root.appendChild(this.separator()), this.undoButton = this.button(null, "undo", "Undo", () => this.control.undo()), this.redoButton = this.button(null, "redo", "Redo", () => this.control.redo()), this.root.appendChild(this.undoButton), this.root.appendChild(this.redoButton);
|
|
379
|
-
const
|
|
380
|
-
(
|
|
407
|
+
const s = t.deleteMode ?? "erase";
|
|
408
|
+
(s === "erase" || s === "both") && (this.root.appendChild(this.separator()), this.root.appendChild(
|
|
381
409
|
this.button(
|
|
382
410
|
"erase",
|
|
383
411
|
"eraser",
|
|
@@ -386,16 +414,18 @@ class tt {
|
|
|
386
414
|
this.control.isEraseModeActive() ? (this.control.disableEraseMode(), this.setActiveMode(null)) : (this.control.enableEraseMode(), this.setActiveMode("erase"));
|
|
387
415
|
}
|
|
388
416
|
)
|
|
389
|
-
)), (
|
|
417
|
+
)), (s === "select" || s === "both") && (s === "select" && this.root.appendChild(this.separator()), this.root.appendChild(
|
|
390
418
|
this.button(null, "trash", "Delete selected", () => {
|
|
391
|
-
const
|
|
392
|
-
|
|
419
|
+
const d = this.control.getSelectedAnnotations().features.filter(
|
|
420
|
+
(h) => this.control.isAnnotationEditable(h.id)
|
|
421
|
+
);
|
|
422
|
+
d.length > 0 && this.control.remove({ type: "FeatureCollection", features: d });
|
|
393
423
|
})
|
|
394
424
|
)), (t.onJsonExport || t.onSvgExport) && (this.root.appendChild(this.separator()), t.onJsonExport && this.root.appendChild(
|
|
395
425
|
this.button(null, "download", "Export annotations", t.onJsonExport)
|
|
396
426
|
), t.onSvgExport && this.root.appendChild(
|
|
397
427
|
this.button(null, "camera", "Export SVG", t.onSvgExport)
|
|
398
|
-
)), this.control.on(
|
|
428
|
+
)), this.control.on(x, this.handleDrawingEnd), this.control.on(M, this.handleDrawingEnd), this.control.on(P, this.handleHistory), this.updateUndoRedo();
|
|
399
429
|
}
|
|
400
430
|
drawingButton(t, e) {
|
|
401
431
|
switch (t) {
|
|
@@ -411,11 +441,11 @@ class tt {
|
|
|
411
441
|
});
|
|
412
442
|
case "comment":
|
|
413
443
|
return this.button("comment", "message-square", "Add comment", () => {
|
|
414
|
-
var
|
|
415
|
-
const o = (
|
|
444
|
+
var s, a, d, h;
|
|
445
|
+
const o = (s = e.comment) == null ? void 0 : s.commentStyle, n = (a = e.comment) == null ? void 0 : a.arrowStyle;
|
|
416
446
|
this.control.enableCommentDrawing({
|
|
417
|
-
offsetX: ((
|
|
418
|
-
offsetY: ((
|
|
447
|
+
offsetX: ((d = e.comment) == null ? void 0 : d.offsetX) ?? 200,
|
|
448
|
+
offsetY: ((h = e.comment) == null ? void 0 : h.offsetY) ?? -150,
|
|
419
449
|
commentStyle: {
|
|
420
450
|
content: "",
|
|
421
451
|
...o,
|
|
@@ -428,13 +458,13 @@ class tt {
|
|
|
428
458
|
}
|
|
429
459
|
},
|
|
430
460
|
arrowStyle: {
|
|
431
|
-
...
|
|
461
|
+
...n,
|
|
432
462
|
style: {
|
|
433
463
|
strokeType: "plain",
|
|
434
464
|
strokeColor: "#3A03CF",
|
|
435
465
|
strokeWidth: 2,
|
|
436
466
|
head: "halo-dot",
|
|
437
|
-
...
|
|
467
|
+
...n == null ? void 0 : n.style
|
|
438
468
|
}
|
|
439
469
|
}
|
|
440
470
|
}), this.setActiveMode("comment");
|
|
@@ -487,13 +517,13 @@ class tt {
|
|
|
487
517
|
);
|
|
488
518
|
}
|
|
489
519
|
}
|
|
490
|
-
button(t, e, o,
|
|
491
|
-
const
|
|
492
|
-
return
|
|
520
|
+
button(t, e, o, n) {
|
|
521
|
+
const s = document.createElement("button");
|
|
522
|
+
return s.className = "oa-toolbar-button", s.dataset.tooltip = o, s.innerHTML = b(e, 16), s.addEventListener("click", n), t && (s.dataset.mode = t), s;
|
|
493
523
|
}
|
|
494
524
|
separator() {
|
|
495
525
|
const t = document.createElement("span");
|
|
496
|
-
return t.className = "separator", t;
|
|
526
|
+
return t.className = "oa-toolbar-separator", t;
|
|
497
527
|
}
|
|
498
528
|
setActiveMode(t) {
|
|
499
529
|
this.activeButton && this.activeButton.classList.remove("active"), this.activeButton = t ? this.root.querySelector(`[data-mode="${t}"]`) : null, this.activeButton && this.activeButton.classList.add("active");
|
|
@@ -509,25 +539,401 @@ class tt {
|
|
|
509
539
|
this.root.dataset.orientation = t;
|
|
510
540
|
}
|
|
511
541
|
destroy() {
|
|
512
|
-
this.control.off(
|
|
542
|
+
this.control.off(x, this.handleDrawingEnd), this.control.off(M, this.handleDrawingEnd), this.control.off(P, this.handleHistory), this.root.remove();
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
class at {
|
|
546
|
+
constructor(t, e) {
|
|
547
|
+
r(this, "element");
|
|
548
|
+
r(this, "onClick", () => {
|
|
549
|
+
this.item.action(this.ctx);
|
|
550
|
+
});
|
|
551
|
+
this.ctx = t, this.item = e, this.element = document.createElement("button"), this.element.type = "button", this.element.className = e.danger ? "oa-toolbar-button oa-toolbar-button-danger" : "oa-toolbar-button", this.element.dataset.tooltip = e.title, this.element.innerHTML = b(e.icon, 16), this.element.addEventListener("click", this.onClick);
|
|
552
|
+
}
|
|
553
|
+
update(t) {
|
|
554
|
+
if (!this.item.isActive) return;
|
|
555
|
+
const e = this.item.isActive(t);
|
|
556
|
+
this.element.classList.toggle("active", e), this.element.setAttribute("aria-pressed", String(e));
|
|
557
|
+
}
|
|
558
|
+
destroy() {
|
|
559
|
+
this.element.removeEventListener("click", this.onClick);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function I(i, t) {
|
|
563
|
+
const e = document.createElement("div");
|
|
564
|
+
e.className = "oa-toolbar-dropdown";
|
|
565
|
+
const o = document.createElement("button");
|
|
566
|
+
o.type = "button", o.className = "oa-toolbar-button oa-toolbar-dropdown-trigger", o.dataset.tooltip = i;
|
|
567
|
+
const n = document.createElement("span");
|
|
568
|
+
n.className = "oa-toolbar-dropdown-label", n.textContent = t;
|
|
569
|
+
const s = document.createElement("span");
|
|
570
|
+
s.className = "oa-toolbar-dropdown-chevron", s.innerHTML = b("chevron-down", 14), o.appendChild(n), o.appendChild(s);
|
|
571
|
+
const a = document.createElement("div");
|
|
572
|
+
a.className = "oa-toolbar-dropdown-panel";
|
|
573
|
+
const d = () => e.classList.remove("open");
|
|
574
|
+
return o.addEventListener("click", (h) => {
|
|
575
|
+
var l;
|
|
576
|
+
h.stopPropagation();
|
|
577
|
+
const c = !e.classList.contains("open");
|
|
578
|
+
(l = e.closest(".annotation-style-toolbar")) == null || l.querySelectorAll(".oa-toolbar-dropdown.open").forEach((u) => {
|
|
579
|
+
u !== e && u.classList.remove("open");
|
|
580
|
+
}), e.classList.toggle("open", c);
|
|
581
|
+
}), e.appendChild(o), e.appendChild(a), {
|
|
582
|
+
element: e,
|
|
583
|
+
panel: a,
|
|
584
|
+
close: d,
|
|
585
|
+
setLabel: (h) => {
|
|
586
|
+
n.textContent = h;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
class ct {
|
|
591
|
+
constructor(t, e) {
|
|
592
|
+
r(this, "element");
|
|
593
|
+
r(this, "dropdown");
|
|
594
|
+
this.ctx = t, this.item = e, this.dropdown = I(e.title, ""), this.element = this.dropdown.element, e.options.forEach((o) => {
|
|
595
|
+
const n = document.createElement("button");
|
|
596
|
+
n.type = "button", n.className = "oa-toolbar-dropdown-option", n.textContent = o.label, o.style && Object.assign(n.style, o.style), n.addEventListener("click", (s) => {
|
|
597
|
+
s.stopPropagation(), e.onSelect(o.value, this.ctx), this.dropdown.close();
|
|
598
|
+
}), this.dropdown.panel.appendChild(n);
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
update(t) {
|
|
602
|
+
const e = this.item.getValue(t), o = this.item.options.find((s) => s.value === e), n = this.item.getLabel ? this.item.getLabel(e, t) : (o == null ? void 0 : o.label) ?? `${e}`;
|
|
603
|
+
this.dropdown.setLabel(n), this.element.title = (o == null ? void 0 : o.label) ?? `${e}`;
|
|
604
|
+
}
|
|
605
|
+
destroy() {
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const dt = 12;
|
|
609
|
+
class ht {
|
|
610
|
+
constructor(t, e) {
|
|
611
|
+
r(this, "control");
|
|
612
|
+
r(this, "ogma");
|
|
613
|
+
r(this, "options");
|
|
614
|
+
r(this, "annotationId");
|
|
615
|
+
r(this, "overlay");
|
|
616
|
+
/** The element handed to `addOverlay` - Ogma writes its own
|
|
617
|
+
* `style.transform` (translate/rotate/scale, recomputed on every
|
|
618
|
+
* viewChanged/zoom/rotate/move) directly onto this node to place it at
|
|
619
|
+
* `position`, so nothing of ours may also set `transform` here or Ogma's
|
|
620
|
+
* assignment clobbers it (inline style, last writer wins - there's no way
|
|
621
|
+
* to compose two separate `transform` writers on one element). Zero-size
|
|
622
|
+
* and otherwise unstyled; it exists purely as the anchor point. */
|
|
623
|
+
r(this, "anchor");
|
|
624
|
+
/** The actual visible pill - a child of `anchor`, `position: absolute`
|
|
625
|
+
* with its own `transform: translate(-50%, -100%)` (see `styles.css`) to
|
|
626
|
+
* center horizontally and sit fully above the anchor point. This is where
|
|
627
|
+
* our own positioning lives, kept off `anchor` for exactly that reason. */
|
|
628
|
+
r(this, "root");
|
|
629
|
+
r(this, "cells", []);
|
|
630
|
+
r(this, "documentClickHandler", (t) => {
|
|
631
|
+
this.root.contains(t.target) || this.root.querySelectorAll(".oa-toolbar-dropdown.open").forEach((e) => e.classList.remove("open"));
|
|
632
|
+
});
|
|
633
|
+
this.control = t.control, this.options = t, this.ogma = this.control.getOgma(), this.annotationId = e.id, this.anchor = document.createElement("div"), this.anchor.className = "annotation-style-toolbar-anchor", this.root = document.createElement("div"), this.root.className = "annotation-style-toolbar oa-toolbar oa-toolbar-bar", this.anchor.appendChild(this.root), ["click", "mousedown", "mousemove"].forEach(
|
|
634
|
+
(n) => this.root.addEventListener(n, (s) => s.stopPropagation())
|
|
635
|
+
);
|
|
636
|
+
const o = {
|
|
637
|
+
getAnnotation: () => this.control.getAnnotation(this.annotationId),
|
|
638
|
+
updateStyle: (n) => this.control.updateStyle(this.annotationId, n),
|
|
639
|
+
deleteAnnotation: () => {
|
|
640
|
+
const n = this.control.getAnnotation(this.annotationId);
|
|
641
|
+
n && this.control.remove(n);
|
|
642
|
+
}
|
|
643
|
+
};
|
|
644
|
+
this.setItems(this.getItems(o), o), this.cells.forEach((n) => n.update(e)), this.overlay = this.ogma.layers.addOverlay({
|
|
645
|
+
element: this.anchor,
|
|
646
|
+
position: this.getAnchor(e),
|
|
647
|
+
scaled: !1
|
|
648
|
+
}), document.addEventListener("click", this.documentClickHandler);
|
|
649
|
+
}
|
|
650
|
+
/** Turns one `ToolbarItem` into its `ToolbarCell` - `"separator"` has
|
|
651
|
+
* none (handled by `setItems` directly), `"custom"` calls its own
|
|
652
|
+
* `build()` (the color picker's escape hatch), `"button"`/`"dropdown"`
|
|
653
|
+
* go through the two generic cell classes. */
|
|
654
|
+
buildCell(t, e) {
|
|
655
|
+
switch (t.kind) {
|
|
656
|
+
case "separator":
|
|
657
|
+
return null;
|
|
658
|
+
case "custom":
|
|
659
|
+
return t.build(e);
|
|
660
|
+
case "button":
|
|
661
|
+
return new at(e, t);
|
|
662
|
+
case "dropdown":
|
|
663
|
+
return new ct(e, t);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
setItems(t, e) {
|
|
667
|
+
this.cells = [], t.forEach((o) => {
|
|
668
|
+
if (o.kind === "separator") {
|
|
669
|
+
const s = document.createElement("span");
|
|
670
|
+
s.className = "oa-toolbar-separator", this.root.appendChild(s);
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const n = this.buildCell(o, e);
|
|
674
|
+
this.cells.push(n), this.root.appendChild(n.element);
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Top-center of the annotation's box, in graph space, offset outward by
|
|
679
|
+
* `ANCHOR_GAP` (screen-constant, so divided by zoom) and rotated by the
|
|
680
|
+
* global annotation-rotation angle - the same `ctx.rotate(rotation)`
|
|
681
|
+
* transform `Handles.renderOutline` applies to a Text box's outline, so
|
|
682
|
+
* the pill tracks the box exactly as it visually rotates.
|
|
683
|
+
*/
|
|
684
|
+
getAnchor(t) {
|
|
685
|
+
var l;
|
|
686
|
+
const e = this.control.getZoom(), o = this.control.getRotation(), n = ((l = t.properties.style) == null ? void 0 : l.fixedSize) === !0;
|
|
687
|
+
let { height: s } = W(t);
|
|
688
|
+
n && (s /= e);
|
|
689
|
+
const a = V(t), d = -(s / 2 + dt / e), h = Math.sin(o), c = Math.cos(o);
|
|
690
|
+
return {
|
|
691
|
+
x: a.x - d * h,
|
|
692
|
+
y: a.y + d * c
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
/** Refreshes every cell and repositions the pill for `annotation` -
|
|
696
|
+
* called after a select, an own-cell edit, or an external update to the
|
|
697
|
+
* same annotation. Does not rebuild cells; the host recreates the whole
|
|
698
|
+
* instance when the annotation identity/kind changes. */
|
|
699
|
+
update(t) {
|
|
700
|
+
this.cells.forEach((e) => e.update(t)), this.overlay.setPosition(this.getAnchor(t));
|
|
701
|
+
}
|
|
702
|
+
destroy() {
|
|
703
|
+
document.removeEventListener("click", this.documentClickHandler), this.cells.forEach((t) => t.destroy()), this.overlay.destroy();
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
class pt {
|
|
707
|
+
constructor(t, e) {
|
|
708
|
+
r(this, "element");
|
|
709
|
+
r(this, "dropdown");
|
|
710
|
+
r(this, "swatch");
|
|
711
|
+
r(this, "more");
|
|
712
|
+
r(this, "morePicker", null);
|
|
713
|
+
r(this, "morePickerHost", null);
|
|
714
|
+
this.ctx = t, this.options = e;
|
|
715
|
+
const { swatches: o } = e;
|
|
716
|
+
this.dropdown = I("Color", ""), this.element = this.dropdown.element, this.element.classList.add("oa-toolbar-color-cell"), this.swatch = document.createElement("span"), this.swatch.className = "oa-toolbar-swatch", this.dropdown.element.querySelector(".oa-toolbar-dropdown-trigger").insertBefore(this.swatch, this.dropdown.element.querySelector(".oa-toolbar-dropdown-label"));
|
|
717
|
+
const n = document.createElement("div");
|
|
718
|
+
n.className = "oa-toolbar-swatch-grid", o.forEach((s) => {
|
|
719
|
+
const a = document.createElement("button");
|
|
720
|
+
a.type = "button", a.className = "oa-toolbar-swatch-cell", a.classList.toggle("oa-toolbar-swatch-cell-transparent", s.fill === "transparent"), a.title = s.fill, a.style.setProperty("--oa-swatch-fill", s.fill), a.style.setProperty("--oa-swatch-stroke", s.stroke), a.addEventListener("click", (d) => {
|
|
721
|
+
d.stopPropagation(), this.pick(s.fill), this.dropdown.close();
|
|
722
|
+
}), n.appendChild(a);
|
|
723
|
+
}), this.dropdown.panel.appendChild(n), this.more = document.createElement("button"), this.more.type = "button", this.more.className = "oa-toolbar-more-colors", this.more.textContent = "More colors…", this.more.addEventListener("click", (s) => {
|
|
724
|
+
s.stopPropagation(), this.openMorePicker();
|
|
725
|
+
}), this.dropdown.panel.appendChild(this.more);
|
|
726
|
+
}
|
|
727
|
+
pick(t) {
|
|
728
|
+
this.ctx.updateStyle({ background: t });
|
|
729
|
+
}
|
|
730
|
+
openMorePicker() {
|
|
731
|
+
var e;
|
|
732
|
+
if (this.options.onMoreColors) {
|
|
733
|
+
this.dropdown.close(), this.options.onMoreColors(this.ctx, this.more);
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
if (this.morePickerHost) {
|
|
737
|
+
this.closeMorePicker();
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
this.morePickerHost = document.createElement("div"), this.morePickerHost.className = "oa-toolbar-more-colors-host", this.morePicker = N();
|
|
741
|
+
const t = ((e = this.ctx.getAnnotation().properties.style) == null ? void 0 : e.background) || m.background;
|
|
742
|
+
this.morePicker.color = F(t), this.morePicker.addEventListener("color-changed", (o) => {
|
|
743
|
+
this.pick(D(o.detail.value));
|
|
744
|
+
}), this.morePickerHost.appendChild(this.morePicker), this.dropdown.panel.appendChild(this.morePickerHost);
|
|
745
|
+
}
|
|
746
|
+
closeMorePicker() {
|
|
747
|
+
var t;
|
|
748
|
+
(t = this.morePickerHost) == null || t.remove(), this.morePickerHost = null, this.morePicker = null;
|
|
749
|
+
}
|
|
750
|
+
update(t) {
|
|
751
|
+
var o;
|
|
752
|
+
const e = ((o = t.properties.style) == null ? void 0 : o.background) || m.background;
|
|
753
|
+
this.swatch.style.setProperty("--oa-swatch-fill", e), this.swatch.classList.toggle("oa-toolbar-swatch-transparent", e === "transparent");
|
|
754
|
+
}
|
|
755
|
+
destroy() {
|
|
756
|
+
this.closeMorePicker();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
const ut = [
|
|
760
|
+
{ fill: "#FFE49B", stroke: "#D9A926" },
|
|
761
|
+
{ fill: "#FFC8A7", stroke: "#CC8C66" },
|
|
762
|
+
{ fill: "#FFA7B5", stroke: "#C2707D" },
|
|
763
|
+
{ fill: "#D9F3B0", stroke: "#A2C270" },
|
|
764
|
+
{ fill: "#C7F7EF", stroke: "#8CD9CC" },
|
|
765
|
+
{ fill: "#99D6FF", stroke: "#5CA5D6" },
|
|
766
|
+
{ fill: "#D1C7FA", stroke: "#9B8CD9" },
|
|
767
|
+
{ fill: "#C3DAFE", stroke: "#668ECC" },
|
|
768
|
+
{ fill: "transparent", stroke: "#CCCCCC" }
|
|
769
|
+
], mt = [
|
|
770
|
+
{ value: "sans-serif", label: "Sans Serif" },
|
|
771
|
+
{ value: "serif", label: "Serif", style: { fontFamily: "serif" } },
|
|
772
|
+
{ value: "monospace", label: "Monospace", style: { fontFamily: "monospace" } },
|
|
773
|
+
{
|
|
774
|
+
value: "IBM Plex Sans",
|
|
775
|
+
label: "IBM Plex Sans",
|
|
776
|
+
style: { fontFamily: "IBM Plex Sans" }
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
value: "IBM Plex Mono",
|
|
780
|
+
label: "IBM Plex Mono",
|
|
781
|
+
style: { fontFamily: "IBM Plex Mono" }
|
|
782
|
+
}
|
|
783
|
+
], yt = [12, 14, 16, 18, 24, 32, 48, 64];
|
|
784
|
+
class H extends ht {
|
|
785
|
+
getItems(t) {
|
|
786
|
+
var d, h;
|
|
787
|
+
const e = this.options.fonts ?? mt, o = this.options.fontSizes ?? yt, n = this.options.swatches ?? ut, s = this.options.onMoreColors, a = [
|
|
788
|
+
{
|
|
789
|
+
kind: "custom",
|
|
790
|
+
id: "color",
|
|
791
|
+
build: (c) => new pt(c, { swatches: n, onMoreColors: s })
|
|
792
|
+
},
|
|
793
|
+
{ kind: "separator" },
|
|
794
|
+
{
|
|
795
|
+
kind: "dropdown",
|
|
796
|
+
id: "font",
|
|
797
|
+
title: "Font",
|
|
798
|
+
options: e,
|
|
799
|
+
getValue: (c) => {
|
|
800
|
+
var l;
|
|
801
|
+
return ((l = c.properties.style) == null ? void 0 : l.font) || m.font;
|
|
802
|
+
},
|
|
803
|
+
getLabel: () => "Aa",
|
|
804
|
+
// `fonts` entries are always string values (font-family names) -
|
|
805
|
+
// ToolbarDropdownValue is string | number only because the size
|
|
806
|
+
// cell also uses this same item shape with numbers.
|
|
807
|
+
onSelect: (c, l) => l.updateStyle({ font: `${c}` })
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
kind: "dropdown",
|
|
811
|
+
id: "fontSize",
|
|
812
|
+
title: "Font size",
|
|
813
|
+
options: o.map((c) => ({ value: c, label: `${c}` })),
|
|
814
|
+
getValue: (c) => {
|
|
815
|
+
const l = c.properties.style;
|
|
816
|
+
return Math.round(
|
|
817
|
+
q(
|
|
818
|
+
(l == null ? void 0 : l.fontSize) ?? m.fontSize,
|
|
819
|
+
l == null ? void 0 : l.fontScale
|
|
820
|
+
)
|
|
821
|
+
);
|
|
822
|
+
},
|
|
823
|
+
// Setting fontSize directly (not fontScale) resets any accumulated
|
|
824
|
+
// resize-driven scale, matching what picking an explicit size means.
|
|
825
|
+
onSelect: (c, l) => l.updateStyle({ fontSize: c, fontScale: 1 })
|
|
826
|
+
},
|
|
827
|
+
{ kind: "separator" },
|
|
828
|
+
{
|
|
829
|
+
kind: "button",
|
|
830
|
+
id: "bold",
|
|
831
|
+
title: "Bold",
|
|
832
|
+
icon: "bold",
|
|
833
|
+
isActive: (c) => {
|
|
834
|
+
var l;
|
|
835
|
+
return ((l = c.properties.style) == null ? void 0 : l.fontWeight) === "bold";
|
|
836
|
+
},
|
|
837
|
+
action: (c) => {
|
|
838
|
+
var u;
|
|
839
|
+
const l = ((u = c.getAnnotation().properties.style) == null ? void 0 : u.fontWeight) === "bold";
|
|
840
|
+
c.updateStyle({ fontWeight: l ? "normal" : "bold" });
|
|
841
|
+
}
|
|
842
|
+
},
|
|
843
|
+
{ kind: "separator" },
|
|
844
|
+
{
|
|
845
|
+
kind: "button",
|
|
846
|
+
id: "showAuthor",
|
|
847
|
+
title: "Show author",
|
|
848
|
+
icon: "user",
|
|
849
|
+
isActive: (c) => {
|
|
850
|
+
var l;
|
|
851
|
+
return ((l = c.properties.style) == null ? void 0 : l.showAuthor) === !0;
|
|
852
|
+
},
|
|
853
|
+
action: (c) => {
|
|
854
|
+
var u;
|
|
855
|
+
const l = ((u = c.getAnnotation().properties.style) == null ? void 0 : u.showAuthor) === !0;
|
|
856
|
+
c.updateStyle({ showAuthor: !l });
|
|
857
|
+
}
|
|
858
|
+
},
|
|
859
|
+
{ kind: "separator" },
|
|
860
|
+
{
|
|
861
|
+
kind: "button",
|
|
862
|
+
id: "delete",
|
|
863
|
+
title: "Delete",
|
|
864
|
+
icon: "trash",
|
|
865
|
+
danger: !0,
|
|
866
|
+
action: (c) => c.deleteAnnotation()
|
|
867
|
+
}
|
|
868
|
+
];
|
|
869
|
+
return ((h = (d = this.options).items) == null ? void 0 : h.call(d, a, t)) ?? a;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
class ft extends H {
|
|
873
|
+
}
|
|
874
|
+
class wt {
|
|
875
|
+
constructor(t) {
|
|
876
|
+
r(this, "control");
|
|
877
|
+
r(this, "options");
|
|
878
|
+
r(this, "current", null);
|
|
879
|
+
r(this, "detachVisibility");
|
|
880
|
+
r(this, "handleUpdate", (t) => {
|
|
881
|
+
this.current && t.id === this.current.annotationId && g(t) && this.current.update(t);
|
|
882
|
+
});
|
|
883
|
+
this.control = t.control, this.options = t, this.detachVisibility = O(this.control, {
|
|
884
|
+
onShow: (e) => this.show(e),
|
|
885
|
+
onHide: () => this.hide(),
|
|
886
|
+
hideWhenNotEditable: t.hideWhenNotEditable
|
|
887
|
+
}), this.control.on(L, this.handleUpdate);
|
|
888
|
+
}
|
|
889
|
+
show(t) {
|
|
890
|
+
if (!g(t)) {
|
|
891
|
+
this.hide();
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
const e = U(t) ? ft : H;
|
|
895
|
+
if (this.current && this.current.annotationId === t.id && this.current instanceof e) {
|
|
896
|
+
this.current.update(t);
|
|
897
|
+
return;
|
|
898
|
+
}
|
|
899
|
+
this.hide(), this.current = new e(this.options, t);
|
|
900
|
+
}
|
|
901
|
+
hide() {
|
|
902
|
+
var t;
|
|
903
|
+
(t = this.current) == null || t.destroy(), this.current = null;
|
|
904
|
+
}
|
|
905
|
+
destroy() {
|
|
906
|
+
this.detachVisibility(), this.control.off(L, this.handleUpdate), this.hide();
|
|
513
907
|
}
|
|
514
908
|
}
|
|
515
909
|
export {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
910
|
+
st as ALL_PANEL_ANNOTATION_TYPES,
|
|
911
|
+
kt as AnnotationPanel,
|
|
912
|
+
ht as AnnotationStyleToolbar,
|
|
913
|
+
Ct as AnnotationToolbar,
|
|
914
|
+
j as BACKGROUNDS,
|
|
915
|
+
at as ButtonItemCell,
|
|
916
|
+
pt as ColorCell,
|
|
917
|
+
nt as DEFAULT_PANEL_ORIENTATION,
|
|
918
|
+
ot as DEFAULT_PANEL_PLACEMENT,
|
|
919
|
+
J as DEFAULT_RECENT_COLORS,
|
|
920
|
+
mt as DEFAULT_TOOLBAR_FONTS,
|
|
921
|
+
yt as DEFAULT_TOOLBAR_FONT_SIZES,
|
|
922
|
+
ct as DropdownItemCell,
|
|
923
|
+
G as EXTREMITY_OPTIONS,
|
|
924
|
+
C as FONTS,
|
|
925
|
+
tt as ICON_PATHS,
|
|
926
|
+
X as LINE_TYPES,
|
|
927
|
+
K as MAX_RECENT_COLORS,
|
|
928
|
+
ut as STICKY_SWATCHES,
|
|
929
|
+
ft as StickyNoteStyleToolbar,
|
|
930
|
+
wt as TextAnnotationToolbar,
|
|
931
|
+
H as TextStyleToolbar,
|
|
932
|
+
O as attachPanelVisibility,
|
|
933
|
+
it as classifyPanelAnnotationType,
|
|
934
|
+
N as createRgbaColorPicker,
|
|
935
|
+
Z as initialRecentColors,
|
|
936
|
+
D as rgbaToString,
|
|
937
|
+
b as svgIcon,
|
|
938
|
+
Q as withColorFromAnnotation
|
|
533
939
|
};
|