@qxs-bns/components-wc 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/editor/blocksuite-editor.mjs +25 -15
- package/es/editor/blocksuite-editor.mjs.map +1 -1
- package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs +2 -0
- package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs.map +1 -0
- package/es/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs +2 -0
- package/es/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs.map +1 -0
- package/es/subject/action.mjs +3 -3
- package/es/subject/action.mjs.map +1 -1
- package/es/subject/layout.mjs +4 -4
- package/es/subject/layout.mjs.map +1 -1
- package/es/subject/list.mjs +9 -12
- package/es/subject/list.mjs.map +1 -1
- package/lib/editor/blocksuite-editor.cjs +13 -3
- package/lib/editor/blocksuite-editor.cjs.map +1 -1
- package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs +2 -0
- package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs.map +1 -0
- package/lib/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs +2 -0
- package/lib/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs.map +1 -0
- package/lib/subject/action.cjs +1 -1
- package/lib/subject/action.cjs.map +1 -1
- package/lib/subject/layout.cjs +2 -2
- package/lib/subject/layout.cjs.map +1 -1
- package/lib/subject/list.cjs +8 -11
- package/lib/subject/list.cjs.map +1 -1
- package/package.json +28 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.mjs","sources":["../../../../packages/components-wc/src/subject/action.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nfunction safeCustomElement(tagName: string) {\n return function (target: any) {\n if (!customElements.get(tagName)) {\n customElements.define(tagName, target)\n }\n return target\n }\n}\n\nconst answerTextList = [\n { value: 2, label: '必须全部都是支持选项,方可下一步' },\n { value: 1, label: '无需判断是否是支持选项' },\n { value: 3, label: '包含全部支持选项,即可下一步' },\n]\n\nconst iconEdit = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"/><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"/></svg>`\nconst iconDelete = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"/></svg>`\nconst iconCheck = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20 6 9 17 4 12\"/></svg>`\nconst iconSort = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z\"/></svg>`\n\n@safeCustomElement('qxs-subject-action')\nexport class QxsSubjectAction extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .action { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }\n .action.active { }\n .left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n .right { display: flex; align-items: center; gap: 4px; }\n\n .action-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 32px; height: 32px; font-size: 18px; color: #303133;\n cursor: pointer; border-radius: 6px; border: 1px solid #dcdfe6;\n background: #fff; transition: all 0.2s;\n }\n .action-icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .action-icon--danger:hover { color: #f56c6c; border-color: #f56c6c; background: #fef0f0; }\n .action-icon:disabled { color: #c0c4cc; cursor: not-allowed; opacity: 0.6; }\n\n .text-btn {\n display: inline-flex; align-items: center; gap: 4px;\n padding: 6px 12px; font-size: 12px; border-radius: 3px;\n cursor: pointer; border: 1px solid; transition: all 0.2s;\n }\n .text-btn--primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .text-btn--primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n .text-btn--default { background: #fff; border-color: #dcdfe6; color: #606266; }\n .text-btn--default:hover { color: #3D61E3; border-color: #a0cfff; }\n .text-btn--danger { background: #f56c6c; border-color: #f56c6c; color: #fff; }\n .text-btn--danger:hover { background: #e05252; border-color: #e05252; }\n\n .link-btn { background: none; border: none; color: #3D61E3; cursor: pointer; font-size: 12px; }\n .link-btn:hover { color: #2D4CB8; }\n\n .checkbox-label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: #606266; user-select: none; font-size: 12px; }\n .checkbox-label.disabled { cursor: not-allowed; opacity: 0.6; }\n .has-set { display: flex; align-items: center; font-size: 12px; color: #bbb; }\n .answer-text { font-size: 11px; color: #909399; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n\n .btn-margin { margin-right: 10px; }\n\n .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; }\n .modal { background: #fff; border-radius: 4px; min-width: 360px; max-width: 460px; box-shadow: 0 12px 32px rgba(0,0,0,.1); }\n .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid #e4e7ed; }\n .modal-title { font-size: 14px; font-weight: 600; color: #303133; }\n .modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: #909399; padding: 0; line-height: 1; }\n .modal-close:hover { color: #3D61E3; }\n .modal-body { padding: 20px; }\n .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4e7ed; }\n .modal-footer button { padding: 6px 16px; font-size: 12px; border-radius: 3px; cursor: pointer; border: 1px solid #dcdfe6; background: #fff; color: #606266; }\n .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }\n .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n\n .radio-item { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; font-size: 13px; color: #606266; }\n .radio-item:last-child { margin-bottom: 0; }\n `\n\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'is-key' }) isKey = false\n @property({ type: Number, attribute: 'answer-check-type' }) answerCheckType = 1\n @property({ type: Boolean, attribute: 'show-other-option' }) showOtherOption = false\n @property({ type: Boolean, attribute: 'show-rich-text' }) showRichText = true\n @property({ type: Boolean, attribute: 'hide-add-rich-text' }) hideAddRichText = false\n @property({ type: Boolean, attribute: 'page-end' }) pageEnd = false\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n\n @state() private _modalOpen = false\n @state() private _currentCheckType = 1\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('answerCheckType')) {\n this._currentCheckType = this.answerCheckType\n }\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private get _answerText() {\n return answerTextList.find(i => i.value === this.answerCheckType)?.label ?? ''\n }\n\n private _renderEditMode() {\n return html`\n <div class=\"left\">\n ${!this.hideAddRichText\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('on-show-rich-text')}>+添加题目描述(图文)</span>\n `\n : ''}\n ${this.showOtherOption\n ? html`\n <span class=\"link-btn\" @click=${() => { this._modalOpen = true }}>答题设置</span>\n <label class=\"checkbox-label\">\n <input type=\"checkbox\" .checked=${this.isKey} @change=${(e: Event) => this._emit('set-key', { value: (e.target as HTMLInputElement).checked })} />\n 核心题\n </label>\n `\n : ''}\n </div>\n <div class=\"right\">\n <button class=\"text-btn text-btn--danger btn-margin\" @click=${() => this._emit('delete')}>删除</button>\n <button class=\"text-btn text-btn--primary\" @click=${() => this._emit('save')}>完成编辑</button>\n </div>\n `\n }\n\n private _renderViewMode() {\n return html`\n <div class=\"left\">\n ${this.showOtherOption\n ? html`\n <label class=\"checkbox-label disabled\">\n <input type=\"checkbox\" disabled .checked=${this.isKey} /> 核心题\n </label>\n <span class=\"answer-text\">${this._answerText}</span>\n `\n : ''}\n </div>\n <div class=\"right\">\n ${!this.pageEnd\n ? html`\n <button class=\"text-btn text-btn--default btn-margin\" @click=${() => this._emit('edit')}>编辑</button>\n `\n : ''}\n <button class=\"text-btn text-btn--danger\" @click=${() => this._emit('delete')}>删除</button>\n </div>\n `\n }\n\n private _renderModal() {\n if (!this._modalOpen) { return '' }\n return html`\n <div class=\"modal-backdrop\" @click=${() => { this._modalOpen = false }}>\n <div class=\"modal\" @click=${(e: Event) => e.stopPropagation()}>\n <div class=\"modal-header\">\n <span class=\"modal-title\">答题设置</span>\n <button class=\"modal-close\" @click=${() => { this._modalOpen = false }}>✕</button>\n </div>\n <div class=\"modal-body\">\n ${answerTextList.map(item => html`\n <label class=\"radio-item\">\n <input type=\"radio\" name=\"answer-check-type\" .value=${String(item.value)}\n .checked=${this._currentCheckType === item.value}\n @change=${() => { this._currentCheckType = item.value }} />\n ${item.label}\n </label>\n `)}\n </div>\n <div class=\"modal-footer\">\n <button @click=${() => { this._modalOpen = false }}>取消</button>\n <button class=\"primary\" @click=${() => {\n this._emit('set-answer-setting', { value: this._currentCheckType })\n this._modalOpen = false\n }}>保存</button>\n </div>\n </div>\n </div>\n `\n }\n\n render() {\n return html`\n <div class=\"action ${this.isEdit ? 'active' : ''}\">\n ${this.isSet\n ? html`<div class=\"has-set\">*此题设置了跳题逻辑</div>`\n : (this.isEdit ? this._renderEditMode() : this._renderViewMode())\n }\n </div>\n ${this._renderModal()}\n `\n }\n}\n\nexport function register() {}\n"],"names":["answerTextList","value","label","html","QxsSubjectAction","LitElement","constructor","super","arguments","this","isEdit","isSet","isKey","answerCheckType","showOtherOption","showRichText","hideAddRichText","pageEnd","examAnswerRelationType","_modalOpen","_currentCheckType","updated","changed","has","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_answerText","find","i","_renderEditMode","e","target","checked","_renderViewMode","_renderModal","stopPropagation","map","item","String","render","tagName","styles","css","__decorateClass","property","type","Boolean","attribute","prototype","Number","state","customElements","get","define"],"mappings":"8fAYA,MAAMA,EAAiB,CACrB,CAAEC,MAAO,EAAGC,MAAO,oBACnB,CAAED,MAAO,EAAGC,MAAO,eACnB,CAAED,MAAO,EAAGC,MAAO,mBAGJC,CAAA,uUACEA,CAAA,yTACDA,CAAA,iOACDA,CAAA,wKAGV,IAAMC,EAAN,cAA+BC,EAA/BC,WAAAA,GAAAC,SAAAC,WA2D8CC,KAAAC,QAAS,EACVD,KAAAE,OAAQ,EACRF,KAAAG,OAAQ,EACEH,KAAAI,gBAAkB,EACjBJ,KAAAK,iBAAkB,EACrBL,KAAAM,cAAe,EACXN,KAAAO,iBAAkB,EAC5BP,KAAAQ,SAAU,EACMR,KAAAS,uBAAyB,EAEpFT,KAAQU,YAAa,EACrBV,KAAQW,kBAAoB,CAAA,CAErCC,OAAAA,CAAQC,GACFA,EAAQC,IAAI,qBACdd,KAAKW,kBAAoBX,KAAKI,gBAElC,CAEQW,KAAAA,CAAMC,EAAcC,GAC1BjB,KAAKkB,cAAc,IAAIC,YAAYH,EAAM,CAAEI,SAAS,EAAMC,UAAU,EAAMJ,OAAQA,GAAU,OAC9F,CAEA,eAAYK,GACV,OAAO/B,EAAegC,KAAKC,GAAKA,EAAEhC,QAAUQ,KAAKI,kBAAkBX,OAAS,EAC9E,CAEQgC,eAAAA,GACN,OAAO/B,CAAA;;UAEAM,KAAKO,gBAIJ,GAHAb,CAAA;0CAC8B,IAAMM,KAAKe,MAAM;;UAGjDf,KAAKK,gBACHX,CAAA;0CAC8B,KAAQM,KAAKU,YAAa;;8CAEtBV,KAAKG,iBAAkBuB,GAAa1B,KAAKe,MAAM,UAAW,CAAEvB,MAAQkC,EAAEC,OAA4BC;;;UAIpI;;;sEAG0D,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UAAA,QAAA,GACUL,EAAA,CAA3DC,EAAS,CAAEC,KAAMI,OAAQF,UAAW,uBA9D1BhD,EA8DiDiD,UAAA,kBAAA,GACCL,EAAA,CAA5DC,EAAS,CAAEC,KAAMC,QAASC,UAAW,uBA/D3BhD,EA+DkDiD,UAAA,kBAAA,GACHL,EAAA,CAAzDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,oBAhE3BhD,EAgE+CiD,UAAA,eAAA,GACIL,EAAA,CAA7DC,EAAS,CAAEC,KAAMC,QAASC,UAAW,wBAjE3BhD,EAiEmDiD,UAAA,kBAAA,GACVL,EAAA,CAAnDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,cAlE3BhD,EAkEyCiD,UAAA,UAAA,GACgBL,EAAA,CAAnEC,EAAS,CAAEC,KAAMI,OAAQF,UAAW,+BAnE1BhD,EAmEyDiD,UAAA,yBAAA,GAEnDL,EAAA,CAAhBO,KArEUnD,EAqEMiD,UAAA,aAAA,GACAL,EAAA,CAAhBO,KAtEUnD,EAsEMiD,UAAA,oBAAA,GAtENjD,EAAN4C,EAAA,EArBoBH,EAoBR,qBAnBV,SAAUT,GAIf,OAHKoB,eAAeC,IAAIZ,IACtBW,eAAeE,OAAOb,EAAST,GAE1BA,CACT,IAeWhC"}
|
|
1
|
+
{"version":3,"file":"action.mjs","sources":["../../../../packages/components-wc/src/subject/action.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\n\nfunction safeCustomElement(tagName: string) {\n return function (target: any) {\n if (!customElements.get(tagName)) {\n customElements.define(tagName, target)\n }\n return target\n }\n}\n\nconst answerTextList = [\n { value: 2, label: '必须全部都是支持选项,方可下一步' },\n { value: 1, label: '无需判断是否是支持选项' },\n { value: 3, label: '包含全部支持选项,即可下一步' },\n]\n\nconst iconEdit = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"/><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"/></svg>`\nconst iconDelete = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\"/></svg>`\nconst iconCheck = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20 6 9 17 4 12\"/></svg>`\nconst iconSort = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z\"/></svg>`\n\n@safeCustomElement('qxs-subject-action')\nexport class QxsSubjectAction extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .action { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; flex-wrap: wrap; gap: 8px; }\n .action.active { background: transparent; }\n .left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }\n .right { display: flex; align-items: center; gap: 4px; }\n\n .action-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 32px; height: 32px; font-size: 18px; color: #303133;\n cursor: pointer; border-radius: 6px; border: 1px solid #dcdfe6;\n background: #fff; transition: all 0.2s;\n }\n .action-icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .action-icon--danger:hover { color: #f56c6c; border-color: #f56c6c; background: #fef0f0; }\n .action-icon:disabled { color: #c0c4cc; cursor: not-allowed; opacity: 0.6; }\n\n .text-btn {\n display: inline-flex; align-items: center; gap: 4px;\n padding: 6px 12px; font-size: 12px; border-radius: 3px;\n cursor: pointer; border: 1px solid; transition: all 0.2s;\n }\n .text-btn--primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .text-btn--primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n .text-btn--default { background: #fff; border-color: #dcdfe6; color: #606266; }\n .text-btn--default:hover { color: #3D61E3; border-color: #a0cfff; }\n .text-btn--danger { background: #f56c6c; border-color: #f56c6c; color: #fff; }\n .text-btn--danger:hover { background: #e05252; border-color: #e05252; }\n\n .link-btn { background: none; border: none; color: #3D61E3; cursor: pointer; font-size: 12px; }\n .link-btn:hover { color: #2D4CB8; }\n\n .checkbox-label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: #606266; user-select: none; font-size: 12px; }\n .checkbox-label.disabled { cursor: not-allowed; opacity: 0.6; }\n .has-set { display: flex; align-items: center; font-size: 12px; color: #bbb; }\n .answer-text { font-size: 11px; color: #909399; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n\n .btn-margin { margin-right: 10px; }\n\n .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; }\n .modal { background: #fff; border-radius: 4px; min-width: 360px; max-width: 460px; box-shadow: 0 12px 32px rgba(0,0,0,.1); }\n .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid #e4e7ed; }\n .modal-title { font-size: 14px; font-weight: 600; color: #303133; }\n .modal-close { background: none; border: none; font-size: 16px; cursor: pointer; color: #909399; padding: 0; line-height: 1; }\n .modal-close:hover { color: #3D61E3; }\n .modal-body { padding: 20px; }\n .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4e7ed; }\n .modal-footer button { padding: 6px 16px; font-size: 12px; border-radius: 3px; cursor: pointer; border: 1px solid #dcdfe6; background: #fff; color: #606266; }\n .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }\n .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n\n .radio-item { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; font-size: 13px; color: #606266; }\n .radio-item:last-child { margin-bottom: 0; }\n `\n\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'is-key' }) isKey = false\n @property({ type: Number, attribute: 'answer-check-type' }) answerCheckType = 1\n @property({ type: Boolean, attribute: 'show-other-option' }) showOtherOption = false\n @property({ type: Boolean, attribute: 'show-rich-text' }) showRichText = true\n @property({ type: Boolean, attribute: 'hide-add-rich-text' }) hideAddRichText = false\n @property({ type: Boolean, attribute: 'page-end' }) pageEnd = false\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n\n @state() private _modalOpen = false\n @state() private _currentCheckType = 1\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('answerCheckType')) {\n this._currentCheckType = this.answerCheckType\n }\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n private get _answerText() {\n return answerTextList.find(i => i.value === this.answerCheckType)?.label ?? ''\n }\n\n private _renderEditMode() {\n return html`\n <div class=\"left\">\n ${!this.hideAddRichText\n ? html`\n <span class=\"link-btn\" @click=${() => this._emit('on-show-rich-text')}>+添加题目描述(图文)</span>\n `\n : ''}\n ${this.showOtherOption\n ? html`\n <span class=\"link-btn\" @click=${() => { this._modalOpen = true }}>答题设置</span>\n <label class=\"checkbox-label\">\n <input type=\"checkbox\" .checked=${this.isKey} @change=${(e: Event) => this._emit('set-key', { value: (e.target as HTMLInputElement).checked })} />\n 核心题\n </label>\n `\n : ''}\n </div>\n <div class=\"right\">\n <button class=\"text-btn text-btn--danger btn-margin\" @click=${() => this._emit('delete')}>删除</button>\n <button class=\"text-btn text-btn--primary\" @click=${() => this._emit('save')}>完成编辑</button>\n </div>\n `\n }\n\n private _renderViewMode() {\n return html`\n <div class=\"left\">\n ${this.showOtherOption\n ? html`\n <label class=\"checkbox-label disabled\">\n <input type=\"checkbox\" disabled .checked=${this.isKey} /> 核心题\n </label>\n <span class=\"answer-text\">${this._answerText}</span>\n `\n : ''}\n </div>\n <div class=\"right\">\n ${!this.pageEnd\n ? html`\n <button class=\"text-btn text-btn--default btn-margin\" @click=${() => this._emit('edit')}>编辑</button>\n `\n : ''}\n <button class=\"text-btn text-btn--danger\" @click=${() => this._emit('delete')}>删除</button>\n </div>\n `\n }\n\n private _renderModal() {\n if (!this._modalOpen) { return '' }\n return html`\n <div class=\"modal-backdrop\" @click=${() => { this._modalOpen = false }}>\n <div class=\"modal\" @click=${(e: Event) => e.stopPropagation()}>\n <div class=\"modal-header\">\n <span class=\"modal-title\">答题设置</span>\n <button class=\"modal-close\" @click=${() => { this._modalOpen = false }}>✕</button>\n </div>\n <div class=\"modal-body\">\n ${answerTextList.map(item => html`\n <label class=\"radio-item\">\n <input type=\"radio\" name=\"answer-check-type\" .value=${String(item.value)}\n .checked=${this._currentCheckType === item.value}\n @change=${() => { this._currentCheckType = item.value }} />\n ${item.label}\n </label>\n `)}\n </div>\n <div class=\"modal-footer\">\n <button @click=${() => { this._modalOpen = false }}>取消</button>\n <button class=\"primary\" @click=${() => {\n this._emit('set-answer-setting', { value: this._currentCheckType })\n this._modalOpen = false\n }}>保存</button>\n </div>\n </div>\n </div>\n `\n }\n\n render() {\n return html`\n <div class=\"action ${this.isEdit ? 'active' : ''}\">\n ${this.isSet\n ? html`<div class=\"has-set\">*此题设置了跳题逻辑</div>`\n : (this.isEdit ? this._renderEditMode() : this._renderViewMode())\n }\n </div>\n ${this._renderModal()}\n `\n }\n}\n\nexport function register() {}\n"],"names":["answerTextList","value","label","html","QxsSubjectAction","LitElement","constructor","super","arguments","this","isEdit","isSet","isKey","answerCheckType","showOtherOption","showRichText","hideAddRichText","pageEnd","examAnswerRelationType","_modalOpen","_currentCheckType","updated","changed","has","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_answerText","find","i","_renderEditMode","e","target","checked","_renderViewMode","_renderModal","stopPropagation","map","item","String","render","tagName","styles","css","__decorateClass","property","type","Boolean","attribute","prototype","Number","state","customElements","get","define"],"mappings":"8fAYA,MAAMA,EAAiB,CACrB,CAAEC,MAAO,EAAGC,MAAO,oBACnB,CAAED,MAAO,EAAGC,MAAO,eACnB,CAAED,MAAO,EAAGC,MAAO,mBAGJC,CAAA,uUACEA,CAAA,yTACDA,CAAA,iOACDA,CAAA,wKAGV,IAAMC,EAAN,cAA+BC,EAA/BC,WAAAA,GAAAC,SAAAC,WA2D8CC,KAAAC,QAAS,EACVD,KAAAE,OAAQ,EACRF,KAAAG,OAAQ,EACEH,KAAAI,gBAAkB,EACjBJ,KAAAK,iBAAkB,EACrBL,KAAAM,cAAe,EACXN,KAAAO,iBAAkB,EAC5BP,KAAAQ,SAAU,EACMR,KAAAS,uBAAyB,EAEpFT,KAAQU,YAAa,EACrBV,KAAQW,kBAAoB,CAAA,CAErCC,OAAAA,CAAQC,GACFA,EAAQC,IAAI,qBACdd,KAAKW,kBAAoBX,KAAKI,gBAElC,CAEQW,KAAAA,CAAMC,EAAcC,GAC1BjB,KAAKkB,cAAc,IAAIC,YAAYH,EAAM,CAAEI,SAAS,EAAMC,UAAU,EAAMJ,OAAQA,GAAU,OAC9F,CAEA,eAAYK,GACV,OAAO/B,EAAegC,KAAKC,GAAKA,EAAEhC,QAAUQ,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0DmCC,EAAA,CAAlDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,aA3D3BhD,EA2DwCiD,UAAA,SAAA,GACDL,EAAA,CAAjDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,YA5D3BhD,EA4DuCiD,UAAA,QAAA,GACAL,EAAA,CAAjDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,YA7D3BhD,EA6DuCiD,UAAA,QAAA,GACUL,EAAA,CAA3DC,EAAS,CAAEC,KAAMI,OAAQF,UAAW,uBA9D1BhD,EA8DiDiD,UAAA,kBAAA,GACCL,EAAA,CAA5DC,EAAS,CAAEC,KAAMC,QAASC,UAAW,uBA/D3BhD,EA+DkDiD,UAAA,kBAAA,GACHL,EAAA,CAAzDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,oBAhE3BhD,EAgE+CiD,UAAA,eAAA,GACIL,EAAA,CAA7DC,EAAS,CAAEC,KAAMC,QAASC,UAAW,wBAjE3BhD,EAiEmDiD,UAAA,kBAAA,GACVL,EAAA,CAAnDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,cAlE3BhD,EAkEyCiD,UAAA,UAAA,GACgBL,EAAA,CAAnEC,EAAS,CAAEC,KAAMI,OAAQF,UAAW,+BAnE1BhD,EAmEyDiD,UAAA,yBAAA,GAEnDL,EAAA,CAAhBO,KArEUnD,EAqEMiD,UAAA,aAAA,GACAL,EAAA,CAAhBO,KAtEUnD,EAsEMiD,UAAA,oBAAA,GAtENjD,EAAN4C,EAAA,EArBoBH,EAoBR,qBAnBV,SAAUT,GAIf,OAHKoB,eAAeC,IAAIZ,IACtBW,eAAeE,OAAOb,EAAST,GAE1BA,CACT,IAeWhC"}
|
package/es/subject/layout.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{css as e,LitElement as t,html as o}from"lit";import{property as s}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{safeCustomElement as
|
|
1
|
+
import{css as e,LitElement as t,html as o}from"lit";import{property as s}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{safeCustomElement as i}from"../base/define.mjs";var r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,p=(e,t,o,s)=>{for(var i,p=s>1?void 0:s?a(t,o):t,d=e.length-1;d>=0;d--)(i=e[d])&&(p=(s?i(t,o,p):i(p))||p);return s&&p&&r(t,o,p),p};let d=class extends t{constructor(){super(...arguments),this.showEdit=!1}render(){return this.showEdit?o`
|
|
2
2
|
<div class="layout">
|
|
3
3
|
<div class="edit">
|
|
4
4
|
<slot name="edit"></slot>
|
|
@@ -12,10 +12,10 @@ import{css as e,LitElement as t,html as o}from"lit";import{property as s}from"..
|
|
|
12
12
|
<slot></slot>
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
|
15
|
-
`}};
|
|
15
|
+
`}};d.styles=e`
|
|
16
16
|
:host { display: block; width: 100%; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
|
|
17
|
-
.layout {
|
|
17
|
+
.layout { }
|
|
18
18
|
.preview { padding: 12px 10px 10px; }
|
|
19
19
|
.edit { position: relative; padding: 12px 10px 10px; background-color: #fff; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
|
|
20
|
-
`,p([s({type:Boolean,attribute:"show-edit"})],
|
|
20
|
+
`,p([s({type:Boolean,attribute:"show-edit"})],d.prototype,"showEdit",2),d=p([i("qxs-subject-layout")],d);export{d as QxsSubjectLayout};
|
|
21
21
|
//# sourceMappingURL=layout.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.mjs","sources":["../../../../packages/components-wc/src/subject/layout.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\n@safeCustomElement('qxs-subject-layout')\nexport class QxsSubjectLayout extends LitElement {\n static styles = css`\n :host { display: block; width: 100%; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n .layout {
|
|
1
|
+
{"version":3,"file":"layout.mjs","sources":["../../../../packages/components-wc/src/subject/layout.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\n@safeCustomElement('qxs-subject-layout')\nexport class QxsSubjectLayout extends LitElement {\n static styles = css`\n :host { display: block; width: 100%; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n .layout { }\n .preview { padding: 12px 10px 10px; }\n .edit { position: relative; padding: 12px 10px 10px; background-color: #fff; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }\n `\n\n @property({ type: Boolean, attribute: 'show-edit' }) showEdit = false\n\n render() {\n if (this.showEdit) {\n return html`\n <div class=\"layout\">\n <div class=\"edit\">\n <slot name=\"edit\"></slot>\n <slot></slot>\n </div>\n </div>\n `\n }\n return html`\n <div class=\"layout\">\n <div class=\"preview\">\n <slot name=\"preview\"></slot>\n <slot></slot>\n </div>\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["QxsSubjectLayout","LitElement","constructor","super","arguments","this","showEdit","render","html","styles","css","__decorateClass","property","type","Boolean","attribute","prototype","safeCustomElement"],"mappings":"mbAKO,IAAMA,EAAN,cAA+BC,EAA/BC,WAAAA,GAAAC,SAAAC,WAQgDC,KAAAC,UAAW,CAAA,CAEhEC,MAAAA,GACE,OAAIF,KAAKC,SACAE,CAAA;;;;;;;QASFA,CAAA;;;;;;;KAQT,GA7BWR,EACJS,OAASC,CAAA;;;;;IAOqCC,EAAA,CAApDC,EAAS,CAAEC,KAAMC,QAASC,UAAW,eAR3Bf,EAQ0CgB,UAAA,WAAA,GAR1ChB,EAANW,EAAA,CADNM,EAAkB,uBACNjB"}
|
package/es/subject/list.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{css as e,LitElement as t,html as s}from"lit";import{
|
|
1
|
+
import{css as e,LitElement as t,html as s}from"lit";import{property as i}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as a}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import o from"sortablejs";import{safeCustomElement as r}from"../base/define.mjs";import{uid as n}from"../base/uid.mjs";import{SubjectError as l}from"./single.mjs";var d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,h=(e,t,s,i)=>{for(var a,o=i>1?void 0:i?c(t,s):t,r=e.length-1;r>=0;r--)(a=e[r])&&(o=(i?a(t,s,o):a(o))||o);return i&&o&&d(t,s,o),o};const p={single:"单选题",multiple:"多选题",sort:"排序题",blank_fill:"填空题",text_fill:"问答题",scale:"量表题",rich_text:"富文本",page_end:"分页符"};let m=class extends t{constructor(){super(...arguments),this.isPreview=!1,this.uploadImage=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this._list=[],this._sortMode=!1,this._sortable=null,this._initialDataProcessed=!1}get subjectList(){return this._list}set subjectList(e){if(e){if("string"==typeof e)try{e=JSON.parse(e)}catch{return this._list=[],void this.requestUpdate()}if(!Array.isArray(e))return this._list=[],void this.requestUpdate();this._list=e.map(e=>({...e,customId:e.customId||n()})),this.requestUpdate()}else this._list=[]}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback(e,t,s),"subject-list"===e&&s&&!this._list.length){if(s.includes("[object Object]"))return;try{const e=JSON.parse(s);Array.isArray(e)&&(this._list=e.map(e=>({...e,customId:e.customId||n()})),this.requestUpdate())}catch{}}}get _isPreviewValue(){const e=this.isPreview;return"string"==typeof e?"false"!==e:!!e}connectedCallback(){super.connectedCallback(),this._initialDataProcessed||(this._initialDataProcessed=!0,Promise.resolve().then(()=>{0===this._list.length&&this._processAttributeList()}))}_processAttributeList(){const e=this.getAttribute("subject-list");if(e&&"[]"!==e&&!e.includes("[object Object]"))try{const t=JSON.parse(e);Array.isArray(t)&&t.length>0&&(this._list=t.map(e=>({...e,customId:e.customId||n()})),this.requestUpdate())}catch{}}firstUpdated(){this.updateComplete.then(()=>this._initSortable())}updated(e){e.has("_sortMode")&&(this._sortable?.destroy(),this._sortable=null,this.updateComplete.then(()=>this._initSortable())),e.has("_list")&&this._sortMode&&setTimeout(()=>{this._sortable&&(this._sortable.destroy(),this._sortable=null),this._initSortable()},50)}disconnectedCallback(){super.disconnectedCallback(),this._sortable?.destroy(),this._sortable=null}_initSortable(){if(!this._sortMode)return;const e=this.shadowRoot?.querySelector(".sort-list");e&&(this._sortable&&(this._sortable.destroy(),this._sortable=null),requestAnimationFrame(()=>{const e=this.shadowRoot?.querySelector(".sort-list");e&&!this._sortable&&(this._sortable=o.create(e,{handle:".sort-handle",animation:200,ghostClass:"sort-ghost",chosenClass:"sort-chosen",onEnd:e=>{const{oldIndex:t,newIndex:s}=e;if(void 0===t||void 0===s||t===s)return;const i=[...this._list],[a]=i.splice(t,1);i.splice(s,0,a),this._list=i,this._emit("change",this._list)}}))}))}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}async toJSON(){const e=this.shadowRoot?.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text");if(!e||0===e.length)return[];const t=[],s=[];for(const i of e)if("function"==typeof i.toJSON)try{const e=await i.toJSON();t.push(e)}catch(e){e instanceof l?s.push(e):s.push(new l(e.message||"未知错误","UNKNOWN","unknown"))}if(s.length>0)throw s;return t}async validate(){const e=this.shadowRoot?.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text");if(!e||0===e.length)return{valid:!0,errors:[]};const t=[];for(const s of e)if("function"==typeof s.validate){const e=s.validate();e?.length&&t.push(...e)}return{valid:0===t.length,errors:t}}get currentList(){return this._list}addSubject(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const i={customId:n(),answerType:e,title:"",answers:[],analysis:"",scaleQuestionList:[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1,isKey:!1,answerCheckType:1,examAnswerRelationType:s??0},a=[...this._list];"number"==typeof t&&t>=0?a.splice(t+1,0,i):a.push(i),this._list=a,this._emit("change",this._list)}addExam(e){let t=1;const s=[];e.forEach(e=>{const i={...e,customId:e.customId||n(),answers:e.answers?.map(e=>({...e,title:e.answer,answerId:e.examAnswerId,isCorrect:e.isCorrect}))||[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1};e.richTextContent||(i.answerType=e.examTypeEnum),i.pageIndex>t&&(s.push({customId:n(),answerType:"page_end",analysis:"",scaleQuestionList:[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1,examAnswerRelationType:0}),t=i.pageIndex),s.push(i)}),this._list=[...this._list,...s],this._emit("change",this._list)}uploadExcel(e){this._list=[...this._list,...e.map(e=>({...e,customId:e.customId||n(),isRealCanDel:!0}))],this._emit("change",this._list)}setAnswerRelation(e,t,s){const i=this._list.find(e=>e.customId===t);if(i){const t=i.answers?.find(e=>e.customAnswerId===s);t&&(t.answerRelations=e)}this.requestUpdate(),this._emit("change",this._list)}_orderIndex(e){let t=0,s=0;return this._list.forEach(i=>{"page_end"!==i.answerType&&(t++,i.customId===e&&(s=t))}),s-1}_pageIndex(e){return this._list.filter(e=>"page_end"===e.answerType).findIndex(t=>t.customId===e)+1}_totalPages(){return this._list.filter(e=>"page_end"===e.answerType).length}_move(e,t){const s=[...this._list];"up"===t&&e>0?[s[e-1],s[e]]=[s[e],s[e-1]]:"down"===t&&e<s.length-1&&([s[e],s[e+1]]=[s[e+1],s[e]]),this._list=s,this._emit("change",this._list)}_save(e,t){this._list=this._list.map((s,i)=>i===e?{...s,...t.detail,isEdit:!1,isSave:!0}:s),this._emit("change",this._list)}_deleteByCustomId(e){this._list=this._list.filter(t=>t.customId!==e),this._emit("change",this._list)}_delete(e){const t=[...this._list];t.splice(e,1),this._list=t,this._emit("change",this._list)}_setEdit(e,t){this._list=this._list.map((s,i)=>i===e?{...s,isEdit:t}:s)}_renderItem(e,t){const i=this._orderIndex(e.customId),a=(e.isEdit,e.hasSet,e.isRealCanDel,this._isPreviewValue,e.examAnswerRelationType,e=>this._move(t,e.detail)),o=()=>this._deleteByCustomId(e.customId),r=e=>this._save(t,e),n=()=>this._setEdit(t,!0),l=e=>this.addSubject(e.detail?.type??e.detail,t);return["single","multiple","sort"].includes(e.answerType)?s`<qxs-subject-single
|
|
2
2
|
.title=${e.title||""}
|
|
3
3
|
.answerList=${e.answers||[]}
|
|
4
4
|
.uploadImage=${this.uploadImage}
|
|
@@ -70,8 +70,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
70
70
|
total-page=${this._totalPages()}
|
|
71
71
|
?show-action=${!this._isPreviewValue}
|
|
72
72
|
@move=${a} @delete=${o} @add=${l}
|
|
73
|
-
></qxs-page-end>`:s`<div style="color:#909399;padding:8px">未知题型: ${e.answerType}</div>`}render(){return s`
|
|
74
|
-
<div class="wrapper">
|
|
73
|
+
></qxs-page-end>`:s`<div style="color:#909399;padding:8px">未知题型: ${e.answerType}</div>`}render(){return 0===this._list.length?s``:s`
|
|
75
74
|
${!this._isPreviewValue&&this._list.length>1?s`
|
|
76
75
|
<div class="sort-mode-toggle">
|
|
77
76
|
<button class="btn ${this._sortMode?"primary":""}" @click=${()=>{this._sortMode=!this._sortMode}}>
|
|
@@ -86,7 +85,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
86
85
|
`:""}
|
|
87
86
|
${this._sortMode?s`
|
|
88
87
|
<div class="sort-list">
|
|
89
|
-
${
|
|
88
|
+
${this._list.map((e,t)=>s`
|
|
90
89
|
<div class="sort-item" data-id=${e.customId}>
|
|
91
90
|
<span class="sort-handle">
|
|
92
91
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
|
@@ -95,7 +94,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
95
94
|
</span>
|
|
96
95
|
<span class="sort-index">${t+1}.</span>
|
|
97
96
|
<span class="sort-title">${e.title||"未命名题目"}</span>
|
|
98
|
-
<span class="sort-type">${
|
|
97
|
+
<span class="sort-type">${p[e.answerType]||e.answerType}</span>
|
|
99
98
|
</div>
|
|
100
99
|
`)}
|
|
101
100
|
</div>
|
|
@@ -108,16 +107,14 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
108
107
|
`)}
|
|
109
108
|
</div>
|
|
110
109
|
`}
|
|
111
|
-
|
|
112
|
-
`}};u.styles=e`
|
|
110
|
+
`}};m.styles=e`
|
|
113
111
|
:host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 13px; }
|
|
114
112
|
*, ::before, ::after { box-sizing: border-box; }
|
|
115
|
-
.wrapper { width: 100%; padding: 16px; margin-bottom: 16px; background: #fff; border: 1px solid #ebeef5; border-radius: 4px; }
|
|
116
113
|
.sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }
|
|
117
114
|
.btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }
|
|
118
|
-
.btn:hover { color: #
|
|
119
|
-
.btn.primary { background: #
|
|
120
|
-
.btn.primary:hover { background: #
|
|
115
|
+
.btn:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }
|
|
116
|
+
.btn.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }
|
|
117
|
+
.btn.primary:hover { background: #3D61E3; border-color: #3D61E3; }
|
|
121
118
|
.subject-list { display: flex; flex-direction: column; }
|
|
122
119
|
.subject-item { position: relative; display: flex; align-items: flex-start; transition: background-color 0.3s ease; }
|
|
123
120
|
.subject-content { flex: 1; min-width: 0; }
|
|
@@ -133,5 +130,5 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
133
130
|
.sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }
|
|
134
131
|
.sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
135
132
|
.sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }
|
|
136
|
-
`,
|
|
133
|
+
`,h([i({attribute:"is-preview"})],m.prototype,"isPreview",2),h([i({type:Object})],m.prototype,"uploadImage",2),h([i({type:Array})],m.prototype,"subjectList",1),h([a()],m.prototype,"_list",2),h([a()],m.prototype,"_sortMode",2),m=h([r("qxs-subject-list")],m);export{m as QxsSubjectList};
|
|
137
134
|
//# sourceMappingURL=list.mjs.map
|
package/es/subject/list.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.mjs","sources":["../../../../packages/components-wc/src/subject/list.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { repeat } from 'lit/directives/repeat.js'\nimport { property, state } from 'lit/decorators.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\n\nconst TYPE_LABEL: Record<string, string> = {\n single: '单选题', multiple: '多选题', sort: '排序题',\n blank_fill: '填空题', text_fill: '问答题', scale: '量表题',\n rich_text: '富文本', page_end: '分页符',\n}\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .wrapper { width: 100%; padding: 16px; margin-bottom: 16px; background: #fff; border: 1px solid #ebeef5; border-radius: 4px; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #409eff; border-color: #c6e2ff; background: #ecf5ff; }\n .btn.primary { background: #409eff; border-color: #409eff; color: #fff; }\n .btn.primary:hover { background: #337ecc; border-color: #337ecc; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-item { position: relative; display: flex; align-items: flex-start; transition: background-color 0.3s ease; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n @property({ attribute: 'is-preview' }) isPreview = false\n\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = (e) => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n\n @property({ type: Array })\n get subjectList() { return this._list }\n\n set subjectList(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = v.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = (this as any).isPreview\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode)\n return\n const el = this.shadowRoot?.querySelector<HTMLElement>('.sort-list')\n if (!el)\n return\n \n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n \n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.shadowRoot?.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) return\n \n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emit('change', this._list)\n },\n })\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.shadowRoot?.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return results\n }\n\n async validate(): Promise<{ valid: boolean; errors: SubjectError[] }> {\n const subjectEls = this.shadowRoot?.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n const item = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n isKey: false, answerCheckType: 1,\n examAnswerRelationType: examAnswerRelationType ?? 0,\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this._emit('change', this._list)\n }\n\n addExam(items: any[]) {\n let pageIdx = 1\n const newItems: any[] = []\n items.forEach((v: any) => {\n const item: any = {\n ...v,\n customId: v.customId || uid(),\n answers: v.answers?.map((c: any) => ({ ...c, title: c.answer, answerId: c.examAnswerId, isCorrect: c.isCorrect })) || [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n }\n if (!v.richTextContent) {\n item.answerType = v.examTypeEnum\n }\n if (item.pageIndex > pageIdx) {\n newItems.push({ customId: uid(), answerType: 'page_end', analysis: '', scaleQuestionList: [], isEdit: true, isSave: false, isRealCanDel: true, hasSet: false, examAnswerRelationType: 0 })\n pageIdx = item.pageIndex\n }\n newItems.push(item)\n })\n this._list = [...this._list, ...newItems]\n this._emit('change', this._list)\n }\n\n uploadExcel(list: any[]) {\n this._list = [...this._list, ...list.map((i: any) => ({ ...i, customId: i.customId || uid(), isRealCanDel: true }))]\n this._emit('change', this._list)\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n if (v.answerType !== 'page_end') {\n n++; if (v.customId === customId) { out = n }\n }\n })\n return out - 1\n }\n\n private _pageIndex(customId: string) {\n const pages = this._list.filter((v: any) => v.answerType === 'page_end')\n const idx = pages.findIndex((v: any) => v.customId === customId)\n return idx + 1\n }\n\n private _totalPages() {\n return this._list.filter((v: any) => v.answerType === 'page_end').length\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _save(index: number, e: CustomEvent) {\n this._list = this._list.map((item, i) =>\n i === index ? { ...item, ...e.detail, isEdit: false, isSave: true } : item,\n )\n this._emit('change', this._list)\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emit('change', this._list)\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?is-save': !item.isRealCanDel,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if (['single', 'multiple', 'sort'].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit}\n ?is-set=${item.hasSet}\n ?is-save=${!item.isRealCanDel}\n ?show-action=${!this._isPreviewValue}\n ?is-key=${item.isKey}\n type=${item.answerType}\n answer-check-type=${item.answerCheckType ?? 1}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n least-answer-count=${item.leastAnswerCount ?? 2}\n exam-expand=${item.examExpand || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @set-relation=${(e: CustomEvent) => this._emit('set-relation', e.detail)}\n ></qxs-subject-single>`\n }\n if (item.answerType === 'blank_fill') {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-blank-fill>`\n }\n if (item.answerType === 'text_fill') {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-text-fill>`\n }\n if (item.answerType === 'scale') {\n return html`<qxs-scale\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .scaleQuestions=${item.scaleQuestionList || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-scale>`\n }\n if (item.answerType === 'rich_text') {\n return html`<qxs-subject-rich-text\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.richTextContent || item.examRichTextContent || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-subject-rich-text>`\n }\n if (item.answerType === 'page_end') {\n return html`<qxs-page-end\n current-page-index=${this._pageIndex(item.customId)}\n total-page=${this._totalPages()}\n ?show-action=${!this._isPreviewValue}\n @move=${onMove} @delete=${onDelete} @add=${onAdd}\n ></qxs-page-end>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n return html`\n <div class=\"wrapper\">\n ${!this._isPreviewValue && this._list.length > 1\n ? html`\n <div class=\"sort-mode-toggle\">\n <button class=\"btn ${this._sortMode ? 'primary' : ''}\" @click=${() => { this._sortMode = !this._sortMode }}>\n ${!this._sortMode\n ? html`\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z\"/>\n </svg>\n `\n : ''}\n ${this._sortMode ? '完成排序' : '排序'}\n </button>\n </div>\n `\n : ''}\n ${this._sortMode\n ? html`\n <div class=\"sort-list\">\n ${repeat(this._list, (item) => item.customId, (item, i) => html`\n <div class=\"sort-item\" data-id=${item.customId}>\n <span class=\"sort-handle\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z\"/>\n </svg>\n </span>\n <span class=\"sort-index\">${i + 1}.</span>\n <span class=\"sort-title\">${item.title || '未命名题目'}</span>\n <span class=\"sort-type\">${TYPE_LABEL[item.answerType] || item.answerType}</span>\n </div>\n `)}\n </div>\n `\n : html`\n <div class=\"subject-list\">\n ${this._list.map((item, i) => html`\n <div class=\"subject-item ${this._isPreviewValue ? 'is-preview' : ''}\" key=${item.customId}>\n <div class=\"subject-content\">${this._renderItem(item, i)}</div>\n </div>\n `)}\n </div>\n `}\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["TYPE_LABEL","single","multiple","sort","blank_fill","text_fill","scale","rich_text","page_end","QxsSubjectList","LitElement","constructor","super","arguments","this","isPreview","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","subjectList","v","JSON","parse","requestUpdate","Array","isArray","map","i","customId","uid","attributeChangedCallback","name","oldVal","newVal","length","includes","parsed","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","el","shadowRoot","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","item","splice","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","subjectEls","querySelectorAll","results","errors","data","push","err","SubjectError","message","validate","valid","errs","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","addExam","items","pageIdx","newItems","forEach","c","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","pageIndex","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","_orderIndex","n","out","_pageIndex","filter","findIndex","_totalPages","_move","dir","_save","_deleteByCustomId","_delete","_setEdit","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","html","examRichTextContent","leastAnswerCount","examExpand","examId","examAnswerSettingVO","render","repeat","styles","css","__decorateClass","property","attribute","prototype","Object","state","safeCustomElement"],"mappings":"2wBAQA,MAAMA,EAAqC,CACzCC,OAAQ,MAAOC,SAAU,MAAOC,KAAM,MACtCC,WAAY,MAAOC,UAAW,MAAOC,MAAO,MAC5CC,UAAW,MAAOC,SAAU,OAIvB,IAAMC,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WA2BkCC,KAAAC,WAAY,EAGnDD,KAAAE,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAAUC,GAAML,EAAQK,EAAEC,QAAQC,QACzCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAkDhBf,KAAQgB,MAAe,GACvBhB,KAAQiB,WAAY,EAC7BjB,KAAQkB,UAA6B,KAOrClB,KAAQmB,uBAAwB,CAAA,CAtDhC,eAAIC,GAAgB,OAAOpB,KAAKgB,KAAM,CAEtC,eAAII,CAAYC,GACd,GAAKA,EAAL,CAIA,GAAiB,iBAANA,EACT,IACEA,EAAIC,KAAKC,MAAMF,EACjB,CAAA,MAIE,OAFArB,KAAKgB,MAAQ,QACbhB,KAAKwB,eAEP,CAEF,IAAKC,MAAMC,QAAQL,GAGjB,OAFArB,KAAKgB,MAAQ,QACbhB,KAAKwB,gBAGPxB,KAAKgB,MAAQK,EAAEM,IAAKC,IAAA,IAAiBA,EAAGC,SAAUD,EAAEC,UAAYC,OAChE9B,KAAKwB,eAjBL,MAFExB,KAAKgB,MAAQ,EAoBjB,CAEAe,wBAAAA,CAAyBC,EAAcC,EAAuBC,GAE5D,GADApC,MAAMiC,yBAAyBC,EAAMC,EAAQC,GAChC,iBAATF,GAA2BE,IAAWlC,KAAKgB,MAAMmB,OAAQ,CAC3D,GAAID,EAAOE,SAAS,mBAClB,OAEF,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OAAON,CAAA;;SAEFpJ,KAAKsC,iBAAmBtC,KAAKgB,MAAMmB,OAAS,EAC3CiH,CAAA;;+BAEqBpJ,KAAKiB,UAAY,UAAY,cAAc,KAAQjB,KAAKiB,WAAajB,KAAKiB;cAC1FjB,KAAKiB,UAMJ,GALAmI,CAAA;;;;;cAMFpJ,KAAKiB,UAAY,OAAS;;;QAI9B;QACFjB,KAAKiB,UACHmI,CAAA;;YAEEO,EAAO3J,KAAKgB,MAAQsD,GAASA,EAAKzC,SAAU,CAACyC,EAAM1C,IAAMwH,CAAA;6CACxB9E,EAAKzC;;;;;;yCAMTD,EAAI;yCACJ0C,EAAK4B,OAAS;wCACfhH,EAAWoF,EAAK2B,aAAe3B,EAAK2B;;;;QAKlEmD,CAAA;;YAEEpJ,KAAKgB,MAAMW,IAAI,CAAC2C,EAAM1C,IAAMwH,CAAA;uCACDpJ,KAAKsC,gBAAkB,aAAe,WAAWgC,EAAKzC;6CAChD7B,KAAK6I,YAAYvE,EAAM1C;;;;;;KAOlE,GAxgBWjC,EACJiK,OAASC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;IA0BuBC,EAAA,CAAtCC,EAAS,CAAEC,UAAW,gBA3BZrK,EA2B4BsK,UAAA,YAAA,GAGvCH,EAAA,CADCC,EAAS,CAAElE,KAAMqE,UA7BPvK,EA8BXsK,UAAA,cAAA,GAUIH,EAAA,CADHC,EAAS,CAAElE,KAAMpE,SAvCP9B,EAwCPsK,UAAA,cAAA,GA6CaH,EAAA,CAAhBK,KArFUxK,EAqFMsK,UAAA,QAAA,GACAH,EAAA,CAAhBK,KAtFUxK,EAsFMsK,UAAA,YAAA,GAtFNtK,EAANmK,EAAA,CADNM,EAAkB,qBACNzK"}
|
|
1
|
+
{"version":3,"file":"list.mjs","sources":["../../../../packages/components-wc/src/subject/list.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport Sortable from 'sortablejs'\nimport { safeCustomElement } from '../base/define'\nimport { uid } from '../base/uid'\nimport { SubjectError } from './single'\n\nconst TYPE_LABEL: Record<string, string> = {\n single: '单选题', multiple: '多选题', sort: '排序题',\n blank_fill: '填空题', text_fill: '问答题', scale: '量表题',\n rich_text: '富文本', page_end: '分页符',\n}\n\n@safeCustomElement('qxs-subject-list')\nexport class QxsSubjectList extends LitElement {\n static styles = css`\n :host { display: block; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 13px; }\n *, ::before, ::after { box-sizing: border-box; }\n .sort-mode-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }\n .btn { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px; font-size: 12px; border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266; cursor: pointer; transition: all 0.2s; }\n .btn:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .btn.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .btn.primary:hover { background: #3D61E3; border-color: #3D61E3; }\n .subject-list { display: flex; flex-direction: column; }\n .subject-item { position: relative; display: flex; align-items: flex-start; transition: background-color 0.3s ease; }\n .subject-content { flex: 1; min-width: 0; }\n .ghost { opacity: 0.5; background: #ecf5ff; }\n .chosen { box-shadow: 0 4px 16px rgba(64,158,255,.3); }\n .sort-list { display: flex; flex-direction: column; gap: 8px; }\n .sort-item { display: flex; align-items: center; padding: 12px 16px; background: #f8f9fa; border: 1px solid #e4e7ed; border-radius: 6px; cursor: grab; transition: all 0.3s ease; }\n .sort-item:hover { background: #ecf5ff; border-color: #c6e2ff; }\n .sort-item:active { cursor: grabbing; }\n .sort-item.sort-ghost { opacity: 0.5; background: #ecf5ff; border: 2px dashed #409eff; }\n .sort-item.sort-chosen { background: #ecf5ff; border-color: #409eff; box-shadow: 0 4px 16px rgba(64,158,255,.3); transform: scale(1.02); }\n .sort-handle { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 12px; color: #909399; flex-shrink: 0; }\n .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }\n .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }\n `\n\n @property({ attribute: 'is-preview' }) isPreview = false\n\n @property({ type: Object })\n uploadImage: (file: File) => Promise<string> = async (file: File) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = e => resolve(e.target?.result as string)\n reader.onerror = reject\n reader.readAsDataURL(file)\n })\n }\n\n @property({ type: Array })\n get subjectList() { return this._list }\n\n set subjectList(v: any) {\n if (!v) {\n this._list = []\n return\n }\n if (typeof v === 'string') {\n try {\n v = JSON.parse(v)\n }\n catch {\n this._list = []\n this.requestUpdate()\n return\n }\n }\n if (!Array.isArray(v)) {\n this._list = []\n this.requestUpdate()\n return\n }\n this._list = v.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n\n attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null) {\n super.attributeChangedCallback(name, oldVal, newVal)\n if (name === 'subject-list' && newVal && !this._list.length) {\n if (newVal.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(newVal)\n if (Array.isArray(parsed)) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n }\n\n @state() private _list: any[] = []\n @state() private _sortMode = false\n private _sortable: Sortable | null = null\n\n private get _isPreviewValue(): boolean {\n const val = (this as any).isPreview\n return typeof val === 'string' ? val !== 'false' : !!val\n }\n\n private _initialDataProcessed = false\n\n connectedCallback() {\n super.connectedCallback()\n if (!this._initialDataProcessed) {\n this._initialDataProcessed = true\n Promise.resolve().then(() => {\n if (this._list.length === 0) {\n this._processAttributeList()\n }\n })\n }\n }\n\n private _processAttributeList() {\n const attr = this.getAttribute('subject-list')\n if (!attr || attr === '[]') { return }\n if (attr.includes('[object Object]')) {\n return\n }\n try {\n const parsed = JSON.parse(attr)\n if (Array.isArray(parsed) && parsed.length > 0) {\n this._list = parsed.map((i: any) => ({ ...i, customId: i.customId || uid() }))\n this.requestUpdate()\n }\n }\n catch {\n // Not valid JSON, ignore\n }\n }\n\n firstUpdated() {\n this.updateComplete.then(() => this._initSortable())\n }\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('_sortMode')) {\n this._sortable?.destroy()\n this._sortable = null\n this.updateComplete.then(() => this._initSortable())\n }\n // Reinitialize Sortable when list changes in sort mode\n if (changed.has('_list') && this._sortMode) {\n // Small delay to let Lit finish DOM updates\n setTimeout(() => {\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n this._initSortable()\n }, 50)\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this._sortable?.destroy()\n this._sortable = null\n }\n\n private _initSortable() {\n if (!this._sortMode) { return }\n const el = this.shadowRoot?.querySelector<HTMLElement>('.sort-list')\n if (!el) { return }\n\n // Destroy existing instance first\n if (this._sortable) {\n this._sortable.destroy()\n this._sortable = null\n }\n\n // Small delay to ensure DOM is ready after previous destroy\n requestAnimationFrame(() => {\n const currentEl = this.shadowRoot?.querySelector<HTMLElement>('.sort-list')\n if (!currentEl || this._sortable) { return }\n\n this._sortable = Sortable.create(currentEl, {\n handle: '.sort-handle',\n animation: 200,\n ghostClass: 'sort-ghost',\n chosenClass: 'sort-chosen',\n onEnd: (evt) => {\n const { oldIndex, newIndex } = evt\n if (oldIndex === undefined || newIndex === undefined || oldIndex === newIndex) { return }\n const arr = [...this._list]\n const [item] = arr.splice(oldIndex, 1)\n arr.splice(newIndex, 0, item)\n this._list = arr\n this._emit('change', this._list)\n },\n })\n })\n }\n\n private _emit(name: string, detail?: unknown) {\n this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail: detail ?? null }))\n }\n\n async toJSON(): Promise<any[]> {\n const subjectEls = this.shadowRoot?.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return []\n }\n\n const results: any[] = []\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.toJSON === 'function') {\n try {\n const data = await el.toJSON()\n results.push(data)\n }\n catch (err: any) {\n if (err instanceof SubjectError) {\n errors.push(err)\n }\n else {\n errors.push(new SubjectError(err.message || '未知错误', 'UNKNOWN', 'unknown'))\n }\n }\n }\n }\n\n if (errors.length > 0) {\n throw errors\n }\n\n return results\n }\n\n async validate(): Promise<{ valid: boolean, errors: SubjectError[] }> {\n const subjectEls = this.shadowRoot?.querySelectorAll<any>(\n 'qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-subject-rich-text',\n )\n if (!subjectEls || subjectEls.length === 0) {\n return { valid: true, errors: [] }\n }\n\n const errors: SubjectError[] = []\n\n for (const el of subjectEls) {\n if (typeof el.validate === 'function') {\n const errs = el.validate()\n if (errs?.length) {\n errors.push(...errs)\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n }\n }\n\n // ── public API ────────────────────────────────────────────────\n get currentList() { return this._list }\n\n addSubject(type: string, index?: number, examAnswerRelationType: number | null = null) {\n const item = {\n customId: uid(), answerType: type, title: '',\n answers: [], analysis: '', scaleQuestionList: [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n isKey: false, answerCheckType: 1,\n examAnswerRelationType: examAnswerRelationType ?? 0,\n }\n const arr = [...this._list]\n if (typeof index === 'number' && index >= 0) {\n arr.splice(index + 1, 0, item)\n }\n else { arr.push(item) }\n this._list = arr\n this._emit('change', this._list)\n }\n\n addExam(items: any[]) {\n let pageIdx = 1\n const newItems: any[] = []\n items.forEach((v: any) => {\n const item: any = {\n ...v,\n customId: v.customId || uid(),\n answers: v.answers?.map((c: any) => ({ ...c, title: c.answer, answerId: c.examAnswerId, isCorrect: c.isCorrect })) || [],\n isEdit: true, isSave: false, isRealCanDel: true, hasSet: false,\n }\n if (!v.richTextContent) {\n item.answerType = v.examTypeEnum\n }\n if (item.pageIndex > pageIdx) {\n newItems.push({ customId: uid(), answerType: 'page_end', analysis: '', scaleQuestionList: [], isEdit: true, isSave: false, isRealCanDel: true, hasSet: false, examAnswerRelationType: 0 })\n pageIdx = item.pageIndex\n }\n newItems.push(item)\n })\n this._list = [...this._list, ...newItems]\n this._emit('change', this._list)\n }\n\n uploadExcel(list: any[]) {\n this._list = [...this._list, ...list.map((i: any) => ({ ...i, customId: i.customId || uid(), isRealCanDel: true }))]\n this._emit('change', this._list)\n }\n\n setAnswerRelation(answerRelations: any, customId: string, customAnswerId: string) {\n const item = this._list.find((v: any) => v.customId === customId)\n if (item) {\n const ans = item.answers?.find((c: any) => c.customAnswerId === customAnswerId)\n if (ans) { ans.answerRelations = answerRelations }\n }\n this.requestUpdate()\n this._emit('change', this._list)\n }\n\n // ── private helpers ───────────────────────────────────────────\n private _orderIndex(customId: string) {\n let n = 0; let out = 0\n this._list.forEach((v: any) => {\n if (v.answerType !== 'page_end') {\n n++; if (v.customId === customId) { out = n }\n }\n })\n return out - 1\n }\n\n private _pageIndex(customId: string) {\n const pages = this._list.filter((v: any) => v.answerType === 'page_end')\n const idx = pages.findIndex((v: any) => v.customId === customId)\n return idx + 1\n }\n\n private _totalPages() {\n return this._list.filter((v: any) => v.answerType === 'page_end').length\n }\n\n private _move(index: number, dir: 'up' | 'down') {\n const arr = [...this._list]\n if (dir === 'up' && index > 0) { [arr[index - 1], arr[index]] = [arr[index], arr[index - 1]] }\n else if (dir === 'down' && index < arr.length - 1) { [arr[index], arr[index + 1]] = [arr[index + 1], arr[index]] }\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _save(index: number, e: CustomEvent) {\n this._list = this._list.map((item, i) =>\n i === index ? { ...item, ...e.detail, isEdit: false, isSave: true } : item,\n )\n this._emit('change', this._list)\n }\n\n private _deleteByCustomId(customId: string) {\n this._list = this._list.filter(item => item.customId !== customId)\n this._emit('change', this._list)\n }\n\n private _delete(index: number) {\n const arr = [...this._list]\n arr.splice(index, 1)\n this._list = arr\n this._emit('change', this._list)\n }\n\n private _setEdit(index: number, val: boolean) {\n this._list = this._list.map((item, i) => i === index ? { ...item, isEdit: val } : item)\n }\n\n private _renderItem(item: any, index: number) {\n const common = {\n 'order-index': this._orderIndex(item.customId),\n '?is-edit': item.isEdit || false,\n '?is-set': item.hasSet || false,\n '?is-save': !item.isRealCanDel,\n '?show-action': !this._isPreviewValue,\n 'exam-answer-relation-type': item.examAnswerRelationType ?? 0,\n }\n const onMove = (e: CustomEvent) => this._move(index, e.detail as 'up' | 'down')\n const onDelete = () => this._deleteByCustomId(item.customId)\n const onSave = (e: CustomEvent) => this._save(index, e)\n const onEdit = () => this._setEdit(index, true)\n const onAdd = (e: CustomEvent) => this.addSubject(e.detail?.type ?? e.detail, index)\n\n if (['single', 'multiple', 'sort'].includes(item.answerType)) {\n return html`<qxs-subject-single\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit}\n ?is-set=${item.hasSet}\n ?is-save=${!item.isRealCanDel}\n ?show-action=${!this._isPreviewValue}\n ?is-key=${item.isKey}\n type=${item.answerType}\n answer-check-type=${item.answerCheckType ?? 1}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n least-answer-count=${item.leastAnswerCount ?? 2}\n exam-expand=${item.examExpand || ''}\n custom-id=${item.customId || ''}\n exam-id=${item.examId ?? 0}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n @set-relation=${(e: CustomEvent) => this._emit('set-relation', e.detail)}\n ></qxs-subject-single>`\n }\n if (item.answerType === 'blank_fill') {\n return html`<qxs-blank-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-blank-fill>`\n }\n if (item.answerType === 'text_fill') {\n return html`<qxs-text-fill\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .examAnswerSetting=${item.examAnswerSettingVO || {}}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n exam-expand=${item.examExpand || ''}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-text-fill>`\n }\n if (item.answerType === 'scale') {\n return html`<qxs-scale\n .title=${item.title || ''}\n .answerList=${item.answers || []}\n .scaleQuestions=${item.scaleQuestionList || []}\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.examRichTextContent || ''}\n analysis=${item.analysis || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-scale>`\n }\n if (item.answerType === 'rich_text') {\n return html`<qxs-subject-rich-text\n .uploadImage=${this.uploadImage}\n order-index=${common['order-index']}\n ?is-edit=${item.isEdit} ?is-set=${item.hasSet} ?is-save=${!item.isRealCanDel} ?show-action=${!this._isPreviewValue}\n exam-answer-relation-type=${item.examAnswerRelationType ?? 0}\n rich-text-content=${item.richTextContent || item.examRichTextContent || ''}\n custom-id=${item.customId || ''}\n @move=${onMove} @delete=${onDelete} @save=${onSave} @edit=${onEdit} @add=${onAdd}\n ></qxs-subject-rich-text>`\n }\n if (item.answerType === 'page_end') {\n return html`<qxs-page-end\n current-page-index=${this._pageIndex(item.customId)}\n total-page=${this._totalPages()}\n ?show-action=${!this._isPreviewValue}\n @move=${onMove} @delete=${onDelete} @add=${onAdd}\n ></qxs-page-end>`\n }\n return html`<div style=\"color:#909399;padding:8px\">未知题型: ${item.answerType}</div>`\n }\n\n render() {\n if (this._list.length === 0) {\n return html``\n }\n return html`\n ${!this._isPreviewValue && this._list.length > 1\n ? html`\n <div class=\"sort-mode-toggle\">\n <button class=\"btn ${this._sortMode ? 'primary' : ''}\" @click=${() => { this._sortMode = !this._sortMode }}>\n ${!this._sortMode\n ? html`\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z\"/>\n </svg>\n `\n : ''}\n ${this._sortMode ? '完成排序' : '排序'}\n </button>\n </div>\n `\n : ''}\n ${this._sortMode\n ? html`\n <div class=\"sort-list\">\n ${this._list.map((item: any, i: number) => html`\n <div class=\"sort-item\" data-id=${item.customId}>\n <span class=\"sort-handle\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"currentColor\">\n <path d=\"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z\"/>\n </svg>\n </span>\n <span class=\"sort-index\">${i + 1}.</span>\n <span class=\"sort-title\">${item.title || '未命名题目'}</span>\n <span class=\"sort-type\">${TYPE_LABEL[item.answerType] || item.answerType}</span>\n </div>\n `)}\n </div>\n `\n : html`\n <div class=\"subject-list\">\n ${this._list.map((item, i) => html`\n <div class=\"subject-item ${this._isPreviewValue ? 'is-preview' : ''}\" key=${item.customId}>\n <div class=\"subject-content\">${this._renderItem(item, i)}</div>\n </div>\n `)}\n </div>\n `}\n `\n }\n}\n\nexport function register() {}\n"],"names":["TYPE_LABEL","single","multiple","sort","blank_fill","text_fill","scale","rich_text","page_end","QxsSubjectList","LitElement","constructor","super","arguments","this","isPreview","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","_list","_sortMode","_sortable","_initialDataProcessed","subjectList","v","JSON","parse","requestUpdate","Array","isArray","map","i","customId","uid","attributeChangedCallback","name","oldVal","newVal","length","includes","parsed","_isPreviewValue","val","connectedCallback","then","_processAttributeList","attr","getAttribute","firstUpdated","updateComplete","_initSortable","updated","changed","has","destroy","setTimeout","disconnectedCallback","el","shadowRoot","querySelector","requestAnimationFrame","currentEl","Sortable","create","handle","animation","ghostClass","chosenClass","onEnd","evt","oldIndex","newIndex","arr","item","splice","_emit","detail","dispatchEvent","CustomEvent","bubbles","composed","toJSON","subjectEls","querySelectorAll","results","errors","data","push","err","SubjectError","message","validate","valid","errs","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","addExam","items","pageIdx","newItems","forEach","c","answer","answerId","examAnswerId","isCorrect","richTextContent","examTypeEnum","pageIndex","uploadExcel","list","setAnswerRelation","answerRelations","customAnswerId","find","ans","_orderIndex","n","out","_pageIndex","filter","findIndex","_totalPages","_move","dir","_save","_deleteByCustomId","_delete","_setEdit","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","html","examRichTextContent","leastAnswerCount","examExpand","examId","examAnswerSettingVO","render","styles","css","__decorateClass","property","attribute","prototype","Object","state","safeCustomElement"],"mappings":"iqBAQA,MAAMA,EAAqC,CACzCC,OAAQ,MAAOC,SAAU,MAAOC,KAAM,MACtCC,WAAY,MAAOC,UAAW,MAAOC,MAAO,MAC5CC,UAAW,MAAOC,SAAU,OAIvB,IAAMC,EAAN,cAA6BC,EAA7BC,WAAAA,GAAAC,SAAAC,WA0BkCC,KAAAC,WAAY,EAGnDD,KAAAE,YAA+CC,SACtC,IAAIC,QAAQ,CAACC,EAASC,KAC3B,MAAMC,EAAS,IAAIC,WACnBD,EAAOE,OAASC,GAAKL,EAAQK,EAAEC,QAAQC,QACvCL,EAAOM,QAAUP,EACjBC,EAAOO,cAAcC,KAkDhBf,KAAQgB,MAAe,GACvBhB,KAAQiB,WAAY,EAC7BjB,KAAQkB,UAA6B,KAOrClB,KAAQmB,uBAAwB,CAAA,CAtDhC,eAAIC,GAAgB,OAAOpB,KAAKgB,KAAM,CAEtC,eAAII,CAAYC,GACd,GAAKA,EAAL,CAIA,GAAiB,iBAANA,EACT,IACEA,EAAIC,KAAKC,MAAMF,EACjB,CAAA,MAIE,OAFArB,KAAKgB,MAAQ,QACbhB,KAAKwB,eAEP,CAEF,IAAKC,MAAMC,QAAQL,GAGjB,OAFArB,KAAKgB,MAAQ,QACbhB,KAAKwB,gBAGPxB,KAAKgB,MAAQK,EAAEM,IAAKC,IAAA,IAAiBA,EAAGC,SAAUD,EAAEC,UAAYC,OAChE9B,KAAKwB,eAjB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vK,EAqFMqK,UAAA,YAAA,GArFNrK,EAANkK,EAAA,CADNM,EAAkB,qBACNxK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("@tiptap/core"),t=require("@tiptap/extension-blockquote"),i=require("@tiptap/extension-bold"),o=require("@tiptap/extension-bullet-list"),r=require("@tiptap/extension-code"),s=require("@tiptap/extension-document"),l=require("@tiptap/extension-heading"),n=require("@tiptap/extension-history"),a=require("@tiptap/extension-horizontal-rule"),d=require("@tiptap/extension-image"),c=require("@tiptap/extension-italic"),h=require("@tiptap/extension-link"),p=require("@tiptap/extension-list-item"),b=require("@tiptap/extension-ordered-list"),u=require("@tiptap/extension-paragraph"),g=require("@tiptap/extension-strike"),x=require("@tiptap/extension-table"),m=require("@tiptap/extension-table-cell"),v=require("@tiptap/extension-table-header"),y=require("@tiptap/extension-table-row"),f=require("@tiptap/extension-text"),_=require("@tiptap/extension-text-align"),w=require("@tiptap/extension-underline"),k=require("../node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs"),C=require("lit"),M=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),T=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),A=require("../base/define.cjs"),$=Object.defineProperty,B=Object.getOwnPropertyDescriptor,q=(e,t,i,o)=>{for(var r,s=o>1?void 0:o?B(t,i):t,l=e.length-1;l>=0;l--)(r=e[l])&&(s=(o?r(t,i,s):r(s))||s);return o&&s&&$(t,i,s),s};exports.QxsBlocksuiteEditor=class extends C.LitElement{constructor(){super(...arguments),this.content="",this.modelValue="",this.useModelAttr="false",this.autoSyncAttr="true",this.readonlyAttr="false",this.previewAttr="false",this.isEditAttr="false",this.uploadImage=async e=>new Promise((t,i)=>{const o=new FileReader;o.onload=e=>t(e.target?.result),o.onerror=i,o.readAsDataURL(e)}),this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._isLoading=!0,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},this._imageToolbar={x:0,y:0,visible:!1},this._imageMoreMenuVisible=!1,this._hasSlashCommand=!1,this._isInitializing=!1,this._tableEdgeDetectionSetup=!1}get useModel(){return"true"===this.useModelAttr}set useModel(e){this.useModelAttr=String(e)}get autoSync(){return"false"!==this.autoSyncAttr}set autoSync(e){this.autoSyncAttr=String(e)}get readonly(){return"false"!==this.readonlyAttr}set readonly(e){this.readonlyAttr=String(e)}get preview(){return"false"!==this.previewAttr}set preview(e){this.previewAttr=String(e)}get isEdit(){return"true"===this.isEditAttr}set isEdit(e){this.isEditAttr=String(e)}_initEditor(){if(this._editor)return;const C=this.shadowRoot?.querySelector(".editor-content");if(!C)return void requestAnimationFrame(()=>this._initEditor());for(this._isInitializing=!0;C.firstChild;)C.removeChild(C.firstChild);this._isLoading=!1;const M=this.useModel||this.hasAttribute("use-model"),T=this.getAttribute("model-value")??this.modelValue,A=this.content,$=M?(this._pendingContent??T)||"<p></p>":(this._pendingContent??A)||"<p></p>",B=[s,u,f,i,c,w,g,r,l.configure({levels:[1,2,3]}),o,b,p,t,a,n,d.configure({inline:!1,allowBase64:!0}),h.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),_.configure({types:["heading","paragraph"]}),x.Table.configure({resizable:!0}),y.TableRow,m.TableCell,v.TableHeader,k.default.configure({placeholder:"输入 / 唤出快捷命令"})];this._editor=new e.Editor({element:C,extensions:B,editable:!this.readonly,content:$}),this._pendingContent=null,requestAnimationFrame(()=>{this._isInitializing=!1,this._emitContentChange()}),this._editor.on("selectionUpdate",()=>{this.requestUpdate(),this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar();const e=this._editor;if(e){const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()}}),this._editor.on("transaction",()=>{this.requestUpdate(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._setupTableEdgeDetection(),this._emitContentChange()}),this._editor.on("update",()=>{this._emitContentChange()})}_emitContentChange(){if(!this._editor)return;const e=this._editor.getHTML();this._isInitializing||(this.dispatchEvent(new CustomEvent("content-change",{detail:e,bubbles:!0,composed:!0})),this.autoSync&&(this.modelValue=e))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content");e&&!this._tableEdgeDetectionSetup&&(this._tableEdgeDetectionSetup=!0,e.addEventListener("mousemove",e=>{this._handleTableEdgeMouseMove(e)}),e.addEventListener("mouseleave",()=>{this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}}}),e.addEventListener("click",e=>{const t=e.target;if("IMG"===t.tagName){const e=this._editor?.view.posAtDOM(t,0);void 0!==e&&this._editor?.chain().focus().setNodeSelection(e).run()}}))}_handleTableEdgeMouseMove(e){if(!this._editor?.isActive("table"))return this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},void this.requestUpdate();const t=e.target.closest("table");if(!t)return this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},void this.requestUpdate();const i=t.getBoundingClientRect(),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),s=e.clientX-r.left,l=e.clientY-r.top,n=10,a=i.height/t.rows.length;for(let o=0;o<t.rows.length;o++){const t=i.top+o*a,l=t+a;if(e.clientY>=t-n&&e.clientY<=t+n)return this._tableEdgeHover={type:"row",index:o,position:{x:s,y:t-r.top}},void this.requestUpdate();if(e.clientY>=l-n&&e.clientY<=l+n)return this._tableEdgeHover={type:"row",index:o+1,position:{x:s,y:l-r.top}},void this.requestUpdate()}const d=i.width/t.rows[0]?.cells.length||1;for(let o=0;o<(t.rows[0]?.cells.length||0);o++){const t=i.left+o*d,s=t+d;if(e.clientX>=t-n&&e.clientX<=t+n)return this._tableEdgeHover={type:"col",index:o,position:{x:t-r.left,y:l}},void this.requestUpdate();if(e.clientX>=s-n&&e.clientX<=s+n)return this._tableEdgeHover={type:"col",index:o+1,position:{x:s-r.left,y:l}},void this.requestUpdate()}this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},this.requestUpdate()}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state,t=this._editor.state.doc.textBetween(Math.max(0,e.from-10),e.from," ");this._hasSlashCommand=t.endsWith("/")}firstUpdated(){this._initEditor()}updated(e){if(this._editor){if(e.has("content")||e.has("modelValue")&&this.useModel){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}e.has("readonly")&&this._editor.setEditable(!this.readonly)}else e.has("content")&&(this._pendingContent=this.content),e.has("modelValue")&&this.useModel&&(this._pendingContent=this.modelValue)}disconnectedCallback(){super.disconnectedCallback(),this._editor?.destroy(),this._editor=null}getContent(){return this._editor?.getHTML()??""}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}}forceSync(){this.forceUpdate()}_applyFormat(e){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}e()}_toggleBold(){this._applyFormat(()=>this._editor?.chain().focus().toggleBold().run())}_toggleItalic(){this._applyFormat(()=>this._editor?.chain().focus().toggleItalic().run())}_toggleUnderline(){this._applyFormat(()=>this._editor?.chain().focus().toggleUnderline().run())}_toggleStrike(){this._applyFormat(()=>this._editor?.chain().focus().toggleStrike().run())}_toggleCode(){this._applyFormat(()=>this._editor?.chain().focus().toggleCode().run())}_setHeading(e){this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleBlockquote(){this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_setLink(){const e=window.prompt("请输入链接地址:");e&&this._applyFormat(()=>this._editor?.chain().focus().setLink({href:e}).run())}_unsetLink(){this._applyFormat(()=>this._editor?.chain().focus().unsetLink().run())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i)try{const e=await this.uploadImage(i);this._editor?.chain().focus().setImage({src:e}).run()}catch(e){}t.value=""}_triggerImageUpload(){const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_insertHorizontalRule(){this._editor?.chain().focus().setHorizontalRule().run()}_showTableCellToolbar(){if(!this._editor?.isActive("table"))return;const{state:e}=this._editor,{selection:t}=e,i=this._editor.view.coordsAtPos(t.from),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),s=this._getTableCellRow(),l=this._getTableCellCol();(0===s||0===l)&&(this._tableCellToolbar={x:i.left-r.left,y:i.bottom-r.top+8,visible:!0,cellRow:s,cellCol:l})}_getTableCellRow(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e-1)}return 0}_getTableCellCol(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e)}return 0}_hideTableCellToolbar(){this._tableCellToolbar={...this._tableCellToolbar,visible:!1}}_addTableRowAbove(){this._editor?.chain().focus().addRowBefore().run(),this._hideTableCellToolbar()}_addTableRowBelow(){this._editor?.chain().focus().addRowAfter().run(),this._hideTableCellToolbar()}_addTableColumnLeft(){this._editor?.chain().focus().addColumnBefore().run(),this._hideTableCellToolbar()}_addTableColumnRight(){this._editor?.chain().focus().addColumnAfter().run(),this._hideTableCellToolbar()}_deleteTableRow(){this._editor?.chain().focus().deleteRow().run(),this._hideTableCellToolbar()}_deleteTableColumn(){this._editor?.chain().focus().deleteColumn().run(),this._hideTableCellToolbar()}_deleteTable(){this._editor?.chain().focus().deleteTable().run(),this._hideTableCellToolbar()}_showImageToolbar(e){this._imageToolbar={x:e.x,y:e.y,visible:!0},this._imageMoreMenuVisible=!1}_hideImageToolbar(){this._imageToolbar={...this._imageToolbar,visible:!1},this._imageMoreMenuVisible=!1}_toggleImageMoreMenu(){this._imageMoreMenuVisible=!this._imageMoreMenuVisible}_deleteImage(){this._editor?.chain().focus().deleteNode("image").run(),this._hideImageToolbar()}_insertImageAfter(){this._triggerImageUpload(),this._imageMoreMenuVisible=!1}_setImageAlignLeft(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto 0 0")}this._imageMoreMenuVisible=!1}_setImageAlignCenter(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto")}this._imageMoreMenuVisible=!1}_setImageAlignRight(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 0 0 auto")}this._imageMoreMenuVisible=!1}_updateImageToolbarPosition(){requestAnimationFrame(()=>{const e=this._editor;if(!e)return;const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name?i.node(i.depth):null){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()})}_getTextLabel(){const e=this._editor;return e?e.isActive("heading",{level:1})?"标题 1":e.isActive("heading",{level:2})?"标题 2":e.isActive("heading",{level:3})?"标题 3":"正文":"正文"}_getAlignLabel(){const e=this._editor;return e?e.isActive({textAlign:"center"})?"居中":e.isActive({textAlign:"right"})?"右对齐":"左对齐":"对齐"}_updateBubbleMenuPosition(){requestAnimationFrame(()=>{const e=this.shadowRoot?.querySelector(".bubble-menu"),t=this.shadowRoot?.querySelector(".ProseMirror"),i=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||!t||!i)return;const o=this._editor,r=o?.isActive("table")??!1,{selection:s}=o?.state??{selection:null};if(r&&s&&!s.empty&&o){const{from:t,to:i}=s,r=o.state.doc.resolve(t),l=o.state.doc.resolve(i);let n=!1;for(let e=r.depth;e>=0;e--)if("table"===r.node(e).type.name){n=!0;break}const a=r.node(r.depth),d=l.node(l.depth);if("table"!==a.type.name&&"table"!==d.type.name||(n=!0),n)return e.style.opacity="0",void(e.style.visibility="hidden")}if(s&&!s.empty);else if(!s||s.empty&&!this._hasSlashCommand)return e.style.opacity="0",void(e.style.visibility="hidden");const l=i.getBoundingClientRect(),n=e.getBoundingClientRect(),{from:a}=s,d=this._editor?.view.coordsAtPos(a);if(!d)return;let c=d.left-l.left,h=d.top-l.top-40;c+n.width>l.width&&(c=l.width-n.width-8),c<0&&(c=8),h<0&&(h=d.bottom-l.top+8),e.style.left=`${c}px`,e.style.top=`${h}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor;return C.html`
|
|
1
|
+
"use strict";var e=require("@tiptap/core"),t=require("@tiptap/extension-blockquote"),i=require("@tiptap/extension-bold"),o=require("@tiptap/extension-bullet-list"),r=require("@tiptap/extension-code"),s=require("@tiptap/extension-document"),l=require("@tiptap/extension-heading"),n=require("@tiptap/extension-history"),a=require("@tiptap/extension-horizontal-rule"),d=require("@tiptap/extension-image"),c=require("@tiptap/extension-italic"),h=require("@tiptap/extension-link"),p=require("@tiptap/extension-list-item"),b=require("@tiptap/extension-ordered-list"),u=require("@tiptap/extension-paragraph"),g=require("@tiptap/extension-strike"),x=require("@tiptap/extension-table"),m=require("@tiptap/extension-table-cell"),v=require("@tiptap/extension-table-header"),y=require("@tiptap/extension-table-row"),f=require("@tiptap/extension-text"),_=require("@tiptap/extension-text-align"),w=require("@tiptap/extension-underline"),k=require("../node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs"),C=require("lit"),M=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),T=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),A=require("../base/define.cjs"),$=Object.defineProperty,B=Object.getOwnPropertyDescriptor,q=(e,t,i,o)=>{for(var r,s=o>1?void 0:o?B(t,i):t,l=e.length-1;l>=0;l--)(r=e[l])&&(s=(o?r(t,i,s):r(s))||s);return o&&s&&$(t,i,s),s};exports.QxsBlocksuiteEditor=class extends C.LitElement{constructor(){super(...arguments),this.content="",this.modelValue="",this.useModelAttr="false",this.autoSyncAttr="true",this.readonlyAttr="false",this.previewAttr="false",this.isEditAttr="false",this.uploadImage=async e=>new Promise((t,i)=>{const o=new FileReader;o.onload=e=>t(e.target?.result),o.onerror=i,o.readAsDataURL(e)}),this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._isLoading=!0,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},this._imageToolbar={x:0,y:0,visible:!1},this._imageMoreMenuVisible=!1,this._hasSlashCommand=!1,this._isInitializing=!1,this._tableEdgeDetectionSetup=!1}get useModel(){return"true"===this.useModelAttr}set useModel(e){this.useModelAttr=String(e)}get autoSync(){return"false"!==this.autoSyncAttr}set autoSync(e){this.autoSyncAttr=String(e)}get readonly(){return"false"!==this.readonlyAttr}set readonly(e){this.readonlyAttr=String(e)}get preview(){return"false"!==this.previewAttr}set preview(e){this.previewAttr=String(e)}get isEdit(){return"true"===this.isEditAttr}set isEdit(e){this.isEditAttr=String(e)}_initEditor(){if(this._editor)return;const C=this.shadowRoot?.querySelector(".editor-content");if(!C)return void requestAnimationFrame(()=>this._initEditor());for(this._isInitializing=!0;C.firstChild;)C.removeChild(C.firstChild);this._isLoading=!1;const M=this.useModel||this.hasAttribute("use-model"),T=this.getAttribute("model-value")??this.modelValue,A=this.content,$=M?(this._pendingContent??T)||"<p></p>":(this._pendingContent??A)||"<p></p>",B=[s,u,f,i,c,w,g,r,l.configure({levels:[1,2,3]}),o,b,p,t,a,n,d.configure({inline:!1,allowBase64:!0}),h.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),_.configure({types:["heading","paragraph"]}),x.Table.configure({resizable:!0}),y.TableRow,m.TableCell,v.TableHeader,k.default.configure({placeholder:"输入 / 唤出快捷命令"}),e.Extension.create({name:"clearMarksOnEnter",addKeyboardShortcuts(){return{Enter:()=>(this.editor.chain().focus().unsetAllMarks().clearNodes().run(),!1)}}})];this._editor=new e.Editor({element:C,extensions:B,editable:!this.readonly,content:$}),this._pendingContent=null,requestAnimationFrame(()=>{this._isInitializing=!1,this._emitContentChange()}),this._editor.on("selectionUpdate",()=>{this.requestUpdate(),this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar();const e=this._editor;if(e){const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()}}),this._editor.on("transaction",()=>{this.requestUpdate(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._setupTableEdgeDetection(),this._emitContentChange()}),this._editor.on("update",()=>{this._emitContentChange()})}_emitContentChange(){if(!this._editor)return;const e=this._editor.getHTML();this._isInitializing||(this.dispatchEvent(new CustomEvent("content-change",{detail:e,bubbles:!0,composed:!0})),this.autoSync&&(this.modelValue=e))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content");e&&!this._tableEdgeDetectionSetup&&(this._tableEdgeDetectionSetup=!0,e.addEventListener("mousemove",e=>{this._handleTableEdgeMouseMove(e)}),e.addEventListener("mouseleave",()=>{this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}}}),e.addEventListener("click",e=>{const t=e.target;if("IMG"===t.tagName){const e=this._editor?.view.posAtDOM(t,0);void 0!==e&&this._editor?.chain().focus().setNodeSelection(e).run()}}))}_handleTableEdgeMouseMove(e){if(!this._editor?.isActive("table"))return this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},void this.requestUpdate();const t=e.target.closest("table");if(!t)return this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},void this.requestUpdate();const i=t.getBoundingClientRect(),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),s=e.clientX-r.left,l=e.clientY-r.top,n=10,a=i.height/t.rows.length;for(let o=0;o<t.rows.length;o++){const t=i.top+o*a,l=t+a;if(e.clientY>=t-n&&e.clientY<=t+n)return this._tableEdgeHover={type:"row",index:o,position:{x:s,y:t-r.top}},void this.requestUpdate();if(e.clientY>=l-n&&e.clientY<=l+n)return this._tableEdgeHover={type:"row",index:o+1,position:{x:s,y:l-r.top}},void this.requestUpdate()}const d=i.width/t.rows[0]?.cells.length||1;for(let o=0;o<(t.rows[0]?.cells.length||0);o++){const t=i.left+o*d,s=t+d;if(e.clientX>=t-n&&e.clientX<=t+n)return this._tableEdgeHover={type:"col",index:o,position:{x:t-r.left,y:l}},void this.requestUpdate();if(e.clientX>=s-n&&e.clientX<=s+n)return this._tableEdgeHover={type:"col",index:o+1,position:{x:s-r.left,y:l}},void this.requestUpdate()}this._tableEdgeHover={type:null,index:0,position:{x:0,y:0}},this.requestUpdate()}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state,t=this._editor.state.doc.textBetween(Math.max(0,e.from-10),e.from," ");this._hasSlashCommand=t.endsWith("/")}firstUpdated(){this._initEditor()}updated(e){if(this._editor){if(e.has("content")||e.has("modelValue")&&this.useModel){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}e.has("readonly")&&this._editor.setEditable(!this.readonly)}else e.has("content")&&(this._pendingContent=this.content),e.has("modelValue")&&this.useModel&&(this._pendingContent=this.modelValue)}disconnectedCallback(){super.disconnectedCallback(),this._editor?.destroy(),this._editor=null}getContent(){return this._editor?.getHTML()??""}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}}forceSync(){this.forceUpdate()}_applyFormat(e){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}e()}_toggleBold(){this._applyFormat(()=>this._editor?.chain().focus().toggleBold().run())}_toggleItalic(){this._applyFormat(()=>this._editor?.chain().focus().toggleItalic().run())}_toggleUnderline(){this._applyFormat(()=>this._editor?.chain().focus().toggleUnderline().run())}_toggleStrike(){this._applyFormat(()=>this._editor?.chain().focus().toggleStrike().run())}_toggleCode(){this._applyFormat(()=>this._editor?.chain().focus().toggleCode().run())}_setHeading(e){this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleBlockquote(){this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_setLink(){const e=window.prompt("请输入链接地址:");e&&this._applyFormat(()=>this._editor?.chain().focus().setLink({href:e}).run())}_unsetLink(){this._applyFormat(()=>this._editor?.chain().focus().unsetLink().run())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i)try{const e=await this.uploadImage(i);this._editor?.chain().focus().setImage({src:e}).run()}catch(e){}t.value=""}_triggerImageUpload(){const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_insertHorizontalRule(){this._editor?.chain().focus().setHorizontalRule().run()}_showTableCellToolbar(){if(!this._editor?.isActive("table"))return;const{state:e}=this._editor,{selection:t}=e,i=this._editor.view.coordsAtPos(t.from),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),s=this._getTableCellRow(),l=this._getTableCellCol();(0===s||0===l)&&(this._tableCellToolbar={x:i.left-r.left,y:i.bottom-r.top+8,visible:!0,cellRow:s,cellCol:l})}_getTableCellRow(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e-1)}return 0}_getTableCellCol(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e)}return 0}_hideTableCellToolbar(){this._tableCellToolbar={...this._tableCellToolbar,visible:!1}}_addTableRowAbove(){this._editor?.chain().focus().addRowBefore().run(),this._hideTableCellToolbar()}_addTableRowBelow(){this._editor?.chain().focus().addRowAfter().run(),this._hideTableCellToolbar()}_addTableColumnLeft(){this._editor?.chain().focus().addColumnBefore().run(),this._hideTableCellToolbar()}_addTableColumnRight(){this._editor?.chain().focus().addColumnAfter().run(),this._hideTableCellToolbar()}_deleteTableRow(){this._editor?.chain().focus().deleteRow().run(),this._hideTableCellToolbar()}_deleteTableColumn(){this._editor?.chain().focus().deleteColumn().run(),this._hideTableCellToolbar()}_deleteTable(){this._editor?.chain().focus().deleteTable().run(),this._hideTableCellToolbar()}_showImageToolbar(e){this._imageToolbar={x:e.x,y:e.y,visible:!0},this._imageMoreMenuVisible=!1}_hideImageToolbar(){this._imageToolbar={...this._imageToolbar,visible:!1},this._imageMoreMenuVisible=!1}_toggleImageMoreMenu(){this._imageMoreMenuVisible=!this._imageMoreMenuVisible}_deleteImage(){this._editor?.chain().focus().deleteNode("image").run(),this._hideImageToolbar()}_insertImageAfter(){this._triggerImageUpload(),this._imageMoreMenuVisible=!1}_setImageAlignLeft(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto 0 0")}this._imageMoreMenuVisible=!1}_setImageAlignCenter(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto")}this._imageMoreMenuVisible=!1}_setImageAlignRight(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 0 0 auto")}this._imageMoreMenuVisible=!1}_updateImageToolbarPosition(){requestAnimationFrame(()=>{const e=this._editor;if(!e)return;const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name?i.node(i.depth):null){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()})}_getTextLabel(){const e=this._editor;return e?e.isActive("heading",{level:1})?"标题 1":e.isActive("heading",{level:2})?"标题 2":e.isActive("heading",{level:3})?"标题 3":"正文":"正文"}_getAlignLabel(){const e=this._editor;return e?e.isActive({textAlign:"center"})?"居中":e.isActive({textAlign:"right"})?"右对齐":"左对齐":"对齐"}_updateBubbleMenuPosition(){requestAnimationFrame(()=>{const e=this.shadowRoot?.querySelector(".bubble-menu"),t=this.shadowRoot?.querySelector(".ProseMirror"),i=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||!t||!i)return;const o=this._editor,r=o?.isActive("table")??!1,{selection:s}=o?.state??{selection:null};if(r&&s&&!s.empty&&o){const{from:t,to:i}=s,r=o.state.doc.resolve(t),l=o.state.doc.resolve(i);let n=!1;for(let e=r.depth;e>=0;e--)if("table"===r.node(e).type.name){n=!0;break}const a=r.node(r.depth),d=l.node(l.depth);if("table"!==a.type.name&&"table"!==d.type.name||(n=!0),n)return e.style.opacity="0",void(e.style.visibility="hidden")}if(s&&!s.empty);else if(!s||s.empty&&!this._hasSlashCommand)return e.style.opacity="0",void(e.style.visibility="hidden");const l=i.getBoundingClientRect(),n=e.getBoundingClientRect(),{from:a}=s,d=this._editor?.view.coordsAtPos(a);if(!d)return;let c=d.left-l.left,h=d.top-l.top-40;c+n.width>l.width&&(c=l.width-n.width-8),c<0&&(c=8),h<0&&(h=d.bottom-l.top+8),e.style.left=`${c}px`,e.style.top=`${h}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor;return C.html`
|
|
2
2
|
<div class="editor-wrapper ${this._isLoading?"loading":""} ${this.preview?"preview":""}">
|
|
3
3
|
${this._isLoading?C.html`
|
|
4
4
|
<div class="loading-placeholder">
|
|
@@ -306,6 +306,7 @@
|
|
|
306
306
|
background: #fff;
|
|
307
307
|
overflow: visible;
|
|
308
308
|
position: relative;
|
|
309
|
+
min-height: 80px;
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
.editor-wrapper:focus-within {
|
|
@@ -341,12 +342,12 @@
|
|
|
341
342
|
color: #c0c0c0;
|
|
342
343
|
pointer-events: none;
|
|
343
344
|
display: block;
|
|
344
|
-
|
|
345
|
+
padding-top: 28px;
|
|
345
346
|
text-align: center;
|
|
346
347
|
}
|
|
347
348
|
|
|
348
349
|
.editor-content .ProseMirror:empty {
|
|
349
|
-
min-height:
|
|
350
|
+
min-height: 80px;
|
|
350
351
|
}
|
|
351
352
|
|
|
352
353
|
.ProseMirror p.is-editor-empty:first-child::before {
|
|
@@ -357,6 +358,15 @@
|
|
|
357
358
|
height: 0;
|
|
358
359
|
}
|
|
359
360
|
|
|
361
|
+
.ProseMirror p.is-empty:only-child::before,
|
|
362
|
+
.ProseMirror p.is-empty:only-child > br:first-child + *::before {
|
|
363
|
+
content: attr(data-placeholder);
|
|
364
|
+
color: #c0c0c0;
|
|
365
|
+
pointer-events: none;
|
|
366
|
+
float: left;
|
|
367
|
+
height: 0;
|
|
368
|
+
}
|
|
369
|
+
|
|
360
370
|
.editor-wrapper.loading {
|
|
361
371
|
display: flex;
|
|
362
372
|
align-items: center;
|