Skip to content

Commit

Permalink
fix incorrect pasted text on copied HTML snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
b1tjoy committed Nov 28, 2022
1 parent e82bcf6 commit 5310f7c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/CopySelectionHelper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import Str from 'expensify-common/lib/str';
import CONST from '../CONST';
import KeyboardShortcut from '../libs/KeyboardShortcut';
import Clipboard from '../libs/Clipboard';
Expand Down Expand Up @@ -35,7 +36,7 @@ class CopySelectionHelper extends React.Component {
Clipboard.setString(parser.htmlToMarkdown(selection));
return;
}
Clipboard.setHtml(selection, parser.htmlToText(selection));
Clipboard.setHtml(selection, Str.htmlDecode(parser.htmlToText(selection)));
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SelectionScraper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const getCurrentSelection = () => {
const domRepresentation = parseDocument(getHTMLOfSelection());
domRepresentation.children = _.map(domRepresentation.children, replaceNodes);

const newHtml = Str.htmlDecode(render(domRepresentation));
const newHtml = render(domRepresentation);
return newHtml || '';
};

Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'underscore';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import * as Expensicons from '../../../../components/Icon/Expensicons';
import * as Report from '../../../../libs/actions/Report';
Expand Down Expand Up @@ -109,7 +110,7 @@ export default [
if (!Clipboard.canSetHtml()) {
Clipboard.setString(parser.htmlToMarkdown(content));
} else {
Clipboard.setHtml(content, parser.htmlToText(content));
Clipboard.setHtml(content, Str.htmlDecode(parser.htmlToText(content)));
}
}
} else {
Expand Down

0 comments on commit 5310f7c

Please sign in to comment.