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 htmlUnescape = HtmlUnescape();
|
||||
|
||||
static const lineHeight100Percent = (
|
||||
static const removeLineHeight1px = (
|
||||
script: '''
|
||||
document.querySelectorAll("*")
|
||||
.forEach((element) => {
|
||||
if (element.style.lineHeight !== "normal")
|
||||
element.style.lineHeight = "100%";
|
||||
});''',
|
||||
name: 'lineHeight100Percent');
|
||||
document.querySelectorAll('[style*="line-height"]').forEach(el => {
|
||||
if (el.style.lineHeight === "1px") {
|
||||
el.style.removeProperty("line-height");
|
||||
}
|
||||
});''',
|
||||
name: 'removeLineHeight1px');
|
||||
|
||||
static const registerDropListener = (
|
||||
script: '''
|
||||
|
||||
@@ -89,7 +89,7 @@ class _WebEditorState extends State<WebEditorWidget> {
|
||||
_dropListener = (event) {
|
||||
if (event is MessageEvent) {
|
||||
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,
|
||||
webInitialScripts: UnmodifiableListView([
|
||||
WebScript(
|
||||
name: HtmlUtils.lineHeight100Percent.name,
|
||||
script: HtmlUtils.lineHeight100Percent.script,
|
||||
name: HtmlUtils.removeLineHeight1px.name,
|
||||
script: HtmlUtils.removeLineHeight1px.script,
|
||||
),
|
||||
WebScript(
|
||||
name: HtmlUtils.registerDropListener.name,
|
||||
@@ -181,7 +181,7 @@ class _WebEditorState extends State<WebEditorWidget> {
|
||||
onChangeCodeview: widget.onChangeContent,
|
||||
onTextFontSizeChanged: widget.onEditorTextSizeChanged,
|
||||
onPaste: () => _editorController.evaluateJavascriptWeb(
|
||||
HtmlUtils.lineHeight100Percent.name
|
||||
HtmlUtils.removeLineHeight1px.name
|
||||
),
|
||||
onDragEnter: widget.onDragEnter,
|
||||
onDragOver: widget.onDragOver,
|
||||
|
||||
Reference in New Issue
Block a user