@nookuio/iframe 0.9.9 → 1.0.0-beta.1
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/drag-drop/dragDropManager.d.ts +101 -0
- package/dist/drag-drop/dragDropManager.js +204 -0
- package/dist/drag-drop/dragDropManager.mjs +183 -0
- package/dist/drag-drop/index.d.ts +3 -0
- package/dist/drag-drop/index.js +38 -0
- package/dist/drag-drop/index.mjs +3 -0
- package/dist/drag-drop/types.d.ts +80 -0
- package/dist/drag-drop/types.js +1 -0
- package/dist/drag-drop/types.mjs +0 -0
- package/dist/drag-drop/utils.d.ts +41 -0
- package/dist/drag-drop/utils.js +93 -0
- package/dist/drag-drop/utils.mjs +68 -0
- package/dist/editor.d.ts +1 -7
- package/dist/editor.js +2 -2
- package/dist/editor.mjs +1 -1
- package/dist/iframe.d.ts +2 -8
- package/dist/iframe.js +90 -64
- package/dist/iframe.mjs +93 -66
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -0
- package/dist/index.mjs +1 -0
- package/dist/types.d.ts +67 -3
- package/package.json +4 -3
- package/dist/createClient.d.ts +0 -51
- package/dist/createClient.js +0 -118
- package/dist/createClient.mjs +0 -114
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.calculateInsertIndex = calculateInsertIndex;
|
|
7
|
+
exports.canAcceptDrop = canAcceptDrop;
|
|
8
|
+
exports.createDropIndicator = createDropIndicator;
|
|
9
|
+
exports.getDropZones = getDropZones;
|
|
10
|
+
exports.getElement = getElement;
|
|
11
|
+
exports.getElementAtPosition = getElementAtPosition;
|
|
12
|
+
exports.getParentContainer = getParentContainer;
|
|
13
|
+
exports.positionDropIndicator = positionDropIndicator;
|
|
14
|
+
function getElement(t, e) {
|
|
15
|
+
return document.querySelector(`[data-node-id="${t}"][data-node-path="${e}"]`);
|
|
16
|
+
}
|
|
17
|
+
function getDropZones() {
|
|
18
|
+
return Array.from(document.querySelectorAll('[data-node-id]:not([data-node-id=""])'));
|
|
19
|
+
}
|
|
20
|
+
function canAcceptDrop(t) {
|
|
21
|
+
return t.getAttribute("data-node-type") !== "text";
|
|
22
|
+
}
|
|
23
|
+
function getElementAtPosition(t, e, i) {
|
|
24
|
+
let o = document.elementFromPoint(t, e);
|
|
25
|
+
if (!o) return null;
|
|
26
|
+
let r = o.getAttribute("data-node-path");
|
|
27
|
+
for (; o && r !== i;) {
|
|
28
|
+
if (o = o.parentElement, !o) return null;
|
|
29
|
+
r = o.getAttribute("data-node-path");
|
|
30
|
+
}
|
|
31
|
+
return o;
|
|
32
|
+
}
|
|
33
|
+
function calculateInsertIndex(t, e, i, o) {
|
|
34
|
+
const r = Array.from(t.children).filter(n => n.hasAttribute("data-node-id") && n !== o && !n.classList.contains("__nooku-drag-clone"));
|
|
35
|
+
if (r.length === 0) return {
|
|
36
|
+
index: 0,
|
|
37
|
+
before: !0,
|
|
38
|
+
layout: "block"
|
|
39
|
+
};
|
|
40
|
+
const s = r.every((n, d) => {
|
|
41
|
+
if (d === 0) return !0;
|
|
42
|
+
const l = r[d - 1].getBoundingClientRect(),
|
|
43
|
+
u = n.getBoundingClientRect();
|
|
44
|
+
return Math.abs(l.bottom - u.top) < 10;
|
|
45
|
+
}),
|
|
46
|
+
a = s ? "block" : "inline";
|
|
47
|
+
for (let n = 0; n < r.length; n++) {
|
|
48
|
+
const l = r[n].getBoundingClientRect();
|
|
49
|
+
if (s) {
|
|
50
|
+
const u = l.top + l.height / 2;
|
|
51
|
+
if (i < u) return {
|
|
52
|
+
index: n,
|
|
53
|
+
before: !0,
|
|
54
|
+
layout: a
|
|
55
|
+
};
|
|
56
|
+
} else {
|
|
57
|
+
const u = l.left + l.width / 2;
|
|
58
|
+
if (e < u) return {
|
|
59
|
+
index: n,
|
|
60
|
+
before: !0,
|
|
61
|
+
layout: a
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
index: r.length,
|
|
67
|
+
before: !1,
|
|
68
|
+
layout: a
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function createDropIndicator(t = "2563EB") {
|
|
72
|
+
const e = document.createElement("div");
|
|
73
|
+
return e.className = "__nooku-drop-indicator", e.style.cssText = `
|
|
74
|
+
position: fixed;
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
z-index: 9999;
|
|
77
|
+
background: #${t};
|
|
78
|
+
border-radius: 2px;
|
|
79
|
+
transition: all 0.1s ease-out;
|
|
80
|
+
box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
|
|
81
|
+
`, e;
|
|
82
|
+
}
|
|
83
|
+
function positionDropIndicator(t, e, i = "block") {
|
|
84
|
+
i === "block" ? (t.style.left = `${e.left}px`, t.style.top = `${e.top}px`, t.style.width = `${e.width}px`, t.style.height = "2px") : (t.style.left = `${e.left}px`, t.style.top = `${e.top}px`, t.style.width = "2px", t.style.height = `${e.height}px`);
|
|
85
|
+
}
|
|
86
|
+
function getParentContainer(t) {
|
|
87
|
+
let e = t.parentElement;
|
|
88
|
+
for (; e;) {
|
|
89
|
+
if (e.hasAttribute("data-node-id") && canAcceptDrop(e)) return e;
|
|
90
|
+
e = e.parentElement;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export function getElement(t, e) {
|
|
2
|
+
return document.querySelector(`[data-node-id="${t}"][data-node-path="${e}"]`);
|
|
3
|
+
}
|
|
4
|
+
export function getDropZones() {
|
|
5
|
+
return Array.from(document.querySelectorAll('[data-node-id]:not([data-node-id=""])'));
|
|
6
|
+
}
|
|
7
|
+
export function canAcceptDrop(t) {
|
|
8
|
+
return t.getAttribute("data-node-type") !== "text";
|
|
9
|
+
}
|
|
10
|
+
export function getElementAtPosition(t, e, i) {
|
|
11
|
+
let o = document.elementFromPoint(t, e);
|
|
12
|
+
if (!o) return null;
|
|
13
|
+
let r = o.getAttribute("data-node-path");
|
|
14
|
+
for (; o && r !== i; ) {
|
|
15
|
+
if (o = o.parentElement, !o) return null;
|
|
16
|
+
r = o.getAttribute("data-node-path");
|
|
17
|
+
}
|
|
18
|
+
return o;
|
|
19
|
+
}
|
|
20
|
+
export function calculateInsertIndex(t, e, i, o) {
|
|
21
|
+
const r = Array.from(t.children).filter(
|
|
22
|
+
(n) => n.hasAttribute("data-node-id") && n !== o && !n.classList.contains("__nooku-drag-clone")
|
|
23
|
+
);
|
|
24
|
+
if (r.length === 0)
|
|
25
|
+
return { index: 0, before: !0, layout: "block" };
|
|
26
|
+
const s = r.every((n, d) => {
|
|
27
|
+
if (d === 0) return !0;
|
|
28
|
+
const l = r[d - 1].getBoundingClientRect(), u = n.getBoundingClientRect();
|
|
29
|
+
return Math.abs(l.bottom - u.top) < 10;
|
|
30
|
+
}), a = s ? "block" : "inline";
|
|
31
|
+
for (let n = 0; n < r.length; n++) {
|
|
32
|
+
const l = r[n].getBoundingClientRect();
|
|
33
|
+
if (s) {
|
|
34
|
+
const u = l.top + l.height / 2;
|
|
35
|
+
if (i < u)
|
|
36
|
+
return { index: n, before: !0, layout: a };
|
|
37
|
+
} else {
|
|
38
|
+
const u = l.left + l.width / 2;
|
|
39
|
+
if (e < u)
|
|
40
|
+
return { index: n, before: !0, layout: a };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return { index: r.length, before: !1, layout: a };
|
|
44
|
+
}
|
|
45
|
+
export function createDropIndicator(t = "2563EB") {
|
|
46
|
+
const e = document.createElement("div");
|
|
47
|
+
return e.className = "__nooku-drop-indicator", e.style.cssText = `
|
|
48
|
+
position: fixed;
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
z-index: 9999;
|
|
51
|
+
background: #${t};
|
|
52
|
+
border-radius: 2px;
|
|
53
|
+
transition: all 0.1s ease-out;
|
|
54
|
+
box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
|
|
55
|
+
`, e;
|
|
56
|
+
}
|
|
57
|
+
export function positionDropIndicator(t, e, i = "block") {
|
|
58
|
+
i === "block" ? (t.style.left = `${e.left}px`, t.style.top = `${e.top}px`, t.style.width = `${e.width}px`, t.style.height = "2px") : (t.style.left = `${e.left}px`, t.style.top = `${e.top}px`, t.style.width = "2px", t.style.height = `${e.height}px`);
|
|
59
|
+
}
|
|
60
|
+
export function getParentContainer(t) {
|
|
61
|
+
let e = t.parentElement;
|
|
62
|
+
for (; e; ) {
|
|
63
|
+
if (e.hasAttribute("data-node-id") && canAcceptDrop(e))
|
|
64
|
+
return e;
|
|
65
|
+
e = e.parentElement;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
package/dist/editor.d.ts
CHANGED
|
@@ -2,10 +2,4 @@ import type { CoreIframeContext, CoreIframeEvents, EditorContext, EditorEvents }
|
|
|
2
2
|
/**
|
|
3
3
|
* This function should be called inside the editor
|
|
4
4
|
*/
|
|
5
|
-
export declare function createEditorClient<IframeContext extends CoreIframeContext, IframeEvents extends CoreIframeEvents>(iframe: string | HTMLIFrameElement):
|
|
6
|
-
$context: EditorContext;
|
|
7
|
-
on: <E extends keyof IframeEvents>(eventName: E, listener: (...args: IframeEvents[E] extends infer T ? T extends IframeEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void) => void;
|
|
8
|
-
off: <E extends keyof IframeEvents>(eventName: E, listener: (...args: IframeEvents[E] extends infer T ? T extends IframeEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void) => void;
|
|
9
|
-
emit: <E extends never>(eventName: E, ...args: EditorEvents[E] extends infer T ? T extends EditorEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void;
|
|
10
|
-
removeAllListeners: () => void;
|
|
11
|
-
};
|
|
5
|
+
export declare function createEditorClient<IframeContext extends CoreIframeContext, IframeEvents extends CoreIframeEvents>(iframe: string | HTMLIFrameElement): import("@nookuio/rpc").ClientReturn<IframeContext, EditorContext, IframeEvents, EditorEvents>;
|
package/dist/editor.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createEditorClient = createEditorClient;
|
|
7
7
|
var _constants = require("./constants");
|
|
8
|
-
var
|
|
8
|
+
var _rpc = require("@nookuio/rpc");
|
|
9
9
|
var _telejson = require("telejson");
|
|
10
10
|
function y(a) {
|
|
11
11
|
const n = (0, _telejson.parse)(a, {
|
|
@@ -33,7 +33,7 @@ function createEditorClient(a) {
|
|
|
33
33
|
function r() {
|
|
34
34
|
return (!n || !n.isConnected) && (n = typeof a == "string" ? document.querySelector(`#${a}`) : a), n;
|
|
35
35
|
}
|
|
36
|
-
return (0,
|
|
36
|
+
return (0, _rpc.createClient)({}, {
|
|
37
37
|
handle(e) {
|
|
38
38
|
window.addEventListener("message", async t => {
|
|
39
39
|
if (typeof t.data != "object" || t.data.source !== _constants.IFRAME_SOURCE_NAME || t.data.type === "event" || !t.data.request) return;
|
package/dist/editor.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EDITOR_SOURCE_NAME as f, IFRAME_SOURCE_NAME as u } from "./constants.mjs";
|
|
2
|
-
import { createClient as E } from "
|
|
2
|
+
import { createClient as E } from "@nookuio/rpc";
|
|
3
3
|
import { stringify as p, parse as l } from "telejson";
|
|
4
4
|
function y(a) {
|
|
5
5
|
const n = l(a, { maxDepth: 1 / 0 }), r = (e) => {
|
package/dist/iframe.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CoreIframeContext, EditorEvents, VueIframeContext, VueIframeEvents } from './types';
|
|
1
|
+
import type { CoreIframeContext, EditorContext, EditorEvents, VueIframeContext, VueIframeEvents } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* This function should be called inside the iframe
|
|
4
4
|
*/
|
|
@@ -9,10 +9,4 @@ export declare function createVueIframeClient(vueCtx: Omit<VueIframeContext, key
|
|
|
9
9
|
* @default false
|
|
10
10
|
*/
|
|
11
11
|
disableDefaultConsole?: boolean;
|
|
12
|
-
}):
|
|
13
|
-
$context: VueIframeContext;
|
|
14
|
-
on: <E extends never>(eventName: E, listener: (...args: EditorEvents[E] extends infer T ? T extends EditorEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void) => void;
|
|
15
|
-
off: <E extends never>(eventName: E, listener: (...args: EditorEvents[E] extends infer T ? T extends EditorEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void) => void;
|
|
16
|
-
emit: <E extends keyof VueIframeEvents>(eventName: E, ...args: VueIframeEvents[E] extends infer T ? T extends VueIframeEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void;
|
|
17
|
-
removeAllListeners: () => void;
|
|
18
|
-
};
|
|
12
|
+
}): import("@nookuio/rpc").ClientReturn<EditorContext, VueIframeContext, EditorEvents, VueIframeEvents>;
|
package/dist/iframe.js
CHANGED
|
@@ -5,93 +5,103 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createVueIframeClient = createVueIframeClient;
|
|
7
7
|
var _constants = require("./constants");
|
|
8
|
-
var
|
|
8
|
+
var _rpc = require("@nookuio/rpc");
|
|
9
9
|
var _telejson = require("telejson");
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var _dragDropManager = require("./drag-drop/dragDropManager");
|
|
11
|
+
function p(m, l) {
|
|
12
|
+
return `[data-node-id="${l}"][data-node-path="${m}"]`;
|
|
12
13
|
}
|
|
13
|
-
function h(
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
const
|
|
17
|
-
const
|
|
14
|
+
function h(m, l) {
|
|
15
|
+
const d = document.querySelectorAll(m);
|
|
16
|
+
if (!d?.length) return;
|
|
17
|
+
const r = Array.from(d).map(f => {
|
|
18
|
+
const c = f.getBoundingClientRect(),
|
|
18
19
|
g = {
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
21
|
-
top:
|
|
22
|
-
left:
|
|
20
|
+
width: c.width,
|
|
21
|
+
height: c.height,
|
|
22
|
+
top: c.top,
|
|
23
|
+
left: c.left
|
|
23
24
|
};
|
|
24
25
|
if (!l) return g;
|
|
25
|
-
const
|
|
26
|
+
const u = window.getComputedStyle(f) ?? {};
|
|
26
27
|
return {
|
|
27
28
|
...g,
|
|
28
29
|
padding: {
|
|
29
|
-
top:
|
|
30
|
-
right:
|
|
31
|
-
bottom:
|
|
32
|
-
left:
|
|
30
|
+
top: u.paddingTop,
|
|
31
|
+
right: u.paddingRight,
|
|
32
|
+
bottom: u.paddingBottom,
|
|
33
|
+
left: u.paddingLeft
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
});
|
|
36
|
-
if (
|
|
37
|
+
if (r?.length) return r.length === 1 ? r[0] : r;
|
|
37
38
|
}
|
|
38
|
-
function createVueIframeClient(
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
function createVueIframeClient(m, l) {
|
|
40
|
+
const d = new _dragDropManager.DragDropManager();
|
|
41
|
+
d.setCallbacks({
|
|
42
|
+
onDragStart: e => {
|
|
43
|
+
r.emit("drag-start", e);
|
|
44
|
+
},
|
|
45
|
+
onDragEnd: e => {
|
|
46
|
+
r.emit("drag-end", e);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const r = (0, _rpc.createClient)({
|
|
50
|
+
...m,
|
|
41
51
|
async editText({
|
|
42
52
|
path: e,
|
|
43
53
|
id: t
|
|
44
54
|
}) {
|
|
45
55
|
if (!e || t === void 0) return;
|
|
46
|
-
const
|
|
47
|
-
n = document.querySelector(
|
|
56
|
+
const a = p(e, t),
|
|
57
|
+
n = document.querySelector(a);
|
|
48
58
|
if (!n) return;
|
|
49
59
|
n.style.outline = "none", n.setAttribute("spellcheck", "false"), n.setAttribute("contenteditable", "true");
|
|
50
|
-
const o =
|
|
51
|
-
const E =
|
|
60
|
+
const o = i => {
|
|
61
|
+
const E = i.target;
|
|
52
62
|
if (!E) return;
|
|
53
63
|
const y = E.innerText;
|
|
54
|
-
n.removeAttribute("contenteditable"),
|
|
64
|
+
n.removeAttribute("contenteditable"), r.emit("text-update", {
|
|
55
65
|
path: e,
|
|
56
66
|
id: t,
|
|
57
67
|
content: y
|
|
58
|
-
}), n.removeEventListener("blur", o), n.removeEventListener("keydown",
|
|
68
|
+
}), n.removeEventListener("blur", o), n.removeEventListener("keydown", s), n.blur();
|
|
59
69
|
},
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
s = i => {
|
|
71
|
+
i.key === "Enter" && (i.stopPropagation(), i.preventDefault(), o(i));
|
|
62
72
|
};
|
|
63
|
-
n.addEventListener("keydown",
|
|
73
|
+
n.addEventListener("keydown", s), n.addEventListener("blur", o), n.focus();
|
|
64
74
|
},
|
|
65
75
|
async getHoveredElement({
|
|
66
76
|
path: e,
|
|
67
77
|
id: t,
|
|
68
|
-
x:
|
|
78
|
+
x: a,
|
|
69
79
|
y: n
|
|
70
80
|
}) {
|
|
71
|
-
if (e) if (
|
|
72
|
-
let o = document.elementFromPoint(
|
|
81
|
+
if (e) if (a !== void 0 && n !== void 0) {
|
|
82
|
+
let o = document.elementFromPoint(a, n);
|
|
73
83
|
if (!o) return;
|
|
74
|
-
let
|
|
75
|
-
if (
|
|
84
|
+
let s = o.getAttribute("data-node-path");
|
|
85
|
+
if (s !== e) {
|
|
76
86
|
if (!o.parentElement) return;
|
|
77
|
-
for (; o.parentElement &&
|
|
87
|
+
for (; o.parentElement && s !== e;) o = o.parentElement, s = o.getAttribute("data-node-path");
|
|
78
88
|
}
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
const E =
|
|
89
|
+
const i = o.getAttribute("data-node-id");
|
|
90
|
+
if (!i) return;
|
|
91
|
+
const E = p(e, i),
|
|
82
92
|
y = h(E, !1);
|
|
83
93
|
return y ? {
|
|
84
|
-
id:
|
|
94
|
+
id: i,
|
|
85
95
|
path: e,
|
|
86
96
|
data: y
|
|
87
97
|
} : void 0;
|
|
88
98
|
} else {
|
|
89
|
-
const o =
|
|
90
|
-
|
|
91
|
-
return
|
|
99
|
+
const o = p(e, t),
|
|
100
|
+
s = h(o, !1);
|
|
101
|
+
return s ? {
|
|
92
102
|
id: t,
|
|
93
103
|
path: e,
|
|
94
|
-
data:
|
|
104
|
+
data: s
|
|
95
105
|
} : void 0;
|
|
96
106
|
}
|
|
97
107
|
},
|
|
@@ -102,35 +112,51 @@ function createVueIframeClient(c, l) {
|
|
|
102
112
|
path: e,
|
|
103
113
|
id: t
|
|
104
114
|
}) {
|
|
105
|
-
const
|
|
106
|
-
n = h(
|
|
115
|
+
const a = p(e, t),
|
|
116
|
+
n = h(a, !0);
|
|
107
117
|
if (n) return {
|
|
108
118
|
path: e,
|
|
109
119
|
id: t,
|
|
110
120
|
data: n
|
|
111
121
|
};
|
|
112
122
|
},
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
setTheme(e) {
|
|
124
|
+
const t = document.querySelector("body");
|
|
125
|
+
e === "dark" ? (document.documentElement.classList.remove("light"), document.documentElement.classList.add("dark"), t && (t.classList.remove("light"), t.classList.add("dark"))) : (document.documentElement.classList.remove("dark"), document.documentElement.classList.add("light"), t && (t.classList.remove("dark"), t.classList.add("light")));
|
|
126
|
+
},
|
|
127
|
+
async startDrag(e) {
|
|
128
|
+
return d.startDrag(e);
|
|
129
|
+
},
|
|
130
|
+
async updateDragPosition(e) {
|
|
131
|
+
return d.updateDragPosition(e);
|
|
132
|
+
},
|
|
133
|
+
async endDrag(e) {
|
|
134
|
+
return d.endDrag(e);
|
|
135
|
+
},
|
|
136
|
+
async getDropZones(e) {
|
|
137
|
+
return d.getDropZones(e);
|
|
138
|
+
},
|
|
139
|
+
async highlightDropZone(e) {
|
|
140
|
+
return d.highlightDropZone(e);
|
|
115
141
|
}
|
|
116
142
|
}, {
|
|
117
143
|
handle(e) {
|
|
118
144
|
window.addEventListener("message", async t => {
|
|
119
145
|
if (typeof t.data != "object" || t.data.source !== _constants.EDITOR_SOURCE_NAME || t.data.type === "event" || !t.data.request) return;
|
|
120
|
-
const
|
|
146
|
+
const a = await e(t.data.request);
|
|
121
147
|
window.parent.postMessage({
|
|
122
148
|
source: _constants.IFRAME_SOURCE_NAME,
|
|
123
|
-
response:
|
|
149
|
+
response: a
|
|
124
150
|
}, "*");
|
|
125
151
|
});
|
|
126
152
|
},
|
|
127
153
|
invoke(e) {
|
|
128
|
-
return new Promise((t,
|
|
154
|
+
return new Promise((t, a) => {
|
|
129
155
|
const n = setTimeout(() => {
|
|
130
|
-
window.removeEventListener("message", o),
|
|
156
|
+
window.removeEventListener("message", o), a(new Error("Request timed out"));
|
|
131
157
|
}, 5e3);
|
|
132
|
-
function o(
|
|
133
|
-
typeof
|
|
158
|
+
function o(s) {
|
|
159
|
+
typeof s.data == "object" && (s.data.source !== _constants.EDITOR_SOURCE_NAME || !s.data.response || s.data.response.id === e.id && (clearTimeout(n), window.removeEventListener("message", o), t(s.data.response)));
|
|
134
160
|
}
|
|
135
161
|
window.parent.postMessage({
|
|
136
162
|
source: _constants.IFRAME_SOURCE_NAME,
|
|
@@ -155,22 +181,22 @@ function createVueIframeClient(c, l) {
|
|
|
155
181
|
maxDepth: 1 / 0
|
|
156
182
|
})
|
|
157
183
|
}),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
184
|
+
f = l?.disableDefaultConsole ? void 0 : console.log.bind(console),
|
|
185
|
+
c = l?.disableDefaultConsole ? void 0 : console.warn.bind(console),
|
|
186
|
+
g = l?.disableDefaultConsole ? void 0 : console.error.bind(console),
|
|
187
|
+
u = l?.disableDefaultConsole ? void 0 : console.info.bind(console);
|
|
162
188
|
return console.log = (...e) => {
|
|
163
|
-
|
|
189
|
+
r.emit("console", "log", e), f?.(...e);
|
|
164
190
|
}, console.warn = (...e) => {
|
|
165
|
-
|
|
191
|
+
c?.(...e);
|
|
166
192
|
}, console.error = (...e) => {
|
|
167
|
-
|
|
193
|
+
r.emit("console", "error", e), g?.(...e);
|
|
168
194
|
}, console.info = (...e) => {
|
|
169
|
-
|
|
170
|
-
}, window.addEventListener("resize", async () =>
|
|
195
|
+
r.emit("console", "info", e), u?.(...e);
|
|
196
|
+
}, window.addEventListener("resize", async () => r.emit("resize", await r.$context.getPageHeight())), new MutationObserver(async () => r.emit("resize", await r.$context.getPageHeight())).observe(document.body, {
|
|
171
197
|
childList: !0,
|
|
172
198
|
subtree: !0,
|
|
173
199
|
attributes: !0,
|
|
174
200
|
characterData: !0
|
|
175
|
-
}),
|
|
201
|
+
}), r.emit("ready"), r;
|
|
176
202
|
}
|