Skip to content

Commit 879cbdc

Browse files
committed
Mark the ciphertext element with attr
1 parent 303e265 commit 879cbdc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/zero/dbclick/default-decryptor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import cryptor from "../cryptor"
22
import FloatAlert from "./float-alert"
33
import $ = require('jquery')
44
import AbstractDomDecryptor from "./abstract-dom-decryptor"
5+
import { CIPHER_ATTR_NAME } from "."
6+
57

68
export default class DefaultDecryptor extends AbstractDomDecryptor {
79
private static ELE_TYPES_2_LISTEN = ['span', 'p', 'pre']
@@ -22,7 +24,7 @@ export default class DefaultDecryptor extends AbstractDomDecryptor {
2224
private addListener(selecotor: JQuery) {
2325
const _this_ = this
2426
selecotor.filter((index: number, el: HTMLElement) => {
25-
const support = cryptor.support(el.innerText)
27+
const support = el.hasAttribute(CIPHER_ATTR_NAME) || cryptor.support(el.innerText)
2628
if (support && !super.hasMarked(el)) {
2729
super.mark(el)
2830
}

src/components/zero/dbclick/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import AbstractDomDecryptor from "./abstract-dom-decryptor";
33
import DefaultDecryptor from "./default-decryptor";
44
import WeiboDecryptor from './weibo-decryptor'
55

6+
/**
7+
* Mark the ciphertext element with attr.
8+
*
9+
* @since 1.4.0
10+
*/
11+
export const CIPHER_ATTR_NAME = 'make-zero-ciphertext'
12+
613
/**
714
* Show the float button while the user moves its mouse on <p> tags within ciphertexts
815
* @author zhy

0 commit comments

Comments
 (0)