feat: terms style
This commit is contained in:
@@ -52,6 +52,7 @@ export const matchRule = async (href, { injectRules, subrulesList }) => {
|
||||
"ignoreSelector",
|
||||
"terms",
|
||||
"aiTerms",
|
||||
"termsStyle",
|
||||
"selectStyle",
|
||||
"parentStyle",
|
||||
"grandStyle",
|
||||
@@ -136,6 +137,7 @@ export const checkRules = (rules) => {
|
||||
ignoreSelector,
|
||||
terms,
|
||||
aiTerms,
|
||||
termsStyle,
|
||||
selectStyle,
|
||||
parentStyle,
|
||||
grandStyle,
|
||||
@@ -170,6 +172,7 @@ export const checkRules = (rules) => {
|
||||
ignoreSelector: type(ignoreSelector) === "string" ? ignoreSelector : "",
|
||||
terms: type(terms) === "string" ? terms : "",
|
||||
aiTerms: type(aiTerms) === "string" ? aiTerms : "",
|
||||
termsStyle: type(termsStyle) === "string" ? termsStyle : "",
|
||||
selectStyle: type(selectStyle) === "string" ? selectStyle : "",
|
||||
parentStyle: type(parentStyle) === "string" ? parentStyle : "",
|
||||
grandStyle: type(grandStyle) === "string" ? grandStyle : "",
|
||||
|
||||
@@ -959,6 +959,7 @@ export class Translator {
|
||||
transStartHook,
|
||||
transEndHook,
|
||||
transOnly,
|
||||
termsStyle,
|
||||
selectStyle,
|
||||
parentStyle,
|
||||
grandStyle,
|
||||
@@ -988,8 +989,10 @@ export class Translator {
|
||||
}
|
||||
|
||||
try {
|
||||
const [processedString, placeholderMap] =
|
||||
this.#serializeForTranslation(nodes);
|
||||
const [processedString, placeholderMap] = this.#serializeForTranslation(
|
||||
nodes,
|
||||
termsStyle
|
||||
);
|
||||
// console.log("processedString", processedString);
|
||||
if (this.#isInvalidText(processedString)) return;
|
||||
|
||||
@@ -1078,7 +1081,7 @@ export class Translator {
|
||||
}
|
||||
|
||||
// 处理节点转为翻译字符串
|
||||
#serializeForTranslation(nodes) {
|
||||
#serializeForTranslation(nodes, termsStyle) {
|
||||
let replaceCounter = 0; // {{n}}
|
||||
let wrapCounter = 0; // <tagn>
|
||||
const placeholderMap = new Map();
|
||||
@@ -1118,7 +1121,7 @@ export class Translator {
|
||||
const termValue = this.#termValues[matchedIndex];
|
||||
|
||||
return pushReplace(
|
||||
`<i class="${Translator.KISS_CLASS.term}">${termValue || fullMatch}</i>`
|
||||
`<i class="${Translator.KISS_CLASS.term}" style="${termsStyle}">${termValue || fullMatch}</i>`
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user