From 66ac3a52f58d9a7995adfaee60d8e347bdf7dc1d Mon Sep 17 00:00:00 2001 From: Mike Ungers Date: Wed, 17 Feb 2021 12:03:26 +0100 Subject: [PATCH] added support for multi line comments --- src/controllers/postil.js | 44 ++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/controllers/postil.js b/src/controllers/postil.js index 68b1aac..5f75177 100644 --- a/src/controllers/postil.js +++ b/src/controllers/postil.js @@ -227,9 +227,15 @@ const luckysheetPostil = { let size = _this.getArrowCanvasSize(fromX, fromY, toX, toY); + let commentDivs = ''; + let valueLines = value.split('\n'); + for (let line of valueLines) { + commentDivs += '
' + _this.htmlEscape(line) + '
'; + } + let html = '
' + '' + - '
'+ _this.htmlEscape(value) +'
' + + '
'+ commentDivs +'
' + '
'; $(html).appendTo($("#luckysheet-cell-main")); @@ -371,6 +377,12 @@ const luckysheetPostil = { let size = _this.getArrowCanvasSize(left, top, toX, toY); + let commentDivs = ''; + let valueLines = value.split('\n'); + for (let line of valueLines) { + commentDivs += '
' + _this.htmlEscape(line) + '
'; + } + let html = '
' + '' + '
' + @@ -392,7 +404,7 @@ const luckysheetPostil = { '
' + '
' + '
' + - _this.htmlEscape(value) + + commentDivs + '
' + '
' + '
' + @@ -543,6 +555,12 @@ const luckysheetPostil = { let size = _this.getArrowCanvasSize(left, top, toX, toY); + let commentDivs = ''; + let valueLines = value.split('\n'); + for (let line of valueLines) { + commentDivs += '
' + _this.htmlEscape(line) + '
'; + } + let html = '
' + '' + '
' + @@ -564,7 +582,7 @@ const luckysheetPostil = { '
' + '
' + '
' + - _this.htmlEscape(value) + + commentDivs + '
' + '
' + '
' + @@ -664,7 +682,11 @@ const luckysheetPostil = { } let size = _this.getArrowCanvasSize(left, top, toX, toY); - + let commentDivs = ''; + let valueLines = value.split('\n'); + for (let line of valueLines) { + commentDivs += '
' + _this.htmlEscape(line) + '
'; + } let html = '
' + '' + '
' + @@ -686,7 +708,7 @@ const luckysheetPostil = { '
' + '
' + '
' + - _this.htmlEscape(value) + + commentDivs + '
' + '
' + '
' + @@ -789,6 +811,12 @@ const luckysheetPostil = { let size = _this.getArrowCanvasSize(left, top, toX, toY); + let commentDivs = ''; + let valueLines = value.split('\n'); + for (let line of valueLines) { + commentDivs += '
' + _this.htmlEscape(line) + '
'; + } + let html = '
' + '' + '
' + @@ -810,7 +838,7 @@ const luckysheetPostil = { '
' + '
' + '
' + - _this.htmlEscape(value) + + commentDivs + '
' + '
' + '
' + @@ -840,8 +868,8 @@ const luckysheetPostil = { let r = id.split("luckysheet-postil-show_")[1].split("_")[0]; let c = id.split("luckysheet-postil-show_")[1].split("_")[1]; - let value = $("#" + id).find(".formulaInputFocus").text(); - + // interpret
as new line + let value = $("#" + id).find(".formulaInputFocus").html().replaceAll('
', '\n').replaceAll(/<(.*)>.*?|<(.*) \/>/g, '').trim(); // Hook function if(!method.createHookFunction('commentUpdateBefore',r,c,value)){ return;