Javascript canvas editor based on konva.js (https://konvajs.org/)
npm install pvr-ajte-canvas-editorInstall via npm:
``shell`
$ npm install pvr-ajte-canvas-editor
Install via yarn:
`shell`
$ yarn add pvr-ajte-canvas-editor
Include code and style:
`js
import 'pvr-ajte-canvas-editor/ajteditor.scss';
import JTEEditor from 'pvr-ajte-canvas-editor';
const AJTEAdminEditor = AJTEEditor.AJTEAdminEditor;
const AJTEUserEditor = AJTEEditor.AJTEUserEditor;
`
---
> Please take into consideration to use the modern version and add polyfills later to your final bundle!
> (Or better: give a hint to users that they should use the latest browsers).
> Browsers such as IE are not supported (at least not officially).
`html
`
`javascript
import FontFaceObserver from 'fontfaceobserver';
document.addEventListener('DOMContentLoaded', function () {
var fontA = new FontFaceObserver('Akaya Telivigala');
var ajteEditor = new AJTEAdminEditor({
containerOffset: {
x: 0,
y: 70
},
saveInfo: {
requestHeaders: [
{'X-CSRF-TOKEN': csrf}
],
url: "path/to/controllers/which/save/templates",
},
scriptUrl: "path/to/module",
code: code,
title: title,
category: category,
templateId: templateId,
cb:{
image_cb: function(){
console.log('image is loaded then user used Image element')
},
after_create_cb: function(templateId){
console.log('editor elements are loaded')
},
success_cb: function(message){
console.log('success callback')
},
error_cb: function(message){
console.log('error callback')
},
init_cb: function(){
console.log('editor inited elements')
afterInit()
}
}
});
function afterInit(){
fontA.load().then(function () {
ajteEditor.addFont('Akaya Telivigala');
});
}
});
``html
You can use FontFaceObserver only if you are going to load font.
You can get more information from example https://github.com/povverster/AJTE-canvas-editor/example