Files
classroomio/src/lib/components/TextEditor/index.svelte
T

42 lines
1.2 KiB
Svelte
Raw Normal View History

2020-12-29 04:01:30 +02:00
<script>
2023-09-05 13:21:44 +00:00
import { PUBLIC_TINYMCE_API_KEY } from '$env/static/public';
import Editor from '@tinymce/tinymce-svelte';
2020-12-29 04:01:30 +02:00
2023-09-05 13:21:44 +00:00
export let value;
export let onChange = (html = '') => {};
export let height = 300;
export let placeholder = '';
export let editorWindowRef;
2020-12-29 04:01:30 +02:00
2023-09-05 13:21:44 +00:00
const apiKey = PUBLIC_TINYMCE_API_KEY;
// editor configuration
let conf = {
plugins: 'lists',
toolbar: [
{ name: 'history', items: ['undo', 'redo'] },
{ name: 'styles', items: ['styles'] },
{ name: 'formatting', items: ['bold', 'italic'] },
{ name: 'alignment', items: ['alignleft', 'aligncenter', 'alignright', 'alignjustify'] },
{ name: 'indentation', items: ['outdent', 'indent'] },
{ name: 'list', items: ['numlist', 'bullist'] }
],
lists_indent_on_tab: false,
min_height: height,
placeholder: placeholder,
init_instance_callback: function (editor) {
editorWindowRef = editor.iframeElement?.contentWindow;
editor.on('Input', function (e) {
const html = editor.getContent();
if (onChange) {
onChange(html);
}
});
}
2021-05-08 11:47:18 +03:00
};
2020-12-29 04:01:30 +02:00
</script>
2023-09-05 13:21:44 +00:00
<div>
<Editor onIni {value} {apiKey} {conf} />
2021-05-08 11:47:18 +03:00
</div>