mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Redesign WYSIWYG handling to allow any editor (quill, tiny, etc. etc.)
This commit is contained in:
parent
e6db60e76c
commit
9eb5646aec
12 changed files with 180 additions and 51 deletions
82
plugins/wysiwyg-example/example.js
Normal file
82
plugins/wysiwyg-example/example.js
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
(rl => {
|
||||
class Example
|
||||
{
|
||||
constructor(owner, editor) {
|
||||
this.mode = 'wysiwyg';
|
||||
this.owner = owner;
|
||||
this.editor = editor;
|
||||
console.dir({editor});
|
||||
}
|
||||
|
||||
setMode(mode) {
|
||||
console.log(`WYSIWYG-Example.setMode(${mode})`);
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
on(type, fn) {
|
||||
console.log(`WYSIWYG-Example.on(${type}, ${fn})`);
|
||||
}
|
||||
|
||||
execCommand(cmd, cfg) {
|
||||
console.log(`WYSIWYG-Example.execCommand(${cmd}, ${cfg})`);
|
||||
/*
|
||||
execCommand('insertSignature', {
|
||||
clearCache: true
|
||||
}));
|
||||
|
||||
execCommand('insertSignature', {
|
||||
isHtml: html,
|
||||
insertBefore: insertBefore,
|
||||
signature: signature
|
||||
}));
|
||||
*/
|
||||
}
|
||||
|
||||
getData() {
|
||||
console.log(`WYSIWYG-Example.getData()`);
|
||||
return this.editor.innerHTML;
|
||||
}
|
||||
|
||||
setData(html) {
|
||||
console.log(`WYSIWYG-Example.setData(${html})`);
|
||||
this.editor.innerHTML = html;
|
||||
}
|
||||
|
||||
getPlainData() {
|
||||
console.log(`WYSIWYG-Example.getPlainData()`);
|
||||
return this.editor.innerText;
|
||||
}
|
||||
|
||||
setPlainData(text) {
|
||||
console.log(`WYSIWYG-Example.setPlainData(${text})`);
|
||||
return this.editor.textContent = text;
|
||||
}
|
||||
|
||||
blur() {
|
||||
console.log(`WYSIWYG-Example.blur()`);
|
||||
this.editor.blur();
|
||||
}
|
||||
|
||||
focus() {
|
||||
console.log(`WYSIWYG-Example.focus()`);
|
||||
}
|
||||
}
|
||||
|
||||
if (rl) {
|
||||
const path = rl.settings.app('webVersionPath'),
|
||||
script = document.createElement('script');
|
||||
script.src = path + 'static/wysiwyg-example/example.min.js';
|
||||
document.head.append(script);
|
||||
|
||||
/**
|
||||
* owner = HtmlEditor
|
||||
* container = HTMLElement
|
||||
* onReady = callback(SMQuill)
|
||||
*/
|
||||
rl.registerWYSIWYG('Example', (owner, container, onReady) => {
|
||||
const editor = new Example(owner, container);
|
||||
onReady(editor);
|
||||
});
|
||||
}
|
||||
|
||||
})(window.rl);
|
||||
41
plugins/wysiwyg-example/index.php
Normal file
41
plugins/wysiwyg-example/index.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
class WysiwygQuillPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
const
|
||||
NAME = 'WYSIWYG Example',
|
||||
VERSION = '1.0',
|
||||
RELEASE = '2024-01-30',
|
||||
REQUIRED = '2.34.0',
|
||||
DESCRIPTION = 'Add Example as WYSIWYG editor option';
|
||||
|
||||
public function Init() : void
|
||||
{
|
||||
$path = APP_VERSION_ROOT_PATH . 'static/wysiwyg-example';
|
||||
|
||||
// Apache AH00037: Symbolic link not allowed or link target not accessible
|
||||
// That's why we clone the source
|
||||
if (!\is_dir($path)/* && !\is_link($path)*/) {
|
||||
$old_mask = umask(0022);
|
||||
// $active = \symlink(__DIR__ . '/src', $path);
|
||||
\mkdir($path, 0755);
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator(__DIR__ . '/static', \RecursiveDirectoryIterator::SKIP_DOTS),
|
||||
\RecursiveIteratorIterator::SELF_FIRST
|
||||
);
|
||||
foreach ($iterator as $item) {
|
||||
if ($item->isDir()) {
|
||||
\mkdir($path . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
||||
} else {
|
||||
\copy($item, $path . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
|
||||
}
|
||||
}
|
||||
umask($old_mask);
|
||||
}
|
||||
|
||||
if (\is_file("{$path}/example.min.js")) {
|
||||
// $this->addCss('style.css');
|
||||
$this->addJs('example.js');
|
||||
}
|
||||
}
|
||||
}
|
||||
1
plugins/wysiwyg-example/static/example.min.js
vendored
Normal file
1
plugins/wysiwyg-example/static/example.min.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
Loading…
Add table
Add a link
Reference in a new issue