🐛 Fix: fix fixit-encryptor shortcode duplicate binding events

This commit is contained in:
Cell
2024-08-26 10:58:34 +08:00
parent 466bb7b7e9
commit 91f3c7c3cf
5 changed files with 8 additions and 7 deletions
+3 -2
View File
@@ -139,10 +139,11 @@ FixItDecryptor = function (options = {}) {
/**
* initialize fixit-encryptor shortcodes
* @param {Element} [$container=document] container element
*/
_proto.initShortcodes = () => {
_proto.initShortcodes = ($container = document) => {
customElements.get('fixit-encryptor') || customElements.define('fixit-encryptor', class extends HTMLElement {});
const $shortcodes = document.querySelectorAll('fixit-encryptor:not(:has(.decrypted))');
const $shortcodes = $container.querySelectorAll('fixit-encryptor:not(:has(.decrypted))');
$shortcodes.forEach($shortcode => {
const decryptorHandler = () => {
+2 -2
View File
@@ -1047,8 +1047,8 @@ class FixIt {
this.decryptor.addEventListener('decrypted', () => {
this.decryptor.initShortcodes();
})
this.decryptor.addEventListener('partial-decrypted', () => {
this.decryptor.initShortcodes();
this.decryptor.addEventListener('partial-decrypted', ($content) => {
this.decryptor.initShortcodes($content);
})
this.decryptor.initShortcodes();
}
+1 -1
View File
@@ -1,4 +1,4 @@
{{- .Scratch.Set "version" "v0.3.10-53484f8c" -}}
{{- .Scratch.Set "version" "v0.3.10-466bb7b7" -}}
{{- .Scratch.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}
+1 -1
View File
@@ -172,7 +172,7 @@
{{- end -}}
<div class="content" id="content"
{{- with $params.endFlag }} data-end-flag="{{ . }}"{{ end }}
{{- with $params.password }} data-password="{{ hash.XxHash . }}"{{ end }}
{{- with $params.password }} data-password="{{ xxhash . }}"{{ end }}
{{- with $params.password }} data-content="{{ $content }}"{{ end -}}
>
{{- if not $params.password -}}
+1 -1
View File
@@ -29,7 +29,7 @@
{{- dict "Class" "fa-solid fa-unlock" | partial "plugin/icon.html" }} {{ T "single.enterBtn" -}}
</button>
</div>
<div data-password="{{ md5 $password }}" data-content="{{ $content }}"></div>
<div data-password="{{ xxhash $password }}" data-content="{{ $content }}"></div>
</fixit-encryptor>
{{- .Page.Scratch.SetInMap "this" "encryptPartial" true -}}
{{- else -}}