mirror of
https://github.com/discourse/discourse.git
synced 2025-02-13 12:23:27 +08:00
28 lines
584 B
JavaScript
28 lines
584 B
JavaScript
![]() |
const gridRule = {
|
||
|
tag: "grid",
|
||
|
before(state) {
|
||
|
let token = state.push("bbcode_open", "div", 1);
|
||
|
token.attrs = [["class", "d-image-grid"]];
|
||
|
},
|
||
|
|
||
|
after(state) {
|
||
|
state.push("bbcode_close", "div", -1);
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export function setup(helper) {
|
||
|
helper.registerOptions((opts, siteSettings) => {
|
||
|
opts.enableGrid = !!siteSettings.experimental_post_image_grid;
|
||
|
});
|
||
|
|
||
|
helper.allowList(["div.d-image-grid"]);
|
||
|
|
||
|
helper.registerPlugin((md) => {
|
||
|
if (!md.options.discourse.enableGrid) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
md.block.bbcode.ruler.push("grid", gridRule);
|
||
|
});
|
||
|
}
|