mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-25 16:19:59 +08:00
Added base RTL support
For #939 - Adds way to check if current language is RTL via config system. - Made TinyMCE default direction be based on current language text direction. - Fixed bullet points to be RTL compatible. - Set page content body to have direction based on content.
This commit is contained in:
@ -8,6 +8,7 @@ class MarkdownEditor {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.textDirection = document.getElementById('page-editor').getAttribute('text-direction');
|
||||
this.markdown = new MarkdownIt({html: true});
|
||||
this.markdown.use(mdTasksLists, {label: true});
|
||||
|
||||
@ -98,6 +99,9 @@ class MarkdownEditor {
|
||||
|
||||
codeMirrorSetup() {
|
||||
let cm = this.cm;
|
||||
// Text direction
|
||||
// cm.setOption('direction', this.textDirection);
|
||||
cm.setOption('direction', 'ltr'); // Will force to remain as ltr for now due to issues when HTML is in editor.
|
||||
// Custom key commands
|
||||
let metaKey = code.getMetaKey();
|
||||
const extraKeys = {};
|
||||
|
@ -370,6 +370,7 @@ class WysiwygEditor {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.textDirection = document.getElementById('page-editor').getAttribute('text-direction');
|
||||
|
||||
this.plugins = "image table textcolor paste link autolink fullscreen imagetools code customhr autosave lists codeeditor media";
|
||||
this.loadPlugins();
|
||||
@ -385,6 +386,14 @@ class WysiwygEditor {
|
||||
drawIoPlugin();
|
||||
this.plugins += ' drawio';
|
||||
}
|
||||
if (this.textDirection === 'rtl') {
|
||||
this.plugins += ' directionality'
|
||||
}
|
||||
}
|
||||
|
||||
getToolBar() {
|
||||
const textDirPlugins = this.textDirection === 'rtl' ? 'ltr rtl' : '';
|
||||
return `undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr drawio media | removeformat code ${textDirPlugins} fullscreen`
|
||||
}
|
||||
|
||||
getTinyMceConfig() {
|
||||
@ -397,6 +406,7 @@ class WysiwygEditor {
|
||||
body_class: 'page-content',
|
||||
browser_spellcheck: true,
|
||||
relative_urls: false,
|
||||
directionality : this.textDirection,
|
||||
remove_script_host: false,
|
||||
document_base_url: window.baseUrl('/'),
|
||||
statusbar: false,
|
||||
@ -407,7 +417,7 @@ class WysiwygEditor {
|
||||
valid_children: "-div[p|h1|h2|h3|h4|h5|h6|blockquote],+div[pre],+div[img]",
|
||||
plugins: this.plugins,
|
||||
imagetools_toolbar: 'imageoptions',
|
||||
toolbar: "undo redo | styleselect | bold italic underline strikethrough superscript subscript | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image-insert link hr drawio media | removeformat code fullscreen",
|
||||
toolbar: this.getToolBar(),
|
||||
content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}",
|
||||
style_formats: [
|
||||
{title: "Header Large", format: "h2"},
|
||||
|
Reference in New Issue
Block a user