迁移后台输入选中事件
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// 后台只读输入框选择事件代理,用于复制类配置项的一键选中文本。
|
||||
|
||||
let adminInputSelectionBound = false;
|
||||
|
||||
/**
|
||||
* 绑定后台只读输入框点击选中逻辑。
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
export function bindAdminInputSelection() {
|
||||
if (adminInputSelectionBound || typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
adminInputSelectionBound = true;
|
||||
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!(event.target instanceof HTMLInputElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 回调地址等只读字段点击后直接选中,便于管理员复制。
|
||||
if (event.target.hasAttribute("data-admin-select-on-click")) {
|
||||
event.target.select();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user