I am attempting to incorporate a custom style class into the Notion edit page. It appears Notion might be using a technology similar to flutter-web that restricts direct DOM manipulations, as evidenced by a console warning when a class is added.
const notionSection = document.querySelector('.notion-block');
notionSection.classList.toggle('my-custom-style');
Any suggestions for a workaround?
I encountered a similar need to adjust the Notion interface with custom styles. It appears that Notion’s underlying framework is designed to prevent direct DOM changes, which means trying to inject a custom class might not be the best solution for long-term functionality. Instead, one approach that worked for me was to use a browser extension specifically created for UI tweaks. This method allows more controlled adjustments without risking instability from direct DOM manipulation. Keep in mind that reliance on unofficial methods might lead to issues when Notion updates its interface.
I have experimented with customizing the Notion editing interface and found that using user scripts, in combination with tools like Tampermonkey, is a promising approach. Instead of attempting direct DOM manipulation, I tailored my scripts to look for updates on dynamically loaded elements. This strategy minimizes the risk of unexpected behavior when Notion updates its layout. While it can be a bit tedious to maintain scripts after updates, it offers a more resilient method without device-level hacks. In my experience, this method strikes a balance between customization and stability.
hey, i used a mutation observer to catch dynamically added notion blocks and tack on my cuat style class. its a bit hacky but works for me. might be worth a try if u dont mind a workaround.
Notion’s architecture makes applying custom classes a challenge due to how its interface is rendered. In a recent project, I chose to implement CSS overrides by targeting specific element identifiers using a browser extension. This allows the injection of style rules that don’t rely on modifying the DOM structure directly. Although this method isn’t officially supported, it has provided a stable workaround for me by keeping changes isolated and easier to update after Notion’s revisions. This approach also avoids potential conflicts from direct DOM manipulation.