@tmagic/stage 1.1.4 → 1.1.6

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.
@@ -172,7 +172,9 @@ const calcValueByFontsize = (doc, value) => {
172
172
  const down = (deltaTop, target) => {
173
173
  let swapIndex = 0;
174
174
  let addUpH = target.clientHeight;
175
- const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
175
+ const brothers = Array.from(target.parentNode?.children || []).filter(
176
+ (node) => !node.id.startsWith(GHOST_EL_ID_PREFIX)
177
+ );
176
178
  const index = brothers.indexOf(target);
177
179
  const downEls = brothers.slice(index + 1);
178
180
  for (let i = 0; i < downEls.length; i++) {
@@ -193,7 +195,9 @@ const down = (deltaTop, target) => {
193
195
  };
194
196
  };
195
197
  const up = (deltaTop, target) => {
196
- const brothers = Array.from(target.parentNode?.children || []).filter((node) => !node.id.startsWith(GHOST_EL_ID_PREFIX));
198
+ const brothers = Array.from(target.parentNode?.children || []).filter(
199
+ (node) => !node.id.startsWith(GHOST_EL_ID_PREFIX)
200
+ );
197
201
  const index = brothers.indexOf(target);
198
202
  const upEls = brothers.slice(0, index);
199
203
  let addUpH = target.clientHeight;
@@ -981,19 +985,22 @@ class StageMask extends Rule {
981
985
  this.wrapperResizeObserver?.disconnect();
982
986
  this.intersectionObserver?.disconnect();
983
987
  if (typeof IntersectionObserver !== "undefined") {
984
- this.intersectionObserver = new IntersectionObserver((entries) => {
985
- entries.forEach((entry) => {
986
- const { target, intersectionRatio } = entry;
987
- if (intersectionRatio <= 0) {
988
- this.scrollIntoView(target);
989
- }
990
- this.intersectionObserver?.unobserve(target);
991
- });
992
- }, {
993
- root: this.pageScrollParent,
994
- rootMargin: "0px",
995
- threshold: 1
996
- });
988
+ this.intersectionObserver = new IntersectionObserver(
989
+ (entries) => {
990
+ entries.forEach((entry) => {
991
+ const { target, intersectionRatio } = entry;
992
+ if (intersectionRatio <= 0) {
993
+ this.scrollIntoView(target);
994
+ }
995
+ this.intersectionObserver?.unobserve(target);
996
+ });
997
+ },
998
+ {
999
+ root: this.pageScrollParent,
1000
+ rootMargin: "0px",
1001
+ threshold: 1
1002
+ }
1003
+ );
997
1004
  }
998
1005
  if (typeof ResizeObserver !== "undefined") {
999
1006
  this.pageResizeObserver = new ResizeObserver((entries) => {
@@ -1169,9 +1176,12 @@ class StageMultiDragResize extends EventEmitter {
1169
1176
  });
1170
1177
  this.moveableForMulti?.destroy();
1171
1178
  this.multiMoveableHelper?.clear();
1172
- this.moveableForMulti = new Moveable(this.container, this.getOptions({
1173
- target: this.dragElList
1174
- }));
1179
+ this.moveableForMulti = new Moveable(
1180
+ this.container,
1181
+ this.getOptions({
1182
+ target: this.dragElList
1183
+ })
1184
+ );
1175
1185
  this.multiMoveableHelper = MoveableHelper.create({
1176
1186
  useBeforeRender: true,
1177
1187
  useRender: false,
@@ -1180,7 +1190,9 @@ class StageMultiDragResize extends EventEmitter {
1180
1190
  const frames = [];
1181
1191
  const setFrames = (events) => {
1182
1192
  events.forEach((ev) => {
1183
- const matchEventTarget = this.targetList.find((targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, ""));
1193
+ const matchEventTarget = this.targetList.find(
1194
+ (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1195
+ );
1184
1196
  if (!matchEventTarget)
1185
1197
  return;
1186
1198
  frames.push({
@@ -1199,10 +1211,14 @@ class StageMultiDragResize extends EventEmitter {
1199
1211
  const { events } = params;
1200
1212
  events.forEach((ev) => {
1201
1213
  const { width, height, beforeTranslate } = ev.drag;
1202
- const frameSnapShot = frames.find((frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, ""));
1214
+ const frameSnapShot = frames.find(
1215
+ (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1216
+ );
1203
1217
  if (!frameSnapShot)
1204
1218
  return;
1205
- const targeEl = this.targetList.find((targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, ""));
1219
+ const targeEl = this.targetList.find(
1220
+ (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1221
+ );
1206
1222
  if (!targeEl)
1207
1223
  return;
1208
1224
  const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
@@ -1226,10 +1242,14 @@ class StageMultiDragResize extends EventEmitter {
1226
1242
  }).on("dragGroup", (params) => {
1227
1243
  const { events } = params;
1228
1244
  events.forEach((ev) => {
1229
- const frameSnapShot = frames.find((frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, ""));
1245
+ const frameSnapShot = frames.find(
1246
+ (frameItem) => frameItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1247
+ );
1230
1248
  if (!frameSnapShot)
1231
1249
  return;
1232
- const targeEl = this.targetList.find((targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, ""));
1250
+ const targeEl = this.targetList.find(
1251
+ (targetItem) => targetItem.id === ev.target.id.replace(DRAG_EL_ID_PREFIX, "")
1252
+ );
1233
1253
  if (!targeEl)
1234
1254
  return;
1235
1255
  const isParentIncluded = this.targetList.find((targetItem) => targetItem.id === targeEl.parentElement?.id);
@@ -1420,9 +1440,12 @@ class StageRender extends EventEmitter {
1420
1440
  postTmagicRuntimeReady() {
1421
1441
  this.contentWindow = this.iframe?.contentWindow;
1422
1442
  this.contentWindow.magic = this.getMagicApi();
1423
- this.contentWindow.postMessage({
1424
- tmagicRuntimeReady: true
1425
- }, "*");
1443
+ this.contentWindow.postMessage(
1444
+ {
1445
+ tmagicRuntimeReady: true
1446
+ },
1447
+ "*"
1448
+ );
1426
1449
  }
1427
1450
  }
1428
1451