1let customCssAppended = false; 2let editor; 3 4export async function editorjsSave() { 5 if (!editor) { 6 return null; 7 } 8 9 const savedData = await editor.save(); 10 const json = JSON.stringify(savedData); 11 return json; 12} 13 14export function editorjsInit(elementId, content, entityType, entityId) { 15 const contentData = content != null && content != "" ? JSON.parse(content) : {}; 16 17 editor = new EditorJS({ 18 holder: elementId, 19 tools: { 20 header: { 21 class: Header, 22 config: { 23 placeholder: 'Enter a header', 24 levels: [1, 2, 3, 4, 5, 6], 25 defaultLevel: 3 26 } 27 }, 28 // delimiter: Delimiter, 29 alert: { 30 class: Alert, 31 inlineToolbar: true, 32 config: { 33 defaultType: 'warning' 34 } 35 }, 36 list: { 37 class: EditorjsList, 38 inlineToolbar: true, 39 config: { 40 defaultStyle: 'unordered' 41 }, 42 }, 43 image: { 44 class: ImageTool, 45 config: { 46 endpoints: { 47 byFile: '/manage/upload-content-image', 48 byUrl: '/manage/upload-content-image' 49 }, 50 additionalRequestData: { 51 entityType: entityType, 52 entityId: entityId 53 } 54 } 55 }, 56 // carousel: { 57 // class: Carousel, 58 // config: { 59 // endpoints: { 60 // byFile: "/manage/upload-content-image", 61 // }, 62 // additionalRequestData: { 63 // entityType: entityType, 64 // entityId: entityId 65 // } 66 // } 67 // }, 68 embed: Embed, 69 // table: Table, 70 raw: RawTool 71 }, 72 data: contentData 73 }); 74 75 if (!customCssAppended) 76 { 77 appendCustomCss(); 78 customCssAppended = true; 79 } 80} 81 82function appendCustomCss() { 83 const customCss = 84 `.image-tool--empty .image-tool__caption, .image-tool--uploading .image-tool__caption { 85 display: block !important; 86 }` 87 88 // Create a style tag and append it to the end of the document 89 const style = document.createElement('style'); 90 style.innerHTML = customCss; 91 document.body.appendChild(style); 92}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.