@3sln/deck 0.0.10 → 0.0.11
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/package.json +1 -1
- package/src/deck-demo.js +26 -8
package/package.json
CHANGED
package/src/deck-demo.js
CHANGED
|
@@ -222,12 +222,14 @@ function createEngine(src, canonicalSrc) {
|
|
|
222
222
|
};
|
|
223
223
|
|
|
224
224
|
const driver = {
|
|
225
|
-
panel: (name, render, {pane = 'left', order = undefined} = {}) => {
|
|
225
|
+
panel: (name, render, {pane = 'left', order = undefined, mode = 'shadow', colorScheme = undefined} = {}) => {
|
|
226
226
|
const panel = {
|
|
227
227
|
name,
|
|
228
228
|
pane,
|
|
229
229
|
render,
|
|
230
230
|
order,
|
|
231
|
+
mode,
|
|
232
|
+
colorScheme,
|
|
231
233
|
};
|
|
232
234
|
engine.dispatch(new CreateOrUpdatePanel(panel));
|
|
233
235
|
},
|
|
@@ -737,7 +739,7 @@ const demoStyle = css`
|
|
|
737
739
|
.panel-content.active {
|
|
738
740
|
pointer-events: auto;
|
|
739
741
|
overflow: auto;
|
|
740
|
-
width:
|
|
742
|
+
width: 100%;
|
|
741
743
|
}
|
|
742
744
|
pre > code {
|
|
743
745
|
padding: 1em;
|
|
@@ -820,16 +822,32 @@ class DeckDemo extends HTMLElement {
|
|
|
820
822
|
}
|
|
821
823
|
|
|
822
824
|
el._aborter?.abort();
|
|
823
|
-
|
|
824
|
-
const div = document.createElement('div');
|
|
825
|
-
const shadow = div.attachShadow({mode: 'open'});
|
|
826
825
|
const aborter = new AbortController();
|
|
827
|
-
|
|
828
|
-
el.replaceChildren(div);
|
|
829
826
|
el._aborter = aborter;
|
|
830
827
|
el._renderer = p.render;
|
|
831
828
|
|
|
832
|
-
p.
|
|
829
|
+
if (p.mode === 'iframe') {
|
|
830
|
+
const iframe = document.createElement('iframe');
|
|
831
|
+
iframe.style.cssText = 'border: none; width: 100%; height: 100%; display: block;';
|
|
832
|
+
|
|
833
|
+
iframe.onload = () => {
|
|
834
|
+
const doc = iframe.contentDocument;
|
|
835
|
+
if (!doc) return;
|
|
836
|
+
|
|
837
|
+
if (p.colorScheme) {
|
|
838
|
+
doc.documentElement.style.colorScheme = p.colorScheme;
|
|
839
|
+
}
|
|
840
|
+
doc.body.style.margin = '0';
|
|
841
|
+
|
|
842
|
+
p.render(doc.body, aborter.signal);
|
|
843
|
+
};
|
|
844
|
+
el.replaceChildren(iframe);
|
|
845
|
+
} else {
|
|
846
|
+
const div = document.createElement('div');
|
|
847
|
+
const shadow = div.attachShadow({mode: 'open'});
|
|
848
|
+
el.replaceChildren(div);
|
|
849
|
+
p.render(shadow, aborter.signal);
|
|
850
|
+
}
|
|
833
851
|
},
|
|
834
852
|
$detach: el => {
|
|
835
853
|
el._aborter?.abort();
|