// Copyright (c) 2023, JINGROW
// For license information, please see license.txt

jingrow.ui.form.on("Custom HTML Block", {
	refresh(frm) {
		if (
			!has_common(jingrow.user_roles, [
				"Administrator",
				"System Manager",
				"Workspace Manager",
			])
		) {
			frm.set_value("private", true);
		} else {
			frm.set_df_property("private", "read_only", false);
		}

		let wrapper = frm.fields_dict["preview"].wrapper;
		wrapper.classList.add("mb-3");

		jingrow.create_shadow_element(wrapper, frm.pg.html, frm.pg.style, frm.pg.script);
	},
});
