@nookuio/iframe 0.9.2 → 0.9.4
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/editor.js +1 -1
- package/dist/editor.mjs +1 -1
- package/dist/iframe.js +34 -1
- package/dist/iframe.mjs +22 -1
- package/dist/types.d.ts +17 -3
- package/package.json +1 -1
package/dist/editor.js
CHANGED
|
@@ -39,7 +39,7 @@ function deserialize(data) {
|
|
|
39
39
|
function createEditorClient(iframe) {
|
|
40
40
|
let iframeElement;
|
|
41
41
|
function getIframe() {
|
|
42
|
-
if (!iframeElement) {
|
|
42
|
+
if (!iframeElement || !iframeElement.isConnected) {
|
|
43
43
|
iframeElement = typeof iframe === "string" ? document.querySelector(`#${iframe}`) : iframe;
|
|
44
44
|
}
|
|
45
45
|
return iframeElement;
|
package/dist/editor.mjs
CHANGED
|
@@ -31,7 +31,7 @@ function deserialize(data) {
|
|
|
31
31
|
export function createEditorClient(iframe) {
|
|
32
32
|
let iframeElement;
|
|
33
33
|
function getIframe() {
|
|
34
|
-
if (!iframeElement) {
|
|
34
|
+
if (!iframeElement || !iframeElement.isConnected) {
|
|
35
35
|
iframeElement = typeof iframe === "string" ? document.querySelector(`#${iframe}`) : iframe;
|
|
36
36
|
}
|
|
37
37
|
return iframeElement;
|
package/dist/iframe.js
CHANGED
|
@@ -39,7 +39,6 @@ function getElementStyles(selector, withPadding) {
|
|
|
39
39
|
function createVueIframeClient(vueCtx, options) {
|
|
40
40
|
const client = (0, _createClient.createClient)({
|
|
41
41
|
...vueCtx,
|
|
42
|
-
document: window.document,
|
|
43
42
|
async editText({
|
|
44
43
|
path,
|
|
45
44
|
id
|
|
@@ -140,6 +139,40 @@ function createVueIframeClient(vueCtx, options) {
|
|
|
140
139
|
document.documentElement.classList.remove("dark");
|
|
141
140
|
document.documentElement.classList.add("light");
|
|
142
141
|
}
|
|
142
|
+
},
|
|
143
|
+
updateElementClass({
|
|
144
|
+
className,
|
|
145
|
+
id,
|
|
146
|
+
path
|
|
147
|
+
}) {
|
|
148
|
+
const selector = getSelector(path, id);
|
|
149
|
+
const elements = document.querySelectorAll(selector);
|
|
150
|
+
if (!elements?.length) return;
|
|
151
|
+
elements.forEach(elm => elm.className = className);
|
|
152
|
+
},
|
|
153
|
+
updateElementAttribute({
|
|
154
|
+
attribute,
|
|
155
|
+
value,
|
|
156
|
+
id,
|
|
157
|
+
path
|
|
158
|
+
}) {
|
|
159
|
+
const selector = getSelector(path, id);
|
|
160
|
+
const elements = document.querySelectorAll(selector);
|
|
161
|
+
if (!elements?.length) return;
|
|
162
|
+
elements.forEach(elm => elm.setAttribute(attribute, value));
|
|
163
|
+
},
|
|
164
|
+
duplicateElement({
|
|
165
|
+
id,
|
|
166
|
+
path
|
|
167
|
+
}) {
|
|
168
|
+
const selector = getSelector(path, id);
|
|
169
|
+
const elements = document.querySelectorAll(selector);
|
|
170
|
+
if (!elements?.length) return;
|
|
171
|
+
elements.forEach(elm => {
|
|
172
|
+
const clone = elm.cloneNode(true);
|
|
173
|
+
clone.setAttribute("data-node-id", String(Number(clone.getAttribute("data-node-id")) + 1));
|
|
174
|
+
elm.parentElement?.appendChild(clone);
|
|
175
|
+
});
|
|
143
176
|
}
|
|
144
177
|
}, {
|
|
145
178
|
handle(handler) {
|
package/dist/iframe.mjs
CHANGED
|
@@ -34,7 +34,6 @@ export function createVueIframeClient(vueCtx, options) {
|
|
|
34
34
|
const client = createClient(
|
|
35
35
|
{
|
|
36
36
|
...vueCtx,
|
|
37
|
-
document: window.document,
|
|
38
37
|
async editText({ path, id }) {
|
|
39
38
|
if (!path || id === void 0) return;
|
|
40
39
|
const selector = getSelector(path, id);
|
|
@@ -120,6 +119,28 @@ export function createVueIframeClient(vueCtx, options) {
|
|
|
120
119
|
document.documentElement.classList.remove("dark");
|
|
121
120
|
document.documentElement.classList.add("light");
|
|
122
121
|
}
|
|
122
|
+
},
|
|
123
|
+
updateElementClass({ className, id, path }) {
|
|
124
|
+
const selector = getSelector(path, id);
|
|
125
|
+
const elements = document.querySelectorAll(selector);
|
|
126
|
+
if (!elements?.length) return;
|
|
127
|
+
elements.forEach((elm) => elm.className = className);
|
|
128
|
+
},
|
|
129
|
+
updateElementAttribute({ attribute, value, id, path }) {
|
|
130
|
+
const selector = getSelector(path, id);
|
|
131
|
+
const elements = document.querySelectorAll(selector);
|
|
132
|
+
if (!elements?.length) return;
|
|
133
|
+
elements.forEach((elm) => elm.setAttribute(attribute, value));
|
|
134
|
+
},
|
|
135
|
+
duplicateElement({ id, path }) {
|
|
136
|
+
const selector = getSelector(path, id);
|
|
137
|
+
const elements = document.querySelectorAll(selector);
|
|
138
|
+
if (!elements?.length) return;
|
|
139
|
+
elements.forEach((elm) => {
|
|
140
|
+
const clone = elm.cloneNode(true);
|
|
141
|
+
clone.setAttribute("data-node-id", String(Number(clone.getAttribute("data-node-id")) + 1));
|
|
142
|
+
elm.parentElement?.appendChild(clone);
|
|
143
|
+
});
|
|
123
144
|
}
|
|
124
145
|
},
|
|
125
146
|
{
|
package/dist/types.d.ts
CHANGED
|
@@ -40,7 +40,21 @@ export interface CoreIframeContext {
|
|
|
40
40
|
path: string;
|
|
41
41
|
id: string;
|
|
42
42
|
}) => void;
|
|
43
|
-
|
|
43
|
+
updateElementClass(options: {
|
|
44
|
+
id: string;
|
|
45
|
+
path: string;
|
|
46
|
+
className: string;
|
|
47
|
+
}): void;
|
|
48
|
+
updateElementAttribute(options: {
|
|
49
|
+
id: string;
|
|
50
|
+
path: string;
|
|
51
|
+
attribute: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}): void;
|
|
54
|
+
duplicateElement(options: {
|
|
55
|
+
id: string;
|
|
56
|
+
path: string;
|
|
57
|
+
}): void;
|
|
44
58
|
}
|
|
45
59
|
export interface CoreIframeEvents {
|
|
46
60
|
ready: () => void;
|
|
@@ -72,7 +86,7 @@ export interface VueIframeContext extends CoreIframeContext {
|
|
|
72
86
|
*
|
|
73
87
|
* Works only on VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH
|
|
74
88
|
*/
|
|
75
|
-
updateVirtualSfcCode
|
|
89
|
+
updateVirtualSfcCode: (path: string, code: string) => void;
|
|
76
90
|
}
|
|
77
91
|
export interface VueIframeEvents extends CoreIframeEvents {
|
|
78
92
|
'route-change': (to: string) => void;
|
|
@@ -96,7 +110,7 @@ export interface ElementStyles extends ElementPosition {
|
|
|
96
110
|
left: string;
|
|
97
111
|
};
|
|
98
112
|
}
|
|
99
|
-
export interface
|
|
113
|
+
export interface IframePageOptions {
|
|
100
114
|
path: string;
|
|
101
115
|
layout?: string | false;
|
|
102
116
|
injectTailwind?: boolean;
|