@hankchen/canvas-editor-vue 2.0.0 → 2.1.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/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "./canvas-DuvO27sj.js";
|
|
2
2
|
import { a as _, c as v, i as y, l as b, n as x, o as S, r as C, s as w, t as T } from "./layer-panel-BouAYiDq.js";
|
|
3
|
-
import { a as E, c as D, d as O, f as k, i as A, l as j, n as M, o as N, r as P, s as F, t as I, u as L } from "./property-panel-
|
|
3
|
+
import { a as E, c as D, d as O, f as k, i as A, l as j, n as M, o as N, r as P, s as F, t as I, u as L } from "./property-panel-CwdTufiP.js";
|
|
4
4
|
import { a as R, c as z, i as B, n as V, o as H, r as U, s as W, t as G } from "./ExpressionPathPicker-DchGsK70.js";
|
|
5
5
|
import { n as K, t as q } from "./resourceTemplate-D-DKEo7Z.js";
|
|
6
6
|
import { a as J, d as Y, i as X, n as Z, o as Q, s as $, t as ee, u as te } from "./useTransientFeedback-BN_O7V2w.js";
|
|
@@ -123,8 +123,10 @@ export declare const EMPTY_CANVAS_BACKGROUND: CanvasBackground;
|
|
|
123
123
|
/**
|
|
124
124
|
* 图层级读取视图(image-fit 工单 05,canvasFieldTarget 同门):ImageLayer 的 fit
|
|
125
125
|
* 缺省态(wire 无键 = cover)投影为 cover——适配字段否则被 readField 的 ok:false
|
|
126
|
-
*
|
|
127
|
-
*
|
|
126
|
+
* 过滤掉,选中任一未声明的图片层「适配」行即消失;裁剪形状同门(image-clip-shape
|
|
127
|
+
* 工票 05,ADR 0026):clip 缺省态(wire 无键 = rect)投影为 rect 回显。已声明
|
|
128
|
+
* (含未知值)与非图片层原样透传(不拷贝不重整);投影只作用读侧,提交仍走
|
|
129
|
+
* updateSpec 直写文档(显式 rect/cover 落领域值,wire 归一不落键归核心 encode)
|
|
128
130
|
*/
|
|
129
131
|
export declare function layerFieldTarget(layer: Layer): Layer;
|
|
130
132
|
export type FieldReadResult = {
|
|
@@ -200,36 +200,49 @@ var Te = "当前层内容未绘制,padding 不影响预览", H = {
|
|
|
200
200
|
control: "boolean"
|
|
201
201
|
}
|
|
202
202
|
]
|
|
203
|
-
}, De = "cover", Oe = "contain", ke = "fill", Ae = "tile", je = {
|
|
203
|
+
}, De = "cover", Oe = "contain", ke = "fill", Ae = "tile", je = "rect", Me = "circle", Ne = {
|
|
204
204
|
ImageLayer: [
|
|
205
205
|
H,
|
|
206
206
|
U,
|
|
207
207
|
W,
|
|
208
208
|
{
|
|
209
209
|
title: "图片",
|
|
210
|
-
fields: [
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
210
|
+
fields: [
|
|
211
|
+
{
|
|
212
|
+
key: ["src"],
|
|
213
|
+
label: "资源地址",
|
|
214
|
+
control: "imageSrc",
|
|
215
|
+
data: !0,
|
|
216
|
+
resource: !0
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
key: ["fit"],
|
|
220
|
+
label: "适配",
|
|
221
|
+
control: "select",
|
|
222
|
+
domain: [
|
|
223
|
+
De,
|
|
224
|
+
Oe,
|
|
225
|
+
ke,
|
|
226
|
+
Ae
|
|
227
|
+
],
|
|
228
|
+
optionLabels: {
|
|
229
|
+
[De]: "铺满裁切",
|
|
230
|
+
[Oe]: "完整显示",
|
|
231
|
+
[ke]: "拉伸铺满",
|
|
232
|
+
[Ae]: "平铺"
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
key: ["clip"],
|
|
237
|
+
label: "裁剪形状",
|
|
238
|
+
control: "select",
|
|
239
|
+
domain: [je, Me],
|
|
240
|
+
optionLabels: {
|
|
241
|
+
[je]: "矩形",
|
|
242
|
+
[Me]: "圆形"
|
|
243
|
+
}
|
|
231
244
|
}
|
|
232
|
-
|
|
245
|
+
]
|
|
233
246
|
}
|
|
234
247
|
],
|
|
235
248
|
TextLayer: [
|
|
@@ -292,15 +305,15 @@ var Te = "当前层内容未绘制,padding 不影响预览", H = {
|
|
|
292
305
|
}]
|
|
293
306
|
}]
|
|
294
307
|
};
|
|
295
|
-
function
|
|
296
|
-
return
|
|
308
|
+
function Pe(e) {
|
|
309
|
+
return Ne[e] ?? [];
|
|
297
310
|
}
|
|
298
|
-
function
|
|
311
|
+
function Fe(e) {
|
|
299
312
|
if (e[e.length - 1] === "content") return h(e) ? "templateContent" : "content";
|
|
300
313
|
let t = e[e.length - 2];
|
|
301
314
|
return t === "rows" ? "row" : t === "cells" ? "cell" : "root";
|
|
302
315
|
}
|
|
303
|
-
var
|
|
316
|
+
var Ie = {
|
|
304
317
|
root: [],
|
|
305
318
|
cell: [],
|
|
306
319
|
row: ["shape.width", "shape.autoWidth"],
|
|
@@ -315,9 +328,9 @@ var Pe = {
|
|
|
315
328
|
function G(e, t) {
|
|
316
329
|
return [...e.key, ...t.key];
|
|
317
330
|
}
|
|
318
|
-
function
|
|
319
|
-
let n = new Set(
|
|
320
|
-
for (let e of
|
|
331
|
+
function Le(e, t) {
|
|
332
|
+
let n = new Set(Ie[Fe(e)]), r = [];
|
|
333
|
+
for (let e of Pe(t.type)) {
|
|
321
334
|
let i = [];
|
|
322
335
|
for (let r of e.fields) {
|
|
323
336
|
if (r.items) {
|
|
@@ -337,7 +350,7 @@ function Fe(e, t) {
|
|
|
337
350
|
}
|
|
338
351
|
return r;
|
|
339
352
|
}
|
|
340
|
-
var
|
|
353
|
+
var Re = [{
|
|
341
354
|
title: "画布",
|
|
342
355
|
fields: [{
|
|
343
356
|
key: ["width"],
|
|
@@ -365,23 +378,24 @@ var Ie = [{
|
|
|
365
378
|
control: "imageSrc"
|
|
366
379
|
}]
|
|
367
380
|
}];
|
|
368
|
-
function
|
|
381
|
+
function ze(e) {
|
|
369
382
|
return e === null ? null : e.background === null ? {
|
|
370
383
|
...e,
|
|
371
|
-
background:
|
|
384
|
+
background: Be
|
|
372
385
|
} : e;
|
|
373
386
|
}
|
|
374
|
-
var
|
|
387
|
+
var Be = {
|
|
375
388
|
color: null,
|
|
376
389
|
image: null
|
|
377
390
|
};
|
|
378
|
-
function
|
|
379
|
-
return e.type === "ImageLayer" && e.fit === void 0 ? {
|
|
391
|
+
function Ve(e) {
|
|
392
|
+
return e.type === "ImageLayer" && (e.fit === void 0 || e.clip === void 0) ? {
|
|
380
393
|
...e,
|
|
381
|
-
fit: "cover"
|
|
394
|
+
...e.fit === void 0 ? { fit: "cover" } : {},
|
|
395
|
+
...e.clip === void 0 ? { clip: "rect" } : {}
|
|
382
396
|
} : e;
|
|
383
397
|
}
|
|
384
|
-
function
|
|
398
|
+
function K(e, t) {
|
|
385
399
|
let n = e;
|
|
386
400
|
for (let e = 0; e < t.length; e += 1) {
|
|
387
401
|
if (typeof n != "object" || !n) return { ok: !1 };
|
|
@@ -394,14 +408,14 @@ function q(e, t) {
|
|
|
394
408
|
}
|
|
395
409
|
//#endregion
|
|
396
410
|
//#region src/property-panel/fields/AlignField.vue?vue&type=script&setup=true&lang.ts
|
|
397
|
-
var
|
|
411
|
+
var He = ["aria-label"], Ue = [
|
|
398
412
|
"aria-pressed",
|
|
399
413
|
"title",
|
|
400
414
|
"onClick"
|
|
401
|
-
],
|
|
415
|
+
], We = {
|
|
402
416
|
key: 1,
|
|
403
417
|
class: "truncate px-1 text-[10px] leading-none"
|
|
404
|
-
},
|
|
418
|
+
}, Ge = /* @__PURE__ */ j({
|
|
405
419
|
__name: "AlignField",
|
|
406
420
|
props: {
|
|
407
421
|
field: {},
|
|
@@ -463,28 +477,28 @@ var ze = ["aria-label"], Be = [
|
|
|
463
477
|
}, [t.icon ? (P(), E(g, {
|
|
464
478
|
key: 0,
|
|
465
479
|
icon: t.icon
|
|
466
|
-
}, null, 8, ["icon"])) : (P(), O("span",
|
|
480
|
+
}, null, 8, ["icon"])) : (P(), O("span", We, R(t.value), 1))], 10, Ue))), 128))], 8, He));
|
|
467
481
|
}
|
|
468
|
-
}),
|
|
482
|
+
}), Ke = { class: "block" }, qe = ["aria-expanded", "title"], Je = { class: "cn-prop-field__label shrink-0 select-none truncate text-[11px] leading-none text-cn-muted" }, Ye = { class: "flex shrink-0 items-center gap-1.5" }, Xe = {
|
|
469
483
|
viewBox: "0 0 24 24",
|
|
470
484
|
class: "size-3.5",
|
|
471
485
|
"aria-hidden": "true"
|
|
472
|
-
},
|
|
486
|
+
}, Ze = [
|
|
473
487
|
"cx",
|
|
474
488
|
"cy",
|
|
475
489
|
"r"
|
|
476
|
-
],
|
|
490
|
+
], Qe = {
|
|
477
491
|
key: 0,
|
|
478
492
|
class: "mt-2 flex justify-end"
|
|
479
|
-
},
|
|
493
|
+
}, $e = {
|
|
480
494
|
class: "cn-anchor grid w-[66px] shrink-0 grid-cols-3 gap-[3px]",
|
|
481
495
|
role: "group",
|
|
482
496
|
"aria-label": "九宫锚点"
|
|
483
|
-
},
|
|
497
|
+
}, et = [
|
|
484
498
|
"aria-pressed",
|
|
485
499
|
"title",
|
|
486
500
|
"onClick"
|
|
487
|
-
],
|
|
501
|
+
], tt = /* @__PURE__ */ j({
|
|
488
502
|
__name: "AnchorDisclosureField",
|
|
489
503
|
props: {
|
|
490
504
|
field: {},
|
|
@@ -504,31 +518,31 @@ var ze = ["aria-label"], Be = [
|
|
|
504
518
|
function s(e) {
|
|
505
519
|
r("change", e);
|
|
506
520
|
}
|
|
507
|
-
return (t, n) => (P(), O("span",
|
|
521
|
+
return (t, n) => (P(), O("span", Ke, [k("button", {
|
|
508
522
|
type: "button",
|
|
509
523
|
class: "cn-anchor-disclosure__header flex w-full items-center justify-between gap-2",
|
|
510
524
|
"aria-expanded": e.expanded,
|
|
511
525
|
title: e.expanded ? "收起锚点" : `锚点:${e.modelValue}(点击展开调整)`,
|
|
512
526
|
onClick: n[0] ||= (e) => r("toggle")
|
|
513
|
-
}, [k("span",
|
|
527
|
+
}, [k("span", Je, R(e.field.label), 1), k("span", Ye, [(P(), O("svg", Xe, [(P(!0), O(w, null, I(z(a), (e) => (P(), O("circle", {
|
|
514
528
|
key: e.index,
|
|
515
529
|
cx: e.cx,
|
|
516
530
|
cy: e.cy,
|
|
517
531
|
r: e.index === o.value ? 3.2 : 2.2,
|
|
518
532
|
class: N(e.index === o.value ? "fill-cn-accent" : "fill-cn-muted/35")
|
|
519
|
-
}, null, 10,
|
|
533
|
+
}, null, 10, Ze))), 128))])), A(g, {
|
|
520
534
|
icon: z(u),
|
|
521
535
|
class: N(["text-cn-muted transition-transform duration-150", { "rotate-180": e.expanded }])
|
|
522
|
-
}, null, 8, ["icon", "class"])])], 8,
|
|
536
|
+
}, null, 8, ["icon", "class"])])], 8, qe), e.expanded ? (P(), O("span", Qe, [k("span", $e, [(P(!0), O(w, null, I(z(i), (t) => (P(), O("button", {
|
|
523
537
|
key: t,
|
|
524
538
|
type: "button",
|
|
525
539
|
class: N(["cn-anchor__cell relative aspect-square min-w-0 rounded-[4px] border p-0 transition-colors duration-100", t === e.modelValue ? "cn-anchor__cell--active border-cn-accent bg-cn-accent shadow-[0_0_8px_rgba(56,189,248,0.35)]" : "border-cn-field-line bg-cn-field hover:border-cn-muted/50"]),
|
|
526
540
|
"aria-pressed": t === e.modelValue,
|
|
527
541
|
title: t,
|
|
528
542
|
onClick: (e) => s(t)
|
|
529
|
-
}, null, 10,
|
|
543
|
+
}, null, 10, et))), 128))])])) : D("", !0)]));
|
|
530
544
|
}
|
|
531
|
-
}),
|
|
545
|
+
}), nt = { class: "cn-bool relative inline-flex h-4 w-7 shrink-0 cursor-pointer items-center" }, rt = ["checked"], it = /* @__PURE__ */ j({
|
|
532
546
|
__name: "BooleanField",
|
|
533
547
|
props: {
|
|
534
548
|
field: {},
|
|
@@ -542,7 +556,7 @@ var ze = ["aria-label"], Be = [
|
|
|
542
556
|
}
|
|
543
557
|
return ve(() => {
|
|
544
558
|
i.value && (i.value.checked = n.modelValue);
|
|
545
|
-
}), (t, n) => (P(), O("label",
|
|
559
|
+
}), (t, n) => (P(), O("label", nt, [
|
|
546
560
|
k("input", {
|
|
547
561
|
ref_key: "inputRef",
|
|
548
562
|
ref: i,
|
|
@@ -550,12 +564,12 @@ var ze = ["aria-label"], Be = [
|
|
|
550
564
|
type: "checkbox",
|
|
551
565
|
checked: e.modelValue,
|
|
552
566
|
onChange: a
|
|
553
|
-
}, null, 40,
|
|
567
|
+
}, null, 40, rt),
|
|
554
568
|
n[0] ||= k("span", { class: "absolute inset-0 rounded-full border border-cn-field-line bg-cn-field transition-colors duration-150 peer-checked:border-cn-accent/60 peer-checked:bg-cn-accent/30 peer-focus-visible:ring-[3px] peer-focus-visible:ring-cn-accent/20" }, null, -1),
|
|
555
569
|
n[1] ||= k("span", { class: "relative mx-0.5 size-3 rounded-full bg-cn-muted shadow-sm transition-transform duration-150 peer-checked:translate-x-3 peer-checked:bg-cn-accent" }, null, -1)
|
|
556
570
|
]));
|
|
557
571
|
}
|
|
558
|
-
}),
|
|
572
|
+
}), at = {
|
|
559
573
|
1: [{
|
|
560
574
|
label: "四边",
|
|
561
575
|
rep: "top",
|
|
@@ -598,13 +612,13 @@ var ze = ["aria-label"], Be = [
|
|
|
598
612
|
}
|
|
599
613
|
]
|
|
600
614
|
};
|
|
601
|
-
function
|
|
615
|
+
function ot(e) {
|
|
602
616
|
return e === 1 ? 2 : e === 2 ? 4 : 1;
|
|
603
617
|
}
|
|
604
|
-
function
|
|
618
|
+
function st(e) {
|
|
605
619
|
return e.top === e.bottom && e.bottom === e.left && e.left === e.right ? 1 : e.top === e.bottom && e.left === e.right ? 2 : 4;
|
|
606
620
|
}
|
|
607
|
-
function
|
|
621
|
+
function ct(e, t) {
|
|
608
622
|
if (t === 1) {
|
|
609
623
|
let { top: t } = e;
|
|
610
624
|
return {
|
|
@@ -625,17 +639,17 @@ function at(e, t) {
|
|
|
625
639
|
}
|
|
626
640
|
return e;
|
|
627
641
|
}
|
|
628
|
-
function
|
|
642
|
+
function lt(e, t) {
|
|
629
643
|
return e.top === t.top && e.bottom === t.bottom && e.left === t.left && e.right === t.right;
|
|
630
644
|
}
|
|
631
|
-
function
|
|
645
|
+
function q(e, t) {
|
|
632
646
|
return e === null || t === null ? e === t : e.width === t.width && e.color === t.color;
|
|
633
647
|
}
|
|
634
|
-
function
|
|
648
|
+
function ut(e) {
|
|
635
649
|
let { top: t, bottom: n, left: r, right: i } = e;
|
|
636
|
-
return t === null && n === null && r === null && i === null || t !== null &&
|
|
650
|
+
return t === null && n === null && r === null && i === null || t !== null && q(t, n) && q(t, r) && q(t, i) ? 1 : q(t, n) && q(r, i) ? 2 : 4;
|
|
637
651
|
}
|
|
638
|
-
function
|
|
652
|
+
function dt(e, t) {
|
|
639
653
|
let n = (e) => e === null ? null : { ...e };
|
|
640
654
|
if (t === 1) {
|
|
641
655
|
let t = n(e.top);
|
|
@@ -657,18 +671,18 @@ function ct(e, t) {
|
|
|
657
671
|
}
|
|
658
672
|
return e;
|
|
659
673
|
}
|
|
660
|
-
function
|
|
661
|
-
return
|
|
674
|
+
function ft(e, t) {
|
|
675
|
+
return q(e.top, t.top) && q(e.bottom, t.bottom) && q(e.left, t.left) && q(e.right, t.right);
|
|
662
676
|
}
|
|
663
677
|
//#endregion
|
|
664
678
|
//#region src/property-panel/useShorthandMode.ts
|
|
665
|
-
function
|
|
679
|
+
function pt(e, t) {
|
|
666
680
|
let n = T(() => t(e())), r = F(null), i = T(() => r.value ?? n.value);
|
|
667
681
|
B(e, () => {
|
|
668
682
|
r.value = null;
|
|
669
683
|
});
|
|
670
684
|
function a() {
|
|
671
|
-
let e = i.value, t =
|
|
685
|
+
let e = i.value, t = ot(e);
|
|
672
686
|
return r.value = t, {
|
|
673
687
|
from: e,
|
|
674
688
|
to: t
|
|
@@ -681,7 +695,7 @@ function ut(e, t) {
|
|
|
681
695
|
}
|
|
682
696
|
//#endregion
|
|
683
697
|
//#region src/property-panel/controlStyles.ts
|
|
684
|
-
var
|
|
698
|
+
var J = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-field text-[11.5px] leading-none text-cn-fg outline-none transition-[border-color,box-shadow,background-color] duration-100 placeholder:text-cn-muted/60 hover:border-cn-muted/40 focus:border-cn-accent/70 focus:ring-[3px] focus:ring-cn-accent/15 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-cn-field-line", Y = `${J} text-right font-mono tabular-nums`, mt = J, ht = "w-full flex-1 min-w-0 resize-y rounded-md border border-cn-field-line bg-cn-field px-2 py-1.5 text-[11.5px] leading-5 text-cn-fg outline-none transition-[border-color,box-shadow] duration-100 placeholder:text-cn-muted/60 hover:border-cn-muted/40 focus:border-cn-accent/70 focus:ring-[3px] focus:ring-cn-accent/15 disabled:cursor-not-allowed disabled:opacity-40", gt = "size-7 shrink-0 cursor-pointer self-center rounded-md border border-cn-field-line bg-cn-field p-0.5 transition-colors hover:border-cn-muted/40 disabled:cursor-not-allowed disabled:opacity-40", _t = ["aria-label"], vt = /* @__PURE__ */ j({
|
|
685
699
|
__name: "BorderWidthInput",
|
|
686
700
|
props: {
|
|
687
701
|
value: {},
|
|
@@ -721,7 +735,7 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
721
735
|
}
|
|
722
736
|
return (t, n) => be((P(), O("input", {
|
|
723
737
|
"onUpdate:modelValue": n[0] ||= (e) => i.value = e,
|
|
724
|
-
class: N(["cn-field cn-field--number min-w-0 flex-1", z(
|
|
738
|
+
class: N(["cn-field cn-field--number min-w-0 flex-1", z(Y)]),
|
|
725
739
|
type: "number",
|
|
726
740
|
"aria-label": e.label,
|
|
727
741
|
min: 0,
|
|
@@ -732,9 +746,9 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
732
746
|
onFocus: n[1] ||= (e) => a.value = !0,
|
|
733
747
|
onBlur: u,
|
|
734
748
|
onChange: u
|
|
735
|
-
}, null, 42,
|
|
749
|
+
}, null, 42, _t)), [[_e, i.value]]);
|
|
736
750
|
}
|
|
737
|
-
}),
|
|
751
|
+
}), yt = ["aria-label", "title"], X = /* @__PURE__ */ j({
|
|
738
752
|
__name: "ShorthandModeButton",
|
|
739
753
|
props: {
|
|
740
754
|
mode: {},
|
|
@@ -765,14 +779,14 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
765
779
|
}, [A(g, {
|
|
766
780
|
icon: a.value.icon,
|
|
767
781
|
size: 12
|
|
768
|
-
}, null, 8, ["icon"])], 8,
|
|
782
|
+
}, null, 8, ["icon"])], 8, yt));
|
|
769
783
|
}
|
|
770
|
-
}),
|
|
784
|
+
}), bt = { class: "cn-border flex w-full min-w-0 items-center gap-1" }, xt = { class: "grid min-w-0 flex-1 gap-1 grid-cols-1" }, St = { class: "w-5 shrink-0 select-none text-[10px] leading-none text-cn-muted" }, Ct = [
|
|
771
785
|
"value",
|
|
772
786
|
"disabled",
|
|
773
787
|
"onInput",
|
|
774
788
|
"onChange"
|
|
775
|
-
],
|
|
789
|
+
], wt = "#000000", Tt = /* @__PURE__ */ j({
|
|
776
790
|
__name: "BorderField",
|
|
777
791
|
props: {
|
|
778
792
|
field: {},
|
|
@@ -780,12 +794,12 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
780
794
|
},
|
|
781
795
|
emits: ["input", "change"],
|
|
782
796
|
setup(e, { emit: t }) {
|
|
783
|
-
let n = e, r = t, { mode: i, cycle: a } =
|
|
797
|
+
let n = e, r = t, { mode: i, cycle: a } = pt(() => n.modelValue, ut), o = T(() => at[i.value]);
|
|
784
798
|
function s(e) {
|
|
785
799
|
return n.modelValue[e.rep]?.width ?? null;
|
|
786
800
|
}
|
|
787
801
|
function c(e) {
|
|
788
|
-
return n.modelValue[e.rep]?.color ??
|
|
802
|
+
return n.modelValue[e.rep]?.color ?? wt;
|
|
789
803
|
}
|
|
790
804
|
function l(e, t, i) {
|
|
791
805
|
let a = { ...n.modelValue };
|
|
@@ -793,7 +807,7 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
793
807
|
r(i ? "change" : "input", a);
|
|
794
808
|
}
|
|
795
809
|
function u(e, t, r) {
|
|
796
|
-
let i = n.modelValue[e.rep]?.color ??
|
|
810
|
+
let i = n.modelValue[e.rep]?.color ?? wt;
|
|
797
811
|
l(e, t <= 0 ? null : {
|
|
798
812
|
width: t,
|
|
799
813
|
color: i
|
|
@@ -811,20 +825,20 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
811
825
|
function f() {
|
|
812
826
|
let { from: e, to: t } = a();
|
|
813
827
|
if (t < e) {
|
|
814
|
-
let e =
|
|
815
|
-
|
|
828
|
+
let e = dt(n.modelValue, t);
|
|
829
|
+
ft(e, n.modelValue) || r("change", e);
|
|
816
830
|
}
|
|
817
831
|
}
|
|
818
|
-
return (t, n) => (P(), O("span",
|
|
832
|
+
return (t, n) => (P(), O("span", bt, [A(X, {
|
|
819
833
|
mode: z(i),
|
|
820
834
|
label: "边框",
|
|
821
835
|
onCycle: f
|
|
822
|
-
}, null, 8, ["mode"]), k("span",
|
|
836
|
+
}, null, 8, ["mode"]), k("span", xt, [(P(!0), O(w, null, I(o.value, (t) => (P(), O("label", {
|
|
823
837
|
key: t.rep,
|
|
824
838
|
class: "flex items-center gap-1.5"
|
|
825
839
|
}, [
|
|
826
|
-
k("span",
|
|
827
|
-
A(
|
|
840
|
+
k("span", St, R(t.label), 1),
|
|
841
|
+
A(vt, {
|
|
828
842
|
class: "cn-border__width",
|
|
829
843
|
value: s(t),
|
|
830
844
|
label: t.label,
|
|
@@ -844,17 +858,17 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
844
858
|
disabled: e.modelValue[t.rep] === null,
|
|
845
859
|
onInput: (e) => d(t, e, !1),
|
|
846
860
|
onChange: (e) => d(t, e, !0)
|
|
847
|
-
}, null, 40,
|
|
861
|
+
}, null, 40, Ct)
|
|
848
862
|
]))), 128))])]));
|
|
849
863
|
}
|
|
850
|
-
}),
|
|
864
|
+
}), Et = ["value"], Dt = {
|
|
851
865
|
key: 1,
|
|
852
866
|
class: "flex flex-1 items-center gap-1.5"
|
|
853
|
-
},
|
|
867
|
+
}, Ot = ["value"], kt = ["value"], At = [
|
|
854
868
|
"disabled",
|
|
855
869
|
"title",
|
|
856
870
|
"data-upload-error"
|
|
857
|
-
],
|
|
871
|
+
], jt = /* @__PURE__ */ j({
|
|
858
872
|
__name: "FontField",
|
|
859
873
|
props: {
|
|
860
874
|
field: {},
|
|
@@ -917,22 +931,22 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
917
931
|
}
|
|
918
932
|
return (t, n) => z(i) === null ? (P(), O("input", {
|
|
919
933
|
key: 0,
|
|
920
|
-
class: N(["cn-field", z(
|
|
934
|
+
class: N(["cn-field", z(mt)]),
|
|
921
935
|
type: "text",
|
|
922
936
|
value: e.modelValue,
|
|
923
937
|
onInput: l,
|
|
924
938
|
onCompositionstart: u,
|
|
925
939
|
onCompositionend: d,
|
|
926
940
|
onChange: f
|
|
927
|
-
}, null, 42,
|
|
941
|
+
}, null, 42, Et)) : (P(), O("div", Dt, [
|
|
928
942
|
k("select", {
|
|
929
|
-
class: N(["cn-field cn-select", z(
|
|
943
|
+
class: N(["cn-field cn-select", z(J)]),
|
|
930
944
|
value: e.modelValue,
|
|
931
945
|
onChange: s
|
|
932
946
|
}, [(P(!0), O(w, null, I(a.value, (e) => (P(), O("option", {
|
|
933
947
|
key: e.value,
|
|
934
948
|
value: e.value
|
|
935
|
-
}, R(e.label), 9,
|
|
949
|
+
}, R(e.label), 9, kt))), 128))], 42, Ot),
|
|
936
950
|
k("input", {
|
|
937
951
|
ref_key: "fileInput",
|
|
938
952
|
ref: h,
|
|
@@ -949,10 +963,10 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
949
963
|
title: m.value ?? "上传本机字体(加入清单后可选)",
|
|
950
964
|
"data-upload-error": m.value ?? void 0,
|
|
951
965
|
onClick: g
|
|
952
|
-
}, R(p.value ? "…" : m.value ? "!" : "上传"), 9,
|
|
966
|
+
}, R(p.value ? "…" : m.value ? "!" : "上传"), 9, At)) : D("", !0)
|
|
953
967
|
]));
|
|
954
968
|
}
|
|
955
|
-
}),
|
|
969
|
+
}), Mt = { class: "cn-color flex min-w-0 flex-1 items-center gap-1.5" }, Nt = ["checked"], Pt = ["value", "disabled"], Ft = ["value", "disabled"], It = "#000000", Lt = /* @__PURE__ */ j({
|
|
956
970
|
__name: "ColorField",
|
|
957
971
|
props: {
|
|
958
972
|
field: {},
|
|
@@ -965,7 +979,7 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
965
979
|
i.value = e !== null, i.value && (a.value = o(e));
|
|
966
980
|
});
|
|
967
981
|
function o(e) {
|
|
968
|
-
return e !== null && /^#[0-9a-fA-F]{6}$/.test(e) ? e :
|
|
982
|
+
return e !== null && /^#[0-9a-fA-F]{6}$/.test(e) ? e : It;
|
|
969
983
|
}
|
|
970
984
|
function s(e) {
|
|
971
985
|
let t = e.target.checked;
|
|
@@ -992,7 +1006,7 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
992
1006
|
}
|
|
993
1007
|
a.value = o(t), r("change", t);
|
|
994
1008
|
}
|
|
995
|
-
return (t, n) => (P(), O("span",
|
|
1009
|
+
return (t, n) => (P(), O("span", Mt, [
|
|
996
1010
|
e.field.nullable ? (P(), O("input", {
|
|
997
1011
|
key: 0,
|
|
998
1012
|
class: "cn-color__toggle size-3.5 shrink-0 cursor-pointer accent-cn-accent",
|
|
@@ -1000,43 +1014,43 @@ var Y = "h-7 flex-1 w-full min-w-0 rounded-md border border-cn-field-line bg-cn-
|
|
|
1000
1014
|
title: "启用颜色",
|
|
1001
1015
|
checked: i.value,
|
|
1002
1016
|
onChange: s
|
|
1003
|
-
}, null, 40,
|
|
1017
|
+
}, null, 40, Nt)) : D("", !0),
|
|
1004
1018
|
k("input", {
|
|
1005
|
-
class: N(["cn-color__swatch", z(
|
|
1019
|
+
class: N(["cn-color__swatch", z(gt)]),
|
|
1006
1020
|
type: "color",
|
|
1007
1021
|
value: a.value,
|
|
1008
1022
|
disabled: !i.value,
|
|
1009
1023
|
onInput: c,
|
|
1010
1024
|
onChange: l
|
|
1011
|
-
}, null, 42,
|
|
1025
|
+
}, null, 42, Pt),
|
|
1012
1026
|
k("input", {
|
|
1013
|
-
class: N(["cn-color__text min-w-0 flex-1", z(
|
|
1027
|
+
class: N(["cn-color__text min-w-0 flex-1", z(J)]),
|
|
1014
1028
|
type: "text",
|
|
1015
1029
|
value: e.modelValue ?? "",
|
|
1016
1030
|
disabled: !i.value,
|
|
1017
1031
|
placeholder: "无",
|
|
1018
1032
|
onChange: u
|
|
1019
|
-
}, null, 42,
|
|
1033
|
+
}, null, 42, Ft)
|
|
1020
1034
|
]));
|
|
1021
1035
|
}
|
|
1022
1036
|
}), Z = Symbol("canvas-image-upload");
|
|
1023
|
-
function
|
|
1037
|
+
function Rt() {
|
|
1024
1038
|
return fe(Z, null);
|
|
1025
1039
|
}
|
|
1026
1040
|
//#endregion
|
|
1027
1041
|
//#region src/property-panel/fields/intrinsicSize.ts
|
|
1028
|
-
function
|
|
1042
|
+
function zt(e, t) {
|
|
1029
1043
|
let n = e, r = t;
|
|
1030
1044
|
for (; r !== 0;) [n, r] = [r, n % r];
|
|
1031
1045
|
let i = e / n, a = t / n;
|
|
1032
1046
|
return Math.max(i, a) <= 32 ? `${i}:${a}` : `${Math.round(e / t * 100) / 100}:1`;
|
|
1033
1047
|
}
|
|
1034
|
-
function
|
|
1035
|
-
return !Number.isFinite(e) || !Number.isFinite(t) || e <= 0 || t <= 0 ? null : `${e}×${t} · ${
|
|
1048
|
+
function Bt(e, t) {
|
|
1049
|
+
return !Number.isFinite(e) || !Number.isFinite(t) || e <= 0 || t <= 0 ? null : `${e}×${t} · ${zt(e, t)}`;
|
|
1036
1050
|
}
|
|
1037
1051
|
//#endregion
|
|
1038
1052
|
//#region src/property-panel/fields/TextField.vue?vue&type=script&setup=true&lang.ts
|
|
1039
|
-
var
|
|
1053
|
+
var Vt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
1040
1054
|
__name: "TextField",
|
|
1041
1055
|
props: {
|
|
1042
1056
|
field: {},
|
|
@@ -1066,7 +1080,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1066
1080
|
o(t) || r("change", t);
|
|
1067
1081
|
}
|
|
1068
1082
|
return (t, n) => (P(), O("input", {
|
|
1069
|
-
class: N(["cn-field", [z(
|
|
1083
|
+
class: N(["cn-field", [z(mt), a.value ? "cn-field--invalid" : ""]]),
|
|
1070
1084
|
type: "text",
|
|
1071
1085
|
value: e.modelValue,
|
|
1072
1086
|
placeholder: e.field.placeholder,
|
|
@@ -1074,9 +1088,9 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1074
1088
|
onCompositionstart: c,
|
|
1075
1089
|
onCompositionend: l,
|
|
1076
1090
|
onChange: u
|
|
1077
|
-
}, null, 42,
|
|
1091
|
+
}, null, 42, Vt));
|
|
1078
1092
|
}
|
|
1079
|
-
}),
|
|
1093
|
+
}), Ht = /* @__PURE__ */ j({
|
|
1080
1094
|
__name: "ResourceValueField",
|
|
1081
1095
|
props: {
|
|
1082
1096
|
field: {},
|
|
@@ -1123,20 +1137,20 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1123
1137
|
"disabled"
|
|
1124
1138
|
]));
|
|
1125
1139
|
}
|
|
1126
|
-
}),
|
|
1140
|
+
}), Ut = {
|
|
1127
1141
|
key: 0,
|
|
1128
1142
|
class: "flex flex-col gap-1.5"
|
|
1129
|
-
},
|
|
1143
|
+
}, Wt = [
|
|
1130
1144
|
"disabled",
|
|
1131
1145
|
"title",
|
|
1132
1146
|
"data-upload-error"
|
|
1133
|
-
],
|
|
1147
|
+
], Gt = ["src"], Kt = {
|
|
1134
1148
|
key: 2,
|
|
1135
1149
|
class: "relative"
|
|
1136
|
-
},
|
|
1150
|
+
}, qt = { class: "flex items-center gap-1.5" }, Jt = {
|
|
1137
1151
|
key: 0,
|
|
1138
1152
|
class: "cn-imagesrc__intrinsic text-[11px] leading-4 text-cn-muted"
|
|
1139
|
-
},
|
|
1153
|
+
}, Yt = /* @__PURE__ */ j({
|
|
1140
1154
|
__name: "ImageSrcField",
|
|
1141
1155
|
props: {
|
|
1142
1156
|
field: {},
|
|
@@ -1148,7 +1162,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1148
1162
|
},
|
|
1149
1163
|
emits: ["input", "change"],
|
|
1150
1164
|
setup(e, { emit: t }) {
|
|
1151
|
-
let n = e, r = t, i =
|
|
1165
|
+
let n = e, r = t, i = Rt(), a = T(() => i !== null && i.canUpload && n.dataMode !== "expression"), o = T(() => typeof n.modelValue == "string" && n.modelValue !== ""), s = T(() => n.resourceStatus === "pending" ? "装载中" : n.resourceStatus === "failed" ? "失败" : null), c = F(!1), l = F(null), u = F(null), d = F(null), f = T(() => d.value === null ? null : Bt(d.value.width, d.value.height));
|
|
1152
1166
|
function p(e) {
|
|
1153
1167
|
let t = e.target;
|
|
1154
1168
|
d.value = t.naturalWidth > 0 && t.naturalHeight > 0 ? {
|
|
@@ -1176,7 +1190,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1176
1190
|
}
|
|
1177
1191
|
}
|
|
1178
1192
|
}
|
|
1179
|
-
return (t, n) => a.value ? (P(), O("div",
|
|
1193
|
+
return (t, n) => a.value ? (P(), O("div", Ut, [
|
|
1180
1194
|
k("button", {
|
|
1181
1195
|
type: "button",
|
|
1182
1196
|
class: "cn-imagesrc__thumb relative flex h-16 w-full items-center justify-center overflow-hidden rounded-md border border-dashed border-cn-field-line bg-cn-field/40 text-[11px] leading-none text-cn-muted transition-colors duration-100 hover:border-cn-muted/40 disabled:cursor-not-allowed disabled:opacity-40",
|
|
@@ -1192,13 +1206,13 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1192
1206
|
alt: "",
|
|
1193
1207
|
onLoad: p,
|
|
1194
1208
|
onError: n[0] ||= (e) => d.value = null
|
|
1195
|
-
}, null, 40,
|
|
1209
|
+
}, null, 40, Gt)) : D("", !0),
|
|
1196
1210
|
s.value ? (P(), O("span", {
|
|
1197
1211
|
key: 1,
|
|
1198
1212
|
class: N(["cn-imagesrc__status absolute right-1 top-1 rounded bg-cn-bg-elevated/90 px-1 py-0.5 text-[10px] leading-none", e.resourceStatus === "failed" ? "text-red-400" : "text-cn-muted"])
|
|
1199
1213
|
}, R(s.value), 3)) : D("", !0),
|
|
1200
|
-
o.value ? D("", !0) : (P(), O("span",
|
|
1201
|
-
], 8,
|
|
1214
|
+
o.value ? D("", !0) : (P(), O("span", Kt, R(c.value ? "…" : l.value ? "!" : "点击上传图片"), 1))
|
|
1215
|
+
], 8, Wt),
|
|
1202
1216
|
k("input", {
|
|
1203
1217
|
ref_key: "fileInput",
|
|
1204
1218
|
ref: u,
|
|
@@ -1207,7 +1221,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1207
1221
|
accept: "image/*",
|
|
1208
1222
|
onChange: h
|
|
1209
1223
|
}, null, 544),
|
|
1210
|
-
k("div",
|
|
1224
|
+
k("div", qt, [A(Q, {
|
|
1211
1225
|
class: "flex-1",
|
|
1212
1226
|
field: e.field,
|
|
1213
1227
|
"model-value": e.modelValue ?? "",
|
|
@@ -1225,8 +1239,8 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1225
1239
|
title: "清除图片(资源地址置空)",
|
|
1226
1240
|
onClick: n[3] ||= (e) => r("change", "")
|
|
1227
1241
|
}, "清除")) : D("", !0)]),
|
|
1228
|
-
f.value ? (P(), O("span",
|
|
1229
|
-
])) : e.dataMode === "expression" ? (P(), E(
|
|
1242
|
+
f.value ? (P(), O("span", Jt, "源图 " + R(f.value), 1)) : D("", !0)
|
|
1243
|
+
])) : e.dataMode === "expression" ? (P(), E(Ht, {
|
|
1230
1244
|
key: 1,
|
|
1231
1245
|
field: e.field,
|
|
1232
1246
|
"model-value": e.modelValue,
|
|
@@ -1253,7 +1267,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1253
1267
|
"aria-label"
|
|
1254
1268
|
]));
|
|
1255
1269
|
}
|
|
1256
|
-
}),
|
|
1270
|
+
}), Xt = [
|
|
1257
1271
|
"aria-label",
|
|
1258
1272
|
"min",
|
|
1259
1273
|
"max",
|
|
@@ -1296,7 +1310,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1296
1310
|
}
|
|
1297
1311
|
return (t, n) => be((P(), O("input", {
|
|
1298
1312
|
"onUpdate:modelValue": n[0] ||= (e) => i.value = e,
|
|
1299
|
-
class: N(["cn-field cn-field--number", z(
|
|
1313
|
+
class: N(["cn-field cn-field--number", z(Y)]),
|
|
1300
1314
|
type: "number",
|
|
1301
1315
|
"aria-label": e.field.label,
|
|
1302
1316
|
min: e.field.min,
|
|
@@ -1306,9 +1320,9 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1306
1320
|
onFocus: n[1] ||= (e) => a.value = !0,
|
|
1307
1321
|
onBlur: l,
|
|
1308
1322
|
onChange: l
|
|
1309
|
-
}, null, 42,
|
|
1323
|
+
}, null, 42, Xt)), [[_e, i.value]]);
|
|
1310
1324
|
}
|
|
1311
|
-
}),
|
|
1325
|
+
}), Zt = { class: "cn-padding flex w-full min-w-0 items-center gap-1.5" }, Qt = { class: "w-5 shrink-0 select-none text-[10px] leading-none text-cn-muted" }, $t = /* @__PURE__ */ j({
|
|
1312
1326
|
__name: "PaddingField",
|
|
1313
1327
|
props: {
|
|
1314
1328
|
field: {},
|
|
@@ -1316,7 +1330,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1316
1330
|
},
|
|
1317
1331
|
emits: ["input", "change"],
|
|
1318
1332
|
setup(e, { emit: t }) {
|
|
1319
|
-
let n = e, r = t, { mode: i, cycle: a } =
|
|
1333
|
+
let n = e, r = t, { mode: i, cycle: a } = pt(() => n.modelValue, st), o = T(() => at[i.value]);
|
|
1320
1334
|
function s(e) {
|
|
1321
1335
|
return {
|
|
1322
1336
|
key: ["padding", e.rep],
|
|
@@ -1332,18 +1346,18 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1332
1346
|
function l() {
|
|
1333
1347
|
let { from: e, to: t } = a();
|
|
1334
1348
|
if (t < e) {
|
|
1335
|
-
let e =
|
|
1336
|
-
|
|
1349
|
+
let e = ct(n.modelValue, t);
|
|
1350
|
+
lt(e, n.modelValue) || r("change", e);
|
|
1337
1351
|
}
|
|
1338
1352
|
}
|
|
1339
|
-
return (t, n) => (P(), O("span",
|
|
1353
|
+
return (t, n) => (P(), O("span", Zt, [A(X, {
|
|
1340
1354
|
mode: z(i),
|
|
1341
1355
|
label: "内边距",
|
|
1342
1356
|
onCycle: l
|
|
1343
1357
|
}, null, 8, ["mode"]), k("span", { class: N(["grid min-w-0 flex-1 gap-1.5", z(i) === 1 ? "grid-cols-1" : "grid-cols-2"]) }, [(P(!0), O(w, null, I(o.value, (t) => (P(), O("label", {
|
|
1344
1358
|
key: t.rep,
|
|
1345
1359
|
class: "flex min-w-0 items-center gap-1.5"
|
|
1346
|
-
}, [k("span",
|
|
1360
|
+
}, [k("span", Qt, R(t.label), 1), A($, {
|
|
1347
1361
|
class: "min-w-0 flex-1",
|
|
1348
1362
|
field: s(t),
|
|
1349
1363
|
"model-value": e.modelValue[t.rep],
|
|
@@ -1356,16 +1370,16 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1356
1370
|
"onChange"
|
|
1357
1371
|
])]))), 128))], 2)]));
|
|
1358
1372
|
}
|
|
1359
|
-
}),
|
|
1373
|
+
}), en = { class: "grid w-full min-w-0 grid-cols-2 gap-1" }, tn = ["title"], nn = { class: "w-3.5 shrink-0 select-none text-[10px] leading-none text-cn-muted" }, rn = [
|
|
1360
1374
|
"aria-pressed",
|
|
1361
1375
|
"title",
|
|
1362
1376
|
"onClick"
|
|
1363
|
-
],
|
|
1377
|
+
], an = [
|
|
1364
1378
|
"aria-label",
|
|
1365
1379
|
"value",
|
|
1366
1380
|
"placeholder",
|
|
1367
1381
|
"title"
|
|
1368
|
-
],
|
|
1382
|
+
], on = /* @__PURE__ */ j({
|
|
1369
1383
|
__name: "PairField",
|
|
1370
1384
|
props: {
|
|
1371
1385
|
field: {},
|
|
@@ -1381,7 +1395,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1381
1395
|
let n = e, r = t, i = T(() => n.field.items ?? []);
|
|
1382
1396
|
function a(e) {
|
|
1383
1397
|
if (!e.auto) return !1;
|
|
1384
|
-
let t =
|
|
1398
|
+
let t = K(n.modelValue, e.auto.key);
|
|
1385
1399
|
return t.ok && t.value === !0;
|
|
1386
1400
|
}
|
|
1387
1401
|
function o(e) {
|
|
@@ -1404,7 +1418,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1404
1418
|
r("sub-commit", s(e), !a(e), !0);
|
|
1405
1419
|
}
|
|
1406
1420
|
function u(e) {
|
|
1407
|
-
let t =
|
|
1421
|
+
let t = K(n.modelValue, e.key);
|
|
1408
1422
|
return t.ok && typeof t.value == "number" ? t.value : 0;
|
|
1409
1423
|
}
|
|
1410
1424
|
function d(e) {
|
|
@@ -1421,12 +1435,12 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1421
1435
|
let t = d(e);
|
|
1422
1436
|
return t?.preview ? "模板子树:预览盒尺寸(随行实例变化,非文档声明值)" : t === void 0 ? `${e.label}自适应:已开启` : `${e.label}自适应:布局解析值(与画布选择框同源)`;
|
|
1423
1437
|
}
|
|
1424
|
-
return (e, t) => (P(), O("span",
|
|
1438
|
+
return (e, t) => (P(), O("span", en, [(P(!0), O(w, null, I(i.value, (e) => (P(), O("label", {
|
|
1425
1439
|
key: e.key.join("."),
|
|
1426
1440
|
class: "flex min-w-0 items-center gap-1",
|
|
1427
1441
|
title: e.auto ? void 0 : e.label
|
|
1428
1442
|
}, [
|
|
1429
|
-
k("span",
|
|
1443
|
+
k("span", nn, R(e.label), 1),
|
|
1430
1444
|
e.auto ? (P(), O("button", {
|
|
1431
1445
|
key: 0,
|
|
1432
1446
|
type: "button",
|
|
@@ -1434,17 +1448,17 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1434
1448
|
"aria-pressed": a(e),
|
|
1435
1449
|
title: p(e),
|
|
1436
1450
|
onClick: V((t) => l(e), ["prevent"])
|
|
1437
|
-
}, "自", 10,
|
|
1451
|
+
}, "自", 10, rn)) : D("", !0),
|
|
1438
1452
|
a(e) ? (P(), O("input", {
|
|
1439
1453
|
key: 2,
|
|
1440
|
-
class: N(["cn-field cn-field--number min-w-0 flex-1", [z(
|
|
1454
|
+
class: N(["cn-field cn-field--number min-w-0 flex-1", [z(Y), d(e)?.preview ? "cn-field--preview" : ""]]),
|
|
1441
1455
|
type: "number",
|
|
1442
1456
|
disabled: "",
|
|
1443
1457
|
"aria-label": e.label,
|
|
1444
1458
|
value: f(e),
|
|
1445
1459
|
placeholder: e.auto?.placeholder ?? "",
|
|
1446
1460
|
title: m(e)
|
|
1447
|
-
}, null, 10,
|
|
1461
|
+
}, null, 10, an)) : (P(), E($, {
|
|
1448
1462
|
key: 1,
|
|
1449
1463
|
class: "min-w-0 flex-1",
|
|
1450
1464
|
field: e,
|
|
@@ -1457,9 +1471,9 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1457
1471
|
"onInput",
|
|
1458
1472
|
"onChange"
|
|
1459
1473
|
]))
|
|
1460
|
-
], 8,
|
|
1474
|
+
], 8, tn))), 128))]));
|
|
1461
1475
|
}
|
|
1462
|
-
}),
|
|
1476
|
+
}), sn = /* @__PURE__ */ j({
|
|
1463
1477
|
__name: "RowsPathField",
|
|
1464
1478
|
props: {
|
|
1465
1479
|
field: {},
|
|
@@ -1488,7 +1502,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1488
1502
|
"aria-label"
|
|
1489
1503
|
]));
|
|
1490
1504
|
}
|
|
1491
|
-
}),
|
|
1505
|
+
}), cn = ["value"], ln = ["value"], un = /* @__PURE__ */ j({
|
|
1492
1506
|
__name: "SelectField",
|
|
1493
1507
|
props: {
|
|
1494
1508
|
field: {},
|
|
@@ -1507,9 +1521,9 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1507
1521
|
}, [(P(!0), O(w, null, I(e.field.domain ?? [], (t) => (P(), O("option", {
|
|
1508
1522
|
key: t,
|
|
1509
1523
|
value: t
|
|
1510
|
-
}, R(e.field.optionLabels?.[t] ?? t), 9,
|
|
1524
|
+
}, R(e.field.optionLabels?.[t] ?? t), 9, ln))), 128))], 40, cn));
|
|
1511
1525
|
}
|
|
1512
|
-
}),
|
|
1526
|
+
}), dn = ["value", "disabled"], fn = /* @__PURE__ */ j({
|
|
1513
1527
|
__name: "TextareaField",
|
|
1514
1528
|
props: {
|
|
1515
1529
|
field: {},
|
|
@@ -1533,7 +1547,7 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1533
1547
|
r = !1, n("change", e.target.value);
|
|
1534
1548
|
}
|
|
1535
1549
|
return (t, n) => (P(), O("textarea", {
|
|
1536
|
-
class: N(["cn-field", z(
|
|
1550
|
+
class: N(["cn-field", z(ht)]),
|
|
1537
1551
|
rows: "3",
|
|
1538
1552
|
value: e.modelValue,
|
|
1539
1553
|
disabled: e.disabled,
|
|
@@ -1541,28 +1555,28 @@ var zt = ["value", "placeholder"], Q = /* @__PURE__ */ j({
|
|
|
1541
1555
|
onCompositionstart: a,
|
|
1542
1556
|
onCompositionend: o,
|
|
1543
1557
|
onChange: s
|
|
1544
|
-
}, null, 42,
|
|
1558
|
+
}, null, 42, dn));
|
|
1545
1559
|
}
|
|
1546
|
-
}),
|
|
1560
|
+
}), pn = {
|
|
1547
1561
|
number: M($),
|
|
1548
1562
|
text: M(Q),
|
|
1549
|
-
textarea: M(
|
|
1550
|
-
color: M(
|
|
1551
|
-
select: M(
|
|
1552
|
-
boolean: M(
|
|
1553
|
-
pair: M(
|
|
1554
|
-
anchor: M(
|
|
1555
|
-
align: M(
|
|
1556
|
-
padding: M(
|
|
1557
|
-
border: M(
|
|
1558
|
-
font: M(
|
|
1559
|
-
imageSrc: M(
|
|
1560
|
-
resourceValue: M(
|
|
1561
|
-
rowsPath: M(
|
|
1563
|
+
textarea: M(fn),
|
|
1564
|
+
color: M(Lt),
|
|
1565
|
+
select: M(un),
|
|
1566
|
+
boolean: M(it),
|
|
1567
|
+
pair: M(on),
|
|
1568
|
+
anchor: M(tt),
|
|
1569
|
+
align: M(Ge),
|
|
1570
|
+
padding: M($t),
|
|
1571
|
+
border: M(Tt),
|
|
1572
|
+
font: M(jt),
|
|
1573
|
+
imageSrc: M(Yt),
|
|
1574
|
+
resourceValue: M(Ht),
|
|
1575
|
+
rowsPath: M(sn)
|
|
1562
1576
|
};
|
|
1563
1577
|
//#endregion
|
|
1564
1578
|
//#region src/property-panel/usePropertyPanel.ts
|
|
1565
|
-
function
|
|
1579
|
+
function mn(e) {
|
|
1566
1580
|
let t = L(e.store.doc), n = L(e.store.ui.selection), r = L(e.store.ui.anchorExpanded), i = L(e.store.ui.dataSourceSchema), a = L(e.store.ui.resourceStatuses), o = L(e.store.ui.editing), s = e.subscribe((s) => {
|
|
1567
1581
|
s.scope === "doc" ? (t.value = e.store.doc, n.value = e.store.ui.selection, a.value = e.store.ui.resourceStatuses, o.value = e.store.ui.editing) : s.scope === "ui" && (s.branch === "selection" ? (n.value = e.store.ui.selection, e.store.closeMerge()) : s.branch === "anchorExpanded" ? r.value = e.store.ui.anchorExpanded : s.branch === "dataSourceSchema" ? i.value = e.store.ui.dataSourceSchema : s.branch === "resourceStatuses" ? a.value = e.store.ui.resourceStatuses : s.branch === "editing" && (o.value = e.store.ui.editing));
|
|
1568
1582
|
});
|
|
@@ -1572,7 +1586,7 @@ function fn(e) {
|
|
|
1572
1586
|
return e && r ? p(e, r) : null;
|
|
1573
1587
|
}), l = T(() => t.value), u = T(() => {
|
|
1574
1588
|
let e = c.value, r = n.value;
|
|
1575
|
-
return e && r ?
|
|
1589
|
+
return e && r ? Le(r, e) : t.value ? Re : [];
|
|
1576
1590
|
}), d = T(() => {
|
|
1577
1591
|
let r = n.value;
|
|
1578
1592
|
return r && t.value ? e.layerBoxAt(r) : null;
|
|
@@ -1631,7 +1645,7 @@ function fn(e) {
|
|
|
1631
1645
|
function ae(t, n, r) {
|
|
1632
1646
|
let i = t.key[1];
|
|
1633
1647
|
if (i !== "color" && i !== "image") return;
|
|
1634
|
-
let a = l.value?.background ??
|
|
1648
|
+
let a = l.value?.background ?? Be, o = typeof n == "string" && n !== "" ? n : null, s = {
|
|
1635
1649
|
...a,
|
|
1636
1650
|
[i]: o
|
|
1637
1651
|
}, c = `canvas:background.${i}`;
|
|
@@ -1659,14 +1673,14 @@ function fn(e) {
|
|
|
1659
1673
|
}
|
|
1660
1674
|
//#endregion
|
|
1661
1675
|
//#region src/property-panel/fields/ValueTypeSegmented.vue?vue&type=script&setup=true&lang.ts
|
|
1662
|
-
var
|
|
1676
|
+
var hn = ["aria-disabled"], gn = [
|
|
1663
1677
|
"aria-pressed",
|
|
1664
1678
|
"title",
|
|
1665
1679
|
"data-mode-static",
|
|
1666
1680
|
"data-mode-expression",
|
|
1667
1681
|
"disabled",
|
|
1668
1682
|
"onClick"
|
|
1669
|
-
],
|
|
1683
|
+
], _n = /* @__PURE__ */ j({
|
|
1670
1684
|
__name: "ValueTypeSegmented",
|
|
1671
1685
|
props: {
|
|
1672
1686
|
mode: {},
|
|
@@ -1701,15 +1715,15 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1701
1715
|
"data-mode-expression": t.value === "expression" || void 0,
|
|
1702
1716
|
disabled: e.disabled,
|
|
1703
1717
|
onClick: V((e) => a(t.value), ["prevent"])
|
|
1704
|
-
}, R(t.label), 11,
|
|
1718
|
+
}, R(t.label), 11, gn)), 64))], 10, hn));
|
|
1705
1719
|
}
|
|
1706
|
-
}),
|
|
1720
|
+
}), vn = ["title"], yn = {
|
|
1707
1721
|
key: 2,
|
|
1708
1722
|
class: "cn-prop-field__hint col-span-2 block text-[11px] leading-4 text-cn-muted"
|
|
1709
|
-
},
|
|
1723
|
+
}, bn = ["title"], xn = {
|
|
1710
1724
|
key: 4,
|
|
1711
1725
|
class: "cn-prop-field__hint col-span-2 block text-[11px] leading-4 text-cn-muted"
|
|
1712
|
-
},
|
|
1726
|
+
}, Sn = /* @__PURE__ */ j({
|
|
1713
1727
|
__name: "PropertyField",
|
|
1714
1728
|
props: {
|
|
1715
1729
|
field: {},
|
|
@@ -1729,7 +1743,7 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1729
1743
|
"sub-commit"
|
|
1730
1744
|
],
|
|
1731
1745
|
setup(e, { emit: t }) {
|
|
1732
|
-
let n = e, r = t, i = T(() =>
|
|
1746
|
+
let n = e, r = t, i = T(() => pn[n.field.control]), a = T(() => n.dataMode === "expression"), o = T(() => n.field.control === "pair" ? "cn-prop-field block" : "cn-prop-field grid grid-cols-[60px_minmax(0,1fr)] items-center gap-x-2 gap-y-1.5"), s = T(() => n.field.data === !0 ? "col-span-2" : ""), c = T(() => n.field.data === !0 && n.field.control === "textarea"), l = T(() => n.field.control === "rowsPath"), u = T(() => n.field.resource === !0 || l.value), d = F(null), f = T(() => n.field.data === !0 && a.value && typeof n.value == "string" ? n.field.resource === !0 ? n.value === "" ? [] : x(n.value) : c.value ? ne(n.value) : [] : []), p = T(() => f.value.length === 0 ? "" : n.field.resource === !0 ? le(n.completion != null) : se(f.value)), m = T(() => (n.field.resource === !0 ? a.value : l.value) && n.completion == null && f.value.length === 0 ? C : ""), h = T(() => f.value.length > 0 || l.value && n.drifted === !0), g = T(() => n.field.control === "textarea");
|
|
1733
1747
|
function _() {
|
|
1734
1748
|
let e = f.value[0], t = d.value?.$el;
|
|
1735
1749
|
e !== void 0 && (t instanceof HTMLTextAreaElement || t instanceof HTMLInputElement) && (t.focus(), t.setSelectionRange(e.at.start, e.at.end));
|
|
@@ -1754,8 +1768,8 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1754
1768
|
key: 0,
|
|
1755
1769
|
class: "cn-prop-field__label shrink-0 select-none truncate text-[11px] leading-none text-cn-muted",
|
|
1756
1770
|
title: e.field.title
|
|
1757
|
-
}, R(e.field.label), 9,
|
|
1758
|
-
e.field.data ? (P(), E(
|
|
1771
|
+
}, R(e.field.label), 9, vn)),
|
|
1772
|
+
e.field.data ? (P(), E(_n, {
|
|
1759
1773
|
key: 1,
|
|
1760
1774
|
class: "justify-self-end",
|
|
1761
1775
|
mode: e.dataMode ?? "static",
|
|
@@ -1789,14 +1803,14 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1789
1803
|
"source",
|
|
1790
1804
|
"resource-status"
|
|
1791
1805
|
])),
|
|
1792
|
-
e.hint ? (P(), O("span",
|
|
1806
|
+
e.hint ? (P(), O("span", yn, R(e.hint), 1)) : D("", !0),
|
|
1793
1807
|
p.value ? (P(), O("span", {
|
|
1794
1808
|
key: 3,
|
|
1795
1809
|
class: N(["cn-prop-field__hint cn-prop-field__hint--error col-span-2 block text-[11px] leading-4 text-cn-danger", { "cursor-pointer": g.value }]),
|
|
1796
1810
|
title: g.value ? "点击选中出错片段" : void 0,
|
|
1797
1811
|
onClick: _
|
|
1798
|
-
}, R(p.value), 11,
|
|
1799
|
-
m.value ? (P(), O("span",
|
|
1812
|
+
}, R(p.value), 11, bn)) : D("", !0),
|
|
1813
|
+
m.value ? (P(), O("span", xn, R(m.value), 1)) : D("", !0)
|
|
1800
1814
|
]),
|
|
1801
1815
|
_: 1
|
|
1802
1816
|
}, 8, ["class"])), c.value ? (P(), E(ae, {
|
|
@@ -1807,14 +1821,14 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1807
1821
|
onSelect: z(S)
|
|
1808
1822
|
}, null, 8, ["state", "onSelect"])) : D("", !0)], 64));
|
|
1809
1823
|
}
|
|
1810
|
-
}),
|
|
1824
|
+
}), Cn = { class: "cn-props flex w-[288px] shrink-0 flex-col overflow-y-auto rounded-xl border border-cn-line bg-cn-bg text-cn-fg shadow-[0_16px_40px_-12px_rgba(2,6,23,0.55)]" }, wn = { class: "sticky top-0 z-10 border-b border-cn-line bg-cn-bg-elevated/95 px-3.5 py-2.5 backdrop-blur-sm" }, Tn = { class: "flex items-center gap-2" }, En = { class: "inline-flex items-center gap-1.5 rounded border border-cn-accent/25 bg-cn-accent-soft px-1.5 py-0.5 font-mono text-[10px] leading-4 text-cn-accent" }, Dn = { class: "text-[12px] font-medium tracking-wide text-cn-fg/90" }, On = {
|
|
1811
1825
|
key: 0,
|
|
1812
1826
|
class: "mx-3.5 my-4 rounded-lg border border-dashed border-cn-line px-3 py-6 text-center text-[11px] leading-5 text-cn-muted"
|
|
1813
|
-
},
|
|
1827
|
+
}, kn = { class: "cn-props__section-title mb-2 text-[10px] font-semibold uppercase tracking-[0.16em] text-cn-muted" }, An = { class: "flex flex-col gap-2" }, jn = "内容编辑中:请在画布编辑框内修改,退出后此处更新", Mn = /* @__PURE__ */ j({
|
|
1814
1828
|
__name: "PropertyPanel",
|
|
1815
1829
|
props: { editor: {} },
|
|
1816
1830
|
setup(e) {
|
|
1817
|
-
let t = e, n =
|
|
1831
|
+
let t = e, n = mn(t.editor);
|
|
1818
1832
|
he(Z, {
|
|
1819
1833
|
canUpload: t.editor.canUpload,
|
|
1820
1834
|
uploadImage: (e) => t.editor.uploadImage(e)
|
|
@@ -1826,13 +1840,13 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1826
1840
|
let e = n.layer.value;
|
|
1827
1841
|
return e ? e.type : n.canvas.value ? "Canvas" : "—";
|
|
1828
1842
|
}), o = T(() => {
|
|
1829
|
-
let e = n.layer.value === null ? n.selection.value ? null :
|
|
1843
|
+
let e = n.layer.value === null ? n.selection.value ? null : ze(n.canvas.value) : Ve(n.layer.value);
|
|
1830
1844
|
if (!e) return [];
|
|
1831
1845
|
let t = n.selection.value?.join(".") ?? "canvas", r = n.layer.value, i = n.resourceStatuses.value, a = [];
|
|
1832
1846
|
for (let o of n.sections.value) {
|
|
1833
1847
|
let s = [];
|
|
1834
1848
|
for (let a of o.fields) {
|
|
1835
|
-
let o =
|
|
1849
|
+
let o = K(e, a.key);
|
|
1836
1850
|
if (!o.ok) continue;
|
|
1837
1851
|
let c = n.contentLocked.value && a.data === !0;
|
|
1838
1852
|
s.push({
|
|
@@ -1841,7 +1855,7 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1841
1855
|
value: o.value,
|
|
1842
1856
|
dataMode: a.data ? n.isDataMarked(a) ? "expression" : "static" : void 0,
|
|
1843
1857
|
locked: c,
|
|
1844
|
-
hint: c ?
|
|
1858
|
+
hint: c ? jn : a.hint && r ? a.hint(r, i) ?? void 0 : void 0,
|
|
1845
1859
|
resourceStatus: a.control === "imageSrc" && typeof o.value == "string" && o.value !== "" ? i[o.value] : void 0,
|
|
1846
1860
|
drifted: a.control === "rowsPath" ? n.rowsPathDrifted.value : void 0
|
|
1847
1861
|
});
|
|
@@ -1869,16 +1883,16 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1869
1883
|
function c() {
|
|
1870
1884
|
n.setAnchorExpanded(!n.anchorExpanded.value);
|
|
1871
1885
|
}
|
|
1872
|
-
return (e, t) => (P(), O("aside",
|
|
1873
|
-
k("header",
|
|
1886
|
+
return (e, t) => (P(), O("aside", Cn, [
|
|
1887
|
+
k("header", wn, [k("div", Tn, [k("span", En, [t[0] ||= k("i", {
|
|
1874
1888
|
class: "size-1.5 rounded-full bg-cn-accent",
|
|
1875
1889
|
"aria-hidden": "true"
|
|
1876
|
-
}, null, -1), de(" " + R(a.value), 1)]), k("span",
|
|
1877
|
-
o.value.length === 0 ? (P(), O("p",
|
|
1890
|
+
}, null, -1), de(" " + R(a.value), 1)]), k("span", Dn, R(i.value ? "图层属性" : "画布属性"), 1)])]),
|
|
1891
|
+
o.value.length === 0 ? (P(), O("p", On, " 打开文档后可编辑属性 ")) : D("", !0),
|
|
1878
1892
|
(P(!0), O(w, null, I(o.value, (e) => (P(), O("section", {
|
|
1879
1893
|
key: e.title,
|
|
1880
1894
|
class: "cn-props__section border-b border-cn-line/70 px-3.5 py-3 last:border-b-0"
|
|
1881
|
-
}, [k("h3",
|
|
1895
|
+
}, [k("h3", kn, R(e.title), 1), k("div", An, [(P(!0), O(w, null, I(e.fields, (e) => (P(), O(w, { key: e.key }, [e.field.control === "anchor" ? (P(), E(tt, {
|
|
1882
1896
|
key: 0,
|
|
1883
1897
|
field: e.field,
|
|
1884
1898
|
"model-value": e.value,
|
|
@@ -1890,7 +1904,7 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1890
1904
|
"model-value",
|
|
1891
1905
|
"expanded",
|
|
1892
1906
|
"onChange"
|
|
1893
|
-
])) : (P(), E(
|
|
1907
|
+
])) : (P(), E(Sn, {
|
|
1894
1908
|
key: 1,
|
|
1895
1909
|
field: e.field,
|
|
1896
1910
|
value: e.value,
|
|
@@ -1924,4 +1938,4 @@ var pn = ["aria-disabled"], mn = [
|
|
|
1924
1938
|
}
|
|
1925
1939
|
});
|
|
1926
1940
|
//#endregion
|
|
1927
|
-
export { Z as a,
|
|
1941
|
+
export { Z as a, Ne as c, Fe as d, K as f, pn as i, Le as l, Sn as n, Rt as o, mn as r, Re as s, Mn as t, Pe as u };
|
package/dist/property-panel.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./property-panel-
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./property-panel-CwdTufiP.js";
|
|
2
2
|
import { i as f, r as p } from "./uploadFile-mXJVPEzm.js";
|
|
3
3
|
export { l as CANVAS_FIELD_SECTIONS, t as FIELD_SECTIONS_BY_TYPE, p as FONT_PICKER_KEY, e as IMAGE_UPLOAD_KEY, o as PropertyField, u as PropertyPanel, i as controlRegistry, a as fieldSectionsForPath, d as fieldSectionsForType, f as injectFontPicker, s as injectImageUpload, n as layerRoleAt, r as readField, c as usePropertyPanel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hankchen/canvas-editor-vue",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue 3 薄绑定:响应式桥、composables、画布表面组件、textarea 文本编辑 overlay、schema 驱动属性面板注册表",
|
|
6
6
|
"type": "module",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@lucide/vue": "^1.48.0",
|
|
61
|
-
"@hankchen/canvas-editor": "2.
|
|
61
|
+
"@hankchen/canvas-editor": "2.1.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"vue": "^3.5.0"
|