mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
WYSIWYG: Updated code handling to respect direction
Specifically supports "dir" attribute being on top level "pre" element, and handles application/switching of this within the editor. For #4809
This commit is contained in:
@ -205,6 +205,11 @@ function register(editor) {
|
||||
contenteditable: 'false',
|
||||
});
|
||||
|
||||
const direction = el.attr('dir');
|
||||
if (direction) {
|
||||
wrapper.attr('dir', direction);
|
||||
}
|
||||
|
||||
const spans = el.getAll('span');
|
||||
for (const span of spans) {
|
||||
span.unwrap();
|
||||
@ -222,6 +227,13 @@ function register(editor) {
|
||||
|
||||
editor.serializer.addNodeFilter('code-block', elms => {
|
||||
for (const el of elms) {
|
||||
const direction = el.attr('dir');
|
||||
if (direction && el.firstChild) {
|
||||
el.firstChild.attr('dir', direction);
|
||||
} else if (el.firstChild) {
|
||||
el.firstChild.attr('dir', null);
|
||||
}
|
||||
|
||||
el.unwrap();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user