зеркало из
https://github.com/rs-pro/activeadmin-quill_editor.git
synced 2026-09-03 10:16:18 +03:00
feat: API: expose quill editor query functions
Этот коммит содержится в:
@@ -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)
|
||||
|
||||
Ссылка в новой задаче
Block a user