libokj's picture
Create panel.js
b5f72e9 verified
raw
history blame
837 Bytes
function executeScriptFormatter(cell, formatterParams, onRendered) {
onRendered(function(){
const shadowRoot = cell.getElement().getRootNode();
if (shadowRoot instanceof ShadowRoot) {
const script = cell.getElement().querySelector('script');
console.log('script:', 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,
});