From e42dc525ca532b8945dc4e45aaae6f4d9adb811f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 27 Oct 2023 12:41:16 +0800 Subject: [PATCH 1/4] update expensify-common --- package-lock.json | 12 ++++++------ package.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index f852bc4ddee4..09eece0a894d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,7 +51,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#2adc24c4e889b3a15f199a6b273e343c7d9cff78", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#82bfcd1cb077afd03d1c8c069618c7dd5bd405d8", "fbjs": "^3.0.2", "htmlparser2": "^7.2.0", "idb-keyval": "^6.2.1", @@ -30219,8 +30219,8 @@ }, "node_modules/expensify-common": { "version": "1.0.0", - "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#2adc24c4e889b3a15f199a6b273e343c7d9cff78", - "integrity": "sha512-O7XTAfJoCHiFof+X5oFcCgAZAVVJbdIZ+ANA3WBlvabxcPqN0c+dGxIroV8HlRBbTNAkD3CoDVoF61YBUOxCUg==", + "resolved": "git+ssh://git@github.com/Expensify/expensify-common.git#82bfcd1cb077afd03d1c8c069618c7dd5bd405d8", + "integrity": "sha512-Pvji3XqRyCbhgaKLVPT0HfRl/cazGStQeo8V6tWcU1n3UNiG/6Qey4jAdfN8WQZlfslrSzFiZTWrD7UT0JeRrQ==", "license": "MIT", "dependencies": { "classnames": "2.3.1", @@ -74832,9 +74832,9 @@ } }, "expensify-common": { - "version": "git+ssh://git@github.com/Expensify/expensify-common.git#2adc24c4e889b3a15f199a6b273e343c7d9cff78", - "integrity": "sha512-O7XTAfJoCHiFof+X5oFcCgAZAVVJbdIZ+ANA3WBlvabxcPqN0c+dGxIroV8HlRBbTNAkD3CoDVoF61YBUOxCUg==", - "from": "expensify-common@git+ssh://git@github.com/Expensify/expensify-common.git#2adc24c4e889b3a15f199a6b273e343c7d9cff78", + "version": "git+ssh://git@github.com/Expensify/expensify-common.git#82bfcd1cb077afd03d1c8c069618c7dd5bd405d8", + "integrity": "sha512-Pvji3XqRyCbhgaKLVPT0HfRl/cazGStQeo8V6tWcU1n3UNiG/6Qey4jAdfN8WQZlfslrSzFiZTWrD7UT0JeRrQ==", + "from": "expensify-common@git+ssh://git@github.com/Expensify/expensify-common.git#82bfcd1cb077afd03d1c8c069618c7dd5bd405d8", "requires": { "classnames": "2.3.1", "clipboard": "2.0.4", diff --git a/package.json b/package.json index a5d189bf943c..4ce5a999c254 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#2adc24c4e889b3a15f199a6b273e343c7d9cff78", + "expensify-common": "git+ssh://git@github.com/Expensify/expensify-common.git#82bfcd1cb077afd03d1c8c069618c7dd5bd405d8", "fbjs": "^3.0.2", "htmlparser2": "^7.2.0", "idb-keyval": "^6.2.1", From 59381e1d4d6f6877fbeb5bc63c763b7fdf3a8773 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 27 Oct 2023 12:41:36 +0800 Subject: [PATCH 2/4] only rename the element tag if it's a markdown element --- src/libs/SelectionScraper/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/SelectionScraper/index.js b/src/libs/SelectionScraper/index.js index 44b87deba796..ff62f66e9096 100644 --- a/src/libs/SelectionScraper/index.js +++ b/src/libs/SelectionScraper/index.js @@ -4,7 +4,7 @@ import _ from 'underscore'; import Str from 'expensify-common/lib/str'; import CONST from '../../CONST'; -const elementsWillBeSkipped = ['html', 'body']; +const markdownElements = ['h1', 'strong', 'em', 'del', 'blockquote', 'code', 'pre', 'a', 'br']; const tagAttribute = 'data-testid'; /** @@ -111,10 +111,9 @@ const replaceNodes = (dom, isChildOfEditorElement) => { data = Str.htmlEncode(dom.data); } - // We are skipping elements which has html and body in data-testid, since ExpensiMark can't parse it. Also this data - // has no meaning for us. if (dom.attribs && dom.attribs[tagAttribute]) { - if (!elementsWillBeSkipped.includes(dom.attribs[tagAttribute])) { + // If it's a markdown element, rename it according to the value of data-testid, so ExpensiMark can parse it + if (markdownElements.includes(dom.attribs[tagAttribute])) { domName = dom.attribs[tagAttribute]; } } else if (dom.name === 'div' && dom.children.length === 1 && isChildOfEditorElement) { From dd2b6c2af41f9a8f4a3afad96273b83d16a9a53f Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 27 Oct 2023 13:27:28 +0800 Subject: [PATCH 3/4] add more md elements --- src/libs/SelectionScraper/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SelectionScraper/index.js b/src/libs/SelectionScraper/index.js index ff62f66e9096..7a7ef4b79bf9 100644 --- a/src/libs/SelectionScraper/index.js +++ b/src/libs/SelectionScraper/index.js @@ -4,7 +4,7 @@ import _ from 'underscore'; import Str from 'expensify-common/lib/str'; import CONST from '../../CONST'; -const markdownElements = ['h1', 'strong', 'em', 'del', 'blockquote', 'code', 'pre', 'a', 'br']; +const markdownElements = ['h1', 'strong', 'em', 'del', 'blockquote', 'code', 'pre', 'a', 'br', 'li', 'ul', 'ol', 'b', 'i', 's']; const tagAttribute = 'data-testid'; /** From 6ce72af97f871564f778a6ef915e9eabdae385b9 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Fri, 27 Oct 2023 14:36:23 +0800 Subject: [PATCH 4/4] add more md elements --- src/libs/SelectionScraper/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SelectionScraper/index.js b/src/libs/SelectionScraper/index.js index 7a7ef4b79bf9..389ef9aaf8da 100644 --- a/src/libs/SelectionScraper/index.js +++ b/src/libs/SelectionScraper/index.js @@ -4,7 +4,7 @@ import _ from 'underscore'; import Str from 'expensify-common/lib/str'; import CONST from '../../CONST'; -const markdownElements = ['h1', 'strong', 'em', 'del', 'blockquote', 'code', 'pre', 'a', 'br', 'li', 'ul', 'ol', 'b', 'i', 's']; +const markdownElements = ['h1', 'strong', 'em', 'del', 'blockquote', 'q', 'code', 'pre', 'a', 'br', 'li', 'ul', 'ol', 'b', 'i', 's']; const tagAttribute = 'data-testid'; /**