import { $, $$, addStyle, DOMUtils, httpx, log, pops, utils } from "@/env"; import { MTRegExp } from "@/utils/MTRegExp"; import { MTUtils } from "@/utils/MTUtils"; import { Panel } from "@components/setting/panel"; import { unsafeWindow } from "ViteGM"; import optimizationCSS from "./css/editor-optimization.css?raw"; import { MTEditorImageBed_Hello } from "./MTEditorImageBed_Hello"; import { MTEditorImageBed_MT } from "./MTEditorImageBed_MT"; import { MTEditorSmilies } from "./MTEditorSmilies"; import { MTQuickUBB, MTUBB_Rainbow } from "./MTQuickUBB"; import Utils from "@whitesev/utils"; import Qmsg from "qmsg"; export type EditorNormalStorageOption = { /** 帖子id */ forumId: string; /** 回复的url */ repquote: undefined | string; /** 内容 */ text: string; /** 帖子链接 */ url: string; }; const ErrorCodeMapList = [ { match: "抱歉,您填写的内容包含敏感词而无法提交", msg: "{$0}", }, { match: /抱歉,管理员设置了本版块发表于 (.+?) 天以前的主题自动关闭,不再接受新回复/, msg: "抱歉,管理员设置了本版块发表于 {$1} 天以前的主题自动关闭,不再接受新回复", }, { match: "抱歉,本主题已关闭,不再接受新内容", msg: "{$0}", }, { match: /抱歉,您的帖子小于 (.+?) 个字符的限制/, msg: "抱歉,您的帖子小于 {$1} 个字符的限制", }, ]; let tempReplyBtnNode: HTMLElement | null = null; export const MTEditorOptimizationNormal = { $data: { /** * 是否是ubb代码插入的点击 */ isUBBCodeInsertClick: false, /** * 当前是否正在回复|发表中 */ isPosting: false, db: new Utils.indexedDB("mt_reply_record", "input_text"), forum_action: null as any as string, get tid() { return MTUtils.getThreadId(window.location.href); }, }, $el: { /** 点赞按钮 */ $like: null as any as HTMLAnchorElement, /** 发表按钮 */ $btn_submit: null as any as HTMLInputElement, /** 输入框 */ $input: null as any as HTMLTextAreaElement, /** 表单元素 */ $form: null as any as HTMLFormElement, /** 发表|回复按钮 */ $fastpostsubmit: null as any as HTMLInputElement, }, init() { log.info(`编辑器优化-简略版`); addStyle(optimizationCSS); this.overridePageEditor(); }, /** * 覆盖页面的编辑器 */ overridePageEditor() { // 评论图标 let $old_commentIcon = $("#comiis_foot_memu .comiis_flex li:nth-child(2)")!; // 点赞图标 let $old_linkIcon = $("#comiis_foot_memu .comiis_flex li:nth-child(3)")!; // 收藏图标 let $old_collectIcon = $("#comiis_foot_memu .comiis_flex li:nth-child(4)")!; this.$el.$form = $("#fastpostform")!; this.$data.forum_action = this.$el.$form.getAttribute("action")!; let forum_serialize = DOMUtils.serialize(this.$el.$form); let forum_url = $("#fastpostform .header_y a")!.href; // 移除页面原来的输入框 DOMUtils.remove("#needmessage[name='message']"); // 移除表情列表 DOMUtils.remove("#imglist"); // 移除回复按钮 DOMUtils.remove("#fastpostsubmitline"); DOMUtils.remove("#fastpostsubmit"); let $footMenu = $("#comiis_foot_memu")!; DOMUtils.hide($footMenu, false); let smiliesList = MTEditorSmilies(); let first_smilies = Object.keys(smiliesList[0]).map((key) => { let smilies_url: string = (smiliesList as any)[0][key]; return /*html*/ `
  • `; }); let second_smilies = Object.keys(smiliesList[1]).map((key) => { let smilies_url: string = (smiliesList as any)[1][key]; return /*html*/ `
  • `; }); let third_smilies = Object.keys(smiliesList[2]).map((key) => { let smilies_url: string = (smiliesList as any)[2][key]; return /*html*/ `
  • `; }); DOMUtils.after( $footMenu, /*html*/ `
    • ${$old_commentIcon.innerHTML}
    • ${$old_linkIcon.innerHTML}
    • ${$old_collectIcon.innerHTML}
    `, /*html*/ `