@qxs-bns/components-wc 0.0.26 → 0.0.28

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.
Files changed (57) hide show
  1. package/es/editor/blocksuite-editor.mjs +442 -43
  2. package/es/editor/blocksuite-editor.mjs.map +1 -1
  3. package/es/entry-subject.mjs +1 -1
  4. package/es/index.mjs +1 -1
  5. package/es/subject/blank-fill.mjs +19 -13
  6. package/es/subject/blank-fill.mjs.map +1 -1
  7. package/es/subject/draft.mjs +2 -0
  8. package/es/subject/draft.mjs.map +1 -0
  9. package/es/subject/page-end.mjs +3 -3
  10. package/es/subject/page-end.mjs.map +1 -1
  11. package/es/subject/pagination.mjs +2 -0
  12. package/es/subject/pagination.mjs.map +1 -0
  13. package/es/subject/runtime.mjs +2 -0
  14. package/es/subject/runtime.mjs.map +1 -0
  15. package/es/subject/scale.mjs +58 -34
  16. package/es/subject/scale.mjs.map +1 -1
  17. package/es/subject/single.mjs +72 -42
  18. package/es/subject/single.mjs.map +1 -1
  19. package/es/subject/sort-controller.mjs +2 -0
  20. package/es/subject/sort-controller.mjs.map +1 -0
  21. package/es/subject/sortable.mjs +30 -0
  22. package/es/subject/sortable.mjs.map +1 -0
  23. package/es/subject/sorting-card.mjs +52 -0
  24. package/es/subject/sorting-card.mjs.map +1 -0
  25. package/es/subject/text-fill.mjs +43 -37
  26. package/es/subject/text-fill.mjs.map +1 -1
  27. package/es/subject/types.mjs +1 -1
  28. package/es/subject/types.mjs.map +1 -1
  29. package/lib/editor/blocksuite-editor.cjs +434 -35
  30. package/lib/editor/blocksuite-editor.cjs.map +1 -1
  31. package/lib/entry-subject.cjs +1 -1
  32. package/lib/index.cjs +1 -1
  33. package/lib/subject/blank-fill.cjs +19 -13
  34. package/lib/subject/blank-fill.cjs.map +1 -1
  35. package/lib/subject/draft.cjs +2 -0
  36. package/lib/subject/draft.cjs.map +1 -0
  37. package/lib/subject/page-end.cjs +3 -3
  38. package/lib/subject/page-end.cjs.map +1 -1
  39. package/lib/subject/pagination.cjs +2 -0
  40. package/lib/subject/pagination.cjs.map +1 -0
  41. package/lib/subject/runtime.cjs +2 -0
  42. package/lib/subject/runtime.cjs.map +1 -0
  43. package/lib/subject/scale.cjs +53 -29
  44. package/lib/subject/scale.cjs.map +1 -1
  45. package/lib/subject/single.cjs +72 -42
  46. package/lib/subject/single.cjs.map +1 -1
  47. package/lib/subject/sort-controller.cjs +2 -0
  48. package/lib/subject/sort-controller.cjs.map +1 -0
  49. package/lib/subject/sortable.cjs +30 -0
  50. package/lib/subject/sortable.cjs.map +1 -0
  51. package/lib/subject/sorting-card.cjs +52 -0
  52. package/lib/subject/sorting-card.cjs.map +1 -0
  53. package/lib/subject/text-fill.cjs +18 -12
  54. package/lib/subject/text-fill.cjs.map +1 -1
  55. package/lib/subject/types.cjs +1 -1
  56. package/lib/subject/types.cjs.map +1 -1
  57. package/package.json +1 -1
@@ -1,15 +1,17 @@
1
- import{html as e,css as t,LitElement as s}from"lit";import{property as i,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{uid as a}from"../base/uid.mjs";var n=Object.defineProperty,l=Object.getOwnPropertyDescriptor,c=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?l(t,s):t,a=e.length-1;a>=0;a--)(r=e[a])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&n(t,s,o),o};class h extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new h(e.message,e.code,e.field,e.row)}}const d=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,p=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`,u=e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;function g(e){return e.replace(/^\d+\.\s*/,"").replace(/[\s,,。.!!??;;::、'"“”‘’()()[\]【】\-_/\\]+/g,"").toLowerCase()}function m(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 w=class extends s{constructor(){super(...arguments),this["order-index"]=0,this["is-edit"]=!1,this["is-save"]=!1,this["is-set"]=!1,this["is-set-correct-answer"]=!1,this.lockAnswerKey=!1,this["is-key"]=!1,this["show-action"]=!0,this["show-add"]=!0,this["show-answer-setting"]=!1,this["show-key"]=!1,this["show-analysis"]=!0,this.type="single",this["answer-check-type"]=1,this["exam-answer-relation-type"]=0,this["rich-text-content"]="",this.analysis="",this["least-answer-count"]=null,this["exam-expand"]="",this["custom-id"]="",this["exam-id"]=0,this["category-id"]="",this["upload-image"]=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this["tag-list"]=[],this["category-list"]=[],this["ai-answer"]="",this["resource-list"]=[],this["show-tag"]=!1,this["show-category"]=!1,this["show-ai"]=!1,this["show-resource"]=!1,this["show-jump"]=!1,this["has-jump"]=!1,this["search-api"]="",this["model-value"]="",this["use-model"]=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.title="",this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=null,this._answerCheckType=1,this._isKey=!1,this._orderList=[],this._selectedTagList=[],this._categoryId="",this._searchResults=[],this._searchOpen=!1,this._searchLoading=!1,this._resultDialogOpen=!1,this._resultDialogIndex=0,this._resultDialogValue="",this._sortDropdownOpen=!1,this._imageViewerOpen=!1,this._imageViewerIndex=0,this._videoViewerOpen=!1,this._correctHintDialogOpen=!1,this._hasShownCorrectHint=!1,this._changeTypeDialogOpen=!1,this._searchTimer=null,this._searchToken=0,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper"),i=this.shadowRoot?.querySelector(".search-wrap");s&&!t.includes(s)&&(this._sortDropdownOpen=!1),i&&!t.includes(i)&&(this._searchOpen=!1),this.requestUpdate()}}get"answer-list"(){return this._answers}set"answer-list"(e){if(this["is-edit"])return;const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>this._normalizeAnswerItem(e)):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answer-list")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick),this._syncExternalProps()}firstUpdated(){this._syncExternalProps()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick),this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null)}willUpdate(e){e.has("is-edit")&&this["is-edit"]&&this._syncProps(),!this["is-edit"]&&(e.has("title")||e.has("answer-list")||e.has("analysis")||e.has("least-answer-count")||e.has("answer-check-type")||e.has("tag-list")||e.has("category-id")||e.has("rich-text-content"))&&this._syncExternalProps(),e.has("is-key")&&(this._isKey=this["is-key"]),e.has("tag-list")&&(this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[]),e.has("category-id")&&(this._categoryId=this["category-id"]?String(this["category-id"]):""),(e.has("exam-expand")||e.has("answer-list"))&&this._syncExamExpand(),e.has("model-value")&&this["use-model"]&&(this._title=this["model-value"])}_supportsLeastAnswerCount(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.type;return"multiple"===e||"sort"===e}_normalizeLeastAnswerCount(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;if(!this._supportsLeastAnswerCount(t)||""===e||null==e)return null;const s=Number(e);return Number.isFinite(s)&&s>0?s:null}_leastAnswerCountSuffix(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;return this._supportsLeastAnswerCount(t)&&null!==e?`,至少选${e}项${"sort"===t?"并排序":""}`:""}_normalizeAnswerItem(e){const t={...e,title:String(e?.title??e?.answer??""),isCorrect:!!e?.isCorrect},s=e?.answerId??e?.examAnswerId;return void 0!==s&&(t.answerId=s),t}_syncExternalProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this._normalizeLeastAnswerCount(this["least-answer-count"]),this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>this._normalizeAnswerItem(e)))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this._normalizeLeastAnswerCount(this["least-answer-count"]),this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>this._normalizeAnswerItem(e))),this._syncExamExpand()}_syncExamExpand(){if(!this["exam-expand"]||!this["answer-list"]?.length)return;const e=this["exam-expand"].split(","),t=this["answer-list"];this._orderList=e.map(e=>{const s=t.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return s>=0?this._label(s):""}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_searchAnswerType(){return"single"===this.type?0:"multiple"===this.type?1:5}_queueSearch(e){this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null);const t=e.trim();if(!t||!this["search-api"]&&"function"!=typeof this["search-handler"])return this._searchResults=[],this._searchOpen=!1,void(this._searchLoading=!1);this._searchTimer=window.setTimeout(()=>{this._runSearch(t)},300)}async _runSearch(e){const t=++this._searchToken;this._searchLoading=!0,this._searchOpen=!0,this.requestUpdate();try{let s=[];if("function"==typeof this["search-handler"])s=await this["search-handler"](e,this._searchAnswerType());else if(this["search-api"]){const t=new URLSearchParams({searchKey:e,answerType:String(this._searchAnswerType())}),i=await fetch(`${this["search-api"]}${this["search-api"].includes("?")?"&":"?"}${t.toString()}`);if(!i.ok)throw new Error(`HTTP ${i.status}`);const r=await i.json();s=(Array.isArray(r)?r:Array.isArray(r?.data)?r.data:[]).map(e=>({...e,value:e?.value||e?.title||""}))}if(t!==this._searchToken)return;this._searchResults=Array.isArray(s)?s:[]}catch(e){if(t!==this._searchToken)return;this._searchResults=[],m(e?.message||"题库搜索失败")}finally{t===this._searchToken&&(this._searchLoading=!1,this.requestUpdate())}}_selectSearchResult(e){const t=e.value||e.title||"";this._title=t,this._searchResults=[],this._searchOpen=!1,this["use-model"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title})),this._emit("title-select",{...e,id:e.id??e.examId??e.questionId,title:e.title||t,value:t,customId:this["custom-id"]||""})}_applyAiAnswer(){if(!this["ai-answer"]?.trim())return void m("暂无 AI 推荐答案");const e=this["ai-answer"].split(/\r?\n/).map(e=>g(e)).filter(Boolean);let t=0;if("single"===this.type){let s=!1;this._answers=this._answers.map(i=>{const r=!s&&e.includes(g(i.title||""));return r&&(s=!0,t++),{...i,isCorrect:r}})}else this._answers=this._answers.map(s=>{const i=e.includes(g(s.title||""));return i&&t++,{...s,isCorrect:i}});t?this.requestUpdate():m("未找到匹配的选项,请检查选项内容是否一致")}_onCategoryChange(e){this._categoryId=e,this._emit("category-change",{value:e,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_setRelation(e,t){const s=e.customAnswerId?{...e}:{...e,customAnswerId:e.answerId||a()};this._answers=this._answers.map((e,i)=>i===t?s:e),this.requestUpdate(),this._emit("set-relation",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerIndex:t,answer:s})}_relationLength(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce((e,t)=>e+(Array.isArray(t?.relationAnswers)?t.relationAnswers.length:0),0)}_imageResources(){return(this["resource-list"]||[]).filter(e=>1===e.resourceType).map(e=>e.resource.middle||e.resource.url).filter(Boolean)}_videoResource(){return(this["resource-list"]||[]).find(e=>2===e.resourceType)?.resource||null}_openImageViewer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._imageResources().length&&(this._imageViewerIndex=e,this._imageViewerOpen=!0)}_closeImageViewer(){this._imageViewerOpen=!1}_moveImage(e){const t=this._imageResources();t.length&&(this._imageViewerIndex=(this._imageViewerIndex+e+t.length)%t.length)}_openVideoViewer(){this._videoResource()?.url&&(this._videoViewerOpen=!0)}_closeVideoViewer(){this._videoViewerOpen=!1}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){this.lockAnswerKey||(e.isCorrect=t,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,this._queueSearch(this._title),this["use-model"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(e,t){const s=e.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[t].title=s.value,this.requestUpdate()}_addAnswer(e){const t=[...this._answers];t.splice(e+1,0,{title:"",isCorrect:!1,customAnswerId:a()}),this._answers=t}_deleteAnswer(e){this._answers.length<3||(this._answers=this._answers.filter((t,s)=>s!==e))}_toggleSortItem(e){const t=this._orderList.indexOf(e);this._orderList=t>=0?this._orderList.filter(t=>t!==e):[...this._orderList,e],this.requestUpdate()}_removeSortItem(e){this._orderList=this._orderList.filter(t=>t!==e),this.requestUpdate()}_getSortOrder(e){const t=this._orderList.indexOf(this._label(e));return t>=0?t+1:null}_sortAnswerValue(e){const t=e.charCodeAt(0)-65,s=this._answers[t];return s?.answerId??t+1}_rowMeta(){return{customId:this["custom-id"]||void 0,answerType:this.type,orderIndex:this["order-index"]}}_collectSnapshot(){const e=(this["is-edit"]?this._answers:this["answer-list"]||[]).map(e=>({...e,title:e?.title||"",isCorrect:!!e?.isCorrect})),t=this["is-edit"]?[...this._orderList]:(()=>{const e=this["exam-expand"];return e?e.split(",").map(e=>{const t=this["answer-list"]?.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return t>=0?this._label(t):""}).filter(Boolean):[]})();return{title:this["is-edit"]?this._title:this.title||"",answers:e,analysis:this["is-edit"]?this._analysis:this.analysis||"",leastAnswerCount:this["is-edit"]?this._leastAnswerCount:this._normalizeLeastAnswerCount(this["least-answer-count"]),selectedTagList:Array.isArray(this._selectedTagList)?[...this._selectedTagList]:[],examExpand:this["is-edit"]?t.map(e=>this._sortAnswerValue(e)).join(","):this["exam-expand"]||"",showRichText:this["is-edit"]?this._showRichText:!!this["rich-text-content"],richText:this["is-edit"]?this._richText:this["rich-text-content"]||"",orderList:t}}_validateSnapshot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;const s=this._rowMeta(),i=[];e.title||i.push(new h("题目标题不能为空!","EMPTY_TITLE","title",s));let r=!1,o=0;e.answers.forEach((e,a)=>{e.title?.trim()||i.push(new h(`选项${String.fromCharCode(65+a)}未填写`,"ANSWER_EMPTY","answers",s)),"sort"!==t&&e.isCorrect&&(r=!0,o++)});return new Set(e.answers.map(e=>e.title)).size!==e.answers.length&&e.answers.length>0&&i.push(new h("选项不能重复","DUPLICATE_ANSWERS","answers",s)),"single"===t&&o>1&&i.push(new h("此题为单选题,设置了多个推荐/正确选项,请保存时确认是否切换为多选题","SINGLE_MULTI_CORRECT","answers",s)),"multiple"===t&&(1===o&&i.push(new h("请设置至少两个推荐/正确选项","CORRECT_COUNT_INVALID","answers",s)),o>0&&(r=!0),r&&null!==e.leastAnswerCount&&o<e.leastAnswerCount&&i.push(new h("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))),"sort"===t&&(r=e.orderList.length>0,null!==e.leastAnswerCount&&e.orderList.length<e.leastAnswerCount&&i.push(new h("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","orderList",s))),{errors:i,isSetCorrectAnswer:r,correctAnswerCount:o}}_serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.type;const t=this._collectSnapshot(),{errors:s,isSetCorrectAnswer:i}=this._validateSnapshot(t,e);if(s.length)throw s[0];const r={answerType:String(e),examTypeEnum:String(e),title:t.title,answers:t.answers.map((e,t)=>{const s={...e,orderIndex:t+1,answer:e.title};return void 0!==e.answerId&&(s.examAnswerId=e.answerId),s}),examExpand:t.examExpand,analysis:t.analysis,isSetCorrectAnswer:i,examRichTextContent:t.showRichText?t.richText:""};return this._supportsLeastAnswerCount(e)&&(r.leastAnswerCount=t.leastAnswerCount),this["custom-id"]&&(r.customId=this["custom-id"]),r}_shouldShowCorrectHint(){return"sort"===this.type?!this._orderList.length:!this._answers.some(e=>!!e.isCorrect)}async toJSON(){return Promise.resolve(this._serialize())}validate(){return this._validateSnapshot(this._collectSnapshot()).errors}_openResultDialog(e){this._resultDialogIndex=e,this._resultDialogValue=this._answers[e].resultItem||"",this._resultDialogOpen=!0}_saveResultDialog(){this._answers[this._resultDialogIndex].resultItem=this._resultDialogValue,this._resultDialogOpen=!1,this.requestUpdate()}_renderCorrectHintDialog(){return this._correctHintDialogOpen?e`
1
+ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{uid as a}from"../base/uid.mjs";import{sortingCardStyles as n,renderSortingCard as l}from"./sorting-card.mjs";import{SubjectTypeLabel as c}from"./types.mjs";var h=Object.defineProperty,d=Object.getOwnPropertyDescriptor,p=(e,t,s,i)=>{for(var r,o=i>1?void 0:i?d(t,s):t,a=e.length-1;a>=0;a--)(r=e[a])&&(o=(i?r(t,s,o):r(o))||o);return i&&o&&h(t,s,o),o};class u extends Error{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"VALIDATION_ERROR",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;super(e),this.code=t,this.field=s,this.row=i,this.name="SubjectError"}static from(e){return new u(e.message,e.code,e.field,e.row)}}const m=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,g=e`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`,w=e`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>`;function x(e){return e.replace(/^\d+\.\s*/,"").replace(/[\s,,。.!!??;;::、'"“”‘’()()[\]【】\-_/\\]+/g,"").toLowerCase()}function y(e){return String(e??"").trim()}function _(e){return String(e??"").split(",").map(e=>e.trim()).filter(Boolean).join(",")}function v(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 f=class extends s{constructor(){super(...arguments),this["order-index"]=0,this["is-edit"]=!1,this["is-save"]=!1,this["is-set"]=!1,this["is-set-correct-answer"]=!1,this.lockAnswerKey=!1,this["is-key"]=!1,this["show-action"]=!0,this["show-add"]=!0,this.sorting=!1,this["show-answer-setting"]=!1,this["show-key"]=!1,this["show-analysis"]=!0,this.type="single",this["answer-check-type"]=1,this["exam-answer-relation-type"]=0,this["rich-text-content"]="",this.analysis="",this["least-answer-count"]=null,this["exam-expand"]="",this["custom-id"]="",this["exam-id"]=0,this["category-id"]="",this["upload-image"]=async e=>new Promise((t,s)=>{const i=new FileReader;i.onload=e=>t(e.target?.result),i.onerror=s,i.readAsDataURL(e)}),this["tag-list"]=[],this["category-list"]=[],this["ai-answer"]="",this["resource-list"]=[],this["show-tag"]=!1,this["show-category"]=!1,this["show-ai"]=!1,this["show-resource"]=!1,this["show-jump"]=!1,this["has-jump"]=!1,this["search-api"]="",this["model-value"]="",this["use-model"]=!1,this._answers=[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.title="",this._title="",this._analysis="",this._richText="",this._showRichText=!1,this._leastAnswerCount=null,this._answerCheckType=1,this._isKey=!1,this._orderList=[],this._selectedTagList=[],this._categoryId="",this._searchResults=[],this._searchOpen=!1,this._searchLoading=!1,this._sortDropdownOpen=!1,this._imageViewerOpen=!1,this._imageViewerIndex=0,this._videoViewerOpen=!1,this._correctHintDialogOpen=!1,this._hasShownCorrectHint=!1,this._changeTypeDialogOpen=!1,this._searchTimer=null,this._searchToken=0,this.TITLE_MAX=200,this.ANSWER_MAX=100,this._handleDocumentClick=e=>{const t=e.composedPath(),s=this.shadowRoot?.querySelector(".multi-select-wrapper"),i=this.shadowRoot?.querySelector(".search-wrap");s&&!t.includes(s)&&(this._sortDropdownOpen=!1),i&&!t.includes(i)&&(this._searchOpen=!1),this.requestUpdate()}}get"answer-list"(){return this._answers}set"answer-list"(e){if(this["is-edit"])return;const t=Array.isArray(e)?e:[];this._answers=t.length?t.map(e=>this._normalizeAnswerItem(e)):[{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1},{title:"",isCorrect:!1}],this.requestUpdate("answer-list")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this._handleDocumentClick),this._syncExternalProps()}firstUpdated(){this._syncExternalProps()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick),this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null)}willUpdate(e){e.has("is-edit")&&this["is-edit"]&&this._syncProps(),!this["is-edit"]&&(e.has("title")||e.has("answer-list")||e.has("analysis")||e.has("least-answer-count")||e.has("answer-check-type")||e.has("tag-list")||e.has("category-id")||e.has("rich-text-content"))&&this._syncExternalProps(),e.has("is-key")&&(this._isKey=this["is-key"]),e.has("tag-list")&&(this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[]),e.has("category-id")&&(this._categoryId=this["category-id"]?String(this["category-id"]):""),(e.has("exam-expand")||e.has("answer-list"))&&this._syncExamExpand(),e.has("model-value")&&this["use-model"]&&(this._title=this["model-value"])}_supportsLeastAnswerCount(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.type;return"multiple"===e||"sort"===e}_normalizeLeastAnswerCount(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;if(!this._supportsLeastAnswerCount(t)||""===e||null==e)return null;const s=Number(e);return Number.isFinite(s)&&s>0?s:null}_leastAnswerCountSuffix(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;return this._supportsLeastAnswerCount(t)&&null!==e?`,至少选${e}项${"sort"===t?"并排序":""}`:""}_normalizeAnswerItem(e){const t={...e,title:y(e?.title??e?.answer??""),isCorrect:!!e?.isCorrect},s=e?.answerId??e?.examAnswerId;return void 0!==s&&(t.answerId=s),t}_syncExternalProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this._normalizeLeastAnswerCount(this["least-answer-count"]),this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>this._normalizeAnswerItem(e)))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this._leastAnswerCount=this._normalizeLeastAnswerCount(this["least-answer-count"]),this._answerCheckType=this["answer-check-type"]||1,this._isKey=this["is-key"],this._selectedTagList=Array.isArray(this["tag-list"])?this["tag-list"].map(e=>({...e})):[],this._categoryId=this["category-id"]?String(this["category-id"]):"",this._richText=this["rich-text-content"]||"",this._showRichText=!!this["rich-text-content"],this["answer-list"]?.length&&(this._answers=this["answer-list"].map(e=>this._normalizeAnswerItem(e))),this._syncExamExpand()}_syncExamExpand(){if(!this["exam-expand"]||!this["answer-list"]?.length)return;const e=this["exam-expand"].split(","),t=this["answer-list"];this._orderList=e.map(e=>{const s=t.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return s>=0?this._label(s):""}).filter(Boolean)}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_searchAnswerType(){return"single"===this.type?0:"multiple"===this.type?1:5}_queueSearch(e){this._searchTimer&&(window.clearTimeout(this._searchTimer),this._searchTimer=null);const t=e.trim();if(!t||!this["search-api"]&&"function"!=typeof this["search-handler"])return this._searchResults=[],this._searchOpen=!1,void(this._searchLoading=!1);this._searchTimer=window.setTimeout(()=>{this._runSearch(t)},300)}async _runSearch(e){const t=++this._searchToken;this._searchLoading=!0,this._searchOpen=!0,this.requestUpdate();try{let s=[];if("function"==typeof this["search-handler"])s=await this["search-handler"](e,this._searchAnswerType());else if(this["search-api"]){const t=new URLSearchParams({searchKey:e,answerType:String(this._searchAnswerType())}),i=await fetch(`${this["search-api"]}${this["search-api"].includes("?")?"&":"?"}${t.toString()}`);if(!i.ok)throw new Error(`HTTP ${i.status}`);const r=await i.json();s=(Array.isArray(r)?r:Array.isArray(r?.data)?r.data:[]).map(e=>({...e,value:e?.value||e?.title||""}))}if(t!==this._searchToken)return;this._searchResults=Array.isArray(s)?s:[]}catch(e){if(t!==this._searchToken)return;this._searchResults=[],v(e?.message||"题库搜索失败")}finally{t===this._searchToken&&(this._searchLoading=!1,this.requestUpdate())}}_selectSearchResult(e){const t=e.value||e.title||"";this._title=t,this._searchResults=[],this._searchOpen=!1,this["use-model"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title})),this._emit("title-select",{...e,id:e.id??e.examId??e.questionId,title:e.title||t,value:t,customId:this["custom-id"]||""})}_applyAiAnswer(){if(!this["ai-answer"]?.trim())return void v("暂无 AI 推荐答案");const e=this["ai-answer"].split(/\r?\n/).map(e=>x(e)).filter(Boolean);let t=0;if("single"===this.type){let s=!1;this._answers=this._answers.map(i=>{const r=!s&&e.includes(x(i.title||""));return r&&(s=!0,t++),{...i,isCorrect:r}})}else this._answers=this._answers.map(s=>{const i=e.includes(x(s.title||""));return i&&t++,{...s,isCorrect:i}});t?this.requestUpdate():v("未找到匹配的选项,请检查选项内容是否一致")}_onCategoryChange(e){this._categoryId=e,this._emit("category-change",{value:e,customId:this["custom-id"]||"",examId:this["exam-id"]||0})}_setRelation(e,t){const s=e.customAnswerId?{...e}:{...e,customAnswerId:e.answerId||a()};this._answers=this._answers.map((e,i)=>i===t?s:e),this.requestUpdate(),this._emit("set-relation",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerIndex:t,answer:s})}_relationLength(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).reduce((e,t)=>e+(Array.isArray(t?.relationAnswers)?t.relationAnswers.length:0),0)}_emitEditResultItem(e,t){this._emit("edit-result-item",{customId:this["custom-id"]||"",examId:this["exam-id"]||0,answerIndex:t,answer:{...e},resultItem:e.resultItem||""})}_resultSlotName(e){return`business-result-item-${e}`}_imageResources(){return(this["resource-list"]||[]).filter(e=>1===e.resourceType).map(e=>e.resource.middle||e.resource.url).filter(Boolean)}_videoResource(){return(this["resource-list"]||[]).find(e=>2===e.resourceType)?.resource||null}_openImageViewer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._imageResources().length&&(this._imageViewerIndex=e,this._imageViewerOpen=!0)}_closeImageViewer(){this._imageViewerOpen=!1}_moveImage(e){const t=this._imageResources();t.length&&(this._imageViewerIndex=(this._imageViewerIndex+e+t.length)%t.length)}_openVideoViewer(){this._videoResource()?.url&&(this._videoViewerOpen=!0)}_closeVideoViewer(){this._videoViewerOpen=!1}_label(e){return String.fromCharCode(65+e)}get _titlePlaceholder(){return"single"===this.type?"单选题":"multiple"===this.type?"多选题":"排序题"}_setCorrect(e,t){this.lockAnswerKey||(e.isCorrect=t,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,this._queueSearch(this._title),this["use-model"]&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_onAnswerInput(e,t){const s=e.target;s.value.length>this.ANSWER_MAX&&(s.value=s.value.slice(0,this.ANSWER_MAX)),this._answers[t].title=s.value,this.requestUpdate()}_addAnswer(e){const t=[...this._answers];t.splice(e+1,0,{title:"",isCorrect:!1,customAnswerId:a()}),this._answers=t}_deleteAnswer(e){this._answers.length<3||(this._answers=this._answers.filter((t,s)=>s!==e))}_toggleSortItem(e){const t=this._orderList.indexOf(e);this._orderList=t>=0?this._orderList.filter(t=>t!==e):[...this._orderList,e],this.requestUpdate()}_removeSortItem(e){this._orderList=this._orderList.filter(t=>t!==e),this.requestUpdate()}_getSortOrder(e){const t=this._orderList.indexOf(this._label(e));return t>=0?t+1:null}_sortAnswerValue(e){const t=e.charCodeAt(0)-65,s=this._answers[t];return s?.answerId??t+1}_rowMeta(){return{customId:this["custom-id"]||void 0,answerType:this.type,orderIndex:this["order-index"]}}_collectSnapshot(){const e=(this["is-edit"]?this._answers:this["answer-list"]||[]).map(e=>({...e,title:y(e?.title??e?.answer??""),isCorrect:!!e?.isCorrect,resultItem:y(e?.resultItem??"")})),t=this["is-edit"]?[...this._orderList]:(()=>{const e=this["exam-expand"];return e?e.split(",").map(e=>{const t=this["answer-list"]?.findIndex((t,s)=>String(t.answerId??t.orderIndex??s+1)===String(e));return t>=0?this._label(t):""}).filter(Boolean):[]})();return{title:y(this["is-edit"]?this._title:this.title||""),answers:e,analysis:y(this["is-edit"]?this._analysis:this.analysis||""),leastAnswerCount:this["is-edit"]?this._leastAnswerCount:this._normalizeLeastAnswerCount(this["least-answer-count"]),selectedTagList:Array.isArray(this._selectedTagList)?[...this._selectedTagList]:[],examExpand:this["is-edit"]?t.map(e=>this._sortAnswerValue(e)).join(","):this["exam-expand"]||"",showRichText:this["is-edit"]?this._showRichText:!!this["rich-text-content"],richText:this["is-edit"]?this._richText:this["rich-text-content"]||"",orderList:t}}_validateSnapshot(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.type;const s=this._rowMeta(),i=[];e.title||i.push(new u("题目标题不能为空!","EMPTY_TITLE","title",s));let r=!1,o=0;e.answers.forEach((e,a)=>{e.title?.trim()||i.push(new u(`选项${String.fromCharCode(65+a)}未填写`,"ANSWER_EMPTY","answers",s)),"sort"!==t&&e.isCorrect&&(r=!0,o++)});return new Set(e.answers.map(e=>e.title)).size!==e.answers.length&&e.answers.length>0&&i.push(new u("选项不能重复","DUPLICATE_ANSWERS","answers",s)),"single"===t&&o>1&&i.push(new u("此题为单选题,设置了多个推荐/正确选项,请保存时确认是否切换为多选题","SINGLE_MULTI_CORRECT","answers",s)),"multiple"===t&&(1===o&&i.push(new u("请设置至少两个推荐/正确选项","CORRECT_COUNT_INVALID","answers",s)),o>0&&(r=!0),r&&null!==e.leastAnswerCount&&o<e.leastAnswerCount&&i.push(new u("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","answers",s))),"sort"===t&&(r=e.orderList.length>0,null!==e.leastAnswerCount&&e.orderList.length<e.leastAnswerCount&&i.push(new u("至少选几项与推荐/正确选项数不符","LEAST_ANSWER_COUNT_INVALID","orderList",s))),{errors:i,isSetCorrectAnswer:r,correctAnswerCount:o}}_serialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.type;const t=this._collectSnapshot(),{errors:s,isSetCorrectAnswer:i}=this._validateSnapshot(t,e);if(s.length)throw s[0];const r={answerType:String(e),examTypeEnum:String(e),title:t.title,answers:t.answers.map((e,t)=>{const s=e.resultItem?1:Array.isArray(e.answerRelations)&&e.answerRelations.length?2:null,i={...e,orderIndex:t+1,answer:e.title,relationType:s};return void 0!==e.answerId&&(i.examAnswerId=e.answerId),null===s&&delete i.relationType,i}),examExpand:t.examExpand,analysis:t.analysis,isSetCorrectAnswer:i,examRichTextContent:t.showRichText?t.richText:""};return this["exam-answer-relation-type"]&&(r.examAnswerRelationType=this["exam-answer-relation-type"]),this._supportsLeastAnswerCount(e)&&(r.leastAnswerCount=t.leastAnswerCount),this["custom-id"]&&(r.customId=this["custom-id"]),r}_shouldShowCorrectHint(){return"sort"===this.type?!this._orderList.length:!this._answers.some(e=>!!e.isCorrect)}async _finalizeSave(){try{const e=await this.toJSON();this._emit("save",e)}catch(e){v(e.message)}}async toJSON(){return Promise.resolve(this._serialize())}validate(){return this._validateSnapshot(this._collectSnapshot()).errors}setResultItem(e,t){e<0||e>=this._answers.length||(this._answers=this._answers.map((s,i)=>i===e?{...s,resultItem:t||""}:s),this.requestUpdate())}setAnswerRelation(e,t){e&&(this._answers=this._answers.map(s=>String(s.customAnswerId??s.answerId??"")===String(e)?{...s,answerRelations:t}:s),this.requestUpdate())}_renderCorrectHintDialog(){return this._correctHintDialogOpen?e`
2
2
  <div class="modal-backdrop" @click=${()=>{this._correctHintDialogOpen=!1}}>
3
- <div class="modal" @click=${e=>e.stopPropagation()}>
3
+ <div class="modal correct-hint-dialog" @click=${e=>e.stopPropagation()}>
4
4
  <div class="modal-header">
5
5
  <span class="modal-title">温馨提示</span>
6
- <button class="modal-close" @click=${()=>{this._correctHintDialogOpen=!1}}>&#x2715;</button>
7
6
  </div>
8
7
  <div class="modal-body">
9
- <div class="value-text">为了收集更全面、有价值的数据,建议您为问卷每题设定推荐/正确选项。</div>
8
+ <div class="correct-hint-copy">
9
+ 为了收集更全面、有价值的数据,建议您为问卷每题设定<span class="correct-hint-highlight">推荐/正确选项</span>。这将助力深入分析,让调研结果更精准、有意义。
10
+ </div>
10
11
  </div>
11
12
  <div class="modal-footer">
12
- <button class="primary" @click=${()=>{this._hasShownCorrectHint=!0,this._correctHintDialogOpen=!1}}>我知道了</button>
13
+ <button @click=${async()=>{this._hasShownCorrectHint=!0,this._correctHintDialogOpen=!1,await this._finalizeSave()}}>完成编辑</button>
14
+ <button class="primary" @click=${()=>{this._correctHintDialogOpen=!1}}>去设置</button>
13
15
  </div>
14
16
  </div>
15
17
  </div>
@@ -25,29 +27,11 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
25
27
  </div>
26
28
  <div class="modal-footer">
27
29
  <button @click=${()=>{this._changeTypeDialogOpen=!1}}>取消</button>
28
- <button class="primary" @click=${()=>{try{const e=this._serialize("multiple");this._changeTypeDialogOpen=!1,this._emit("save",e)}catch(e){m(e?.message||"保存失败")}}}>切换</button>
29
- </div>
30
- </div>
31
- </div>
32
- `:""}_renderResultDialog(){if(!this._resultDialogOpen)return"";const t=this._label(this._resultDialogIndex);return e`
33
- <div class="modal-backdrop" @click=${()=>{this._resultDialogOpen=!1}}>
34
- <div class="modal" @click=${e=>e.stopPropagation()}>
35
- <div class="modal-header">
36
- <span class="modal-title">编辑结果项 — 选项 ${t}</span>
37
- <button class="modal-close" @click=${()=>{this._resultDialogOpen=!1}}>&#x2715;</button>
38
- </div>
39
- <div class="modal-body">
40
- <textarea rows="5" .value=${this._resultDialogValue}
41
- @input=${e=>{this._resultDialogValue=e.target.value}}
42
- placeholder="请输入该选项的结果项内容"></textarea>
43
- </div>
44
- <div class="modal-footer">
45
- <button @click=${()=>{this._resultDialogOpen=!1}}>取消</button>
46
- <button class="primary" @click=${()=>this._saveResultDialog()}>保存</button>
30
+ <button class="primary" @click=${()=>{try{const e=this._serialize("multiple");this._changeTypeDialogOpen=!1,this._emit("save",e)}catch(e){v(e?.message||"保存失败")}}}>切换</button>
47
31
  </div>
48
32
  </div>
49
33
  </div>
50
- `}_renderSearchDropdown(){return this["is-edit"]&&(this._searchOpen||this._searchLoading)?e`
34
+ `:""}_renderSearchDropdown(){return this["is-edit"]&&(this._searchOpen||this._searchLoading)?e`
51
35
  <div class="search-dropdown">
52
36
  ${this._searchLoading?e`<div class="search-empty">搜索中...</div>`:this._searchResults.length?this._searchResults.map(t=>e`
53
37
  <div class="search-item" @click=${()=>this._selectSearchResult(t)}>${t.value||t.title}</div>
@@ -136,7 +120,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
136
120
  </div>
137
121
  </div>
138
122
  </div>
139
- `:""}async _save(e){e?.stopImmediatePropagation();const t=this.validate(),s=t.find(e=>"SINGLE_MULTI_CORRECT"===e.code),i=t.filter(e=>"SINGLE_MULTI_CORRECT"!==e.code);if(i.length)m(i[0].message);else if(s)this._changeTypeDialogOpen=!0;else if(this._hasShownCorrectHint||!this._shouldShowCorrectHint())try{const e=await this.toJSON();this._emit("save",e)}catch(e){m(e.message)}else this._correctHintDialogOpen=!0}_renderPreview(){const t="single"===this.type?"(单选题)":`(${this._titlePlaceholder}${this._leastAnswerCountSuffix(this._normalizeLeastAnswerCount(this["least-answer-count"]))})`,s=this["answer-list"];return e`
123
+ `:""}async _save(e){e?.stopImmediatePropagation();const t=this.validate(),s=t.find(e=>"SINGLE_MULTI_CORRECT"===e.code),i=t.filter(e=>"SINGLE_MULTI_CORRECT"!==e.code);i.length?v(i[0].message):s?this._changeTypeDialogOpen=!0:this._hasShownCorrectHint||!this._shouldShowCorrectHint()?await this._finalizeSave():this._correctHintDialogOpen=!0}_renderPreview(){const t="single"===this.type?"(单选题)":`(${this._titlePlaceholder}${this._leastAnswerCountSuffix(this._normalizeLeastAnswerCount(this["least-answer-count"]))})`,s=this["answer-list"];return e`
140
124
  <div class="preview">
141
125
  <div><span class="title">${this["order-index"]+1}.${this.title||""}${t}</span></div>
142
126
  ${this["rich-text-content"]?e`<div class="rich-text" .innerHTML=${this["rich-text-content"]}></div>`:""}
@@ -146,13 +130,15 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
146
130
  <input type="${"sort"===this.type?"checkbox":"radio"}" .checked=${!!t.isCorrect} disabled />
147
131
  <span class="order">${this._label(s)}.</span> ${t.title}
148
132
  ${"sort"!==this.type&&t.isCorrect?e`<span class="correct">(推荐/正确选项)</span>`:""}
133
+ ${1===this["exam-answer-relation-type"]&&"sort"!==this.type?e`<span class="correct">(${t.resultItem?"已设置结果项":"未设置结果项"})</span>`:""}
134
+ ${2===this["exam-answer-relation-type"]&&"sort"!==this.type?e`<span class="correct">(${Array.isArray(t.answerRelations)&&t.answerRelations.length?`关联了${this._relationLength(t.answerRelations)}项`:"未设置关联"})</span>`:""}
149
135
  </label>
150
136
  `)}
151
137
  </div>
152
138
  ${this["show-category"]&&this._categoryId?e`<div class="section-row"><span class="value-text">分类:${this["category-list"].find(e=>String(e.categoryId)===String(this._categoryId))?.title||this._categoryId}</span></div>`:""}
153
139
  ${this["show-resource"]?this._renderResourceSection():""}
154
140
  </div>
155
- `}_renderEdit(){return e`
141
+ `}_renderSorting(){const e=y(this["is-edit"]?this._title:this.title||"")||"未命名题目",t=`${this["order-index"]+1}. ${e}`;return l(t,c[this.type]||this.type)}_renderEdit(){return e`
156
142
  <div class="flex-items-start">
157
143
  <div class="label"><span>题目:</span></div>
158
144
  <div style="flex:1">
@@ -204,13 +190,27 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
204
190
 
205
191
  <span class="icon"
206
192
  @click=${()=>this._addAnswer(s)}>
207
- ${d}
193
+ ${m}
208
194
  </span>
209
195
  <span class="icon ${this._answers.length<3?"disabled":""}"
210
196
  @click=${()=>this._deleteAnswer(s)}>
211
- ${p}
197
+ ${g}
212
198
  </span>
213
199
 
200
+ ${1===this["exam-answer-relation-type"]&&"sort"!==this.type?e`
201
+ <slot name=${this._resultSlotName(s)}>
202
+ <button class="el-link" @click=${()=>this._emitEditResultItem(t,s)}>
203
+ ${t.resultItem?"编辑结果":"添加结果"}
204
+ </button>
205
+ </slot>
206
+ `:""}
207
+
208
+ ${2===this["exam-answer-relation-type"]&&"sort"!==this.type?e`
209
+ <button class="el-link" @click=${()=>this._setRelation(t,s)}>
210
+ ${Array.isArray(t.answerRelations)&&t.answerRelations.length?`关联了${this._relationLength(t.answerRelations)}项`:"关联检查"}
211
+ </button>
212
+ `:""}
213
+
214
214
  </div>
215
215
  `)}
216
216
  </div>
@@ -228,7 +228,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
228
228
  <span class="tag-close" @click=${e=>{this.lockAnswerKey||(e.stopPropagation(),this._removeSortItem(t))}}>&#x2715;</span>
229
229
  </span>
230
230
  `):e`<span class="placeholder">请按顺序选择排序答案</span>`}
231
- <span class="arrow">${u}</span>
231
+ <span class="arrow">${w}</span>
232
232
  </div>
233
233
  ${this._sortDropdownOpen?e`
234
234
  <div class="multi-select-dropdown">
@@ -255,14 +255,16 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
255
255
 
256
256
  ${this._showRichText?e`
257
257
  <div class="flex-items-start" style="margin-top:12px">
258
- <div class="label"><span>富文本:</span></div>
258
+ <div class="label"><span>副文本:</span></div>
259
259
  <div style="flex:1">
260
- <qxs-blocksuite-editor
261
- .content=${this._richText}
262
- .upload-image=${this["upload-image"]}
263
- ?is-edit=${!0}
264
- @input=${e=>{this._richText=e.target.getContent()}}
265
- ></qxs-blocksuite-editor>
260
+ <slot name="sub-text">
261
+ <qxs-blocksuite-editor
262
+ .content=${this._richText}
263
+ .upload-image=${this["upload-image"]}
264
+ ?is-edit=${!0}
265
+ @input=${e=>{this._richText=e.target.getContent()}}
266
+ ></qxs-blocksuite-editor>
267
+ </slot>
266
268
  ${this["show-action"]?"":e`<div class="flex-justify-end" style="margin-top:8px"><span class="el-link danger" @click=${()=>{this._showRichText=!1,this._richText=""}}>删除富文本</span></div>`}
267
269
  </div>
268
270
  </div>
@@ -278,7 +280,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
278
280
  </div>
279
281
  </div>
280
282
  `:""}
281
- `}render(){const t=this["is-edit"]?e`<div slot="edit">${this._renderEdit()}</div>`:e`<div slot="preview">${this._renderPreview()}</div>`;return e`
283
+ `}render(){if(this.sorting)return this._renderSorting();const t=this["is-edit"]?e`<div slot="edit">${this._renderEdit()}</div>`:e`<div slot="preview">${this._renderPreview()}</div>`;return e`
282
284
  <qxs-subject-layout .show-edit=${this["is-edit"]}>
283
285
  ${t}
284
286
  ${this["show-action"]?e`
@@ -298,12 +300,11 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
298
300
  ></qxs-subject-action>
299
301
  `:""}
300
302
  </qxs-subject-layout>
301
- ${this._renderResultDialog()}
302
303
  ${this._renderCorrectHintDialog()}
303
304
  ${this._renderChangeTypeDialog()}
304
305
  ${this._renderImageViewer()}
305
306
  ${this._renderVideoViewer()}
306
- `}};w.styles=t`
307
+ `}};f.styles=[n,t`
307
308
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
308
309
  *, ::before, ::after { box-sizing: border-box; }
309
310
 
@@ -321,6 +322,9 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
321
322
  }
322
323
  .preview .rich-text { margin-top: 8px; }
323
324
  .preview .rich-text img { max-width: 100%; }
325
+ .preview .rich-text img[data-align="left"] { display: block !important; margin: 0 auto 0 0 !important; }
326
+ .preview .rich-text img[data-align="center"] { display: block !important; margin: 0 auto !important; }
327
+ .preview .rich-text img[data-align="right"] { display: block !important; margin: 0 0 0 auto !important; }
324
328
  .preview-answer { display: flex; flex-direction: column; margin-top: 12px; }
325
329
  .preview-answer .radio { margin-top: 8px; padding-left: 8px; display: flex; align-items: center; gap: 6px; }
326
330
  .preview-answer .order { color: #909399; }
@@ -393,7 +397,7 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
393
397
 
394
398
  .sort-badge { font-weight: bold; color: #3D61E3; margin-left: 10px; }
395
399
 
396
- .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; }
400
+ .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; background: none; border: none; padding: 0; margin: 0; font-family: inherit; }
397
401
  .el-link:hover { color: #2D4CB8; }
398
402
  .el-link.danger { color: #f56c6c; }
399
403
 
@@ -493,5 +497,31 @@ import{html as e,css as t,LitElement as s}from"lit";import{property as i,state a
493
497
  .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }
494
498
  .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }
495
499
  .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }
496
- `,c([i({type:Number,attribute:"order-index"})],w.prototype,"order-index",2),c([i({type:Boolean,attribute:"is-edit"})],w.prototype,"is-edit",2),c([i({type:Boolean,attribute:"is-save"})],w.prototype,"is-save",2),c([i({type:Boolean,attribute:"is-set"})],w.prototype,"is-set",2),c([i({type:Boolean,attribute:"is-set-correct-answer"})],w.prototype,"is-set-correct-answer",2),c([i({type:Boolean,attribute:"lock-answer-key"})],w.prototype,"lockAnswerKey",2),c([i({type:Boolean,attribute:"is-key"})],w.prototype,"is-key",2),c([i({type:Boolean,attribute:"show-action"})],w.prototype,"show-action",2),c([i({type:Boolean,attribute:"show-add"})],w.prototype,"show-add",2),c([i({type:Boolean,attribute:"show-answer-setting"})],w.prototype,"show-answer-setting",2),c([i({type:Boolean,attribute:"show-key"})],w.prototype,"show-key",2),c([i({type:Boolean,attribute:"show-analysis"})],w.prototype,"show-analysis",2),c([i({attribute:"question-type",reflect:!0})],w.prototype,"type",2),c([i({type:Number,attribute:"answer-check-type"})],w.prototype,"answer-check-type",2),c([i({type:Number,attribute:"exam-answer-relation-type"})],w.prototype,"exam-answer-relation-type",2),c([i({type:String,attribute:"rich-text-content"})],w.prototype,"rich-text-content",2),c([i({type:String})],w.prototype,"analysis",2),c([i({type:Number,attribute:"least-answer-count"})],w.prototype,"least-answer-count",2),c([i({type:String,attribute:"exam-expand"})],w.prototype,"exam-expand",2),c([i({type:String,attribute:"custom-id"})],w.prototype,"custom-id",2),c([i({type:Number,attribute:"exam-id"})],w.prototype,"exam-id",2),c([i({type:String,attribute:"category-id"})],w.prototype,"category-id",2),c([i({type:Object,attribute:"upload-image"})],w.prototype,"upload-image",2),c([i({type:Array,attribute:"answer-list"})],w.prototype,"answer-list",1),c([i({type:Array,attribute:"tag-list"})],w.prototype,"tag-list",2),c([i({type:Array,attribute:"category-list"})],w.prototype,"category-list",2),c([i({type:String,attribute:"ai-answer"})],w.prototype,"ai-answer",2),c([i({type:Array,attribute:"resource-list"})],w.prototype,"resource-list",2),c([i({type:Boolean,attribute:"show-tag"})],w.prototype,"show-tag",2),c([i({type:Boolean,attribute:"show-category"})],w.prototype,"show-category",2),c([i({type:Boolean,attribute:"show-ai"})],w.prototype,"show-ai",2),c([i({type:Boolean,attribute:"show-resource"})],w.prototype,"show-resource",2),c([i({type:Boolean,attribute:"show-jump"})],w.prototype,"show-jump",2),c([i({type:Boolean,attribute:"has-jump"})],w.prototype,"has-jump",2),c([i({type:String,attribute:"search-api"})],w.prototype,"search-api",2),c([i({type:Object,attribute:"search-handler"})],w.prototype,"search-handler",2),c([i({type:String,attribute:"model-value"})],w.prototype,"model-value",2),c([i({type:Boolean,attribute:"use-model"})],w.prototype,"use-model",2),c([r()],w.prototype,"_answers",2),c([i({type:String})],w.prototype,"title",2),c([r()],w.prototype,"_title",2),c([r()],w.prototype,"_analysis",2),c([r()],w.prototype,"_richText",2),c([r()],w.prototype,"_showRichText",2),c([r()],w.prototype,"_leastAnswerCount",2),c([r()],w.prototype,"_answerCheckType",2),c([r()],w.prototype,"_isKey",2),c([r()],w.prototype,"_orderList",2),c([r()],w.prototype,"_selectedTagList",2),c([r()],w.prototype,"_categoryId",2),c([r()],w.prototype,"_searchResults",2),c([r()],w.prototype,"_searchOpen",2),c([r()],w.prototype,"_searchLoading",2),c([r()],w.prototype,"_resultDialogOpen",2),c([r()],w.prototype,"_resultDialogIndex",2),c([r()],w.prototype,"_resultDialogValue",2),c([r()],w.prototype,"_sortDropdownOpen",2),c([r()],w.prototype,"_imageViewerOpen",2),c([r()],w.prototype,"_imageViewerIndex",2),c([r()],w.prototype,"_videoViewerOpen",2),c([r()],w.prototype,"_correctHintDialogOpen",2),c([r()],w.prototype,"_hasShownCorrectHint",2),c([r()],w.prototype,"_changeTypeDialogOpen",2),w=c([o("qxs-subject-single")],w);export{w as QxsSubjectSingle,h as SubjectError};
500
+ .correct-hint-dialog { width: 520px; max-width: min(90vw, 520px); }
501
+ .correct-hint-dialog .modal-header { padding: 18px 20px 14px; }
502
+ .correct-hint-dialog .modal-title { font-size: 16px; font-weight: 700; color: #303133; }
503
+ .correct-hint-dialog .modal-close { display: none; }
504
+ .correct-hint-dialog .modal-body {
505
+ padding: 32px 28px 20px;
506
+ font-size: 14px;
507
+ line-height: 1.8;
508
+ color: #303133;
509
+ text-align: center;
510
+ }
511
+ .correct-hint-copy { max-width: 420px; margin: 0 auto; }
512
+ .correct-hint-highlight { color: #4c6fff; }
513
+ .correct-hint-dialog .modal-footer {
514
+ justify-content: center;
515
+ gap: 12px;
516
+ padding: 0 28px 28px;
517
+ border-top: none;
518
+ }
519
+ .correct-hint-dialog .modal-footer button {
520
+ min-width: 120px;
521
+ height: 36px;
522
+ padding: 0 18px;
523
+ font-size: 14px;
524
+ border-radius: 4px;
525
+ }
526
+ `],p([i({type:Number,attribute:"order-index"})],f.prototype,"order-index",2),p([i({type:Boolean,attribute:"is-edit"})],f.prototype,"is-edit",2),p([i({type:Boolean,attribute:"is-save"})],f.prototype,"is-save",2),p([i({type:Boolean,attribute:"is-set"})],f.prototype,"is-set",2),p([i({type:Boolean,attribute:"is-set-correct-answer"})],f.prototype,"is-set-correct-answer",2),p([i({type:Boolean,attribute:"lock-answer-key"})],f.prototype,"lockAnswerKey",2),p([i({type:Boolean,attribute:"is-key"})],f.prototype,"is-key",2),p([i({type:Boolean,attribute:"show-action"})],f.prototype,"show-action",2),p([i({type:Boolean,attribute:"show-add"})],f.prototype,"show-add",2),p([i({type:Boolean,reflect:!0})],f.prototype,"sorting",2),p([i({type:Boolean,attribute:"show-answer-setting"})],f.prototype,"show-answer-setting",2),p([i({type:Boolean,attribute:"show-key"})],f.prototype,"show-key",2),p([i({type:Boolean,attribute:"show-analysis"})],f.prototype,"show-analysis",2),p([i({attribute:"question-type",reflect:!0})],f.prototype,"type",2),p([i({type:Number,attribute:"answer-check-type"})],f.prototype,"answer-check-type",2),p([i({type:Number,attribute:"exam-answer-relation-type"})],f.prototype,"exam-answer-relation-type",2),p([i({type:String,attribute:"rich-text-content"})],f.prototype,"rich-text-content",2),p([i({type:String})],f.prototype,"analysis",2),p([i({type:Number,attribute:"least-answer-count"})],f.prototype,"least-answer-count",2),p([i({type:String,attribute:"exam-expand"})],f.prototype,"exam-expand",2),p([i({type:String,attribute:"custom-id"})],f.prototype,"custom-id",2),p([i({type:Number,attribute:"exam-id"})],f.prototype,"exam-id",2),p([i({type:String,attribute:"category-id"})],f.prototype,"category-id",2),p([i({type:Object,attribute:"upload-image"})],f.prototype,"upload-image",2),p([i({type:Array,attribute:"answer-list"})],f.prototype,"answer-list",1),p([i({type:Array,attribute:"tag-list"})],f.prototype,"tag-list",2),p([i({type:Array,attribute:"category-list"})],f.prototype,"category-list",2),p([i({type:String,attribute:"ai-answer"})],f.prototype,"ai-answer",2),p([i({type:Array,attribute:"resource-list"})],f.prototype,"resource-list",2),p([i({type:Boolean,attribute:"show-tag"})],f.prototype,"show-tag",2),p([i({type:Boolean,attribute:"show-category"})],f.prototype,"show-category",2),p([i({type:Boolean,attribute:"show-ai"})],f.prototype,"show-ai",2),p([i({type:Boolean,attribute:"show-resource"})],f.prototype,"show-resource",2),p([i({type:Boolean,attribute:"show-jump"})],f.prototype,"show-jump",2),p([i({type:Boolean,attribute:"has-jump"})],f.prototype,"has-jump",2),p([i({type:String,attribute:"search-api"})],f.prototype,"search-api",2),p([i({type:Object,attribute:"search-handler"})],f.prototype,"search-handler",2),p([i({type:String,attribute:"model-value"})],f.prototype,"model-value",2),p([i({type:Boolean,attribute:"use-model"})],f.prototype,"use-model",2),p([r()],f.prototype,"_answers",2),p([i({type:String})],f.prototype,"title",2),p([r()],f.prototype,"_title",2),p([r()],f.prototype,"_analysis",2),p([r()],f.prototype,"_richText",2),p([r()],f.prototype,"_showRichText",2),p([r()],f.prototype,"_leastAnswerCount",2),p([r()],f.prototype,"_answerCheckType",2),p([r()],f.prototype,"_isKey",2),p([r()],f.prototype,"_orderList",2),p([r()],f.prototype,"_selectedTagList",2),p([r()],f.prototype,"_categoryId",2),p([r()],f.prototype,"_searchResults",2),p([r()],f.prototype,"_searchOpen",2),p([r()],f.prototype,"_searchLoading",2),p([r()],f.prototype,"_sortDropdownOpen",2),p([r()],f.prototype,"_imageViewerOpen",2),p([r()],f.prototype,"_imageViewerIndex",2),p([r()],f.prototype,"_videoViewerOpen",2),p([r()],f.prototype,"_correctHintDialogOpen",2),p([r()],f.prototype,"_hasShownCorrectHint",2),p([r()],f.prototype,"_changeTypeDialogOpen",2),f=p([o("qxs-subject-single")],f);export{f as QxsSubjectSingle,u as SubjectError,_ as trimCommaSeparatedText,y as trimText};
497
527
  //# sourceMappingURL=single.mjs.map