Added files
This commit is contained in:
commit
2be4a86553
14 changed files with 533 additions and 0 deletions
60
templates/admin/editorjsform.phtml
Normal file
60
templates/admin/editorjsform.phtml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
% if type(form.default_value)==dict:
|
||||
<%
|
||||
form.default_value='{}'
|
||||
%>
|
||||
% endif
|
||||
|
||||
<p>
|
||||
<div id="${form.name_field_id}_editor" style="background: #454545; color: #fbfbfb;">
|
||||
|
||||
</div>
|
||||
<input type="hidden" name="${form.name}" id="${form.name_field_id}" />
|
||||
</p>
|
||||
<script>
|
||||
|
||||
const editor = new EditorJS( {holder : '${form.name_field_id}_editor', data: ${form.default_value|n} ,
|
||||
|
||||
tools: {
|
||||
|
||||
image: {
|
||||
class: ImageTool,
|
||||
config: {
|
||||
endpoints: {
|
||||
byFile: "${url_for('admin_app.pages2_upload_image')}", // Your backend file uploader endpoint
|
||||
//byUrl: "${url_for('admin_app.pages2_upload_image')}", // Your endpoint that provides uploading by Url
|
||||
}
|
||||
}
|
||||
},
|
||||
List: {
|
||||
class: EditorjsList,
|
||||
inlineToolbar: true,
|
||||
config: {
|
||||
defaultStyle: 'unordered'
|
||||
},
|
||||
},
|
||||
header: {
|
||||
class: Header,
|
||||
shortcut: 'CMD+SHIFT+H',
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$('form').submit(function (e) {
|
||||
|
||||
editor.save().then((outputData) => {
|
||||
console.log('Article data: ', outputData)
|
||||
|
||||
$('#${form.name_field_id}').val(JSON.stringify(outputData));
|
||||
|
||||
}).catch((error) => {
|
||||
console.log('Saving failed: ', error)
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
${add_js('editorjs.umd.js', 'pages2')}
|
||||
${add_js('image.umd.js', 'pages2')}
|
||||
${add_js('header.umd.js', 'pages2')}
|
||||
${add_js('editorjs-list.umd.js', 'pages2')}
|
||||
Loading…
Add table
Add a link
Reference in a new issue