Skip to content

Commit

Permalink
fix: section popup text too long
Browse files Browse the repository at this point in the history
change: remove eval
  • Loading branch information
xiangyu committed May 23, 2022
1 parent 5e8a687 commit e9442aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ class AddonEvents extends AddonBase {

let _newLine: string = "";
try {
eval("_newLine = `" + templateText + "`");
_newLine = new Function("return `" + templateText + "`")();
} catch (e) {
alert(e);
return;
Expand Down Expand Up @@ -815,7 +815,10 @@ class AddonEvents extends AddonBase {

let _newLine: string = "";
try {
eval("_newLine = `" + templateText + "`");
_newLine = new Function(
"topItem, itemNotes, copyNoteImage",
"return `" + templateText + "`"
)(topItem, itemNotes, copyNoteImage);
} catch (e) {
alert(e);
continue;
Expand Down Expand Up @@ -883,7 +886,10 @@ class AddonEvents extends AddonBase {
}</a></p>`;
let _newLine: string = "";
try {
eval("_newLine = `" + templateText + "`");
_newLine = new Function(
"noteItem, topItem, link",
"return `" + templateText + "`"
)(noteItem, topItem, link);
} catch (e) {
alert(e);
continue;
Expand Down
5 changes: 4 additions & 1 deletion src/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ class AddonViews extends AddonBase {
);
button.setAttribute("id", buttonParam.id);
button.setAttribute("eventType", buttonParam.eventType);
button.innerHTML = buttonParam.text;
button.innerHTML =
buttonParam.text.length > 30
? `${buttonParam.text.slice(0, 30)}...`
: buttonParam.text;
popup.append(button);
const message = new EditorMessage("", {
itemID: editorInstances._item.id,
Expand Down

0 comments on commit e9442aa

Please sign in to comment.