@nookuio/iframe 0.9.2 → 0.9.3
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 +21 -1
- package/dist/iframe.mjs +12 -1
- package/dist/types.d.ts +13 -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,27 @@ 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));
|
|
143
163
|
}
|
|
144
164
|
}, {
|
|
145
165
|
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,18 @@ 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));
|
|
123
134
|
}
|
|
124
135
|
},
|
|
125
136
|
{
|
package/dist/types.d.ts
CHANGED
|
@@ -40,7 +40,17 @@ 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;
|
|
44
54
|
}
|
|
45
55
|
export interface CoreIframeEvents {
|
|
46
56
|
ready: () => void;
|
|
@@ -72,7 +82,7 @@ export interface VueIframeContext extends CoreIframeContext {
|
|
|
72
82
|
*
|
|
73
83
|
* Works only on VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH
|
|
74
84
|
*/
|
|
75
|
-
updateVirtualSfcCode
|
|
85
|
+
updateVirtualSfcCode: (path: string, code: string) => void;
|
|
76
86
|
}
|
|
77
87
|
export interface VueIframeEvents extends CoreIframeEvents {
|
|
78
88
|
'route-change': (to: string) => void;
|
|
@@ -96,7 +106,7 @@ export interface ElementStyles extends ElementPosition {
|
|
|
96
106
|
left: string;
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
|
-
export interface
|
|
109
|
+
export interface IframePageOptions {
|
|
100
110
|
path: string;
|
|
101
111
|
layout?: string | false;
|
|
102
112
|
injectTailwind?: boolean;
|