Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed Nov 23, 2024
1 parent 8bccd87 commit de6cafd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
10 changes: 3 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
"enabled": true,
"rules": {
"style": {
"useTemplate": "off",
"useSingleVarDeclarator": "off",
"useSelfClosingElements": "off"
"useTemplate": "off"
},
"correctness": {
"useExhaustiveDependencies": "off"
Expand All @@ -27,12 +25,10 @@
},
"suspicious": {
"noExplicitAny": "off",
"noArrayIndexKey": "off",
"noEmptyInterface": "off"
"noArrayIndexKey": "off"
},
"complexity": {
"useRegexLiterals": "off",
"noForEach": "off"
"useRegexLiterals": "off"
},
"performance": {
"noDelete": "off"
Expand Down
14 changes: 7 additions & 7 deletions src/main/core/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,21 @@ const attach = async (settings, dialog, doUpdateContent) => {

const setDialogEvents = (dialog) => {
dialog.addEventListener("mouseenter", (e) => {
e.target.querySelectorAll("[data-md-pronunciation]").forEach((elem) => {
for (const elem of e.target.querySelectorAll("[data-md-pronunciation]")) {
if (elem.dataset.mdPronunciationSet) {
return;
continue;
}
elem.dataset.mdPronunciationSet = "true";
elem.addEventListener("click", () => sound.pronounce(elem.dataset.mdPronunciation));
});
e.target.querySelectorAll("[data-md-hovervisible]").forEach((elem) => {
}
for (const elem of e.target.querySelectorAll("[data-md-hovervisible]")) {
elem.style.visibility = "visible";
});
}
});
dialog.addEventListener("mouseleave", (e) => {
e.target.querySelectorAll("[data-md-hovervisible]").forEach((elem) => {
for (const elem of e.target.querySelectorAll("[data-md-hovervisible]")) {
elem.style.visibility = "hidden";
});
}
});
};

Expand Down
24 changes: 11 additions & 13 deletions src/main/lib/traverser.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,20 @@ class Traverser {
const code = sourceText.charCodeAt(offset);
const isEnglish = isEnglishLikeCharacter(code);

let startIndex, endIndex, text, subText;
if (isEnglish) {
startIndex = searchStartIndex(sourceText, offset, this.getTargetCharacterType);
endIndex = searchEndIndex(sourceText, offset, this.maxWords, this.getTargetCharacterType);
text = sourceText.substring(startIndex, endIndex);
} else {
startIndex = offset;
endIndex = offset + this.JA_MAX_LENGTH;
const startIndex = searchStartIndex(sourceText, offset, this.getTargetCharacterType);
const endIndex = searchEndIndex(sourceText, offset, this.maxWords, this.getTargetCharacterType);
const text = sourceText.substring(startIndex, endIndex);
const end = endIndex >= sourceText.length;
return { text, undefined, end, isEnglish };
}

const properStartIndex = retrieveProperStartIndex(sourceText, startIndex + 1);
text = sourceText.substring(properStartIndex, endIndex);
const startIndex = offset;
const endIndex = offset + this.JA_MAX_LENGTH;
const properStartIndex = retrieveProperStartIndex(sourceText, startIndex + 1);
const text = sourceText.substring(properStartIndex, endIndex);

if (startIndex !== properStartIndex) {
subText = sourceText.substring(startIndex, endIndex);
}
}
const subText = startIndex !== properStartIndex ? sourceText.substring(startIndex, endIndex) : undefined;
const end = endIndex >= sourceText.length;
return { text, subText, end, isEnglish };
}
Expand Down
4 changes: 2 additions & 2 deletions src/options/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ const App = () => {

switch (mode) {
case "loading":
return <div></div>;
return <div />;
case "options":
return <Main />;
case "pdf":
return <div></div>;
return <div />;
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/options/component/atom/EditableSpan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export const EditableSpan: React.FC<Props> = (props) => {
setEditable(false);
}
}}
></input>
/>
);
};

0 comments on commit de6cafd

Please sign in to comment.