Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Previewer/Internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ export default function Internal({
Gtk.StyleContext.add_provider_for_display(
output.get_display(),
css_provider,
// STYLE_PROVIDER_PRIORITY_THEME is 200; only values below that behave correctly
Gtk.STYLE_PROVIDER_PRIORITY_THEME - 1,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
);
}

Expand Down Expand Up @@ -245,7 +244,7 @@ export default function Internal({
// https://github.com/prettier/prettier/issues/9114
// We are not using https://github.com/pazams/postcss-scopify
// because it's not compatible with postcss 8
export function scopeStylesheet(style, id) {
function scopeStylesheet(style, id) {
const ast = postcss.parse(style);
id = id || "workbench_output";

Expand Down
24 changes: 0 additions & 24 deletions src/Previewer/Previewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Gio from "gi://Gio";
import { gettext as _ } from "gettext";

import * as xml from "../langs/xml/xml.js";
import * as postcss from "../lib/postcss.js";

import {
encode,
Expand Down Expand Up @@ -333,29 +332,6 @@ export default function Previewer({
};
}

// We are using postcss because it's also a dependency of prettier
// it would be great to keep the ast around and pass that to prettier
// so there is no need to re-parse but that's not supported yet
// https://github.com/prettier/prettier/issues/9114
// We are not using https://github.com/pazams/postcss-scopify
// because it's not compatible with postcss 8
export function scopeStylesheet(style) {
const ast = postcss.parse(style);

for (const node of ast.nodes) {
if (node.selector) {
node.selector = `#workbench_output ${node.selector}`;
}
}

let str = "";
postcss.stringify(ast, (s) => {
str += s;
});

return str;
}

function getTemplate(tree) {
const template = tree.getChild("template");
if (!template) return;
Expand Down
3 changes: 1 addition & 2 deletions src/Previewer/previewer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ namespace Workbench {
Gtk.StyleContext.add_provider_for_display (
Gdk.Display.get_default (),
this.css,
// STYLE_PROVIDER_PRIORITY_THEME is 200; only values below that behave correctly
Gtk.STYLE_PROVIDER_PRIORITY_THEME - 1);
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}

public void run (string filename, string uri) {
Expand Down