mirror of
https://github.com/Hopiu/django-markdownx.git
synced 2026-03-16 21:40:24 +00:00
Small clean up.
Added variables for element, editor, and preview during initialisation.
This commit is contained in:
parent
50c730b9a4
commit
f2036f6993
1 changed files with 8 additions and 11 deletions
|
|
@ -831,17 +831,14 @@ docReady(() => {
|
|||
const ELEMENTS = document.getElementsByClassName('markdownx');
|
||||
|
||||
return Object.keys(ELEMENTS).map(key => {
|
||||
|
||||
// Only add the new MarkdownX instance to fields that have no MarkdownX instance yet
|
||||
if (!ELEMENTS[key].querySelector('.markdownx-editor').hasAttribute('data-markdownx-init')) {
|
||||
|
||||
return new MarkdownX(
|
||||
ELEMENTS[key],
|
||||
ELEMENTS[key].querySelector('.markdownx-editor'),
|
||||
ELEMENTS[key].querySelector('.markdownx-preview')
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
let element = ELEMENTS[key],
|
||||
editor = element.querySelector('.markdownx-editor'),
|
||||
preview = element.querySelector('.markdownx-preview');
|
||||
|
||||
// Only add the new MarkdownX instance to fields that have no MarkdownX instance yet.
|
||||
if (!editor.hasAttribute('data-markdownx-init'))
|
||||
return new MarkdownX(element, editor, preview)
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue