mce 0.15.21 → 0.15.22

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
@@ -607,6 +607,7 @@
607
607
  border-radius: 8px;
608
608
  font-size: 0.875rem;
609
609
  cursor: pointer;
610
+ white-space: nowrap;
610
611
  }.mce-smart-guides {
611
612
  position: absolute;
612
613
  overflow: hidden;
@@ -694,7 +695,7 @@
694
695
  100% {
695
696
  left: 100%;
696
697
  }
697
- }.mce-statusbar[data-v-79192677] {
698
+ }.mce-statusbar[data-v-a1f0e31b] {
698
699
  user-select: none;
699
700
  position: relative;
700
701
  display: flex;
@@ -708,30 +709,32 @@
708
709
  background-color: rgba(var(--mce-theme-surface), 1);
709
710
  color: rgba(var(--mce-theme-on-surface), 1);
710
711
  font-weight: bold;
712
+ white-space: nowrap;
713
+ overflow-x: auto;
711
714
  }
712
- .mce-statusbar__main[data-v-79192677] {
715
+ .mce-statusbar__main[data-v-a1f0e31b] {
713
716
  flex: 1;
714
717
  display: flex;
715
718
  align-items: center;
716
719
  gap: 4px;
717
720
  height: 100%;
718
721
  }
719
- .mce-statusbar__item[data-v-79192677] {
722
+ .mce-statusbar__item[data-v-a1f0e31b] {
720
723
  display: flex;
721
724
  align-items: center;
722
725
  gap: 4px;
723
726
  }
724
- .mce-statusbar__item > svg[data-v-79192677] {
727
+ .mce-statusbar__item > svg[data-v-a1f0e31b] {
725
728
  width: 1em;
726
729
  height: 1em;
727
730
  }
728
- .mce-statusbar__divider[data-v-79192677] {
731
+ .mce-statusbar__divider[data-v-a1f0e31b] {
729
732
  width: 0;
730
733
  height: 60%;
731
- border-right: 1px solid rgba(var(--mce-theme-on-surface), 0.2);
734
+ border-right: 1px solid rgba(var(--mce-theme-on-surface), 0.1);
732
735
  margin: 0 8px;
733
736
  }
734
- .mce-statusbar__kbd[data-v-79192677] {
737
+ .mce-statusbar__kbd[data-v-a1f0e31b] {
735
738
  outline: 1px solid rgba(var(--mce-theme-on-surface), 0.1);
736
739
  border-radius: 4px;
737
740
  display: flex;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Node as Node$1, Element2D, Timeline, Engine, Camera2D, DrawboardEffect, Aabb2D, IN_BROWSER, clamp, assets, TimelineNode, Video2D, Transform2D, Obb2D, render, Vector2 as Vector2$1, Lottie2D, customNodes, Animation, IN_MAC_OS } from "modern-canvas";
2
- import { reactive, computed, watch, markRaw, isReactive, ref, warn, shallowRef, onBeforeUnmount, defineComponent, createElementBlock, createCommentVNode, unref, openBlock, normalizeStyle as normalizeStyle$1, toDisplayString, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, useId, readonly, toRef, onMounted, onDeactivated, onActivated, onScopeDispose, useModel, useTemplateRef, withDirectives, withModifiers, vModelText, vShow, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, withCtx, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, h, isRef, useSlots } from "vue";
2
+ import { reactive, computed, watch, markRaw, isReactive, ref, warn, shallowRef, defineComponent, createElementBlock, createCommentVNode, unref, openBlock, normalizeStyle as normalizeStyle$1, toDisplayString, onBeforeUnmount, createVNode, useAttrs, createBlock, resolveDynamicComponent, normalizeClass, mergeProps, createElementVNode, inject, toValue, getCurrentInstance, provide, useId, readonly, toRef, onMounted, onDeactivated, onActivated, onScopeDispose, useModel, useTemplateRef, withDirectives, withModifiers, vModelText, vShow, nextTick, Fragment, renderList, renderSlot, mergeModels, resolveComponent, withCtx, Teleport, createTextVNode, createSlots, normalizeProps, guardReactiveProps, onBeforeMount, h, isRef, useSlots } from "vue";
3
3
  import { useFileDialog, useEventListener, isClient, onClickOutside, useDebounceFn, useResizeObserver as useResizeObserver$1, useLocalStorage, useImage } from "@vueuse/core";
4
4
  import { getObjectValueByPath, setObjectValueByPath, Observable, Reactivable, idGenerator, property, normalizeTextContent, isCRLF, textContentToString, normalizeCRLF, isEqualObject } from "modern-idoc";
5
5
  import { saveAs } from "file-saver";
@@ -1121,6 +1121,7 @@ const en = {
1121
1121
  "delete": "Delete",
1122
1122
  "selectAll": "Select all",
1123
1123
  "deselectAll": "Deselect all",
1124
+ "selectChildren": "Select children",
1124
1125
  "selectParent": "Select parent",
1125
1126
  "selectPreviousSibling": "Select previous sibling",
1126
1127
  "selectNextSibling": "Select next sibling",
@@ -1232,6 +1233,7 @@ const zhHans = {
1232
1233
  "delete": "删除",
1233
1234
  "selectAll": "选择全部",
1234
1235
  "deselectAll": "反选全部",
1236
+ "selectChildren": "选择子元素",
1235
1237
  "selectParent": "选择父元素",
1236
1238
  "selectPreviousSibling": "选择前一个",
1237
1239
  "selectNextSibling": "选择后一个",
@@ -2020,8 +2022,8 @@ const _2_box = defineMixin((editor) => {
2020
2022
  return new Aabb2D({
2021
2023
  x: p1.x,
2022
2024
  y: p1.y,
2023
- width: p2.x,
2024
- height: p2.y
2025
+ width: p2.x - p1.x,
2026
+ height: p2.y - p1.y
2025
2027
  });
2026
2028
  });
2027
2029
  const rootAabb = computed(() => getAabb(root.value.children));
@@ -2201,29 +2203,37 @@ const _3_view = defineMixin((editor) => {
2201
2203
  const _4_0_node = defineMixin((editor) => {
2202
2204
  const {
2203
2205
  doc,
2204
- selection
2206
+ selection,
2207
+ root
2205
2208
  } = editor;
2206
2209
  function findSibling(target) {
2207
2210
  const node = selection.value[0];
2211
+ let value, parent;
2208
2212
  if (node) {
2209
- let value;
2210
- switch (target) {
2211
- case "previous":
2213
+ parent = node.parent;
2214
+ } else {
2215
+ parent = root.value;
2216
+ }
2217
+ switch (target) {
2218
+ case "previous":
2219
+ if (node) {
2212
2220
  value = node.nextSibling;
2213
- if (!value && node.parent) {
2214
- value = node.parent.children[0];
2215
- }
2216
- break;
2217
- case "next":
2221
+ }
2222
+ if (!value && parent) {
2223
+ value = parent.children[0];
2224
+ }
2225
+ break;
2226
+ case "next":
2227
+ if (node) {
2218
2228
  value = node.previousSibling;
2219
- if (!value && node.parent) {
2220
- value = node.parent.children[node.parent.children.length - 1];
2221
- }
2222
- break;
2223
- }
2224
- if (value && !node.equal(value)) {
2225
- return value;
2226
- }
2229
+ }
2230
+ if (!value && parent) {
2231
+ value = parent.children[parent.children.length - 1];
2232
+ }
2233
+ break;
2234
+ }
2235
+ if (value && (!node || !node.equal(value))) {
2236
+ return value;
2227
2237
  }
2228
2238
  return void 0;
2229
2239
  }
@@ -3354,9 +3364,10 @@ const _4_2_frame = defineMixin((editor) => {
3354
3364
  if (frame2.equal(options?.parent)) {
3355
3365
  index = options.index;
3356
3366
  }
3367
+ frame2.moveChild(element, index);
3357
3368
  element.style.left = aabb1.x - aabb2.x;
3358
3369
  element.style.top = aabb1.y - aabb2.y;
3359
- frame2.moveChild(element, index);
3370
+ element.updateGlobalTransform();
3360
3371
  exec("layerScrollIntoView");
3361
3372
  }
3362
3373
  flag = false;
@@ -3365,13 +3376,14 @@ const _4_2_frame = defineMixin((editor) => {
3365
3376
  }
3366
3377
  }
3367
3378
  if (flag && frame1) {
3368
- element.style.left = aabb1.x;
3369
- element.style.top = aabb1.y;
3370
3379
  let index = root.value.children.length;
3371
3380
  if (root.value.equal(options?.parent)) {
3372
3381
  index = options.index;
3373
3382
  }
3374
3383
  root.value.moveChild(element, index);
3384
+ element.style.left = aabb1.x;
3385
+ element.style.top = aabb1.y;
3386
+ element.updateGlobalTransform();
3375
3387
  exec("layerScrollIntoView");
3376
3388
  }
3377
3389
  }
@@ -4070,6 +4082,129 @@ const mixins = [
4070
4082
  function definePlugin(cb) {
4071
4083
  return cb;
4072
4084
  }
4085
+ const _arrange = definePlugin((editor) => {
4086
+ const {
4087
+ isElement,
4088
+ rootAabb,
4089
+ elementSelection,
4090
+ selection,
4091
+ getAabb
4092
+ } = editor;
4093
+ function align(direction) {
4094
+ elementSelection.value.forEach((el) => {
4095
+ if (el.parent && isElement(el.parent)) {
4096
+ const parentAabb = getAabb(el.parent);
4097
+ switch (direction) {
4098
+ case "left":
4099
+ el.style.left = 0;
4100
+ break;
4101
+ case "horizontal-center":
4102
+ el.style.left = (parentAabb.width - el.style.width) / 2;
4103
+ break;
4104
+ case "right":
4105
+ el.style.left = parentAabb.width - el.style.width;
4106
+ break;
4107
+ case "top":
4108
+ el.style.top = 0;
4109
+ break;
4110
+ case "vertical-center":
4111
+ el.style.top = (parentAabb.height - el.style.height) / 2;
4112
+ break;
4113
+ case "bottom":
4114
+ el.style.top = parentAabb.height - el.style.height;
4115
+ break;
4116
+ }
4117
+ } else {
4118
+ switch (direction) {
4119
+ case "left":
4120
+ el.style.left = rootAabb.value.left;
4121
+ break;
4122
+ case "horizontal-center":
4123
+ el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
4124
+ break;
4125
+ case "right":
4126
+ el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
4127
+ break;
4128
+ case "top":
4129
+ el.style.top = rootAabb.value.top;
4130
+ break;
4131
+ case "vertical-center":
4132
+ el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
4133
+ break;
4134
+ case "bottom":
4135
+ el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
4136
+ break;
4137
+ }
4138
+ }
4139
+ });
4140
+ }
4141
+ function zOrder2(target, type) {
4142
+ const els = Array.isArray(target) ? target : [target];
4143
+ els.forEach((el) => {
4144
+ const parent = el.getParent();
4145
+ if (!parent)
4146
+ return;
4147
+ let index = el.getIndex();
4148
+ const front = parent.children.length - 1;
4149
+ const back = 0;
4150
+ switch (type) {
4151
+ case "bringForward":
4152
+ index = Math.min(parent.children.length - 1, index + 1);
4153
+ break;
4154
+ case "bringToFront":
4155
+ index = front;
4156
+ break;
4157
+ case "sendBackward":
4158
+ index = Math.max(back, index - 1);
4159
+ break;
4160
+ case "sendToBack":
4161
+ index = back;
4162
+ break;
4163
+ }
4164
+ parent.moveChild(el, index);
4165
+ });
4166
+ }
4167
+ function bringToFront(target = selection.value) {
4168
+ target && zOrder2(target, "bringToFront");
4169
+ }
4170
+ function bringForward(target = selection.value[0]) {
4171
+ target && zOrder2(target, "bringForward");
4172
+ }
4173
+ function sendBackward(target = selection.value[0]) {
4174
+ target && zOrder2(target, "sendBackward");
4175
+ }
4176
+ function sendToBack(target = selection.value) {
4177
+ target && zOrder2(target, "sendToBack");
4178
+ }
4179
+ return {
4180
+ name: "mce:arrange",
4181
+ commands: [
4182
+ { command: "bringForward", handle: bringForward },
4183
+ { command: "sendBackward", handle: sendBackward },
4184
+ { command: "bringToFront", handle: bringToFront },
4185
+ { command: "sendToBack", handle: sendToBack },
4186
+ { command: "align", handle: align },
4187
+ { command: "alignLeft", handle: () => align("left") },
4188
+ { command: "alignRight", handle: () => align("right") },
4189
+ { command: "alignTop", handle: () => align("top") },
4190
+ { command: "alignBottom", handle: () => align("bottom") },
4191
+ { command: "alignHorizontalCenter", handle: () => align("horizontal-center") },
4192
+ { command: "alignVerticalCenter", handle: () => align("vertical-center") }
4193
+ ],
4194
+ hotkeys: [
4195
+ { command: "bringForward", key: "CmdOrCtrl+]" },
4196
+ { command: "sendBackward", key: "CmdOrCtrl+[" },
4197
+ { command: "bringToFront", key: "]" },
4198
+ { command: "sendToBack", key: "[" },
4199
+ { command: "alignLeft", key: "Alt+a" },
4200
+ { command: "alignRight", key: "Alt+d" },
4201
+ { command: "alignTop", key: "Alt+w" },
4202
+ { command: "alignBottom", key: "Alt+s" },
4203
+ { command: "alignHorizontalCenter", key: "Alt+h" },
4204
+ { command: "alignVerticalCenter", key: "Alt+v" }
4205
+ ]
4206
+ };
4207
+ });
4073
4208
  const _cancel = definePlugin((editor) => {
4074
4209
  const {
4075
4210
  state
@@ -4087,7 +4222,97 @@ const _cancel = definePlugin((editor) => {
4087
4222
  ]
4088
4223
  };
4089
4224
  });
4090
- const _clipboard = definePlugin((editor, options) => {
4225
+ const _copyAs = definePlugin((editor) => {
4226
+ const {
4227
+ to,
4228
+ exec,
4229
+ exporters
4230
+ } = editor;
4231
+ const copyAs = async (key, options = {}) => {
4232
+ let res = await to(key, {
4233
+ selected: true,
4234
+ ...options
4235
+ });
4236
+ const exporter = exporters.get(key);
4237
+ if (exporter && typeof exporter.copyAs === "function") {
4238
+ res = exporter.copyAs(res);
4239
+ }
4240
+ exec("copy", res);
4241
+ };
4242
+ return {
4243
+ name: "mce:copyAs",
4244
+ commands: [
4245
+ { command: "copyAs", handle: copyAs }
4246
+ ]
4247
+ };
4248
+ });
4249
+ const _delete = definePlugin((editor) => {
4250
+ const {
4251
+ selection,
4252
+ hoverElement
4253
+ } = editor;
4254
+ function _delete2() {
4255
+ if (selection.value.length) {
4256
+ selection.value.forEach((node) => {
4257
+ node.remove();
4258
+ });
4259
+ selection.value = [];
4260
+ }
4261
+ hoverElement.value = void 0;
4262
+ }
4263
+ const when = () => Boolean(selection.value.length > 0);
4264
+ return {
4265
+ name: "mce:delete",
4266
+ commands: [
4267
+ { command: "delete", handle: _delete2 }
4268
+ ],
4269
+ hotkeys: [
4270
+ { command: "delete", key: ["Backspace", "Delete"], when }
4271
+ ]
4272
+ };
4273
+ });
4274
+ const _hoisted_1$n = {
4275
+ key: 0,
4276
+ class: "mce-drawing__tip"
4277
+ };
4278
+ const _sfc_main$D = /* @__PURE__ */ defineComponent({
4279
+ __name: "Drawing",
4280
+ setup(__props) {
4281
+ const {
4282
+ drawboardPointer,
4283
+ state,
4284
+ activeDrawingTool,
4285
+ t
4286
+ } = useEditor();
4287
+ return (_ctx, _cache) => {
4288
+ return unref(state) === "drawing" && unref(drawboardPointer) ? (openBlock(), createElementBlock("div", {
4289
+ key: 0,
4290
+ class: "mce-drawing",
4291
+ style: normalizeStyle$1({
4292
+ left: `${unref(drawboardPointer).x}px`,
4293
+ top: `${unref(drawboardPointer).y}px`
4294
+ })
4295
+ }, [
4296
+ unref(activeDrawingTool)?.name ? (openBlock(), createElementBlock("div", _hoisted_1$n, toDisplayString(unref(t)(unref(activeDrawingTool).name)), 1)) : createCommentVNode("", true)
4297
+ ], 4)) : createCommentVNode("", true);
4298
+ };
4299
+ }
4300
+ });
4301
+ const _drawingTool = definePlugin((editor) => {
4302
+ const {
4303
+ setActiveDrawingTool
4304
+ } = editor;
4305
+ return {
4306
+ name: "mce:drawingTool",
4307
+ components: [
4308
+ { name: "drawing", type: "overlay", component: _sfc_main$D }
4309
+ ],
4310
+ commands: [
4311
+ { command: "setActiveDrawingTool", handle: (val) => setActiveDrawingTool(val) }
4312
+ ]
4313
+ };
4314
+ });
4315
+ const _edit = definePlugin((editor, options) => {
4091
4316
  const {
4092
4317
  selection,
4093
4318
  exec,
@@ -4306,7 +4531,7 @@ const _clipboard = definePlugin((editor, options) => {
4306
4531
  copiedData
4307
4532
  });
4308
4533
  return {
4309
- name: "mce:clipboard",
4534
+ name: "mce:edit",
4310
4535
  commands: [
4311
4536
  { command: "copy", handle: copy },
4312
4537
  { command: "cut", handle: cut },
@@ -4335,96 +4560,6 @@ const _clipboard = definePlugin((editor, options) => {
4335
4560
  }
4336
4561
  };
4337
4562
  });
4338
- const _copyAs = definePlugin((editor) => {
4339
- const {
4340
- to,
4341
- exec,
4342
- exporters
4343
- } = editor;
4344
- const copyAs = async (key, options = {}) => {
4345
- let res = await to(key, {
4346
- selected: true,
4347
- ...options
4348
- });
4349
- const exporter = exporters.get(key);
4350
- if (exporter && typeof exporter.copyAs === "function") {
4351
- res = exporter.copyAs(res);
4352
- }
4353
- exec("copy", res);
4354
- };
4355
- return {
4356
- name: "mce:copyAs",
4357
- commands: [
4358
- { command: "copyAs", handle: copyAs }
4359
- ]
4360
- };
4361
- });
4362
- const _delete = definePlugin((editor) => {
4363
- const {
4364
- selection,
4365
- hoverElement
4366
- } = editor;
4367
- function _delete2() {
4368
- if (selection.value.length) {
4369
- selection.value.forEach((node) => {
4370
- node.remove();
4371
- });
4372
- selection.value = [];
4373
- }
4374
- hoverElement.value = void 0;
4375
- }
4376
- const when = () => Boolean(selection.value.length > 0);
4377
- return {
4378
- name: "mce:delete",
4379
- commands: [
4380
- { command: "delete", handle: _delete2 }
4381
- ],
4382
- hotkeys: [
4383
- { command: "delete", key: ["Backspace", "Delete"], when }
4384
- ]
4385
- };
4386
- });
4387
- const _hoisted_1$n = {
4388
- key: 0,
4389
- class: "mce-drawing__tip"
4390
- };
4391
- const _sfc_main$D = /* @__PURE__ */ defineComponent({
4392
- __name: "Drawing",
4393
- setup(__props) {
4394
- const {
4395
- drawboardPointer,
4396
- state,
4397
- activeDrawingTool,
4398
- t
4399
- } = useEditor();
4400
- return (_ctx, _cache) => {
4401
- return unref(state) === "drawing" && unref(drawboardPointer) ? (openBlock(), createElementBlock("div", {
4402
- key: 0,
4403
- class: "mce-drawing",
4404
- style: normalizeStyle$1({
4405
- left: `${unref(drawboardPointer).x}px`,
4406
- top: `${unref(drawboardPointer).y}px`
4407
- })
4408
- }, [
4409
- unref(activeDrawingTool)?.name ? (openBlock(), createElementBlock("div", _hoisted_1$n, toDisplayString(unref(t)(unref(activeDrawingTool).name)), 1)) : createCommentVNode("", true)
4410
- ], 4)) : createCommentVNode("", true);
4411
- };
4412
- }
4413
- });
4414
- const _drawingTool = definePlugin((editor) => {
4415
- const {
4416
- setActiveDrawingTool
4417
- } = editor;
4418
- return {
4419
- name: "mce:drawingTool",
4420
- components: [
4421
- { name: "drawing", type: "overlay", component: _sfc_main$D }
4422
- ],
4423
- commands: [
4424
- { command: "setActiveDrawingTool", handle: (val) => setActiveDrawingTool(val) }
4425
- ]
4426
- };
4427
- });
4428
4563
  const _enter = definePlugin((editor) => {
4429
4564
  const {
4430
4565
  selection,
@@ -4452,32 +4587,6 @@ const _enter = definePlugin((editor) => {
4452
4587
  ]
4453
4588
  };
4454
4589
  });
4455
- const _flip = definePlugin((editor) => {
4456
- const {
4457
- elementSelection
4458
- } = editor;
4459
- function flipHorizontal() {
4460
- elementSelection.value.forEach((el) => {
4461
- el.style.scaleX = -el.style.scaleX;
4462
- });
4463
- }
4464
- function flipVertical() {
4465
- elementSelection.value.forEach((el) => {
4466
- el.style.scaleY = -el.style.scaleY;
4467
- });
4468
- }
4469
- return {
4470
- name: "mce:flip",
4471
- commands: [
4472
- { command: "flipHorizontal", handle: flipHorizontal },
4473
- { command: "flipVertical", handle: flipVertical }
4474
- ],
4475
- hotkeys: [
4476
- { command: "flipHorizontal", key: "Shift+h" },
4477
- { command: "flipVertical", key: "Shift+v" }
4478
- ]
4479
- };
4480
- });
4481
4590
  function makeIconProps() {
4482
4591
  return {
4483
4592
  icon: {
@@ -5751,140 +5860,6 @@ const _json = definePlugin((editor) => {
5751
5860
  ]
5752
5861
  };
5753
5862
  });
5754
- const _layerOrder = definePlugin((editor) => {
5755
- const {
5756
- selection
5757
- } = editor;
5758
- function zOrder2(target, type) {
5759
- const els = Array.isArray(target) ? target : [target];
5760
- els.forEach((el) => {
5761
- const parent = el.getParent();
5762
- if (!parent)
5763
- return;
5764
- let index = el.getIndex();
5765
- const front = parent.children.length - 1;
5766
- const back = 0;
5767
- switch (type) {
5768
- case "bringForward":
5769
- index = Math.min(parent.children.length - 1, index + 1);
5770
- break;
5771
- case "bringToFront":
5772
- index = front;
5773
- break;
5774
- case "sendBackward":
5775
- index = Math.max(back, index - 1);
5776
- break;
5777
- case "sendToBack":
5778
- index = back;
5779
- break;
5780
- }
5781
- parent.moveChild(el, index);
5782
- });
5783
- }
5784
- function bringToFront(target = selection.value) {
5785
- target && zOrder2(target, "bringToFront");
5786
- }
5787
- function bringForward(target = selection.value[0]) {
5788
- target && zOrder2(target, "bringForward");
5789
- }
5790
- function sendBackward(target = selection.value[0]) {
5791
- target && zOrder2(target, "sendBackward");
5792
- }
5793
- function sendToBack(target = selection.value) {
5794
- target && zOrder2(target, "sendToBack");
5795
- }
5796
- return {
5797
- name: "mce:layerOrder",
5798
- commands: [
5799
- { command: "bringToFront", handle: bringToFront },
5800
- { command: "bringForward", handle: bringForward },
5801
- { command: "sendBackward", handle: sendBackward },
5802
- { command: "sendToBack", handle: sendToBack }
5803
- ],
5804
- hotkeys: [
5805
- { command: "bringToFront", key: "]" },
5806
- { command: "bringForward", key: "CmdOrCtrl+]" },
5807
- { command: "sendBackward", key: "CmdOrCtrl+[" },
5808
- { command: "sendToBack", key: "[" }
5809
- ]
5810
- };
5811
- });
5812
- const _layerPosition = definePlugin((editor) => {
5813
- const {
5814
- isElement,
5815
- rootAabb,
5816
- elementSelection,
5817
- getAabb
5818
- } = editor;
5819
- function align(direction) {
5820
- elementSelection.value.forEach((el) => {
5821
- if (el.parent && isElement(el.parent)) {
5822
- const parentAabb = getAabb(el.parent);
5823
- switch (direction) {
5824
- case "left":
5825
- el.style.left = 0;
5826
- break;
5827
- case "horizontal-center":
5828
- el.style.left = (parentAabb.width - el.style.width) / 2;
5829
- break;
5830
- case "right":
5831
- el.style.left = parentAabb.width - el.style.width;
5832
- break;
5833
- case "top":
5834
- el.style.top = 0;
5835
- break;
5836
- case "vertical-center":
5837
- el.style.top = (parentAabb.height - el.style.height) / 2;
5838
- break;
5839
- case "bottom":
5840
- el.style.top = parentAabb.height - el.style.height;
5841
- break;
5842
- }
5843
- } else {
5844
- switch (direction) {
5845
- case "left":
5846
- el.style.left = rootAabb.value.left;
5847
- break;
5848
- case "horizontal-center":
5849
- el.style.left = (rootAabb.value.left + rootAabb.value.width - el.style.width) / 2;
5850
- break;
5851
- case "right":
5852
- el.style.left = rootAabb.value.left + rootAabb.value.width - el.style.width;
5853
- break;
5854
- case "top":
5855
- el.style.top = rootAabb.value.top;
5856
- break;
5857
- case "vertical-center":
5858
- el.style.top = (rootAabb.value.top + rootAabb.value.height - el.style.height) / 2;
5859
- break;
5860
- case "bottom":
5861
- el.style.top = rootAabb.value.top + rootAabb.value.height - el.style.height;
5862
- break;
5863
- }
5864
- }
5865
- });
5866
- }
5867
- return {
5868
- name: "mce:layerPosition",
5869
- commands: [
5870
- { command: "align", handle: align },
5871
- { command: "alignLeft", handle: () => align("left") },
5872
- { command: "alignHorizontalCenter", handle: () => align("horizontal-center") },
5873
- { command: "alignRight", handle: () => align("right") },
5874
- { command: "alignTop", handle: () => align("top") },
5875
- { command: "alignVerticalCenter", handle: () => align("vertical-center") },
5876
- { command: "alignBottom", handle: () => align("bottom") }
5877
- ],
5878
- hotkeys: [
5879
- { command: "alignLeft", key: "Alt+a" },
5880
- { command: "alignHorizontalCenter", key: "Alt+h" },
5881
- { command: "alignRight", key: "Alt+d" },
5882
- { command: "alignTop", key: "Alt+w" },
5883
- { command: "alignVerticalCenter", key: "Alt+v" },
5884
- { command: "alignBottom", key: "Alt+s" }
5885
- ]
5886
- };
5887
- });
5888
5863
  const _sfc_main$y = /* @__PURE__ */ defineComponent({
5889
5864
  __name: "Btn",
5890
5865
  props: {
@@ -6827,6 +6802,7 @@ const _menu = definePlugin((editor, options) => {
6827
6802
  children: [
6828
6803
  { key: "selectAll" },
6829
6804
  { key: "deselectAll", disabled: !hasSelected.value },
6805
+ { key: "selectChildren", disabled: !hasSelected.value },
6830
6806
  { key: "selectParent", disabled: !hasSelected.value },
6831
6807
  { key: "selectPreviousSibling", disabled: !hasSelected.value },
6832
6808
  { key: "selectNextSibling", disabled: !hasSelected.value }
@@ -12001,7 +11977,7 @@ const _selection = definePlugin((editor) => {
12001
11977
  isElement,
12002
11978
  selection,
12003
11979
  root,
12004
- scrollTo,
11980
+ zoomTo,
12005
11981
  findSibling
12006
11982
  } = editor;
12007
11983
  function selectAll() {
@@ -12010,6 +11986,12 @@ const _selection = definePlugin((editor) => {
12010
11986
  function deselectAll() {
12011
11987
  selection.value = [];
12012
11988
  }
11989
+ function selectChildren() {
11990
+ const children = selection.value[0]?.children;
11991
+ if (children?.length) {
11992
+ selection.value = [...children];
11993
+ }
11994
+ }
12013
11995
  function selectParent() {
12014
11996
  const parent = selection.value[0]?.parent;
12015
11997
  if (isElement(parent)) {
@@ -12020,8 +12002,9 @@ const _selection = definePlugin((editor) => {
12020
12002
  const value = findSibling(type);
12021
12003
  if (value) {
12022
12004
  selection.value = [value];
12023
- scrollTo("selection", {
12024
- intoView: true
12005
+ zoomTo("selection", {
12006
+ intoView: true,
12007
+ behavior: "smooth"
12025
12008
  });
12026
12009
  }
12027
12010
  }
@@ -12030,6 +12013,7 @@ const _selection = definePlugin((editor) => {
12030
12013
  commands: [
12031
12014
  { command: "selectAll", handle: selectAll },
12032
12015
  { command: "deselectAll", handle: deselectAll },
12016
+ { command: "selectChildren", handle: selectChildren },
12033
12017
  { command: "selectParent", handle: selectParent },
12034
12018
  { command: "selectPreviousSibling", handle: () => selectSibling("previous") },
12035
12019
  { command: "selectNextSibling", handle: () => selectSibling("next") }
@@ -12037,7 +12021,8 @@ const _selection = definePlugin((editor) => {
12037
12021
  hotkeys: [
12038
12022
  { command: "selectAll", key: "CmdOrCtrl+a" },
12039
12023
  { command: "deselectAll", key: "Shift+CmdOrCtrl+a" },
12040
- { command: "selectParent", key: "Alt+\\" },
12024
+ { command: "selectChildren", key: "Enter" },
12025
+ { command: "selectParent", key: "\\" },
12041
12026
  { command: "selectPreviousSibling", key: "Shift+Tab" },
12042
12027
  { command: "selectNextSibling", key: "Tab" }
12043
12028
  ],
@@ -13709,7 +13694,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
13709
13694
  };
13710
13695
  }
13711
13696
  });
13712
- const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-79192677"]]);
13697
+ const Statusbar = /* @__PURE__ */ _export_sfc(_sfc_main$i, [["__scopeId", "data-v-a1f0e31b"]]);
13713
13698
  const _statusbar = definePlugin((editor) => {
13714
13699
  const {
13715
13700
  registerConfig
@@ -14318,6 +14303,32 @@ const _toolbelt = definePlugin((editor) => {
14318
14303
  ]
14319
14304
  };
14320
14305
  });
14306
+ const _transform = definePlugin((editor) => {
14307
+ const {
14308
+ elementSelection
14309
+ } = editor;
14310
+ function flipHorizontal() {
14311
+ elementSelection.value.forEach((el) => {
14312
+ el.style.scaleX = -el.style.scaleX;
14313
+ });
14314
+ }
14315
+ function flipVertical() {
14316
+ elementSelection.value.forEach((el) => {
14317
+ el.style.scaleY = -el.style.scaleY;
14318
+ });
14319
+ }
14320
+ return {
14321
+ name: "mce:transform",
14322
+ commands: [
14323
+ { command: "flipHorizontal", handle: flipHorizontal },
14324
+ { command: "flipVertical", handle: flipVertical }
14325
+ ],
14326
+ hotkeys: [
14327
+ { command: "flipHorizontal", key: "Shift+h" },
14328
+ { command: "flipVertical", key: "Shift+v" }
14329
+ ]
14330
+ };
14331
+ });
14321
14332
  const _ui = definePlugin((editor) => {
14322
14333
  const {
14323
14334
  selectionAabbInDrawboard,
@@ -14472,13 +14483,13 @@ const _zoom = definePlugin((editor) => {
14472
14483
  };
14473
14484
  });
14474
14485
  const plugins = [
14486
+ _arrange,
14475
14487
  _cancel,
14476
- _clipboard,
14477
14488
  _copyAs,
14478
14489
  _delete,
14479
14490
  _drawingTool,
14491
+ _edit,
14480
14492
  _enter,
14481
- _flip,
14482
14493
  _frame,
14483
14494
  _gif,
14484
14495
  _group,
@@ -14488,8 +14499,6 @@ const plugins = [
14488
14499
  _image,
14489
14500
  _import,
14490
14501
  _json,
14491
- _layerOrder,
14492
- _layerPosition,
14493
14502
  _layers,
14494
14503
  _lock,
14495
14504
  _madeWith,
@@ -14512,6 +14521,7 @@ const plugins = [
14512
14521
  _text,
14513
14522
  _timeline,
14514
14523
  _toolbelt,
14524
+ _transform,
14515
14525
  _ui,
14516
14526
  _url,
14517
14527
  _view,
@@ -15576,7 +15586,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
15576
15586
  };
15577
15587
  });
15578
15588
  });
15579
- const _transform = computed(() => {
15589
+ const _transform2 = computed(() => {
15580
15590
  const zoom = camera.value.zoom;
15581
15591
  const { left, top, width, height, rotationDegrees } = selectionObbInDrawboard.value;
15582
15592
  return {
@@ -15618,11 +15628,11 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
15618
15628
  return currentPos;
15619
15629
  }
15620
15630
  const transform = computed({
15621
- get: () => _transform.value,
15631
+ get: () => _transform2.value,
15622
15632
  set: (val) => {
15623
15633
  const handle = transformable.value?.activeHandle ?? "move";
15624
15634
  const zoom = camera.value.zoom;
15625
- const oldTransform = _transform.value;
15635
+ const oldTransform = _transform2.value;
15626
15636
  const transform2 = {
15627
15637
  left: val.left / zoom.x,
15628
15638
  top: val.top / zoom.y,
@@ -57,6 +57,7 @@ declare const _default: {
57
57
  delete: string;
58
58
  selectAll: string;
59
59
  deselectAll: string;
60
+ selectChildren: string;
60
61
  selectParent: string;
61
62
  selectPreviousSibling: string;
62
63
  selectNextSibling: string;
@@ -58,6 +58,7 @@ declare const _default: {
58
58
  delete: string;
59
59
  selectAll: string;
60
60
  deselectAll: string;
61
+ selectChildren: string;
61
62
  selectParent: string;
62
63
  selectPreviousSibling: string;
63
64
  selectNextSibling: string;
@@ -1,14 +1,19 @@
1
+ import type { Node } from 'modern-canvas';
1
2
  declare global {
2
3
  namespace Mce {
3
4
  type AlignCommandDirection = 'left' | 'horizontal-center' | 'right' | 'top' | 'vertical-center' | 'bottom';
4
5
  interface Commands {
6
+ bringForward: (target?: Node) => void;
7
+ sendBackward: (target?: Node) => void;
8
+ bringToFront: (target?: Node | Node[]) => void;
9
+ sendToBack: (target?: Node | Node[]) => void;
5
10
  align: (direction: AlignCommandDirection) => void;
6
11
  alignLeft: () => void;
7
- alignHorizontalCenter: () => void;
8
12
  alignRight: () => void;
9
13
  alignTop: () => void;
10
- alignVerticalCenter: () => void;
11
14
  alignBottom: () => void;
15
+ alignHorizontalCenter: () => void;
16
+ alignVerticalCenter: () => void;
12
17
  }
13
18
  }
14
19
  }
@@ -3,6 +3,7 @@ declare global {
3
3
  interface Hotkeys {
4
4
  selectAll: [event: KeyboardEvent];
5
5
  deselectAll: [event: KeyboardEvent];
6
+ selectChildren: [event: KeyboardEvent];
6
7
  selectParent: [event: KeyboardEvent];
7
8
  selectPreviousSibling: [event: KeyboardEvent];
8
9
  selectNextSibling: [event: KeyboardEvent];
@@ -10,6 +11,7 @@ declare global {
10
11
  interface Commands {
11
12
  selectAll: () => void;
12
13
  deselectAll: () => void;
14
+ selectChildren: () => void;
13
15
  selectParent: () => void;
14
16
  selectPreviousSibling: () => void;
15
17
  selectNextSibling: () => void;
@@ -26,13 +26,13 @@ import './mixins/drawingTool'
26
26
  import './mixins/scroll'
27
27
  import './mixins/snapshot'
28
28
  import './mixins/zoom'
29
+ import './plugins/arrange'
29
30
  import './plugins/cancel'
30
- import './plugins/clipboard'
31
31
  import './plugins/copyAs'
32
32
  import './plugins/delete'
33
33
  import './plugins/drawingTool'
34
+ import './plugins/edit'
34
35
  import './plugins/enter'
35
- import './plugins/flip'
36
36
  import './plugins/frame'
37
37
  import './plugins/gif'
38
38
  import './plugins/group'
@@ -42,8 +42,6 @@ import './plugins/html'
42
42
  import './plugins/image'
43
43
  import './plugins/import'
44
44
  import './plugins/json'
45
- import './plugins/layerOrder'
46
- import './plugins/layerPosition'
47
45
  import './plugins/layers'
48
46
  import './plugins/lock'
49
47
  import './plugins/madeWith'
@@ -66,6 +64,7 @@ import './plugins/statusbar'
66
64
  import './plugins/text'
67
65
  import './plugins/timeline'
68
66
  import './plugins/toolbelt'
67
+ import './plugins/transform'
69
68
  import './plugins/ui'
70
69
  import './plugins/url'
71
70
  import './plugins/view'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.15.21",
4
+ "version": "0.15.22",
5
5
  "description": "The headless canvas editor framework. only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",
@@ -1,19 +0,0 @@
1
- import type { Node } from 'modern-canvas';
2
- declare global {
3
- namespace Mce {
4
- interface Hotkeys {
5
- bringToFront: [event: KeyboardEvent];
6
- bringForward: [event: KeyboardEvent];
7
- sendBackward: [event: KeyboardEvent];
8
- sendToBack: [event: KeyboardEvent];
9
- }
10
- interface Commands {
11
- bringToFront: (target?: Node | Node[]) => void;
12
- bringForward: (target?: Node) => void;
13
- sendBackward: (target?: Node) => void;
14
- sendToBack: (target?: Node | Node[]) => void;
15
- }
16
- }
17
- }
18
- declare const _default: import("..").Plugin;
19
- export default _default;
File without changes
File without changes