You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Core scripts (and extensions/plugins/themes) inside the ace-builds and react-ace node modules have been modified/patched to work with streamlit-code-editor. The problem is multifold.
These modules should not have code specific to any application that uses said module.
The functionality these changes provide should be transferable to future versions of the modules so that component doesnt break when any of the modified modules are updated.
The original reason for such modifications was that these modules were broken and/or are generally no longer maintained/updated.
Examples:
'keyboard' was misspelled in some places the Ace keyboard shortcut extension which broke imports and prevented the extension from working.
Ace does not have the ability to set the default theme to something other than textmate and loading another theme when component is rerenders happens with a delay resulting in a flicker between themes.
Ace doesnt have theme removal functionality.
React-Ace lacks a way to get mode id from Syntax type object
Enhancement:General fixes and features should be added to Ace and React-Ace so that app-specific modifications are not needed.
For example, to add theme removal feature, a new attribute can be added to the theme module object containing other themes to remove after theme is loaded. The theme modules themselves can be defined with this attribute set:
Current solution:
ace.define("ace/theme/streamlit_light",["require","exports","module","ace/theme/streamlit_light.css","ace/lib/dom"],function(require,exports,module){exports.isDark=false;exports.cssClass="ace-streamlit-light";exports.cssText=require("./streamlit_light.css");exports.$id="ace/theme/streamlit_light";vardom=require("../lib/dom");dom.importCssString(exports.cssText,exports.cssClass,false);dom.removeElementById("ace-streamlit-dark");//removes the style element containing the css text for the theme this theme replaces});
And inside setTheme function:
functionafterLoad(module){if(_self.$themeId!=theme)returncb&&cb();if(!module||!module.cssClass)thrownewError("couldn't load module "+theme+" or it didn't call define");if(module.$id)_self.$themeId=module.$id;dom.importCssString(module.cssText,module.cssClass,_self.container);// The following IF/ELSE is a workaround for a theme replacement bug in// Streamlit component that uses ACEif(module.cssClass=="ace-streamlit-light")dom.removeElementById("ace-streamlit-dark");elseif(module.cssClass=="ace-streamlit-dark")dom.removeElementById("ace-streamlit-light");// ... //
Core scripts (and extensions/plugins/themes) inside the
ace-builds
andreact-ace
node modules have been modified/patched to work with streamlit-code-editor. The problem is multifold.The original reason for such modifications was that these modules were broken and/or are generally no longer maintained/updated.
Examples:
textmate
and loading another theme when component is rerenders happens with a delay resulting in a flicker between themes.Enhancement: General fixes and features should be added to Ace and React-Ace so that app-specific modifications are not needed.
For example, to add theme removal feature, a new attribute can be added to the theme module object containing other themes to remove after theme is loaded. The theme modules themselves can be defined with this attribute set:
Current solution:
And inside
setTheme
function:Perhaps something like this would be better:
And inside
setTheme
function:Obviously more consideration is needed.
The text was updated successfully, but these errors were encountered: