Skip to content

Commit 749fbc9

Browse files
author
Éric
authored
add support for callback functions in config (#1)
1 parent 161cdb9 commit 749fbc9

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

  • django_ckeditor_5/static/django_ckeditor_5

django_ckeditor_5/static/django_ckeditor_5/app.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ function getCookie(name) {
2626
/**
2727
* Checks whether the element or its children match the query and returns
2828
* an array with the matches.
29-
*
29+
*
3030
* @param {!HTMLElement} element
3131
* @param {!string} query
32-
*
32+
*
3333
* @returns {array.<HTMLElement>}
3434
*/
3535
function resolveElementArray(element, query) {
@@ -39,9 +39,9 @@ function resolveElementArray(element, query) {
3939
/**
4040
* This function initializes the CKEditor inputs within an optional element and
4141
* assigns properties necessary for the correct operation
42-
*
42+
*
4343
* @param {HTMLElement} [element=document.body] - The element to search for elements
44-
*
44+
*
4545
* @returns {void}
4646
*/
4747
function createEditors(element = document.body) {
@@ -81,6 +81,12 @@ function createEditors(element = document.body) {
8181
var regex = new RegExp(match[1], match[2]);
8282
return regex;
8383
}
84+
if (value.toString().startsWith('::function::-')) {
85+
var funName = value.toString().split('-')[1]
86+
// callback must be installed into this global object first
87+
var func = window.djangoCKEditor5Functions[funcName]
88+
return func;
89+
}
8490
return value;
8591
}
8692
);
@@ -126,10 +132,10 @@ function createEditors(element = document.body) {
126132
* This function filters the list of mutations only by added elements, thus
127133
* eliminates the occurrence of text nodes and tags where it does not make sense
128134
* to try to use with `QuerySelectorAll()` and `matches()` functions.
129-
*
135+
*
130136
* @param {MutationRecord} recordList - It is the object inside the array
131137
* passed to the callback of a MutationObserver.
132-
*
138+
*
133139
* @returns {Array} Array containing filtered nodes.
134140
*/
135141
function getAddedNodes(recordList) {

0 commit comments

Comments
 (0)