Browse Source

解决富文本工具栏单击按钮失效的问题

master
枫谷剑仙 1 year ago
parent
commit
b8044df1ae
2 changed files with 9 additions and 9 deletions
  1. +3
    -3
      script-universal_function.js
  2. +6
    -6
      script.js

+ 3
- 3
script-universal_function.js View File

@@ -1315,7 +1315,7 @@ function richTextCardNClick(){
this.querySelector(".monster").onclick();
}
//创建序号类图标
function createIndexedIcon(type, index) {
function createIndexedIcon(type, index, noFocus = false) {
const className = "drag-able-icon";
let icon;
if (type == 'card') {//卡片头像
@@ -1351,7 +1351,7 @@ function createIndexedIcon(type, index) {
icon.draggable = true;
//icon.tabIndex = 0; // 为了让 :focus 生效
icon.ondragstart = indexedIconOnDragStart;
icon.addEventListener("click", indexedIconFocusSelf);
if (!noFocus) icon.addEventListener("click", indexedIconFocusSelf);
icon.indexedIcon = {type, index}; //拖拽用的
return icon;
}
@@ -1364,7 +1364,7 @@ function indexedIconOnDragStart(event){
}
function indexedIconFocusSelf(event){
const selectRange = document.createRange();
const selection = window.getSelection();
const selection = document.getSelection();
if (!event?.ctrlKey) {
//调整为只选中节点开始的部位
selectRange.setEndBefore(this);


+ 6
- 6
script.js View File

@@ -3364,7 +3364,7 @@ function initialize() {
}
}
let docSelection = document.getSelection();
const docSelection = document.getSelection();
//标题和介绍文本框
const titleBox = formationBox.querySelector(".title-box");
const detailBox = formationBox.querySelector(".detail-box");
@@ -3398,25 +3398,25 @@ function initialize() {
for (let id of official_awoken_sorting) {
const li = document.createElement("li");
const icon = li.appendChild(createIndexedIcon('awoken', id));
const icon = li.appendChild(createIndexedIcon('awoken', id, true));
icon.onclick = insertIconToText;
insertAwokenIconList.appendChild(li);
}
for (let id of Array.from(editBox.querySelectorAll(".setting-box .row-mon-latent details .m-latent-allowable-ul .latent-icon")).map(li=>li.getAttribute("data-latent-icon"))) {
const li = document.createElement("li");
const icon = li.appendChild(createIndexedIcon('latent', id));
const icon = li.appendChild(createIndexedIcon('latent', id, true));
icon.onclick = insertIconToText;
insertLatentIconList.appendChild(li);
}
for (let obj of typekiller_for_type) {
const li = document.createElement("li");
const icon = li.appendChild(createIndexedIcon('type', obj.type));
const icon = li.appendChild(createIndexedIcon('type', obj.type, true));
icon.onclick = insertIconToText;
insertTypeIconList.appendChild(li);
}
for (let i=0;i<10;i++) {
const li = document.createElement("li");
const icon = li.appendChild(createIndexedIcon('orb', i));
const icon = li.appendChild(createIndexedIcon('orb', i, true));
icon.onclick = insertIconToText;
insertOrbList.appendChild(li);
}
@@ -5754,7 +5754,7 @@ function initialize() {
}
else
{
let selection = window.getSelection(), selectNodes = selection?.focusNode?.childNodes;
let selection = docSelection, selectNodes = selection?.focusNode?.childNodes;
//如果正在编辑文本,则不执行快捷键操作
if (selectNodes && Array.from(selectNodes).some(node=>node?.nodeName === "TEXTAREA" || node?.nodeName === "INPUT"))
return;


Loading…
Cancel
Save