@lark-apaas/miaoda-inspector 1.0.4 → 1.0.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.
@@ -200,12 +200,14 @@ function MiaodaInspector(props) {
200
200
  if (element instanceof HTMLImageElement) {
201
201
  originalState.attributes.src = (_b = (_a = element.getAttribute("src")) != null ? _a : element.currentSrc) != null ? _b : null;
202
202
  }
203
- selectedElementMap.set(id, {
203
+ selectedElementMap.set(id, __spreadProps(__spreadValues({
204
+ // 避免再次选中时,originalState 被覆盖
205
+ originalState
206
+ }, selectedElementMap.get(id)), {
204
207
  elementId: id,
205
208
  element,
206
- title,
207
- originalState
208
- });
209
+ title
210
+ }));
209
211
  const importSourceAttr = element.getAttribute("data-miaoda-import-source");
210
212
  const isAntdComponent = importSourceAttr === "antd" && window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__ && window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setProps;
211
213
  const isNativeTagImage = (imageInfo == null ? void 0 : imageInfo.type) === "img" && !isAntdComponent;
@@ -221,7 +223,7 @@ function MiaodaInspector(props) {
221
223
  }
222
224
  } : void 0;
223
225
  const importSource = importSourceAttr != null ? importSourceAttr : isNativeTagImage ? "nativeTag" : void 0;
224
- if (textInfo.hasOnlyTextNodes && canUseNewInspector.current) {
226
+ if (!selectedElementMap.has(id) && textInfo.hasOnlyTextNodes && canUseNewInspector.current) {
225
227
  element.setAttribute("contenteditable", "true");
226
228
  element.focus();
227
229
  const TextUpdate = () => {
@@ -365,7 +367,6 @@ function MiaodaInspector(props) {
365
367
  const { elementId } = data.data;
366
368
  const selectedElement = selectedElementMap.get(elementId);
367
369
  if (selectedElement && selectedElement.element) {
368
- selectedElementMap.delete(elementId);
369
370
  (_e = selectedElement.dispose) == null ? void 0 : _e.call(selectedElement);
370
371
  }
371
372
  } else if (isIncomingMessage(data, "EditText")) {
@@ -621,7 +622,7 @@ function MiaodaInspector(props) {
621
622
  postMessage({
622
623
  type: "PageMounted",
623
624
  data: {
624
- version: "1.0.4",
625
+ version: "1.0.6",
625
626
  feature: {
626
627
  selectParent: true,
627
628
  reverseSelect: true
@@ -1,13 +1,16 @@
1
1
  import "../chunk-I4E63NIC.mjs";
2
2
  function getPreviewParentOrigin() {
3
3
  const { origin } = window.location;
4
+ if (origin.includes("force.byted.org")) {
5
+ return "https://force.feishu-boe.cn";
6
+ }
4
7
  if (origin.includes("feishuapp.cn") || origin.includes("miaoda.feishuapp.net")) {
5
8
  return "https://miaoda.feishu.cn";
6
- }
7
- if (origin.includes("fsapp.kundou.cn") || origin.includes("miaoda-pre.feishuapp.net")) {
9
+ } else if (origin.includes("fsapp.kundou.cn") || origin.includes("miaoda-pre.feishuapp.net")) {
8
10
  return "https://miaoda.feishu-pre.cn";
11
+ } else {
12
+ return "https://miaoda.feishu-boe.cn";
9
13
  }
10
- return "https://miaoda.feishu-boe.cn";
11
14
  }
12
15
  function postMessage(message, targetOrigin) {
13
16
  window.parent.postMessage(message, targetOrigin != null ? targetOrigin : getPreviewParentOrigin());
@@ -218,12 +218,14 @@ function MiaodaInspector(props) {
218
218
  if (element instanceof HTMLImageElement) {
219
219
  originalState.attributes.src = (_b = (_a = element.getAttribute("src")) != null ? _a : element.currentSrc) != null ? _b : null;
220
220
  }
221
- selectedElementMap.set(id, {
221
+ selectedElementMap.set(id, __spreadProps(__spreadValues({
222
+ // 避免再次选中时,originalState 被覆盖
223
+ originalState
224
+ }, selectedElementMap.get(id)), {
222
225
  elementId: id,
223
226
  element,
224
- title,
225
- originalState
226
- });
227
+ title
228
+ }));
227
229
  const importSourceAttr = element.getAttribute("data-miaoda-import-source");
228
230
  const isAntdComponent = importSourceAttr === "antd" && window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__ && window.__MIAODA_DEVTOOLS_GLOBAL_HOOK__.setProps;
229
231
  const isNativeTagImage = (imageInfo == null ? void 0 : imageInfo.type) === "img" && !isAntdComponent;
@@ -239,7 +241,7 @@ function MiaodaInspector(props) {
239
241
  }
240
242
  } : void 0;
241
243
  const importSource = importSourceAttr != null ? importSourceAttr : isNativeTagImage ? "nativeTag" : void 0;
242
- if (textInfo.hasOnlyTextNodes && canUseNewInspector.current) {
244
+ if (!selectedElementMap.has(id) && textInfo.hasOnlyTextNodes && canUseNewInspector.current) {
243
245
  element.setAttribute("contenteditable", "true");
244
246
  element.focus();
245
247
  const TextUpdate = () => {
@@ -383,7 +385,6 @@ function MiaodaInspector(props) {
383
385
  const { elementId } = data.data;
384
386
  const selectedElement = selectedElementMap.get(elementId);
385
387
  if (selectedElement && selectedElement.element) {
386
- selectedElementMap.delete(elementId);
387
388
  (_e = selectedElement.dispose) == null ? void 0 : _e.call(selectedElement);
388
389
  }
389
390
  } else if ((0, import_utils2.isIncomingMessage)(data, "EditText")) {
@@ -639,7 +640,7 @@ function MiaodaInspector(props) {
639
640
  (0, import_utils2.postMessage)({
640
641
  type: "PageMounted",
641
642
  data: {
642
- version: "1.0.4",
643
+ version: "1.0.6",
643
644
  feature: {
644
645
  selectParent: true,
645
646
  reverseSelect: true
@@ -26,13 +26,16 @@ __export(origin_exports, {
26
26
  module.exports = __toCommonJS(origin_exports);
27
27
  function getPreviewParentOrigin() {
28
28
  const { origin } = window.location;
29
+ if (origin.includes("force.byted.org")) {
30
+ return "https://force.feishu-boe.cn";
31
+ }
29
32
  if (origin.includes("feishuapp.cn") || origin.includes("miaoda.feishuapp.net")) {
30
33
  return "https://miaoda.feishu.cn";
31
- }
32
- if (origin.includes("fsapp.kundou.cn") || origin.includes("miaoda-pre.feishuapp.net")) {
34
+ } else if (origin.includes("fsapp.kundou.cn") || origin.includes("miaoda-pre.feishuapp.net")) {
33
35
  return "https://miaoda.feishu-pre.cn";
36
+ } else {
37
+ return "https://miaoda.feishu-boe.cn";
34
38
  }
35
- return "https://miaoda.feishu-boe.cn";
36
39
  }
37
40
  function postMessage(message, targetOrigin) {
38
41
  window.parent.postMessage(message, targetOrigin != null ? targetOrigin : getPreviewParentOrigin());
@@ -1,5 +1,5 @@
1
- import { useEffect } from 'react';
1
+ import { useLayoutEffect as useLayoutEffect$1 } from 'react';
2
2
 
3
- declare const useLayoutEffect: typeof useEffect;
3
+ declare const useLayoutEffect: typeof useLayoutEffect$1;
4
4
 
5
5
  export { useLayoutEffect };
@@ -2,7 +2,7 @@ import { OutgoingMessage, IncomingMessage } from '../types/iframe-events.js';
2
2
  import '../types/feature.js';
3
3
  import '../config/ui-config.js';
4
4
 
5
- declare function getPreviewParentOrigin(): string;
5
+ declare function getPreviewParentOrigin(): "https://force.feishu-boe.cn" | "https://miaoda.feishu.cn" | "https://miaoda.feishu-pre.cn" | "https://miaoda.feishu-boe.cn";
6
6
  declare function postMessage<T extends OutgoingMessage>(message: T, targetOrigin?: string): void;
7
7
  declare function isOutgoingMessage<T extends OutgoingMessage['type']>(msg: OutgoingMessage, type: T): msg is Extract<OutgoingMessage, {
8
8
  type: T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-inspector",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Inspector for Lark Apaas",
5
5
  "sideEffects": [
6
6
  "*.css"