import libraryLoader from "./library_loader.js"; import noteDetailService from './note_detail.js'; import treeService from './tree.js'; import attributeService from "./attributes.js"; const $component = $('#note-detail-text'); let textEditor = null; async function show() { if (!textEditor) { await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); // CKEditor since version 12 needs the element to be visible before initialization. At the same time // we want to avoid flicker - i.e. show editor only once everything is ready. That's why we have separate // display of $component in both branches. $component.show(); // textEditor might have been initialized during previous await so checking again // looks like double initialization can freeze CKEditor pretty badly if (!textEditor) { textEditor = await BalloonEditor.create($component[0], { placeholder: "Type the content of your note here ..." }); onNoteChange(noteDetailService.noteChanged); } } textEditor.isReadOnly = await isReadOnly(); $component.show(); textEditor.setData(noteDetailService.getActiveNote().content); } function getContent() { let content = textEditor.getData(); // if content is only tags/whitespace (typically
), then just make it empty // this is important when setting new note to code if (jQuery(content).text().trim() === '' && !content.includes("