mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Added BIDI to Squire #1158
This commit is contained in:
parent
43d885b922
commit
3b682f5811
2 changed files with 30 additions and 18 deletions
12
dev/External/SquireUI.js
vendored
12
dev/External/SquireUI.js
vendored
|
|
@ -110,6 +110,18 @@ class SquireUI
|
|||
fontSize: {
|
||||
select: ['11px','13px','16px','20px','24px','30px'],
|
||||
cmd: s => squire.setStyle({ fontSize: s.value })
|
||||
},
|
||||
dir: {
|
||||
select: [
|
||||
['LTR','ltr'],
|
||||
['RTL','rtl'],
|
||||
['Auto','auto'],
|
||||
['',''],
|
||||
],
|
||||
cmd: s => {
|
||||
squire.setAttribute('dir', s.value || null);
|
||||
// squire.setStyle({ 'unicode-bidi': 'plaintext' });
|
||||
}
|
||||
}
|
||||
},
|
||||
colors: {
|
||||
|
|
|
|||
36
vendors/squire/build/squire-raw.js
vendored
36
vendors/squire/build/squire-raw.js
vendored
|
|
@ -196,12 +196,16 @@ const
|
|||
return frag;
|
||||
},
|
||||
|
||||
setStyle = (node, style) => {
|
||||
if (typeof style === 'object') {
|
||||
Object.entries(style).forEach(([k,v]) => node.style[k] = v);
|
||||
} else if (style !== undefined) {
|
||||
node.setAttribute('style', style);
|
||||
}
|
||||
setAttributes = (node, props) => {
|
||||
props && Object.entries(props).forEach(([k,v]) => {
|
||||
if ('style' === k && typeof v === 'object') {
|
||||
Object.entries(v).forEach(([k,v]) => node.style[k] = v);
|
||||
} else if (v != null) {
|
||||
node.setAttribute(k, v);
|
||||
} else {
|
||||
node.removeAttribute(k);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
createElement = (tag, props, children) => {
|
||||
|
|
@ -210,13 +214,7 @@ const
|
|||
children = props;
|
||||
props = null;
|
||||
}
|
||||
props && Object.entries(props).forEach(([k,v]) => {
|
||||
if ('style' === k) {
|
||||
setStyle(el, v);
|
||||
} else if (v !== undefined) {
|
||||
el.setAttribute(k, v);
|
||||
}
|
||||
});
|
||||
setAttributes(el, props);
|
||||
children && el.append(...children);
|
||||
return el;
|
||||
},
|
||||
|
|
@ -3520,13 +3518,17 @@ class Squire
|
|||
}
|
||||
|
||||
setStyle(style) {
|
||||
this.setAttribute('style', style);
|
||||
}
|
||||
|
||||
setAttribute(name, value) {
|
||||
let range = this.getSelection();
|
||||
let start = range?.startContainer || {};
|
||||
let end = range ? range.endContainer : 0;
|
||||
// When the selection is all the text inside an element, set style on the element itself
|
||||
if (TEXT_NODE === start?.nodeType && 0 === range.startOffset && start === end && end.length === range.endOffset) {
|
||||
if ('dir' == name || (TEXT_NODE === start?.nodeType && 0 === range.startOffset && start === end && end.length === range.endOffset)) {
|
||||
this.saveUndoState(range);
|
||||
setStyle(start.parentNode, style);
|
||||
setAttributes(start.parentNode, {[name]: value});
|
||||
this.setSelection(range);
|
||||
this._updatePath(range, true);
|
||||
}
|
||||
|
|
@ -3534,9 +3536,7 @@ class Squire
|
|||
else {
|
||||
this.changeFormat({
|
||||
tag: 'SPAN',
|
||||
attributes: {
|
||||
style: style
|
||||
}
|
||||
attributes: {[name]: value}
|
||||
}, null, range);
|
||||
}
|
||||
return this.focus();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue