Skip to content
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 scripts or inline styles in HTML Galley #10675

Open
NateWr opened this issue Dec 10, 2024 · 2 comments
Open

Can't load scripts or inline styles in HTML Galley #10675

NateWr opened this issue Dec 10, 2024 · 2 comments
Assignees

Comments

@NateWr
Copy link
Contributor

NateWr commented Dec 10, 2024

Describe the bug
You can use a special "context" for styles that you want to be included in the HTML Galley. Some these use this to apply styles to all HTML galleys.

class ExampleTheme extends ThemePlugin
{
    public function init()
        $this->addStyle(
            'example', 
            'css/galley.css', 
            ['contexts' => 'htmlGalley']
        );
    }
}

However, the inline option, which prints styles inline in a <styles> tag, is not working. This can be used to set CSS variables based on theme options (like colors).

Also, the htmlGalley context is ignored when using ThemePlugin::addScript() or TemplateManager::addJavaScript().

To Reproduce
Steps to reproduce the behavior:

  1. Add the code in Additional Information below to DefaultThemePlugin::init().
  2. Upload a HTML galley.
  3. View the HTML galley
  4. See that the styles and script are not loaded in the <iframe>.

What application are you using?
stable-3_3_0

Additional information
This is sample code you can use to reproduce this bug. Add it to the top of DefaultThemePlugin::init():

$this->addStyle(
	'inline-style', 
	'body { --example-var: 16px; }',
	[
		'contexts' => 'htmlGalley',
		'inline' => true,
	]
);
$this->addScript(
	'script', 
	'any-script.js',
	[
		'contexts' => 'htmlGalley',
	]
);
NateWr added a commit to NateWr/pkp-lib that referenced this issue Dec 10, 2024
@NateWr
Copy link
Contributor Author

NateWr commented Dec 10, 2024

The following PRs inject scripts and inline styles into the HTML of a HTML galley.

PRs:
#10676

Tests:
pkp/ojs#4548

@asmecher
Copy link
Member

Thanks, @NateWr! @jardakotesovec, would you mind reviewing the PR above?

@jardakotesovec jardakotesovec self-assigned this Dec 12, 2024
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

No branches or pull requests

3 participants