Last active
July 8, 2020 22:42
-
-
Save 3cp/8957ab6d8c6b4fb04341f6ef228e6070 to your computer and use it in GitHub Desktop.
au1 ckeditor5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Dumber Gist</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"> | |
<base href="/"> | |
</head> | |
<!-- | |
Dumber gist uses dumber bundler, the default bundle file | |
is /dist/entry-bundle.js. | |
The starting module is pointed to aurelia-bootstrapper | |
(data-main attribute on script) for Aurelia, | |
The aurelia bootstrapper then loads up user module "main" | |
(aurelia-app attribute on <body>) which is your src/main.js. | |
--> | |
<body aurelia-app="main"> | |
<script src="/dist/entry-bundle.js" data-main="aurelia-bootstrapper"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"aurelia-bootstrapper": "^2.3.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<require from="./rich-editor"></require> | |
<rich-editor value.bind="text"></rich-editor> | |
<hr> | |
<h4>The raw edited text:</h4> | |
<pre>${text}</pre> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
text = 'Hello Aurelia!'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging('info'); | |
aurelia.start().then(() => aurelia.setRoot()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<text-area ref="textArea"></text-area> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {bindable, bindingMode} from 'aurelia-framework'; | |
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; | |
export class RichEditor { | |
@bindable({defaultBindingMode: bindingMode.twoWay}) value = ''; | |
editor = null; | |
attached() { | |
this._clearCKEditor(); | |
ClassicEditor.create(this.textArea, { | |
removePlugins: ['CKFinderUploadAdapter', 'EasyImage', 'ImageCaption', 'ImgeStyle', 'ImageToolbar', 'ImageUpload', 'MediaEmbed'] | |
}) | |
.then( | |
editor => { | |
this.editor = editor; | |
this.editor.setData(this.value); | |
this.editor.model.document.on('change', () => { | |
this.value = this.editor.getData(); | |
}); | |
}, | |
err => this.bcx.showError(err) | |
); | |
} | |
detached() { | |
this._clearCKEditor(); | |
} | |
_clearCKEditor() { | |
if (this.editor) { | |
this.editor.destroy(); | |
this.editor = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment