Skip to content

Conversation

@bajrangCoder
Copy link
Member

This PR introduces a major architectural change in how non-editor tabs are rendered and styled in Acode, implementing Shadow DOM isolation for better encapsulation and avoid conflicts.

Breaking Changes 🚨

  • Non-editor tabs now use Shadow DOM encapsulation
  • Direct DOM manipulation of tab content may not work as before
  • Global styles no longer automatically affect tab content
  • Plugin stylesheets need to be explicitly declared

New APIs for Plugin Developers 🛠

  • addStyle(style: string): Add stylesheet to tab's shadow DOM
  • New options in EditorFile constructor:
    interface FileOptions {
      // ... existing options ...
      stylesheets?: string | string[]; // URLs or CSS strings
    }

Migration Guide for Plugin Developers 📝

Before

const tab = new EditorFile("Custom Tab", {
  type: "page",
  content: myElement
});

// Global styles affected the content
document.head.appendChild(myStyles);

After

const tab = new EditorFile("Custom Tab", {
  type: "page",
  content: myElement,
  stylesheets: [
    '/plugin/styles.css',
    '.my-custom-styles { color: blue; }'
  ]
});

// Add styles later if needed
tab.addStyle('.dynamic-style { background: yellow; }');

@bajrangCoder bajrangCoder requested a review from Copilot April 13, 2025 18:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

src/lib/editorFile.js:6

  • Ensure that the 'html-tag-js' dependency is properly installed and versioned in the project, as its absence could lead to runtime errors during element creation.
import tag from "html-tag-js";

src/lib/editorFile.js:914

  • [nitpick] Consider adding tests to verify that dynamically added styles through 'addStyle' are correctly injected into the Shadow DOM for both external and inline styles.
addStyle(style) {

Copy link
Member

@deadlyjack deadlyjack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR. Working wonderfully.

@bajrangCoder bajrangCoder merged commit cfe14f2 into Acode-Foundation:main Apr 16, 2025
2 checks passed
@bajrangCoder bajrangCoder deleted the feature/shadow-dom-tab-isolation branch May 9, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants