@qxs-bns/components-wc 0.0.2 → 0.0.3
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 +2 -2
- package/es/editor/blocksuite-editor.mjs.map +1 -1
- package/es/subject/blank-fill.mjs +34 -33
- package/es/subject/blank-fill.mjs.map +1 -1
- package/es/subject/list.mjs +7 -2
- package/es/subject/list.mjs.map +1 -1
- package/es/subject/rich-text.mjs +3 -3
- package/es/subject/rich-text.mjs.map +1 -1
- package/es/subject/scale.mjs +4 -3
- package/es/subject/scale.mjs.map +1 -1
- package/es/subject/single.mjs +4 -3
- package/es/subject/single.mjs.map +1 -1
- package/es/subject/text-fill.mjs +4 -3
- package/es/subject/text-fill.mjs.map +1 -1
- package/lib/editor/blocksuite-editor.cjs +2 -2
- package/lib/editor/blocksuite-editor.cjs.map +1 -1
- package/lib/subject/blank-fill.cjs +4 -3
- package/lib/subject/blank-fill.cjs.map +1 -1
- package/lib/subject/list.cjs +13 -8
- package/lib/subject/list.cjs.map +1 -1
- package/lib/subject/rich-text.cjs +3 -3
- package/lib/subject/rich-text.cjs.map +1 -1
- package/lib/subject/scale.cjs +4 -3
- package/lib/subject/scale.cjs.map +1 -1
- package/lib/subject/single.cjs +4 -3
- package/lib/subject/single.cjs.map +1 -1
- package/lib/subject/text-fill.cjs +4 -3
- package/lib/subject/text-fill.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import{html as
|
|
1
|
+
import{html as e,css as t,LitElement as i}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{state as a}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as n}from"../base/define.mjs";var l=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=(e,t,i,s)=>{for(var a,n=s>1?void 0:s?r(t,i):t,o=e.length-1;o>=0;o--)(a=e[o])&&(n=(s?a(t,i,n):a(n))||n);return s&&n&&l(t,i,n),n};const p=e`
|
|
2
2
|
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none"
|
|
3
3
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
4
4
|
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
|
|
5
|
-
</svg>`;function h(
|
|
5
|
+
</svg>`;function h(e){const t=document.createElement("div");t.textContent=e,Object.assign(t.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(t),setTimeout(()=>{t.style.opacity="0",setTimeout(()=>t.remove(),300)},2500)}let d=class extends i{constructor(){super(...arguments),this.orderIndex=0,this.title="",this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAnalysis=!1,this.richTextContent="",this.analysis="",this.examAnswerRelationType=0,this.examExpand="",this.examAnswerSetting={isInOrder:!1,isIgnoreCase:!0},this.uploadImage=async e=>new Promise((t,i)=>{const s=new FileReader;s.onload=e=>t(e.target?.result),s.onerror=i,s.readAsDataURL(e)}),this.answerList=[],this._title="",this._analysis="",this._answers=[{title:"",tag:"",showInput:!1}],this._isInOrder=!1,this._isIgnoreCase=!0,this._showRichText=!1,this._richText="",this.TITLE_MAX=400}updated(e){e.has("isEdit")&&this.isEdit&&this._syncProps()}_syncProps(){if(this._title=(this.title||"").replaceAll(/<filter><\/filter>/g," ______"),this._analysis=this.analysis||"",this.answerList?.length)this._answers=this.answerList.map(e=>({title:e.title||"",tag:"",showInput:!1}));else{const e=(this._title.match(/ ______/g)||[]).length||1;this._answers=Array.from({length:e},()=>({title:"",tag:"",showInput:!1}))}this.examAnswerSetting&&(this._isInOrder=!!this.examAnswerSetting.isInOrder,this._isIgnoreCase=!!this.examAnswerSetting.isIgnoreCase),this.richTextContent&&(this._richText=this.richTextContent,this._showRichText=!0)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_addBlank(){this._title+=" ______",this._answers=[...this._answers,{title:"",tag:"",showInput:!1}],this.requestUpdate()}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value;const i=(this._title.match(/ ______/g)||[]).length;if(i!==this._answers.length)if(i>this._answers.length)for(let e=this._answers.length;e<i;e++)this._answers=[...this._answers,{title:"",tag:"",showInput:!1}];else this._answers=this._answers.slice(0,i)}_handleAddTag(e){e.showInput=!1,e.tag&&(e.title=e.title?[e.title,e.tag].join(","):e.tag,e.tag=""),this.requestUpdate()}_closeTag(e,t){if(e){const i=t.title.split(","),s=i.findIndex(t=>t===e);s>-1&&(i.splice(s,1),t.title=i.join(",")),this.requestUpdate()}}_save(e){e?.stopImmediatePropagation(),this._title?this._answers.length<1?h("至少添加一个填空符!"):this._emit("save",{title:this._title.replaceAll(/ ______/g,"<filter></filter>"),answers:this._answers.map(e=>({title:e.title,isCorrect:!0})),analysis:this._analysis,isSetCorrectAnswer:!0,isKey:this.isKey,examAnswerSettingBO:{isIgnoreCase:this._isIgnoreCase,isInOrder:this._isInOrder},examRichTextContent:this._showRichText?this._richText:""}):h("题目标题不能为空!")}_renderPreview(){const t=this.title.replaceAll(/<filter><\/filter>/g," ______");return e`
|
|
6
6
|
<div class="preview">
|
|
7
|
-
<span class="title">${this.orderIndex+1}.${
|
|
8
|
-
${this.richTextContent?
|
|
9
|
-
${this._answers.some(
|
|
7
|
+
<span class="title">${this.orderIndex+1}.${t}(填空题)</span>
|
|
8
|
+
${this.richTextContent?e`<div class="rich-text" .innerHTML=${this.richTextContent}></div>`:""}
|
|
9
|
+
${this._answers.some(e=>e.title)?e`
|
|
10
10
|
<div class="content flex flex-wrap">
|
|
11
11
|
<span>正确答案:</span>
|
|
12
|
-
${this._answers.map((
|
|
13
|
-
<span style="margin-right:10px">填空${i+1}: ${
|
|
12
|
+
${this._answers.map((t,i)=>t.title?e`
|
|
13
|
+
<span style="margin-right:10px">填空${i+1}: ${t.title}</span>
|
|
14
14
|
`:"")}
|
|
15
15
|
</div>
|
|
16
16
|
`:""}
|
|
17
|
-
${this.analysis?
|
|
17
|
+
${this.analysis?e`<div style="color:#909399;font-size:12px;margin-top:8px">解析: ${this.analysis}</div>`:""}
|
|
18
18
|
</div>
|
|
19
|
-
`}_renderEdit(){return
|
|
19
|
+
`}_renderEdit(){return e`
|
|
20
20
|
<div class="flex flex-items-start">
|
|
21
21
|
<div class="label"><span>题目:</span></div>
|
|
22
22
|
<div style="flex:1">
|
|
23
23
|
<div class="el-input">
|
|
24
24
|
<textarea rows="3" .value=${this._title} ?disabled=${this.isSave}
|
|
25
25
|
maxlength=${this.TITLE_MAX}
|
|
26
|
-
@input=${
|
|
26
|
+
@input=${e=>this._onTitleInput(e)}
|
|
27
27
|
placeholder="【填空题】请输入问题"></textarea>
|
|
28
28
|
<span class="char-counter">${this._title.length}/${this.TITLE_MAX}</span>
|
|
29
29
|
</div>
|
|
@@ -39,36 +39,36 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
|
|
|
39
39
|
<div class="label"><span>答题设置:</span></div>
|
|
40
40
|
<label class="el-checkbox">
|
|
41
41
|
<input type="checkbox" .checked=${this._isInOrder}
|
|
42
|
-
@change=${
|
|
42
|
+
@change=${e=>{this._isInOrder=e.target.checked}} />
|
|
43
43
|
答案不分顺序
|
|
44
44
|
</label>
|
|
45
45
|
<label class="el-checkbox">
|
|
46
46
|
<input type="checkbox" .checked=${this._isIgnoreCase}
|
|
47
|
-
@change=${
|
|
47
|
+
@change=${e=>{this._isIgnoreCase=e.target.checked}} />
|
|
48
48
|
忽略大小写
|
|
49
49
|
</label>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
|
-
${this._answers.map((
|
|
52
|
+
${this._answers.map((t,i)=>e`
|
|
53
53
|
<div class="answer-item" style="margin-top:12px">
|
|
54
54
|
<div class="label"><span>第${i+1}空答案:</span></div>
|
|
55
55
|
<div class="answer-tags">
|
|
56
|
-
${
|
|
56
|
+
${t.title.split(",").filter(Boolean).map(i=>e`
|
|
57
57
|
<span class="el-tag">
|
|
58
58
|
${i}
|
|
59
|
-
${this.isSave?"":
|
|
59
|
+
${this.isSave?"":e`<span class="el-tag__close" @click=${()=>this._closeTag(i,t)}>×</span>`}
|
|
60
60
|
</span>
|
|
61
61
|
`)}
|
|
62
|
-
${this.isSave?"":
|
|
63
|
-
${
|
|
62
|
+
${this.isSave?"":e`
|
|
63
|
+
${t.showInput?e`
|
|
64
64
|
<input type="text" class="el-input--small"
|
|
65
|
-
@keydown=${
|
|
66
|
-
@input=${
|
|
67
|
-
@blur=${()=>this._handleAddTag(
|
|
68
|
-
`:
|
|
69
|
-
<span class="el-button--small" @click=${()=>{
|
|
65
|
+
@keydown=${e=>{"Enter"===e.key&&this._handleAddTag(t)}}
|
|
66
|
+
@input=${e=>{t.tag=e.target.value}}
|
|
67
|
+
@blur=${()=>this._handleAddTag(t)} />
|
|
68
|
+
`:e`
|
|
69
|
+
<span class="el-button--small" @click=${()=>{t.showInput=!0,this.requestUpdate(),this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".el-input--small")?.focus()})}}>
|
|
70
70
|
${p}
|
|
71
|
-
<span>${
|
|
71
|
+
<span>${t.title?"添加同义词":"添加答案"}</span>
|
|
72
72
|
</span>
|
|
73
73
|
`}
|
|
74
74
|
`}
|
|
@@ -76,12 +76,13 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
|
|
|
76
76
|
</div>
|
|
77
77
|
`)}
|
|
78
78
|
|
|
79
|
-
${this._showRichText?
|
|
79
|
+
${this._showRichText?e`
|
|
80
80
|
<div class="flex flex-items-start" style="margin-top:12px">
|
|
81
81
|
<div class="label"><span>富文本:</span></div>
|
|
82
82
|
<div style="flex:1">
|
|
83
83
|
<qxs-blocksuite-editor
|
|
84
|
-
content=${this._richText}
|
|
84
|
+
.content=${this._richText}
|
|
85
|
+
.uploadImage=${this.uploadImage}
|
|
85
86
|
?is-edit=${!0}
|
|
86
87
|
></qxs-blocksuite-editor>
|
|
87
88
|
<div class="flex flex-justify-end" style="margin-top:8px">
|
|
@@ -91,23 +92,23 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
|
|
|
91
92
|
</div>
|
|
92
93
|
`:""}
|
|
93
94
|
|
|
94
|
-
${this.showAnalysis?
|
|
95
|
+
${this.showAnalysis?e`
|
|
95
96
|
<div class="flex flex-items-start" style="margin-top:12px">
|
|
96
97
|
<div class="label"><span>解析:</span></div>
|
|
97
98
|
<div style="flex:1">
|
|
98
99
|
<div class="el-input">
|
|
99
100
|
<textarea rows="2" .value=${this._analysis}
|
|
100
|
-
@input=${
|
|
101
|
+
@input=${e=>{this._analysis=e.target.value}}
|
|
101
102
|
placeholder="请输入题目解析"></textarea>
|
|
102
103
|
</div>
|
|
103
104
|
</div>
|
|
104
105
|
</div>
|
|
105
106
|
`:""}
|
|
106
|
-
`}render(){return
|
|
107
|
+
`}render(){return e`
|
|
107
108
|
<qxs-subject-layout ?show-edit=${this.isEdit}>
|
|
108
109
|
<div slot="preview">${this._renderPreview()}</div>
|
|
109
110
|
<div slot="edit">${this._renderEdit()}</div>
|
|
110
|
-
${this.showAction?
|
|
111
|
+
${this.showAction?e`
|
|
111
112
|
<qxs-subject-action
|
|
112
113
|
?is-edit=${this.isEdit}
|
|
113
114
|
?is-set=${this.isSet}
|
|
@@ -116,13 +117,13 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
|
|
|
116
117
|
@delete=${()=>this._emit("delete")}
|
|
117
118
|
@save=${this._save}
|
|
118
119
|
@edit=${()=>this._emit("edit")}
|
|
119
|
-
@add=${
|
|
120
|
-
@set-key=${
|
|
120
|
+
@add=${e=>this._emit("add",e.detail)}
|
|
121
|
+
@set-key=${e=>{this._emit("set-key",e.detail)}}
|
|
121
122
|
@on-show-rich-text=${()=>{this._showRichText=!0}}
|
|
122
123
|
></qxs-subject-action>
|
|
123
124
|
`:""}
|
|
124
125
|
</qxs-subject-layout>
|
|
125
|
-
`}};d.styles=
|
|
126
|
+
`}};d.styles=t`
|
|
126
127
|
:host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
|
|
127
128
|
*, ::before, ::after { box-sizing: border-box; }
|
|
128
129
|
|
|
@@ -200,5 +201,5 @@ import{html as t,css as e,LitElement as i}from"lit";import{property as s}from"..
|
|
|
200
201
|
.answer-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
|
|
201
202
|
.answer-item .label { min-width: 70px; padding-top: 0; color: #909399; }
|
|
202
203
|
.answer-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
|
|
203
|
-
`,o([s({type:Number,attribute:"order-index"})],d.prototype,"orderIndex",2),o([s({type:String})],d.prototype,"title",2),o([s({type:Boolean,attribute:"is-edit"})],d.prototype,"isEdit",2),o([s({type:Boolean,attribute:"is-save"})],d.prototype,"isSave",2),o([s({type:Boolean,attribute:"is-set"})],d.prototype,"isSet",2),o([s({type:Boolean,attribute:"is-key"})],d.prototype,"isKey",2),o([s({type:Boolean,attribute:"show-action"})],d.prototype,"showAction",2),o([s({type:Boolean,attribute:"show-analysis"})],d.prototype,"showAnalysis",2),o([s({type:String,attribute:"rich-text-content"})],d.prototype,"richTextContent",2),o([s({type:String})],d.prototype,"analysis",2),o([s({type:Number,attribute:"exam-answer-relation-type"})],d.prototype,"examAnswerRelationType",2),o([s({type:String,attribute:"exam-expand"})],d.prototype,"examExpand",2),o([s({type:Object,attribute:"exam-answer-setting"})],d.prototype,"examAnswerSetting",2),o([s({type:Array,attribute:"answer-list"})],d.prototype,"answerList",2),o([a()],d.prototype,"_title",2),o([a()],d.prototype,"_analysis",2),o([a()],d.prototype,"_answers",2),o([a()],d.prototype,"_isInOrder",2),o([a()],d.prototype,"_isIgnoreCase",2),o([a()],d.prototype,"_showRichText",2),o([a()],d.prototype,"_richText",2),d=o([n("qxs-blank-fill")],d);export{d as QxsBlankFill};
|
|
204
|
+
`,o([s({type:Number,attribute:"order-index"})],d.prototype,"orderIndex",2),o([s({type:String})],d.prototype,"title",2),o([s({type:Boolean,attribute:"is-edit"})],d.prototype,"isEdit",2),o([s({type:Boolean,attribute:"is-save"})],d.prototype,"isSave",2),o([s({type:Boolean,attribute:"is-set"})],d.prototype,"isSet",2),o([s({type:Boolean,attribute:"is-key"})],d.prototype,"isKey",2),o([s({type:Boolean,attribute:"show-action"})],d.prototype,"showAction",2),o([s({type:Boolean,attribute:"show-analysis"})],d.prototype,"showAnalysis",2),o([s({type:String,attribute:"rich-text-content"})],d.prototype,"richTextContent",2),o([s({type:String})],d.prototype,"analysis",2),o([s({type:Number,attribute:"exam-answer-relation-type"})],d.prototype,"examAnswerRelationType",2),o([s({type:String,attribute:"exam-expand"})],d.prototype,"examExpand",2),o([s({type:Object,attribute:"exam-answer-setting"})],d.prototype,"examAnswerSetting",2),o([s({type:Object})],d.prototype,"uploadImage",2),o([s({type:Array,attribute:"answer-list"})],d.prototype,"answerList",2),o([a()],d.prototype,"_title",2),o([a()],d.prototype,"_analysis",2),o([a()],d.prototype,"_answers",2),o([a()],d.prototype,"_isInOrder",2),o([a()],d.prototype,"_isIgnoreCase",2),o([a()],d.prototype,"_showRichText",2),o([a()],d.prototype,"_richText",2),d=o([n("qxs-blank-fill")],d);export{d as QxsBlankFill};
|
|
204
205
|
//# sourceMappingURL=blank-fill.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blank-fill.mjs","sources":["../../../../packages/components-wc/src/subject/blank-fill.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\ninterface BlankAnswer { title: string, tag: string, showInput: boolean }\n\nconst iconPlus = html`\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\"\n stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>\n </svg>`\n\nfunction showToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',\n padding: '10px 20px', borderRadius: '4px', fontSize: '13px', color: '#fff',\n background: '#f56c6c', zIndex: '99999', boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s', opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => { el.style.opacity = '0'; setTimeout(() => el.remove(), 300) }, 2500)\n}\n\n@safeCustomElement('qxs-blank-fill')\nexport class QxsBlankFill 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; color: #5a5a5a; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .preview { padding: 12px 0; }\n .preview .title { font-size: 14px; color: #303133; }\n .preview .rich-text { margin-top: 8px; }\n .preview .rich-text img { max-width: 100%; }\n .preview .content { color: #a8abb2; margin-top: 10px; }\n\n .flex { display: flex; }\n .flex-wrap { flex-wrap: wrap; }\n .flex-items-center { display: flex; align-items: center; }\n .flex-items-start { display: flex; align-items: flex-start; }\n .flex-justify-end { display: flex; justify-content: flex-end; }\n .label { min-width: 70px; font-size: 13px; color: #606266; }\n\n textarea {\n border: 1px solid #dcdfe6; border-radius: 3px; padding: 5px 11px;\n font-size: 13px; font-family: inherit; width: 100%; resize: none; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box;\n }\n textarea:focus { border-color: #3D61E3; outline: none; }\n textarea:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n .el-input { position: relative; display: block; }\n .el-input textarea { padding-bottom: 24px; }\n .el-input .char-counter {\n position: absolute; right: 12px; bottom: 8px;\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n /* Tag style */\n .el-tag {\n display: inline-flex; align-items: center; height: 24px; padding: 0 9px;\n font-size: 12px; line-height: 1; color: #3D61E3; background: #ecf5ff;\n border: 1px solid #d9ecff; border-radius: 4px; white-space: nowrap;\n }\n .el-tag .el-tag__close {\n display: inline-flex; align-items: center; justify-content: center;\n margin-left: 4px; width: 16px; height: 16px; border-radius: 50%;\n font-size: 12px; color: #909399; cursor: pointer; transition: all .2s;\n }\n .el-tag .el-tag__close:hover { background: #909399; color: #fff; }\n\n /* Button small style */\n .el-button--small {\n display: inline-flex; align-items: center; gap: 4px;\n height: 24px; padding: 0 10px; font-size: 12px; line-height: 1;\n border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266;\n cursor: pointer; transition: all .2s; white-space: nowrap;\n }\n .el-button--small:hover { color: #3D61E3; border-color: #c6e2ff; background-color: #ecf5ff; }\n\n /* Link style */\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; text-decoration: none; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.is-disabled { color: #c0c4cc; cursor: not-allowed; }\n\n /* Input small for tag */\n .el-input--small { width: 80px; }\n .el-input--small input {\n height: 24px; padding: 0 8px; font-size: 12px; line-height: 24px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n }\n .el-input--small input:focus { border-color: #3D61E3; outline: none; }\n\n /* Checkbox style */\n .el-checkbox {\n display: inline-flex; align-items: center; gap: 6px; cursor: pointer;\n font-size: 13px; color: #606266; user-select: none; margin-right: 16px;\n }\n .el-checkbox input[type=\"checkbox\"] {\n width: 14px; height: 14px; cursor: pointer; accent-color: #3D61E3;\n }\n\n .answer-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }\n .answer-item .label { min-width: 70px; padding-top: 0; color: #909399; }\n .answer-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }\n `\n\n @property({ type: Number, attribute: 'order-index' }) orderIndex = 0\n @property({ type: String }) title = ''\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-save' }) isSave = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'is-key' }) isKey = false\n @property({ type: Boolean, attribute: 'show-action' }) showAction = true\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = false\n @property({ type: String, attribute: 'rich-text-content' }) richTextContent = ''\n @property({ type: String }) analysis = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n @property({ type: String, attribute: 'exam-expand' }) examExpand = ''\n @property({ type: Object, attribute: 'exam-answer-setting' })\n examAnswerSetting: { isInOrder: boolean, isIgnoreCase: boolean } = { isInOrder: false, isIgnoreCase: true }\n\n @property({ type: Array, attribute: 'answer-list' }) answerList: any[] = []\n\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _answers: BlankAnswer[] = [{ title: '', tag: '', showInput: false }]\n @state() private _isInOrder = false\n @state() private _isIgnoreCase = true\n @state() private _showRichText = false\n @state() private _richText = ''\n\n private readonly TITLE_MAX = 400\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n }\n\n private _syncProps() {\n this._title = (this.title || '').replaceAll(/<filter><\\/filter>/g, ' ______')\n this._analysis = this.analysis || ''\n if (this.answerList?.length) {\n this._answers = this.answerList.map((a: any) => ({ title: a.title || '', tag: '', showInput: false }))\n }\n else {\n const blankCount = (this._title.match(/ ______/g) || []).length || 1\n this._answers = Array.from({ length: blankCount }, () => ({ title: '', tag: '', showInput: false }))\n }\n if (this.examAnswerSetting) {\n this._isInOrder = !!this.examAnswerSetting.isInOrder\n this._isIgnoreCase = !!this.examAnswerSetting.isIgnoreCase\n }\n if (this.richTextContent) { this._richText = this.richTextContent; this._showRichText = true }\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 _addBlank() {\n this._title += ' ______'\n this._answers = [...this._answers, { title: '', tag: '', showInput: false }]\n this.requestUpdate()\n }\n\n private _onTitleInput(e: Event) {\n const el = e.target as HTMLTextAreaElement\n if (el.value.length > this.TITLE_MAX) { el.value = el.value.slice(0, this.TITLE_MAX) }\n this._title = el.value\n const blankCount = (this._title.match(/ ______/g) || []).length\n if (blankCount !== this._answers.length) {\n if (blankCount > this._answers.length) {\n for (let i = this._answers.length; i < blankCount; i++) {\n this._answers = [...this._answers, { title: '', tag: '', showInput: false }]\n }\n }\n else {\n this._answers = this._answers.slice(0, blankCount)\n }\n }\n }\n\n private _handleAddTag(item: BlankAnswer) {\n item.showInput = false\n if (item.tag) {\n item.title = item.title ? [item.title, item.tag].join(',') : item.tag\n item.tag = ''\n }\n this.requestUpdate()\n }\n\n private _closeTag(tag: string, item: BlankAnswer) {\n if (tag) {\n const tags = item.title.split(',')\n const idx = tags.findIndex((t: string) => t === tag)\n if (idx > -1) { tags.splice(idx, 1); item.title = tags.join(',') }\n this.requestUpdate()\n }\n }\n\n private _save(e?: Event) {\n e?.stopImmediatePropagation()\n if (!this._title) { showToast('题目标题不能为空!'); return }\n if (this._answers.length < 1) { showToast('至少添加一个填空符!'); return }\n this._emit('save', {\n title: this._title.replaceAll(/ ______/g, '<filter></filter>'),\n answers: this._answers.map(a => ({ title: a.title, isCorrect: true })),\n analysis: this._analysis,\n isSetCorrectAnswer: true,\n isKey: this.isKey,\n examAnswerSettingBO: { isIgnoreCase: this._isIgnoreCase, isInOrder: this._isInOrder },\n examRichTextContent: this._showRichText ? this._richText : '',\n })\n }\n\n private _renderPreview() {\n const displayTitle = this.title.replaceAll(/<filter><\\/filter>/g, ' ______')\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${displayTitle}(填空题)</span>\n ${this.richTextContent ? html`<div class=\"rich-text\" .innerHTML=${this.richTextContent}></div>` : ''}\n ${this._answers.some(a => a.title)\n ? html`\n <div class=\"content flex flex-wrap\">\n <span>正确答案:</span>\n ${this._answers.map((a, i) => a.title\n ? html`\n <span style=\"margin-right:10px\">填空${i + 1}: ${a.title}</span>\n `\n : '')}\n </div>\n `\n : ''}\n ${this.analysis ? html`<div style=\"color:#909399;font-size:12px;margin-top:8px\">解析: ${this.analysis}</div>` : ''}\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"flex flex-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"3\" .value=${this._title} ?disabled=${this.isSave}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【填空题】请输入问题\"></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <div class=\"flex flex-justify-end\">\n <span class=\"el-link ${this.isSave ? 'is-disabled' : ''}\"\n @click=${() => {\n if (!this.isSave) { this._addBlank() }\n }}>插入填空符</span>\n </div>\n\n <div class=\"flex flex-items-center\" style=\"margin-top:12px\">\n <div class=\"label\"><span>答题设置:</span></div>\n <label class=\"el-checkbox\">\n <input type=\"checkbox\" .checked=${this._isInOrder}\n @change=${(e: Event) => { this._isInOrder = (e.target as HTMLInputElement).checked }} />\n 答案不分顺序\n </label>\n <label class=\"el-checkbox\">\n <input type=\"checkbox\" .checked=${this._isIgnoreCase}\n @change=${(e: Event) => { this._isIgnoreCase = (e.target as HTMLInputElement).checked }} />\n 忽略大小写\n </label>\n </div>\n\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\" style=\"margin-top:12px\">\n <div class=\"label\"><span>第${i + 1}空答案:</span></div>\n <div class=\"answer-tags\">\n ${a.title.split(',').filter(Boolean).map(tag => html`\n <span class=\"el-tag\">\n ${tag}\n ${!this.isSave ? html`<span class=\"el-tag__close\" @click=${() => this._closeTag(tag, a)}>×</span>` : ''}\n </span>\n `)}\n ${!this.isSave\n ? html`\n ${a.showInput\n ? html`\n <input type=\"text\" class=\"el-input--small\"\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') { this._handleAddTag(a) }\n }}\n @input=${(e: Event) => { a.tag = (e.target as HTMLInputElement).value }}\n @blur=${() => this._handleAddTag(a)} />\n `\n : html`\n <span class=\"el-button--small\" @click=${() => { a.showInput = true; this.requestUpdate(); this.updateComplete.then(() => { (this.shadowRoot?.querySelector('.el-input--small') as HTMLInputElement)?.focus() }) }}>\n ${iconPlus}\n <span>${a.title ? '添加同义词' : '添加答案'}</span>\n </span>\n `}\n `\n : ''}\n </div>\n </div>\n `)}\n\n ${this._showRichText\n ? html`\n <div class=\"flex flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>富文本:</span></div>\n <div style=\"flex:1\">\n <qxs-blocksuite-editor\n content=${this._richText}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n <div class=\"flex flex-justify-end\" style=\"margin-top:8px\">\n <span class=\"el-link\" style=\"color:#f56c6c\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span>\n </div>\n </div>\n </div>\n `\n : ''}\n\n ${this.showAnalysis\n ? html`\n <div class=\"flex flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>解析:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._analysis}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"></textarea>\n </div>\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n return html`\n <qxs-subject-layout ?show-edit=${this.isEdit}>\n <div slot=\"preview\">${this._renderPreview()}</div>\n <div slot=\"edit\">${this._renderEdit()}</div>\n ${this.showAction\n ? html`\n <qxs-subject-action\n ?is-edit=${this.isEdit}\n ?is-set=${this.isSet}\n ?show-other-option=${false}\n exam-answer-relation-type=${this.examAnswerRelationType}\n @delete=${() => this._emit('delete')}\n @save=${this._save}\n @edit=${() => this._emit('edit')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n @set-key=${(e: CustomEvent) => { this._emit('set-key', e.detail) }}\n @on-show-rich-text=${() => { this._showRichText = true }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","showToast","msg","el","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","QxsBlankFill","LitElement","constructor","super","arguments","this","orderIndex","title","isEdit","isSave","isSet","isKey","showAction","showAnalysis","richTextContent","analysis","examAnswerRelationType","examExpand","examAnswerSetting","isInOrder","isIgnoreCase","answerList","_title","_analysis","_answers","tag","showInput","_isInOrder","_isIgnoreCase","_showRichText","_richText","TITLE_MAX","updated","changed","has","_syncProps","replaceAll","length","map","a","blankCount","match","Array","from","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_addBlank","requestUpdate","_onTitleInput","e","target","value","slice","i","_handleAddTag","item","join","_closeTag","tags","split","idx","findIndex","t","splice","_save","stopImmediatePropagation","answers","isCorrect","isSetCorrectAnswer","examAnswerSettingBO","examRichTextContent","_renderPreview","displayTitle","some","_renderEdit","checked","filter","Boolean","key","updateComplete","then","shadowRoot","querySelector","focus","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","String","state","safeCustomElement"],"mappings":"qjBAMA,MAAMA,EAAWC,CAAA;;;;UAMjB,SAASC,EAAUC,GACjB,MAAMC,EAAKC,SAASC,cAAc,OAClCF,EAAGG,YAAcJ,EACjBK,OAAOC,OAAOL,EAAGM,MAAO,CACtBC,SAAU,QAASC,IAAK,OA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CAAxDC,EAAS,CAAEC,KAAMZ,QAASc,UAAW,mBAxF3BhG,EAwF8CiG,UAAA,eAAA,GACGL,EAAA,CAA3DC,EAAS,CAAEC,KAAMI,OAAQF,UAAW,uBAzF1BhG,EAyFiDiG,UAAA,kBAAA,GAChCL,EAAA,CAA3BC,EAAS,CAAEC,KAAMI,UA1FPlG,EA0FiBiG,UAAA,WAAA,GACwCL,EAAA,CAAnEC,EAAS,CAAEC,KAAMC,OAAQC,UAAW,+BA3F1BhG,EA2FyDiG,UAAA,yBAAA,GACdL,EAAA,CAArDC,EAAS,CAAEC,KAAMI,OAAQF,UAAW,iBA5F1BhG,EA4F2CiG,UAAA,aAAA,GAEtDL,EAAA,CADCC,EAAS,CAAEC,KAAMlH,OAAQoH,UAAW,yBA7F1BhG,EA8FXiG,UAAA,oBAAA,GAEqDL,EAAA,CAApDC,EAAS,CAAEC,KAAMpD,MAAOsD,UAAW,iBAhGzBhG,EAgG0CiG,UAAA,aAAA,GAEpCL,EAAA,CAAhBO,KAlGUnG,EAkGMiG,UAAA,SAAA,GACAL,EAAA,CAAhBO,KAnGUnG,EAmGMiG,UAAA,YAAA,GACAL,EAAA,CAAhBO,KApGUnG,EAoGMiG,UAAA,WAAA,GACAL,EAAA,CAAhBO,KArGUnG,EAqGMiG,UAAA,aAAA,GACAL,EAAA,CAAhBO,KAtGUnG,EAsGMiG,UAAA,gBAAA,GACAL,EAAA,CAAhBO,KAvGUnG,EAuGMiG,UAAA,gBAAA,GACAL,EAAA,CAAhBO,KAxGUnG,EAwGMiG,UAAA,YAAA,GAxGNjG,EAAN4F,EAAA,CADNQ,EAAkB,mBACNpG"}
|
|
1
|
+
{"version":3,"file":"blank-fill.mjs","sources":["../../../../packages/components-wc/src/subject/blank-fill.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property, state } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\ninterface BlankAnswer { title: string, tag: string, showInput: boolean }\n\nconst iconPlus = html`\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\"\n stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/>\n </svg>`\n\nfunction showToast(msg: string) {\n const el = document.createElement('div')\n el.textContent = msg\n Object.assign(el.style, {\n position: 'fixed', top: '20px', left: '50%', transform: 'translateX(-50%)',\n padding: '10px 20px', borderRadius: '4px', fontSize: '13px', color: '#fff',\n background: '#f56c6c', zIndex: '99999', boxShadow: '0 4px 12px rgba(0,0,0,.15)',\n transition: 'opacity .3s', opacity: '1',\n })\n document.body.appendChild(el)\n setTimeout(() => { el.style.opacity = '0'; setTimeout(() => el.remove(), 300) }, 2500)\n}\n\n@safeCustomElement('qxs-blank-fill')\nexport class QxsBlankFill 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; color: #5a5a5a; }\n *, ::before, ::after { box-sizing: border-box; }\n\n .preview { padding: 12px 0; }\n .preview .title { font-size: 14px; color: #303133; }\n .preview .rich-text { margin-top: 8px; }\n .preview .rich-text img { max-width: 100%; }\n .preview .content { color: #a8abb2; margin-top: 10px; }\n\n .flex { display: flex; }\n .flex-wrap { flex-wrap: wrap; }\n .flex-items-center { display: flex; align-items: center; }\n .flex-items-start { display: flex; align-items: flex-start; }\n .flex-justify-end { display: flex; justify-content: flex-end; }\n .label { min-width: 70px; font-size: 13px; color: #606266; }\n\n textarea {\n border: 1px solid #dcdfe6; border-radius: 3px; padding: 5px 11px;\n font-size: 13px; font-family: inherit; width: 100%; resize: none; transition: border-color .2s;\n line-height: 1.5; display: block; box-sizing: border-box;\n }\n textarea:focus { border-color: #3D61E3; outline: none; }\n textarea:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n .el-input { position: relative; display: block; }\n .el-input textarea { padding-bottom: 24px; }\n .el-input .char-counter {\n position: absolute; right: 12px; bottom: 8px;\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n /* Tag style */\n .el-tag {\n display: inline-flex; align-items: center; height: 24px; padding: 0 9px;\n font-size: 12px; line-height: 1; color: #3D61E3; background: #ecf5ff;\n border: 1px solid #d9ecff; border-radius: 4px; white-space: nowrap;\n }\n .el-tag .el-tag__close {\n display: inline-flex; align-items: center; justify-content: center;\n margin-left: 4px; width: 16px; height: 16px; border-radius: 50%;\n font-size: 12px; color: #909399; cursor: pointer; transition: all .2s;\n }\n .el-tag .el-tag__close:hover { background: #909399; color: #fff; }\n\n /* Button small style */\n .el-button--small {\n display: inline-flex; align-items: center; gap: 4px;\n height: 24px; padding: 0 10px; font-size: 12px; line-height: 1;\n border: 1px solid #dcdfe6; border-radius: 3px; background: #fff; color: #606266;\n cursor: pointer; transition: all .2s; white-space: nowrap;\n }\n .el-button--small:hover { color: #3D61E3; border-color: #c6e2ff; background-color: #ecf5ff; }\n\n /* Link style */\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; text-decoration: none; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.is-disabled { color: #c0c4cc; cursor: not-allowed; }\n\n /* Input small for tag */\n .el-input--small { width: 80px; }\n .el-input--small input {\n height: 24px; padding: 0 8px; font-size: 12px; line-height: 24px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n }\n .el-input--small input:focus { border-color: #3D61E3; outline: none; }\n\n /* Checkbox style */\n .el-checkbox {\n display: inline-flex; align-items: center; gap: 6px; cursor: pointer;\n font-size: 13px; color: #606266; user-select: none; margin-right: 16px;\n }\n .el-checkbox input[type=\"checkbox\"] {\n width: 14px; height: 14px; cursor: pointer; accent-color: #3D61E3;\n }\n\n .answer-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }\n .answer-item .label { min-width: 70px; padding-top: 0; color: #909399; }\n .answer-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }\n `\n\n @property({ type: Number, attribute: 'order-index' }) orderIndex = 0\n @property({ type: String }) title = ''\n @property({ type: Boolean, attribute: 'is-edit' }) isEdit = false\n @property({ type: Boolean, attribute: 'is-save' }) isSave = false\n @property({ type: Boolean, attribute: 'is-set' }) isSet = false\n @property({ type: Boolean, attribute: 'is-key' }) isKey = false\n @property({ type: Boolean, attribute: 'show-action' }) showAction = true\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = false\n @property({ type: String, attribute: 'rich-text-content' }) richTextContent = ''\n @property({ type: String }) analysis = ''\n @property({ type: Number, attribute: 'exam-answer-relation-type' }) examAnswerRelationType = 0\n @property({ type: String, attribute: 'exam-expand' }) examExpand = ''\n @property({ type: Object, attribute: 'exam-answer-setting' })\n examAnswerSetting: { isInOrder: boolean, isIgnoreCase: boolean } = { isInOrder: false, isIgnoreCase: true }\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, attribute: 'answer-list' }) answerList: any[] = []\n\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _answers: BlankAnswer[] = [{ title: '', tag: '', showInput: false }]\n @state() private _isInOrder = false\n @state() private _isIgnoreCase = true\n @state() private _showRichText = false\n @state() private _richText = ''\n\n private readonly TITLE_MAX = 400\n\n updated(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n }\n\n private _syncProps() {\n this._title = (this.title || '').replaceAll(/<filter><\\/filter>/g, ' ______')\n this._analysis = this.analysis || ''\n if (this.answerList?.length) {\n this._answers = this.answerList.map((a: any) => ({ title: a.title || '', tag: '', showInput: false }))\n }\n else {\n const blankCount = (this._title.match(/ ______/g) || []).length || 1\n this._answers = Array.from({ length: blankCount }, () => ({ title: '', tag: '', showInput: false }))\n }\n if (this.examAnswerSetting) {\n this._isInOrder = !!this.examAnswerSetting.isInOrder\n this._isIgnoreCase = !!this.examAnswerSetting.isIgnoreCase\n }\n if (this.richTextContent) { this._richText = this.richTextContent; this._showRichText = true }\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 _addBlank() {\n this._title += ' ______'\n this._answers = [...this._answers, { title: '', tag: '', showInput: false }]\n this.requestUpdate()\n }\n\n private _onTitleInput(e: Event) {\n const el = e.target as HTMLTextAreaElement\n if (el.value.length > this.TITLE_MAX) { el.value = el.value.slice(0, this.TITLE_MAX) }\n this._title = el.value\n const blankCount = (this._title.match(/ ______/g) || []).length\n if (blankCount !== this._answers.length) {\n if (blankCount > this._answers.length) {\n for (let i = this._answers.length; i < blankCount; i++) {\n this._answers = [...this._answers, { title: '', tag: '', showInput: false }]\n }\n }\n else {\n this._answers = this._answers.slice(0, blankCount)\n }\n }\n }\n\n private _handleAddTag(item: BlankAnswer) {\n item.showInput = false\n if (item.tag) {\n item.title = item.title ? [item.title, item.tag].join(',') : item.tag\n item.tag = ''\n }\n this.requestUpdate()\n }\n\n private _closeTag(tag: string, item: BlankAnswer) {\n if (tag) {\n const tags = item.title.split(',')\n const idx = tags.findIndex((t: string) => t === tag)\n if (idx > -1) { tags.splice(idx, 1); item.title = tags.join(',') }\n this.requestUpdate()\n }\n }\n\n private _save(e?: Event) {\n e?.stopImmediatePropagation()\n if (!this._title) { showToast('题目标题不能为空!'); return }\n if (this._answers.length < 1) { showToast('至少添加一个填空符!'); return }\n this._emit('save', {\n title: this._title.replaceAll(/ ______/g, '<filter></filter>'),\n answers: this._answers.map(a => ({ title: a.title, isCorrect: true })),\n analysis: this._analysis,\n isSetCorrectAnswer: true,\n isKey: this.isKey,\n examAnswerSettingBO: { isIgnoreCase: this._isIgnoreCase, isInOrder: this._isInOrder },\n examRichTextContent: this._showRichText ? this._richText : '',\n })\n }\n\n private _renderPreview() {\n const displayTitle = this.title.replaceAll(/<filter><\\/filter>/g, ' ______')\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${displayTitle}(填空题)</span>\n ${this.richTextContent ? html`<div class=\"rich-text\" .innerHTML=${this.richTextContent}></div>` : ''}\n ${this._answers.some(a => a.title)\n ? html`\n <div class=\"content flex flex-wrap\">\n <span>正确答案:</span>\n ${this._answers.map((a, i) => a.title\n ? html`\n <span style=\"margin-right:10px\">填空${i + 1}: ${a.title}</span>\n `\n : '')}\n </div>\n `\n : ''}\n ${this.analysis ? html`<div style=\"color:#909399;font-size:12px;margin-top:8px\">解析: ${this.analysis}</div>` : ''}\n </div>\n `\n }\n\n private _renderEdit() {\n return html`\n <div class=\"flex flex-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"3\" .value=${this._title} ?disabled=${this.isSave}\n maxlength=${this.TITLE_MAX}\n @input=${(e: Event) => this._onTitleInput(e)}\n placeholder=\"【填空题】请输入问题\"></textarea>\n <span class=\"char-counter\">${this._title.length}/${this.TITLE_MAX}</span>\n </div>\n </div>\n </div>\n\n <div class=\"flex flex-justify-end\">\n <span class=\"el-link ${this.isSave ? 'is-disabled' : ''}\"\n @click=${() => {\n if (!this.isSave) { this._addBlank() }\n }}>插入填空符</span>\n </div>\n\n <div class=\"flex flex-items-center\" style=\"margin-top:12px\">\n <div class=\"label\"><span>答题设置:</span></div>\n <label class=\"el-checkbox\">\n <input type=\"checkbox\" .checked=${this._isInOrder}\n @change=${(e: Event) => { this._isInOrder = (e.target as HTMLInputElement).checked }} />\n 答案不分顺序\n </label>\n <label class=\"el-checkbox\">\n <input type=\"checkbox\" .checked=${this._isIgnoreCase}\n @change=${(e: Event) => { this._isIgnoreCase = (e.target as HTMLInputElement).checked }} />\n 忽略大小写\n </label>\n </div>\n\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\" style=\"margin-top:12px\">\n <div class=\"label\"><span>第${i + 1}空答案:</span></div>\n <div class=\"answer-tags\">\n ${a.title.split(',').filter(Boolean).map(tag => html`\n <span class=\"el-tag\">\n ${tag}\n ${!this.isSave ? html`<span class=\"el-tag__close\" @click=${() => this._closeTag(tag, a)}>×</span>` : ''}\n </span>\n `)}\n ${!this.isSave\n ? html`\n ${a.showInput\n ? html`\n <input type=\"text\" class=\"el-input--small\"\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') { this._handleAddTag(a) }\n }}\n @input=${(e: Event) => { a.tag = (e.target as HTMLInputElement).value }}\n @blur=${() => this._handleAddTag(a)} />\n `\n : html`\n <span class=\"el-button--small\" @click=${() => { a.showInput = true; this.requestUpdate(); this.updateComplete.then(() => { (this.shadowRoot?.querySelector('.el-input--small') as HTMLInputElement)?.focus() }) }}>\n ${iconPlus}\n <span>${a.title ? '添加同义词' : '添加答案'}</span>\n </span>\n `}\n `\n : ''}\n </div>\n </div>\n `)}\n\n ${this._showRichText\n ? html`\n <div class=\"flex flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>富文本:</span></div>\n <div style=\"flex:1\">\n <qxs-blocksuite-editor\n .content=${this._richText}\n .uploadImage=${this.uploadImage}\n ?is-edit=${true}\n ></qxs-blocksuite-editor>\n <div class=\"flex flex-justify-end\" style=\"margin-top:8px\">\n <span class=\"el-link\" style=\"color:#f56c6c\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span>\n </div>\n </div>\n </div>\n `\n : ''}\n\n ${this.showAnalysis\n ? html`\n <div class=\"flex flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>解析:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .value=${this._analysis}\n @input=${(e: Event) => { this._analysis = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入题目解析\"></textarea>\n </div>\n </div>\n </div>\n `\n : ''}\n `\n }\n\n render() {\n return html`\n <qxs-subject-layout ?show-edit=${this.isEdit}>\n <div slot=\"preview\">${this._renderPreview()}</div>\n <div slot=\"edit\">${this._renderEdit()}</div>\n ${this.showAction\n ? html`\n <qxs-subject-action\n ?is-edit=${this.isEdit}\n ?is-set=${this.isSet}\n ?show-other-option=${false}\n exam-answer-relation-type=${this.examAnswerRelationType}\n @delete=${() => this._emit('delete')}\n @save=${this._save}\n @edit=${() => this._emit('edit')}\n @add=${(e: CustomEvent) => this._emit('add', e.detail)}\n @set-key=${(e: CustomEvent) => { this._emit('set-key', e.detail) }}\n @on-show-rich-text=${() => { this._showRichText = true }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","showToast","msg","el","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","QxsBlankFill","LitElement","constructor","super","arguments","this","orderIndex","title","isEdit","isSave","isSet","isKey","showAction","showAnalysis","richTextContent","analysis","examAnswerRelationType","examExpand","examAnswerSetting","isInOrder","isIgnoreCase","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","answerList","_title","_analysis","_answers","tag","showInput","_isInOrder","_isIgnoreCase","_showRichText","_richText","TITLE_MAX","updated","changed","has","_syncProps","replaceAll","length","map","a","blankCount","match","Array","from","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_addBlank","requestUpdate","_onTitleInput","value","slice","i","_handleAddTag","item","join","_closeTag","tags","split","idx","findIndex","t","splice","_save","stopImmediatePropagation","answers","isCorrect","isSetCorrectAnswer","examAnswerSettingBO","examRichTextContent","_renderPreview","displayTitle","some","_renderEdit","checked","filter","Boolean","key","updateComplete","then","shadowRoot","querySelector","focus","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","String","state","safeCustomElement"],"mappings":"qjBAMA,MAAMA,EAAWC,CAAA;;;;UAMjB,SAASC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AA,CAAhBO,KA/GU/G,EA+GM6G,UAAA,gBAAA,GACAL,EAAA,CAAhBO,KAhHU/G,EAgHM6G,UAAA,gBAAA,GACAL,EAAA,CAAhBO,KAjHU/G,EAiHM6G,UAAA,YAAA,GAjHN7G,EAANwG,EAAA,CADNQ,EAAkB,mBACNhH"}
|
package/es/subject/list.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.mjs";import{property as a}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as r}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 n}from"../base/define.mjs";import{uid as l}from"../base/uid.mjs";var d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,h=(e,t,s,i)=>{for(var a,r=i>1?void 0:i?c(t,s):t,o=e.length-1;o>=0;o--)(a=e[o])&&(r=(i?a(t,s,r):a(r))||r);return i&&r&&d(t,s,r),r};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._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||l()})),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||l()})),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||l()})),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}))}get currentList(){return this._list}addSubject(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const i={customId:l(),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||l(),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:l(),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||l(),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)),r=()=>this._deleteByCustomId(e.customId),o=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
|
|
1
|
+
import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.mjs";import{property as a}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as r}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 n}from"../base/define.mjs";import{uid as l}from"../base/uid.mjs";var d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,h=(e,t,s,i)=>{for(var a,r=i>1?void 0:i?c(t,s):t,o=e.length-1;o>=0;o--)(a=e[o])&&(r=(i?a(t,s,r):a(r))||r);return i&&r&&d(t,s,r),r};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||l()})),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||l()})),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||l()})),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}))}get currentList(){return this._list}addSubject(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const i={customId:l(),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||l(),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:l(),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||l(),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)),r=()=>this._deleteByCustomId(e.customId),o=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
|
+
.uploadImage=${this.uploadImage}
|
|
4
5
|
order-index=${i}
|
|
5
6
|
?is-edit=${e.isEdit}
|
|
6
7
|
?is-set=${e.hasSet}
|
|
@@ -22,6 +23,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
22
23
|
.title=${e.title||""}
|
|
23
24
|
.answerList=${e.answers||[]}
|
|
24
25
|
.examAnswerSetting=${e.examAnswerSettingVO||{}}
|
|
26
|
+
.uploadImage=${this.uploadImage}
|
|
25
27
|
order-index=${i}
|
|
26
28
|
?is-edit=${e.isEdit} ?is-set=${e.hasSet} ?is-save=${!e.isRealCanDel} ?show-action=${!this._isPreviewValue}
|
|
27
29
|
exam-answer-relation-type=${e.examAnswerRelationType??0}
|
|
@@ -33,6 +35,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
33
35
|
.title=${e.title||""}
|
|
34
36
|
.answerList=${e.answers||[]}
|
|
35
37
|
.examAnswerSetting=${e.examAnswerSettingVO||{}}
|
|
38
|
+
.uploadImage=${this.uploadImage}
|
|
36
39
|
order-index=${i}
|
|
37
40
|
?is-edit=${e.isEdit} ?is-set=${e.hasSet} ?is-save=${!e.isRealCanDel} ?show-action=${!this._isPreviewValue}
|
|
38
41
|
exam-answer-relation-type=${e.examAnswerRelationType??0}
|
|
@@ -44,6 +47,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
44
47
|
.title=${e.title||""}
|
|
45
48
|
.answerList=${e.answers||[]}
|
|
46
49
|
.scaleQuestions=${e.scaleQuestionList||[]}
|
|
50
|
+
.uploadImage=${this.uploadImage}
|
|
47
51
|
order-index=${i}
|
|
48
52
|
?is-edit=${e.isEdit} ?is-set=${e.hasSet} ?is-save=${!e.isRealCanDel} ?show-action=${!this._isPreviewValue}
|
|
49
53
|
exam-answer-relation-type=${e.examAnswerRelationType??0}
|
|
@@ -51,6 +55,7 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
51
55
|
analysis=${e.analysis||""}
|
|
52
56
|
@move=${a} @delete=${r} @save=${o} @edit=${n} @add=${l}
|
|
53
57
|
></qxs-scale>`:"rich_text"===e.answerType?s`<qxs-subject-rich-text
|
|
58
|
+
.uploadImage=${this.uploadImage}
|
|
54
59
|
order-index=${i}
|
|
55
60
|
?is-edit=${e.isEdit} ?is-set=${e.hasSet} ?is-save=${!e.isRealCanDel} ?show-action=${!this._isPreviewValue}
|
|
56
61
|
exam-answer-relation-type=${e.examAnswerRelationType??0}
|
|
@@ -124,5 +129,5 @@ import{css as e,LitElement as t,html as s}from"lit";import{repeat as i}from"../n
|
|
|
124
129
|
.sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }
|
|
125
130
|
.sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
126
131
|
.sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }
|
|
127
|
-
`,h([a({attribute:"is-preview"})],m.prototype,"isPreview",2),h([a({type:Array})],m.prototype,"subjectList",1),h([r()],m.prototype,"_list",2),h([r()],m.prototype,"_sortMode",2),m=h([n("qxs-subject-list")],m);export{m as QxsSubjectList};
|
|
132
|
+
`,h([a({attribute:"is-preview"})],m.prototype,"isPreview",2),h([a({type:Object})],m.prototype,"uploadImage",2),h([a({type:Array})],m.prototype,"subjectList",1),h([r()],m.prototype,"_list",2),h([r()],m.prototype,"_sortMode",2),m=h([n("qxs-subject-list")],m);export{m as QxsSubjectList};
|
|
128
133
|
//# 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'\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: 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 // ── 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 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 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 @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 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 @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 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 @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 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 @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","_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","Promise","resolve","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","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","push","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","e","_deleteByCustomId","_delete","_setEdit","_renderItem","common","onMove","onDelete","onSave","onEdit","onAdd","html","examRichTextContent","leastAnswerCount","examExpand","examId","examAnswerSettingVO","render","repeat","styles","css","__decorateClass","property","attribute","prototype","state","safeCustomElement"],"mappings":"+tBAOA,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,EAgD1CD,KAAQE,MAAe,GACvBF,KAAQG,WAAY,EAC7BH,KAAQI,UAA6B,KAOrCJ,KAAQK,uBAAwB,CAAA,CAtDhC,eAAIC,GAAgB,OAAON,KAAKE,KAAM,CAEtC,eAAII,CAAYC,GACd,GAAKA,EAAL,CAIA,GAAiB,iBAANA,EACT,IACEA,EAAIC,KAAKC,MAAMF,EACjB,CAAA,MAIE,OAFAP,KAAKE,MAAQ,QACbF,KAAKU,eAEP,CAEF,IAAKC,MAAMC,QAAQL,GAGjB,OAFAP,KAAKE,MAAQ,QACbF,KAAKU,gBAGPV,KAAKE,MAAQK,EAAEM,IAAKC,IAAA,IAAiBA,EAAGC,SAAUD,EAAEC,UAAYC,O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A5EUhJ,EA4EM+I,UAAA,YAAA,GA5EN/I,EAAN4I,EAAA,CADNK,EAAkB,qBACNjJ"}
|
|
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'\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 // ── 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 @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 @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 @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 @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","currentList","addSubject","type","index","examAnswerRelationType","undefined","answerType","title","answers","analysis","scaleQuestionList","isEdit","isSave","isRealCanDel","hasSet","isKey","answerCheckType","push","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":"+tBAOA,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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iB,UAAY,UAAY,cAAc,KAAQjB,KAAKiB,WAAajB,KAAKiB;cAC1FjB,KAAKiB,UAMJ,GALAuH,CAAA;;;;;cAMFxI,KAAKiB,UAAY,OAAS;;;QAI9B;QACFjB,KAAKiB,UACHuH,CAAA;;YAEEO,EAAO/I,KAAKgB,MAAQsD,GAASA,EAAKzC,SAAU,CAACyC,EAAM1C,IAAM4G,CAAA;6CACxBlE,EAAKzC;;;;;;yCAMTD,EAAI;yCACJ0C,EAAKe,OAAS;wCACfnG,EAAWoF,EAAKc,aAAed,EAAKc;;;;QAKlEoD,CAAA;;YAEExI,KAAKgB,MAAMW,IAAI,CAAC2C,EAAM1C,IAAM4G,CAAA;uCACDxI,KAAKsC,gBAAkB,aAAe,WAAWgC,EAAKzC;6CAChD7B,KAAKiI,YAAY3D,EAAM1C;;;;;;KAOlE,GAxcWjC,EACJqJ,OAASC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;IA0BuBC,EAAA,CAAtCC,EAAS,CAAEC,UAAW,gBA3BZzJ,EA2B4B0J,UAAA,YAAA,GAGvCH,EAAA,CADCC,EAAS,CAAEnE,KAAMsE,UA7BP3J,EA8BX0J,UAAA,cAAA,GAUIH,EAAA,CADHC,EAAS,CAAEnE,KAAMvD,SAvCP9B,EAwCP0J,UAAA,cAAA,GA6CaH,EAAA,CAAhBK,KArFU5J,EAqFM0J,UAAA,QAAA,GACAH,EAAA,CAAhBK,KAtFU5J,EAsFM0J,UAAA,YAAA,GAtFN1J,EAANuJ,EAAA,CADNM,EAAkB,qBACN7J"}
|
package/es/subject/rich-text.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{css as t,LitElement as e,html as o}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 s}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as
|
|
2
|
-
${this.isEdit?o`<qxs-blocksuite-editor .content=${t}></qxs-blocksuite-editor>`:o`<qxs-blocksuite-editor .content=${t} readonly preview></qxs-blocksuite-editor>`}
|
|
1
|
+
import{css as t,LitElement as e,html as o}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 s}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as r}from"../base/define.mjs";import"../editor/blocksuite-editor.mjs";var n=Object.defineProperty,a=Object.getOwnPropertyDescriptor,d=(t,e,o,i)=>{for(var s,r=i>1?void 0:i?a(e,o):e,d=t.length-1;d>=0;d--)(s=t[d])&&(r=(i?s(e,o,r):s(r))||r);return i&&r&&n(e,o,r),r};let p=class extends e{constructor(){super(...arguments),this.orderIndex=0,this.isEdit=!1,this.isSave=!1,this.showAction=!0,this.isSet=!1,this.richTextContent="",this.examAnswerRelationType=0,this.uploadImage=async t=>new Promise((e,o)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=o,i.readAsDataURL(t)}),this._content="",this._editor=null}createRenderRoot(){return this}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}updated(t){t.has("richTextContent")&&(this._content=this.richTextContent)}disconnectedCallback(){super.disconnectedCallback(),this._editor=null}_save(t){t?.stopImmediatePropagation();const e=this.querySelector("qxs-blocksuite-editor"),o=e?.getContent?.()||this._content;o&&"<p></p>"!==o?(this._content=o,this._emit("save",{richTextContent:o})):function(t){const e=document.createElement("div");e.textContent=t,Object.assign(e.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(e),setTimeout(()=>{e.style.opacity="0",setTimeout(()=>e.remove(),300)},2500)}("富文本内容不能为空!")}render(){const t=this._content||this.richTextContent;return o`
|
|
2
|
+
${this.isEdit?o`<qxs-blocksuite-editor .content=${t} .uploadImage=${this.uploadImage}></qxs-blocksuite-editor>`:o`<qxs-blocksuite-editor .content=${t} .uploadImage=${this.uploadImage} readonly preview></qxs-blocksuite-editor>`}
|
|
3
3
|
${this.showAction?o`
|
|
4
4
|
<qxs-subject-action
|
|
5
5
|
?is-edit=${this.isEdit}
|
|
@@ -23,5 +23,5 @@ import{css as t,LitElement as e,html as o}from"lit";import{property as i}from"..
|
|
|
23
23
|
qxs-blocksuite-editor {
|
|
24
24
|
display: block;
|
|
25
25
|
}
|
|
26
|
-
`,d([i({type:Number,attribute:"order-index"})],p.prototype,"orderIndex",2),d([i({type:Boolean,attribute:"is-edit"})],p.prototype,"isEdit",2),d([i({type:Boolean,attribute:"is-save"})],p.prototype,"isSave",2),d([i({type:Boolean,attribute:"show-action"})],p.prototype,"showAction",2),d([i({type:Boolean,attribute:"is-set"})],p.prototype,"isSet",2),d([i({type:String,attribute:"rich-text-content"})],p.prototype,"richTextContent",2),d([i({type:Number,attribute:"exam-answer-relation-type"})],p.prototype,"examAnswerRelationType",2),d([s()],p.prototype,"_content",2),p=d([
|
|
26
|
+
`,d([i({type:Number,attribute:"order-index"})],p.prototype,"orderIndex",2),d([i({type:Boolean,attribute:"is-edit"})],p.prototype,"isEdit",2),d([i({type:Boolean,attribute:"is-save"})],p.prototype,"isSave",2),d([i({type:Boolean,attribute:"show-action"})],p.prototype,"showAction",2),d([i({type:Boolean,attribute:"is-set"})],p.prototype,"isSet",2),d([i({type:String,attribute:"rich-text-content"})],p.prototype,"richTextContent",2),d([i({type:Number,attribute:"exam-answer-relation-type"})],p.prototype,"examAnswerRelationType",2),d([i({type:Object,attribute:"upload-image"})],p.prototype,"uploadImage",2),d([s()],p.prototype,"_content",2),p=d([r("qxs-subject-rich-text")],p);export{p as SubjectRichText};
|
|
27
27
|
//# sourceMappingURL=rich-text.mjs.map
|