Spaces:
Sleeping
Sleeping
Create panel.js
Browse files
panel.js
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function executeScriptFormatter(cell, formatterParams, onRendered) {
|
2 |
+
onRendered(function(){
|
3 |
+
const shadowRoot = cell.getElement().getRootNode();
|
4 |
+
if (shadowRoot instanceof ShadowRoot) {
|
5 |
+
const script = cell.getElement().querySelector('script');
|
6 |
+
console.log('script:', script);
|
7 |
+
if (script) {
|
8 |
+
// Replace "document." with "shadowRoot." in the script code
|
9 |
+
const scriptCode = script.innerText.replace(/document\./g, 'shadowRoot.');
|
10 |
+
// Execute the modified script code
|
11 |
+
const func = new Function('shadowRoot', scriptCode);
|
12 |
+
func(shadowRoot);
|
13 |
+
}
|
14 |
+
}
|
15 |
+
});
|
16 |
+
return cell.getValue();
|
17 |
+
};
|
18 |
+
|
19 |
+
|
20 |
+
Tabulator.extendModule("format", "formatters", {
|
21 |
+
executeScriptFormatter: executeScriptFormatter,
|
22 |
+
});
|