mce 0.15.35 → 0.15.36

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.css CHANGED
@@ -804,20 +804,24 @@
804
804
  display: flex;
805
805
  align-items: center;
806
806
  justify-content: center;
807
- }
808
- .mce-smart-selection .mce-smart-handle--active > .mce-smart-handle__btn {
809
- background: #FF24BD;
807
+ pointer-events: auto;
810
808
  }
811
809
  .mce-smart-selection .mce-smart-handle__btn {
812
- pointer-events: auto;
813
- width: 10px;
814
- height: 10px;
810
+ width: 1px;
811
+ height: 1px;
815
812
  border-radius: 100%;
816
813
  border: 1px solid #FF24BD;
817
814
  outline: 1px solid #FFFFFF;
818
815
  }
819
816
  .mce-smart-selection .mce-smart-handle__btn:hover {
820
817
  background: #FF24BD;
818
+ }
819
+ .mce-smart-selection .mce-smart-handle__btn--active {
820
+ width: 10px;
821
+ height: 10px;
822
+ }
823
+ .mce-smart-selection .mce-smart-handle--active .mce-smart-handle__btn {
824
+ background: #FF24BD;
821
825
  }.progress-indicator[data-v-3b286483] {
822
826
  display: flex;
823
827
  align-items: center;
package/dist/index.js CHANGED
@@ -1996,7 +1996,8 @@ const _2_box = defineMixin((editor) => {
1996
1996
  selection,
1997
1997
  getAncestorFrame,
1998
1998
  drawboardAabb,
1999
- screenControlsOffset
1999
+ screenControlsOffset,
2000
+ getGlobalPointer
2000
2001
  } = editor;
2001
2002
  function obbToFit(element) {
2002
2003
  const min = {
@@ -2208,6 +2209,7 @@ const _2_box = defineMixin((editor) => {
2208
2209
  const selectionAabbInDrawboard = computed(() => aabbToDrawboardAabb(selectionAabb.value));
2209
2210
  const selectionObb = computed(() => getObb(selection.value));
2210
2211
  const selectionObbInDrawboard = computed(() => obbToDrawboardObb(selectionObb.value));
2212
+ const isPointerInSelection = computed(() => selectionAabb.value.contains(getGlobalPointer()));
2211
2213
  Object.assign(editor, {
2212
2214
  obbToFit,
2213
2215
  getObb,
@@ -2219,7 +2221,8 @@ const _2_box = defineMixin((editor) => {
2219
2221
  selectionAabb,
2220
2222
  selectionAabbInDrawboard,
2221
2223
  selectionObb,
2222
- selectionObbInDrawboard
2224
+ selectionObbInDrawboard,
2225
+ isPointerInSelection
2223
2226
  });
2224
2227
  });
2225
2228
  const _2_export = defineMixin((editor) => {
@@ -4291,7 +4294,7 @@ const _autoNest = definePlugin((editor) => {
4291
4294
  let flag = true;
4292
4295
  for (let i = 0, len = frames.value.length; i < len; i++) {
4293
4296
  const frame2 = frames.value[i];
4294
- if (frame2.equal(el)) {
4297
+ if (options?.excluded.has(frame2.instanceId) || frame2.equal(el)) {
4295
4298
  continue;
4296
4299
  }
4297
4300
  const aabb2 = frame2.getGlobalAabb();
@@ -4359,12 +4362,14 @@ const _autoNest = definePlugin((editor) => {
4359
4362
  selectionTransform: ({ handle, startEvent, elements }) => {
4360
4363
  if (handle === "move" && !startEvent?.__FROM__) {
4361
4364
  if (Object.keys(startContext).length > 0) {
4365
+ const excluded = new Set(elements.map((el) => el.instanceId));
4362
4366
  elements.forEach((el) => {
4363
4367
  nestIntoFrame(
4364
4368
  el,
4365
4369
  {
4366
4370
  ...startContext[el.instanceId],
4367
- pointer: getGlobalPointer()
4371
+ pointer: getGlobalPointer(),
4372
+ excluded
4368
4373
  }
4369
4374
  );
4370
4375
  });
@@ -5624,6 +5629,7 @@ const _sfc_main$z = /* @__PURE__ */ defineComponent({
5624
5629
  getObb,
5625
5630
  camera
5626
5631
  } = useEditor();
5632
+ watch(selection, () => hoverElement.value = void 0);
5627
5633
  const hoverElementObb = computed(() => getObb(hoverElement.value, "drawboard"));
5628
5634
  return (_ctx, _cache) => {
5629
5635
  return unref(hoverElement) && !unref(selection).some((node) => node.equal(unref(hoverElement))) ? (openBlock(), createElementBlock("div", {
@@ -14602,7 +14608,6 @@ const _smartGuides = definePlugin((editor) => {
14602
14608
  viewportAabb
14603
14609
  } = editor;
14604
14610
  const snapThreshold = computed(() => Math.max(1, 5 / camera.value.zoom.x));
14605
- const excluded = computed(() => new Set(elementSelection.value.map((el) => el.id)));
14606
14611
  const parnet = computed(() => elementSelection.value[0]?.parent ?? root.value);
14607
14612
  const parentBox = computed(() => createBox(parnet.value));
14608
14613
  function createBox(node) {
@@ -14720,8 +14725,9 @@ const _smartGuides = definePlugin((editor) => {
14720
14725
  const _linePairs = [];
14721
14726
  const box = createBox(selectionAabb.value);
14722
14727
  if (box) {
14728
+ const excluded = new Set(elementSelection.value.map((el) => el.instanceId));
14723
14729
  const boxes = parnet.value.children.filter((node) => {
14724
- return !excluded.value.has(node.id) && isElement(node) && viewportAabb.value.overlap(node.getGlobalAabb());
14730
+ return !excluded.has(node.instanceId) && isElement(node) && viewportAabb.value.overlap(node.getGlobalAabb());
14725
14731
  }).map((node) => createBox(node)).filter(Boolean);
14726
14732
  const { vLines, hLines } = boxes.reduce(
14727
14733
  (store, box2) => {
@@ -14987,7 +14993,7 @@ const _hoisted_1$b = {
14987
14993
  key: 0,
14988
14994
  class: "mce-smart-selection"
14989
14995
  };
14990
- const _hoisted_2$6 = ["onClick"];
14996
+ const _hoisted_2$6 = ["onMousedown"];
14991
14997
  const _sfc_main$h = /* @__PURE__ */ defineComponent({
14992
14998
  __name: "SmartSelection",
14993
14999
  props: {
@@ -14998,16 +15004,19 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
14998
15004
  setup(__props) {
14999
15005
  const currentElement = useModel(__props, "modelValue");
15000
15006
  const {
15007
+ isPointerInSelection,
15001
15008
  elementSelection,
15002
15009
  getObb,
15003
15010
  getAabb,
15004
15011
  state,
15005
15012
  camera,
15006
15013
  resizeElement,
15007
- inEditorIs
15014
+ inEditorIs,
15015
+ getGlobalPointer
15008
15016
  } = useEditor();
15009
15017
  const info = ref({
15010
15018
  active: false,
15019
+ direction: void 0,
15011
15020
  spacing: void 0,
15012
15021
  xItems: [],
15013
15022
  yItems: []
@@ -15018,6 +15027,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
15018
15027
  }
15019
15028
  const els = elementSelection.value;
15020
15029
  let active = false;
15030
+ let direction;
15021
15031
  let spacing;
15022
15032
  let xItems = [];
15023
15033
  let yItems = [];
@@ -15044,6 +15054,7 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
15044
15054
  }
15045
15055
  if (active) {
15046
15056
  yItems = sorted;
15057
+ direction = "vertical";
15047
15058
  } else {
15048
15059
  active = true;
15049
15060
  prev = void 0;
@@ -15067,23 +15078,20 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
15067
15078
  }
15068
15079
  if (active) {
15069
15080
  xItems = sorted2;
15081
+ direction = "horizontal";
15070
15082
  }
15071
15083
  }
15072
15084
  }
15073
15085
  info.value = {
15074
15086
  active,
15087
+ direction,
15075
15088
  spacing,
15076
15089
  xItems,
15077
15090
  yItems
15078
15091
  };
15079
15092
  }
15080
15093
  watch(() => elementSelection.value.map((el) => getAabb(el)), update);
15081
- watch(
15082
- state,
15083
- () => {
15084
- currentElement.value = void 0;
15085
- }
15086
- );
15094
+ watch(elementSelection, () => currentElement.value = void 0);
15087
15095
  const handles = computed(() => {
15088
15096
  return elementSelection.value.map((el) => {
15089
15097
  return {
@@ -15156,6 +15164,11 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
15156
15164
  });
15157
15165
  }
15158
15166
  });
15167
+ function onMouseDown(item, downEvent) {
15168
+ const el = item.el;
15169
+ currentElement.value = el;
15170
+ return;
15171
+ }
15159
15172
  return (_ctx, _cache) => {
15160
15173
  return info.value.active ? (openBlock(), createElementBlock("div", _hoisted_1$b, [
15161
15174
  (openBlock(true), createElementBlock(Fragment, null, renderList(handles.value, (item, index) => {
@@ -15164,12 +15177,15 @@ const _sfc_main$h = /* @__PURE__ */ defineComponent({
15164
15177
  class: normalizeClass(["mce-smart-handle", {
15165
15178
  "mce-smart-handle--active": item.el.equal(currentElement.value)
15166
15179
  }]),
15167
- style: normalizeStyle$1(item.style)
15180
+ style: normalizeStyle$1(item.style),
15181
+ "data-pointerdown_to_drawboard": ""
15168
15182
  }, [
15169
15183
  createElementVNode("div", {
15170
- class: "mce-smart-handle__btn",
15171
- onClick: ($event) => currentElement.value = item.el
15172
- }, null, 8, _hoisted_2$6)
15184
+ class: normalizeClass(["mce-smart-handle__btn", {
15185
+ "mce-smart-handle__btn--active": unref(state) === "transforming" || unref(isPointerInSelection)
15186
+ }]),
15187
+ onMousedown: ($event) => onMouseDown(item)
15188
+ }, null, 42, _hoisted_2$6)
15173
15189
  ], 6);
15174
15190
  }), 128)),
15175
15191
  transform.value.width && transform.value.height ? (openBlock(), createBlock(_sfc_main$k, {
@@ -17237,9 +17253,17 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17237
17253
  ]),
17238
17254
  _: 3
17239
17255
  }),
17256
+ renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(slotProps))),
17240
17257
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(components), (item, key) => {
17241
17258
  return openBlock(), createElementBlock(Fragment, { key }, [
17242
- item.type === "panel" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
17259
+ item.type === "overlay" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
17260
+ unref(drawboardDom) ? (openBlock(), createBlock(Teleport, {
17261
+ key: 0,
17262
+ to: unref(drawboardDom)
17263
+ }, [
17264
+ createVNode(RenderComponent, { item }, null, 8, ["item"])
17265
+ ], 8, ["to"])) : createCommentVNode("", true)
17266
+ ], 64)) : item.type === "panel" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
17243
17267
  item.position === "float" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
17244
17268
  unref(config)[item.name] ? (openBlock(), createBlock(_sfc_main$6, {
17245
17269
  key: 0,
@@ -17277,18 +17301,10 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17277
17301
  _: 2
17278
17302
  }, 1032, ["modelValue", "onUpdate:modelValue", "position", "size", "order"])) : createCommentVNode("", true)
17279
17303
  ], 64))
17280
- ], 64)) : item.type === "overlay" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
17281
- unref(drawboardDom) ? (openBlock(), createBlock(Teleport, {
17282
- key: 0,
17283
- to: unref(drawboardDom)
17284
- }, [
17285
- createVNode(RenderComponent, { item }, null, 8, ["item"])
17286
- ], 8, ["to"])) : createCommentVNode("", true)
17287
17304
  ], 64)) : createCommentVNode("", true)
17288
17305
  ], 64);
17289
17306
  }), 128)),
17290
- createElementVNode("div", _hoisted_3, null, 512),
17291
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(slotProps)))
17307
+ createElementVNode("div", _hoisted_3, null, 512)
17292
17308
  ]),
17293
17309
  _: 3
17294
17310
  }, 8, ["class"]);
@@ -15,6 +15,7 @@ declare global {
15
15
  selectionAabbInDrawboard: ComputedRef<Aabb2D>;
16
16
  selectionObb: ComputedRef<Obb2D>;
17
17
  selectionObbInDrawboard: ComputedRef<Aabb2D>;
18
+ isPointerInSelection: ComputedRef<boolean>;
18
19
  }
19
20
  }
20
21
  }
@@ -5,6 +5,7 @@ declare global {
5
5
  pointer: Vector2Like;
6
6
  parent: Element2D;
7
7
  index: number;
8
+ excluded: Set<number>;
8
9
  }
9
10
  interface Commands {
10
11
  nestIntoFrame: (element: Element2D, options?: NestIntoFrameOptions) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.15.35",
4
+ "version": "0.15.36",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",