-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't load more styles to sceditor #7681
Comments
Did you have a possible solution in mind? Note you can pass css variables to the editor inside the iframe. I do that in my themes, so the editor is updated dynamically. I've wondered why more folks don't use css variables in themes, given the flexibility. |
I only tested it with Namex theme since it's using dark mode and variants. The styles option could be turned into an array so it allows to load multiple files, or pass the $context['css_files'], and then we could move the content of jquery.sceditor.default.css to the index.css |
I think the first of these two options is better. It would only require changes to files in Sources and is the more flexible solution. The second option would require changing the CSS files in the theme, and would do little to help mods (e.g. BBC mods) that might want to tweak the editor's CSS. |
That's fair about editing CSS files, though we've been doing it a bit in recent patches. |
Actually, we didn't even consider that the first option is only useful and viable for mods hooking into integrate_sceditor_options. I was only thinking about my theme already using hooks, but the average theme can't/won't do that... They'd still be stuck if they are using variants or multiple styles. |
Question: Does sceditor accept an array? Interesting that the comment there indicates that the style passed (jquery.sceditor.default.css) is specific to the wysiwyg elements only. |
no
proof
https://github.com/samclarke/SCEditor/blob/0ee103397c5ed12a5a2cac8f397773a264226466/src/lib/SCEditor.js#L583
template
https://github.com/samclarke/SCEditor/blob/0ee103397c5ed12a5a2cac8f397773a264226466/src/lib/templates.js#L17
…On Sat, Aug 5, 2023 at 1:32 PM sbulen ***@***.***> wrote:
Question: Does sceditor accept an array?
https://github.com/samclarke/SCEditor/blob/0ee103397c5ed12a5a2cac8f397773a264226466/src/lib/defaultOptions.js#L32
Interesting that the comment there indicates that the style passed is
specific to the wysiwyg elements only.
—
Reply to this email directly, view it on GitHub
<#7681 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADJNN3M7AQT2KNBBZV6R6TXT2UUJANCNFSM6AAAAAAUNFUVZI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
A 'solution' I found is to append things to the head inside the iframe
I used integrate_sceditor_options though |
It wouldn't be ideal, but perhaps we could use SCEditor's We'd have to get the contents of the CSS files in PHP and then feed them to the editor while setting it up. There would probably have to be some faffing around with our |
That style parameter is ONLY used for WYSIWYG mode tweaks... Do we even really need to pass multiple files for that narrow a scope? It may be sufficient to be able to tell it which variant is being used, & fall back to jquery.sceditor.default.css if no variant applies. The selected variant could help determine which .css to pass, e.g.:
The same approach could apply for the jquery.sceditor.theme.css... Have multiple copies, with the variant as part of the file name. |
Could make sense. |
Yeah, I tried to sum up the current state here:
|
I then suggest removing this Lines 1528 to 1534 in 8a0b818
And using jquery.sceditor.theme.css (when it exists) in here, along with the things you are proposing? Line 1912 in 8a0b818
In addition, should this 'style' setting be added after the hook then? Or is there any reason at all to edit this specific setting with a hook? |
I suppose there's also no reason to use a custom file at all and it would avoid breaking the source view for themes that used jquery.sceditor.theme.css |
I would dynamically build both filenames. And update the docs on theme variants accordingly. For the theme.css:
Similarly, for the default.css (wysiwyg):
The idea is to fully support sceditor within theme variants, with no code needed. And this way, it should be fully backwards compatible with existing themes as well. |
That's a well thought out plan, @sbulen. I like it. It should take care of the needs of theme authors very well. There is one thing I would add to it for the sake of mod authors. Specifically, immediately after this line, I would like us to add the following:
This addition will enable mods to add CSS to the WYSIWYG mode of the editor using the |
I forgot about this but I figured a better solution for my themes, which is just editing the string. However, to pass the correct data attributes I still used jQuery, for example with dark mode: |
A wild plugin has appeared that adds a function to the editor for loading external stylesheets samclarke/SCEditor#966 (comment). But this obviously isn't enough. I have code in ,y theme branch #7933 that copies all |
Description
When toggling the source view in the sceditor, it is possible to load a provided file:
https://www.sceditor.com/documentation/options/#style
SMF/Sources/Subs-Editor.php
Line 1912 in 5bc137d
We are loading jquery.sceditor.default.css and it's fine. However, this is a limitation for custom themes using multiple files (css variables, variants, dark mode, etc), it's currently not possible to load multiple files or pass data attributes to the iframe (so it can be targeted inside a single file).
The text was updated successfully, but these errors were encountered: