Files
ladill-woo-manager/resources/js/woo-rich-text.js
T
isaaccladandCursor 551473f8e5
Deploy Ladill Woo Manager / deploy (push) Successful in 1m16s
Preserve WooCommerce HTML in product descriptions with a rich text editor.
Stop stripping tags on sync so paragraphs and bold book titles round-trip to Woo.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 00:47:01 +00:00

22 lines
540 B
JavaScript

export function registerWooRichText(Alpine) {
Alpine.data('wooRichText', (initial = '') => ({
html: initial,
init() {
this.$refs.editor.innerHTML = this.html || '';
this.sync();
},
sync() {
this.html = this.$refs.editor.innerHTML.trim();
this.$refs.input.value = this.html;
},
format(command) {
document.execCommand(command, false, null);
this.sync();
this.$refs.editor.focus();
},
}));
}