Skip to content

Instantly share code, notes, and snippets.

@Suaz
Created October 27, 2019 20:25
Show Gist options
  • Save Suaz/3dbd3e6e9408e50e5ddf4f5a9696936a to your computer and use it in GitHub Desktop.
Save Suaz/3dbd3e6e9408e50e5ddf4f5a9696936a to your computer and use it in GitHub Desktop.
<?php
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/header@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/paragraph@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/image@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/link@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/embed@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/personality@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/table@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/quote@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/list@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/warning@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/checklist@latest' );
$this->registerJsFile( 'https://cdn.jsdelivr.net/npm/@editorjs/delimiter@latest' );
$this->registerJs( <<<JS
var editor = new EditorJS({
/**
* Create a holder for the Editor and pass its ID
*/
holder : 'editorjs',
/**
* Available Tools list.
* Pass Tool's class or Settings object for each Tool you want to use
*/
tools: {
header: {
class: Header,
inlineToolbar : true,
shortcut: 'CMD+SHIFT+H',
config: {
placeholder: 'Enter a header'
}
},
paragraph: {
class: Paragraph,
inlineToolbar: true,
},
image: {
class: ImageTool,
config: {
endpoints: {
byFile: 'http://localhost:8008/uploadFile', // Your backend file uploader endpoint
byUrl: 'http://localhost:8008/fetchUrl', // Your endpoint that provides uploading by Url
}
}
},
linkTool: {
class: LinkTool,
config: {
endpoint: 'http://localhost:8008/fetchUrl', // Your backend endpoint for url data fetching
}
},
embed: {
class: Embed,
inlineToolbar: true,
config: {
services: {
youtube: true,
coub: true,
}
}
},
personality: {
class: Personality,
config: {
endpoint: 'http://localhost:8008/uploadFile' // Your backend file uploader endpoint
}
},
table: {
class: Table,
inlineToolbar: true,
},
quote: {
class: Quote,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+O',
config: {
quotePlaceholder: 'Enter a quote',
captionPlaceholder: 'Quote\'s author',
},
},
list: {
class: List,
inlineToolbar: true,
},
warning: {
class: Warning,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+W',
config: {
titlePlaceholder: 'Title',
messagePlaceholder: 'Message',
},
},
checklist: {
class: Checklist,
inlineToolbar: true,
},
delimiter: Delimiter,
},
/**
* Previously saved data that should be rendered
*/
data: {}
});
JS
)
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment