Spaces:
Sleeping
Sleeping
| function executeScriptFormatter(cell, formatterParams, onRendered) { | |
| onRendered(function(){ | |
| const shadowRoot = cell.getElement().getRootNode(); | |
| if (shadowRoot instanceof ShadowRoot) { | |
| const script = cell.getElement().querySelector('script'); | |
| if (script) { | |
| // Replace "document." with "shadowRoot." in the script code | |
| const scriptCode = script.innerText.replace(/document\./g, 'shadowRoot.'); | |
| // Execute the modified script code | |
| const func = new Function('shadowRoot', scriptCode); | |
| func(shadowRoot); | |
| } | |
| } | |
| }); | |
| return cell.getValue(); | |
| }; | |
| Tabulator.extendModule("format", "formatters", { | |
| executeScriptFormatter: executeScriptFormatter, | |
| }); | |