feat: API: expose quill editor query functions

Этот коммит содержится в:
Mattia Roccoberton
2025-03-17 18:07:27 +01:00
родитель 328ee0d9fa
Коммит af901f4f7d
4 изменённых файлов: 91 добавлений и 1 удалений

Просмотреть файл

@@ -1,3 +1,4 @@
/* eslint-disable no-undef */
(function () {
'use strict'
@@ -87,6 +88,27 @@
}
}
// --- public functions --------------------------------------------------------
window.getQuillEditors = function() {
const editors = document.querySelectorAll('[data-aa-quill-editor]')
let list = []
editors.forEach(function(editor) { list.push(editor['_quill-editor']) })
return list
}
window.getQuillEditorByIndex = function(index) {
const editors = document.querySelectorAll('[data-aa-quill-editor]')
return (index >= 0 && index < editors.length) ? editors[index]['_quill-editor'] : null
}
window.getQuillEditorByElementId = function(id) {
const editor = document.querySelector(`[data-aa-quill-editor]#${id}`)
return editor ? editor['_quill-editor'] : null
}
// --- events ------------------------------------------------------------------
$(document).ready(initQuillEditors)
$(document).on('has_many_add:after', '.has_many_container', initQuillEditors)