TF-3944 Remove line-height = 1px when drag & drop
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -17,14 +17,14 @@ class HtmlUtils {
|
|||||||
static final random = Random();
|
static final random = Random();
|
||||||
static final htmlUnescape = HtmlUnescape();
|
static final htmlUnescape = HtmlUnescape();
|
||||||
|
|
||||||
static const lineHeight100Percent = (
|
static const removeLineHeight1px = (
|
||||||
script: '''
|
script: '''
|
||||||
document.querySelectorAll("*")
|
document.querySelectorAll('[style*="line-height"]').forEach(el => {
|
||||||
.forEach((element) => {
|
if (el.style.lineHeight === "1px") {
|
||||||
if (element.style.lineHeight !== "normal")
|
el.style.removeProperty("line-height");
|
||||||
element.style.lineHeight = "100%";
|
}
|
||||||
});''',
|
});''',
|
||||||
name: 'lineHeight100Percent');
|
name: 'removeLineHeight1px');
|
||||||
|
|
||||||
static const registerDropListener = (
|
static const registerDropListener = (
|
||||||
script: '''
|
script: '''
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class _WebEditorState extends State<WebEditorWidget> {
|
|||||||
_dropListener = (event) {
|
_dropListener = (event) {
|
||||||
if (event is MessageEvent) {
|
if (event is MessageEvent) {
|
||||||
if (jsonDecode(event.data)['name'] == HtmlUtils.registerDropListener.name) {
|
if (jsonDecode(event.data)['name'] == HtmlUtils.registerDropListener.name) {
|
||||||
_editorController.evaluateJavascriptWeb(HtmlUtils.lineHeight100Percent.name);
|
_editorController.evaluateJavascriptWeb(HtmlUtils.removeLineHeight1px.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -143,8 +143,8 @@ class _WebEditorState extends State<WebEditorWidget> {
|
|||||||
normalizeHtmlTextWhenPasting: true,
|
normalizeHtmlTextWhenPasting: true,
|
||||||
webInitialScripts: UnmodifiableListView([
|
webInitialScripts: UnmodifiableListView([
|
||||||
WebScript(
|
WebScript(
|
||||||
name: HtmlUtils.lineHeight100Percent.name,
|
name: HtmlUtils.removeLineHeight1px.name,
|
||||||
script: HtmlUtils.lineHeight100Percent.script,
|
script: HtmlUtils.removeLineHeight1px.script,
|
||||||
),
|
),
|
||||||
WebScript(
|
WebScript(
|
||||||
name: HtmlUtils.registerDropListener.name,
|
name: HtmlUtils.registerDropListener.name,
|
||||||
@@ -181,7 +181,7 @@ class _WebEditorState extends State<WebEditorWidget> {
|
|||||||
onChangeCodeview: widget.onChangeContent,
|
onChangeCodeview: widget.onChangeContent,
|
||||||
onTextFontSizeChanged: widget.onEditorTextSizeChanged,
|
onTextFontSizeChanged: widget.onEditorTextSizeChanged,
|
||||||
onPaste: () => _editorController.evaluateJavascriptWeb(
|
onPaste: () => _editorController.evaluateJavascriptWeb(
|
||||||
HtmlUtils.lineHeight100Percent.name
|
HtmlUtils.removeLineHeight1px.name
|
||||||
),
|
),
|
||||||
onDragEnter: widget.onDragEnter,
|
onDragEnter: widget.onDragEnter,
|
||||||
onDragOver: widget.onDragOver,
|
onDragOver: widget.onDragOver,
|
||||||
|
|||||||
Reference in New Issue
Block a user