mce 0.15.2 → 0.15.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/index.js +55 -32
- package/dist/mixins/0.context.d.ts +1 -0
- package/dist/plugins/ui.d.ts +5 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -535,13 +535,13 @@ class Doc extends Model {
|
|
|
535
535
|
}
|
|
536
536
|
async load(initFn) {
|
|
537
537
|
return super.load(async () => {
|
|
538
|
+
await initFn?.();
|
|
538
539
|
this._proxyNode(
|
|
539
540
|
this.root,
|
|
540
541
|
this._yProps,
|
|
541
542
|
this._yChildrenIds
|
|
542
543
|
);
|
|
543
544
|
this._yChildren.observe(this._yChildrenChange.bind(this));
|
|
544
|
-
await initFn?.();
|
|
545
545
|
});
|
|
546
546
|
}
|
|
547
547
|
_isSelfTransaction(transaction) {
|
|
@@ -623,7 +623,6 @@ class Doc extends Model {
|
|
|
623
623
|
};
|
|
624
624
|
this.reset();
|
|
625
625
|
this.setProperties(props);
|
|
626
|
-
this._yProps.clear();
|
|
627
626
|
for (const key in props) {
|
|
628
627
|
this._yProps.set(key, props[key]);
|
|
629
628
|
}
|
|
@@ -935,6 +934,9 @@ const _0_context = defineMixin((editor) => {
|
|
|
935
934
|
function isFrame(value) {
|
|
936
935
|
return isElement(value) && value.meta.inEditorIs === "Frame";
|
|
937
936
|
}
|
|
937
|
+
function isRootFrame(value) {
|
|
938
|
+
return isFrame(value) && Boolean(value.parent?.equal(root.value));
|
|
939
|
+
}
|
|
938
940
|
function isVisible(node) {
|
|
939
941
|
return isElement(node) && node.style.visibility === "visible";
|
|
940
942
|
}
|
|
@@ -975,6 +977,7 @@ const _0_context = defineMixin((editor) => {
|
|
|
975
977
|
isRoot,
|
|
976
978
|
isElement,
|
|
977
979
|
isFrame,
|
|
980
|
+
isRootFrame,
|
|
978
981
|
isVisible,
|
|
979
982
|
setVisible,
|
|
980
983
|
isLock,
|
|
@@ -2782,7 +2785,7 @@ const _4_3_element = defineMixin((editor) => {
|
|
|
2782
2785
|
function selectArea(areaInDrawboard) {
|
|
2783
2786
|
const area2 = new Obb2D(areaInDrawboard);
|
|
2784
2787
|
const selected = root.value?.children.flatMap((node) => {
|
|
2785
|
-
if (isFrame(node)) {
|
|
2788
|
+
if (isFrame(node) && node.parent?.equal(root.value)) {
|
|
2786
2789
|
return node.children;
|
|
2787
2790
|
}
|
|
2788
2791
|
return [node];
|
|
@@ -3687,7 +3690,7 @@ const aliases = {
|
|
|
3687
3690
|
const svg = {
|
|
3688
3691
|
component: SvgIcon
|
|
3689
3692
|
};
|
|
3690
|
-
const IconsSymbol = Symbol.for("mce:icons");
|
|
3693
|
+
const IconsSymbol = /* @__PURE__ */ Symbol.for("mce:icons");
|
|
3691
3694
|
function createIcons(options = {}) {
|
|
3692
3695
|
return merge({
|
|
3693
3696
|
defaultSet: "svg",
|
|
@@ -3740,8 +3743,8 @@ function useIcon(props) {
|
|
|
3740
3743
|
iconData
|
|
3741
3744
|
};
|
|
3742
3745
|
}
|
|
3743
|
-
const MceLayerKey = Symbol.for("mce:layer");
|
|
3744
|
-
const MceLayerItemKey = Symbol.for("mce:layer-item");
|
|
3746
|
+
const MceLayerKey = /* @__PURE__ */ Symbol.for("mce:layer");
|
|
3747
|
+
const MceLayerItemKey = /* @__PURE__ */ Symbol.for("mce:layer-item");
|
|
3745
3748
|
function createLayer(options) {
|
|
3746
3749
|
const registered = ref([]);
|
|
3747
3750
|
const nodeItems = /* @__PURE__ */ new Map();
|
|
@@ -3892,8 +3895,8 @@ function useResizeObserver(callback, box = "content") {
|
|
|
3892
3895
|
contentRect: readonly(contentRect)
|
|
3893
3896
|
};
|
|
3894
3897
|
}
|
|
3895
|
-
const MceLayoutKey = Symbol.for("mce:layout");
|
|
3896
|
-
const MceLayoutItemKey = Symbol.for("mce:layout-item");
|
|
3898
|
+
const MceLayoutKey = /* @__PURE__ */ Symbol.for("mce:layout");
|
|
3899
|
+
const MceLayoutItemKey = /* @__PURE__ */ Symbol.for("mce:layout-item");
|
|
3897
3900
|
const ROOT_ZINDEX = 500;
|
|
3898
3901
|
function makeLayoutProps() {
|
|
3899
3902
|
return {
|
|
@@ -4131,8 +4134,8 @@ function createLayout(props) {
|
|
|
4131
4134
|
layoutRef: resizeRef
|
|
4132
4135
|
};
|
|
4133
4136
|
}
|
|
4134
|
-
const MceMenuSymbol = Symbol.for("MceMenuSymbol");
|
|
4135
|
-
const MceOverlaySymbol = Symbol.for("MceOverlaySymbol");
|
|
4137
|
+
const MceMenuSymbol = /* @__PURE__ */ Symbol.for("MceMenuSymbol");
|
|
4138
|
+
const MceOverlaySymbol = /* @__PURE__ */ Symbol.for("MceOverlaySymbol");
|
|
4136
4139
|
const makeMceOverlayProps = propsFactory({
|
|
4137
4140
|
location: String,
|
|
4138
4141
|
offset: Number,
|
|
@@ -4256,7 +4259,9 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4256
4259
|
selection,
|
|
4257
4260
|
state,
|
|
4258
4261
|
config,
|
|
4259
|
-
exec
|
|
4262
|
+
exec,
|
|
4263
|
+
renderEngine,
|
|
4264
|
+
drawboardDom
|
|
4260
4265
|
} = useEditor();
|
|
4261
4266
|
const editing = ref(false);
|
|
4262
4267
|
async function onDblclick() {
|
|
@@ -4267,11 +4272,14 @@ const _sfc_main$B = /* @__PURE__ */ defineComponent({
|
|
|
4267
4272
|
input.value.select();
|
|
4268
4273
|
}
|
|
4269
4274
|
}
|
|
4270
|
-
async function onPointerdown(
|
|
4275
|
+
async function onPointerdown(event) {
|
|
4271
4276
|
if (!editing.value) {
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4277
|
+
const cloend = renderEngine.value.input._clonePointerEvent(event);
|
|
4278
|
+
cloend.srcElement = drawboardDom.value;
|
|
4279
|
+
cloend.target = frame.value;
|
|
4280
|
+
exec("startPointerdown", cloend, {
|
|
4281
|
+
allowRootFrame: true
|
|
4282
|
+
});
|
|
4275
4283
|
}
|
|
4276
4284
|
}
|
|
4277
4285
|
return (_ctx, _cache) => {
|
|
@@ -8543,7 +8551,7 @@ class Curve {
|
|
|
8543
8551
|
}
|
|
8544
8552
|
getLength() {
|
|
8545
8553
|
const lengths = this.getLengths();
|
|
8546
|
-
return lengths[lengths.length - 1];
|
|
8554
|
+
return lengths[lengths.length - 1] ?? 0;
|
|
8547
8555
|
}
|
|
8548
8556
|
getLengths() {
|
|
8549
8557
|
if (this._lengths.length !== this.arcLengthDivision + 1) {
|
|
@@ -13523,7 +13531,7 @@ const plugins = [
|
|
|
13523
13531
|
_zoom
|
|
13524
13532
|
];
|
|
13525
13533
|
class Editor extends Observable {
|
|
13526
|
-
static injectionKey = Symbol.for("EditorKey");
|
|
13534
|
+
static injectionKey = /* @__PURE__ */ Symbol.for("EditorKey");
|
|
13527
13535
|
debug = ref(false);
|
|
13528
13536
|
onEmit;
|
|
13529
13537
|
plugins = /* @__PURE__ */ new Map();
|
|
@@ -14666,7 +14674,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
14666
14674
|
element,
|
|
14667
14675
|
newStyle.width / element.style.width,
|
|
14668
14676
|
newStyle.height / element.style.height,
|
|
14669
|
-
isFrame(element) ? void 0 : !shape.
|
|
14677
|
+
isFrame(element) ? void 0 : !shape.isValid() ? handle.split("-").length > 2 ? { deep: true, textFontSizeToFit: true } : { deep: true, textToFit: true } : void 0
|
|
14670
14678
|
);
|
|
14671
14679
|
newStyle.width = element.style.width;
|
|
14672
14680
|
newStyle.height = element.style.height;
|
|
@@ -14981,7 +14989,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
14981
14989
|
}
|
|
14982
14990
|
function onUpdate() {
|
|
14983
14991
|
const element = elementSelection.value[0];
|
|
14984
|
-
if (!element.shape.
|
|
14992
|
+
if (!element.shape.isValid()) {
|
|
14985
14993
|
textToFit(element);
|
|
14986
14994
|
}
|
|
14987
14995
|
}
|
|
@@ -15076,6 +15084,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15076
15084
|
const {
|
|
15077
15085
|
pluginsComponents,
|
|
15078
15086
|
isElement,
|
|
15087
|
+
isRootFrame,
|
|
15079
15088
|
config,
|
|
15080
15089
|
drawboardDom,
|
|
15081
15090
|
renderEngine,
|
|
@@ -15147,20 +15156,30 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15147
15156
|
event,
|
|
15148
15157
|
editor
|
|
15149
15158
|
});
|
|
15150
|
-
if (result &&
|
|
15159
|
+
if (result && "element" in result) {
|
|
15151
15160
|
hovered = result.element;
|
|
15152
15161
|
cursor = result.cursor;
|
|
15153
15162
|
} else {
|
|
15154
15163
|
hovered = result;
|
|
15155
15164
|
}
|
|
15156
15165
|
}
|
|
15166
|
+
if (!(isElement(hovered) && !isRootFrame(hovered))) {
|
|
15167
|
+
hovered = void 0;
|
|
15168
|
+
cursor = void 0;
|
|
15169
|
+
}
|
|
15157
15170
|
hoverElement.value = hovered;
|
|
15158
15171
|
setCursor(cursor);
|
|
15159
15172
|
}
|
|
15160
|
-
function onPointerdown(downEvent) {
|
|
15161
|
-
if (downEvent.srcElement !== drawboardDom.value && downEvent.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(downEvent.button)) {
|
|
15173
|
+
function onPointerdown(downEvent, options = {}) {
|
|
15174
|
+
if (downEvent.srcElement && downEvent.srcElement !== drawboardDom.value && downEvent.srcElement.dataset?.pointerdown_to_drawboard === void 0 || camera.value.spaceKey || ![0, 2].includes(downEvent.button)) {
|
|
15162
15175
|
return;
|
|
15163
15176
|
}
|
|
15177
|
+
const {
|
|
15178
|
+
allowRootFrame = false
|
|
15179
|
+
} = options;
|
|
15180
|
+
function isIncluded(node) {
|
|
15181
|
+
return isElement(node) && (allowRootFrame || !isRootFrame(node));
|
|
15182
|
+
}
|
|
15164
15183
|
const drawing = state.value === "drawing";
|
|
15165
15184
|
const hand = state.value === "hand";
|
|
15166
15185
|
const element = downEvent.target;
|
|
@@ -15183,11 +15202,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15183
15202
|
event: downEvent,
|
|
15184
15203
|
editor
|
|
15185
15204
|
});
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15189
|
-
selected = result ? [result] : [];
|
|
15205
|
+
let _element = result && "element" in result ? result.element : result;
|
|
15206
|
+
if (!isIncluded(_element)) {
|
|
15207
|
+
_element = void 0;
|
|
15190
15208
|
}
|
|
15209
|
+
selected = _element ? [_element] : [];
|
|
15191
15210
|
elementSelection.value = selected;
|
|
15192
15211
|
}
|
|
15193
15212
|
return;
|
|
@@ -15209,11 +15228,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15209
15228
|
event,
|
|
15210
15229
|
editor
|
|
15211
15230
|
});
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
selected = result ? [result] : [];
|
|
15231
|
+
let _element = result && "element" in result ? result.element : result;
|
|
15232
|
+
if (!isIncluded(_element)) {
|
|
15233
|
+
_element = void 0;
|
|
15216
15234
|
}
|
|
15235
|
+
selected = _element ? [_element] : [];
|
|
15217
15236
|
elementSelection.value = selected;
|
|
15218
15237
|
}
|
|
15219
15238
|
function onSelectArea() {
|
|
@@ -15234,12 +15253,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15234
15253
|
editor
|
|
15235
15254
|
});
|
|
15236
15255
|
let _element;
|
|
15237
|
-
if (result &&
|
|
15256
|
+
if (result && "element" in result) {
|
|
15238
15257
|
_element = result.element;
|
|
15239
15258
|
ctxState = result.state;
|
|
15240
15259
|
} else {
|
|
15241
15260
|
_element = result;
|
|
15242
15261
|
}
|
|
15262
|
+
if (!isIncluded(_element)) {
|
|
15263
|
+
_element = void 0;
|
|
15264
|
+
}
|
|
15243
15265
|
if (_element && (downEvent?.ctrlKey || downEvent?.shiftKey || downEvent?.metaKey)) {
|
|
15244
15266
|
if (elementSelection.value.findIndex((v) => v.equal(_element)) > -1) {
|
|
15245
15267
|
selected = elementSelection.value.filter((v) => !v.equal(_element));
|
|
@@ -15292,7 +15314,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15292
15314
|
);
|
|
15293
15315
|
} else {
|
|
15294
15316
|
if (!inSelection) {
|
|
15295
|
-
if (!element) {
|
|
15317
|
+
if (!isIncluded(element)) {
|
|
15296
15318
|
onSelectArea();
|
|
15297
15319
|
}
|
|
15298
15320
|
}
|
|
@@ -15341,6 +15363,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
15341
15363
|
document.addEventListener("pointermove", onMove);
|
|
15342
15364
|
document.addEventListener("pointerup", onUp);
|
|
15343
15365
|
}
|
|
15366
|
+
editor.registerCommand({ command: "startPointerdown", handle: onPointerdown });
|
|
15344
15367
|
function onPointermove(event) {
|
|
15345
15368
|
if (event.srcElement !== drawboardDom.value) {
|
|
15346
15369
|
return;
|
|
@@ -45,6 +45,7 @@ declare global {
|
|
|
45
45
|
isRoot: (value: any) => value is Node;
|
|
46
46
|
isElement: (value: any) => value is Element2D;
|
|
47
47
|
isFrame: (value: any) => value is Element2D;
|
|
48
|
+
isRootFrame: (value: any) => value is Element2D;
|
|
48
49
|
isVisible: (node: Node) => boolean;
|
|
49
50
|
setVisible: (node: Node, visible: boolean) => void;
|
|
50
51
|
isLock: (node: Node) => boolean;
|
package/dist/plugins/ui.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import type { PointerInputEvent } from 'modern-canvas';
|
|
1
2
|
import type { AxisAlignedBoundingBox } from '../types';
|
|
2
3
|
declare global {
|
|
3
4
|
namespace Mce {
|
|
5
|
+
interface StartPointerdownOptions {
|
|
6
|
+
allowRootFrame?: boolean;
|
|
7
|
+
}
|
|
4
8
|
interface Commands {
|
|
9
|
+
startPointerdown: (e: PointerInputEvent, options?: StartPointerdownOptions) => void;
|
|
5
10
|
startTyping: (e?: MouseEvent | PointerEvent) => Promise<boolean>;
|
|
6
11
|
startTransform: (e?: MouseEvent | PointerEvent) => boolean;
|
|
7
12
|
openContextMenu: (e?: MouseEvent | PointerEvent) => boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mce",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.3",
|
|
5
5
|
"description": "The headless canvas editor framework. only the ESM.",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@vueuse/core": "^14.1.0",
|
|
61
61
|
"diff": "^8.0.2",
|
|
62
62
|
"file-saver": "^2.0.5",
|
|
63
|
-
"lodash-es": "^4.17.
|
|
64
|
-
"modern-canvas": "^0.14.
|
|
63
|
+
"lodash-es": "^4.17.22",
|
|
64
|
+
"modern-canvas": "^0.14.19",
|
|
65
65
|
"modern-font": "^0.4.4",
|
|
66
|
-
"modern-idoc": "^0.10.
|
|
66
|
+
"modern-idoc": "^0.10.7",
|
|
67
67
|
"modern-text": "^1.10.5",
|
|
68
68
|
"yjs": "^13.6.27"
|
|
69
69
|
},
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@vitejs/plugin-vue": "^6.0.3",
|
|
95
95
|
"jiti": "^2.6.1",
|
|
96
96
|
"modern-gif": "^2.0.4",
|
|
97
|
-
"sass-embedded": "^1.
|
|
97
|
+
"sass-embedded": "^1.97.0"
|
|
98
98
|
},
|
|
99
99
|
"scripts": {
|
|
100
100
|
"build:code": "vite build",
|