@oh-just-another/state 0.63.0 → 0.65.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/CHANGELOG.md +12 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/editor/link-label-hit.d.ts +10 -0
- package/dist/editor/link-label-hit.d.ts.map +1 -0
- package/dist/editor/link-label-hit.js +22 -0
- package/dist/editor/link-label-hit.js.map +1 -0
- package/dist/editor/pointer-binding.d.ts.map +1 -1
- package/dist/editor/pointer-binding.js +3 -11
- package/dist/editor/pointer-binding.js.map +1 -1
- package/dist/editor/public/cursor.d.ts +5 -0
- package/dist/editor/public/cursor.d.ts.map +1 -1
- package/dist/editor/public/cursor.js +28 -10
- package/dist/editor/public/cursor.js.map +1 -1
- package/dist/editor.d.ts +14 -2
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +91 -6
- package/dist/editor.js.map +1 -1
- package/dist/interaction/handle.d.ts +6 -7
- package/dist/interaction/handle.d.ts.map +1 -1
- package/dist/interaction/handle.js +40 -15
- package/dist/interaction/handle.js.map +1 -1
- package/package.json +3 -3
package/dist/editor.js
CHANGED
|
@@ -2717,6 +2717,50 @@ export class Editor {
|
|
|
2717
2717
|
tx.commit();
|
|
2718
2718
|
this.notify();
|
|
2719
2719
|
}
|
|
2720
|
+
/**
|
|
2721
|
+
* Text-carrier routing for mixed selections: merge a partial text style
|
|
2722
|
+
* into the element style of text elements and into the label style of
|
|
2723
|
+
* labelable shapes (seeding the label when missing); other elements are
|
|
2724
|
+
* skipped. One undo step. The selection toolbar writes through this so a
|
|
2725
|
+
* shape + text selection shares one text-colour / decoration control
|
|
2726
|
+
* instead of choosing between `updateStyle` and `updateLabelStyle`.
|
|
2727
|
+
*/
|
|
2728
|
+
updateTextStyle(ids, partial) {
|
|
2729
|
+
if (this.readOnly)
|
|
2730
|
+
return;
|
|
2731
|
+
const tx = this._history.transaction();
|
|
2732
|
+
let changed = false;
|
|
2733
|
+
for (const id of ids) {
|
|
2734
|
+
const shape = getElement(this._scene, id);
|
|
2735
|
+
if (shape === undefined)
|
|
2736
|
+
continue;
|
|
2737
|
+
let r;
|
|
2738
|
+
if (isText(shape)) {
|
|
2739
|
+
r = updateElement(this._scene, id, (raw) => ({
|
|
2740
|
+
...raw,
|
|
2741
|
+
style: { ...raw.style, ...partial },
|
|
2742
|
+
}));
|
|
2743
|
+
}
|
|
2744
|
+
else if (withLabel(shape).label !== undefined) {
|
|
2745
|
+
r = updateElement(this._scene, id, (raw) => {
|
|
2746
|
+
const l = withLabel(raw);
|
|
2747
|
+
return l.label === undefined
|
|
2748
|
+
? l
|
|
2749
|
+
: { ...l, label: { ...l.label, style: { ...l.label.style, ...partial } } };
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
else {
|
|
2753
|
+
continue;
|
|
2754
|
+
}
|
|
2755
|
+
this._scene = r.scene;
|
|
2756
|
+
tx.add(r.patch);
|
|
2757
|
+
changed = true;
|
|
2758
|
+
}
|
|
2759
|
+
if (!changed)
|
|
2760
|
+
return;
|
|
2761
|
+
tx.commit();
|
|
2762
|
+
this.notify();
|
|
2763
|
+
}
|
|
2720
2764
|
/**
|
|
2721
2765
|
* Merge font family / size into the embedded label. Picking an
|
|
2722
2766
|
* explicit `fontSize` also leaves auto-fit mode (reference behaviour —
|
|
@@ -3714,17 +3758,58 @@ export class Editor {
|
|
|
3714
3758
|
}
|
|
3715
3759
|
/**
|
|
3716
3760
|
* Update non-style text properties (`fontSize`, `fontFamily`,
|
|
3717
|
-
* `maxWidth`) on every
|
|
3718
|
-
*
|
|
3761
|
+
* `maxWidth`) on every text shape in `ids`; labelable shapes route
|
|
3762
|
+
* `fontSize` / `fontFamily` to their embedded label instead (as
|
|
3763
|
+
* `updateLabelProps` — an explicit size leaves auto-fit). Anything else is
|
|
3764
|
+
* skipped. Single undo step. Used by the selection toolbar, so a mixed
|
|
3765
|
+
* text + shape selection shares one font control.
|
|
3719
3766
|
*/
|
|
3720
3767
|
updateTextProps(ids, partial) {
|
|
3721
3768
|
if (this.readOnly)
|
|
3722
3769
|
return;
|
|
3723
|
-
const
|
|
3724
|
-
|
|
3770
|
+
const textIds = [];
|
|
3771
|
+
const labelIds = [];
|
|
3772
|
+
for (const id of ids) {
|
|
3773
|
+
const el = getElement(this._scene, id);
|
|
3774
|
+
if (el === undefined)
|
|
3775
|
+
continue;
|
|
3776
|
+
if (isText(el))
|
|
3777
|
+
textIds.push(id);
|
|
3778
|
+
else if (withLabel(el).label !== undefined)
|
|
3779
|
+
labelIds.push(id);
|
|
3780
|
+
}
|
|
3781
|
+
const tx = this._history.transaction();
|
|
3782
|
+
let changed = false;
|
|
3783
|
+
const text = computeUpdateTextProps(this._scene, textIds, partial);
|
|
3784
|
+
if (text) {
|
|
3785
|
+
this._scene = text.scene;
|
|
3786
|
+
tx.add(text.patch);
|
|
3787
|
+
changed = true;
|
|
3788
|
+
}
|
|
3789
|
+
const { fontFamily, fontSize } = partial;
|
|
3790
|
+
if (fontFamily !== undefined || fontSize !== undefined) {
|
|
3791
|
+
const labelPartial = {
|
|
3792
|
+
...(fontFamily !== undefined ? { fontFamily } : {}),
|
|
3793
|
+
...(fontSize !== undefined ? { fontSize } : {}),
|
|
3794
|
+
};
|
|
3795
|
+
for (const id of labelIds) {
|
|
3796
|
+
const r = updateElement(this._scene, id, (raw) => {
|
|
3797
|
+
const l = withLabel(raw);
|
|
3798
|
+
if (l.label === undefined)
|
|
3799
|
+
return l;
|
|
3800
|
+
const label = { ...l.label, ...labelPartial };
|
|
3801
|
+
if (fontSize !== undefined)
|
|
3802
|
+
delete label.autoFit;
|
|
3803
|
+
return { ...l, label };
|
|
3804
|
+
});
|
|
3805
|
+
this._scene = r.scene;
|
|
3806
|
+
tx.add(r.patch);
|
|
3807
|
+
changed = true;
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
if (!changed)
|
|
3725
3811
|
return;
|
|
3726
|
-
|
|
3727
|
-
this._history.push(result.patch);
|
|
3812
|
+
tx.commit();
|
|
3728
3813
|
this.notify();
|
|
3729
3814
|
}
|
|
3730
3815
|
/**
|