import libraryLoader from "./library_loader.js"; import noteDetailService from './note_detail.js'; import utils from "./utils.js"; import infoService from "./info.js"; const $noteDetailText = $('#note-detail-text'); const $markdownImportDialog = $('#markdown-import-dialog'); const $markdownImportTextarea = $('#markdown-import-textarea'); const $markdownImportButton = $('#markdown-import-button'); let textEditor = null; async function show() { if (!textEditor) { await libraryLoader.requireLibrary(libraryLoader.CKEDITOR); // 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($noteDetailText[0], { heading: { options: [ { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' }, { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' }, { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }, { model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3' } ] } }); textEditor.model.document.on('change:data', noteDetailService.noteChanged); } } textEditor.setData(noteDetailService.getCurrentNote().content); $noteDetailText.show(); } 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("