@qxs-bns/components-wc 0.0.21 → 0.0.23

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 (163) hide show
  1. package/es/base/define.mjs +1 -1
  2. package/es/base/define.mjs.map +1 -1
  3. package/es/editor/blocksuite-editor.mjs +3 -3
  4. package/es/editor/blocksuite-editor.mjs.map +1 -1
  5. package/es/editor/index.mjs +1 -1
  6. package/es/editor/index.mjs.map +1 -1
  7. package/es/entry-editor.mjs +2 -0
  8. package/es/entry-editor.mjs.map +1 -0
  9. package/es/entry-subject.mjs +2 -0
  10. package/es/entry-subject.mjs.map +1 -0
  11. package/es/index.mjs +1 -1
  12. package/es/subject/action.mjs +5 -5
  13. package/es/subject/action.mjs.map +1 -1
  14. package/es/subject/blank-fill.mjs +8 -8
  15. package/es/subject/blank-fill.mjs.map +1 -1
  16. package/es/subject/layout.mjs +4 -4
  17. package/es/subject/layout.mjs.map +1 -1
  18. package/es/subject/list.mjs +77 -77
  19. package/es/subject/list.mjs.map +1 -1
  20. package/es/subject/page-end.mjs +7 -7
  21. package/es/subject/page-end.mjs.map +1 -1
  22. package/es/subject/scale.mjs +7 -7
  23. package/es/subject/scale.mjs.map +1 -1
  24. package/es/subject/single.mjs +11 -11
  25. package/es/subject/single.mjs.map +1 -1
  26. package/es/subject/text-fill.mjs +32 -32
  27. package/es/subject/text-fill.mjs.map +1 -1
  28. package/lib/base/define.cjs +1 -1
  29. package/lib/base/define.cjs.map +1 -1
  30. package/lib/editor/blocksuite-editor.cjs +2 -2
  31. package/lib/editor/blocksuite-editor.cjs.map +1 -1
  32. package/lib/editor/index.cjs +1 -1
  33. package/lib/editor/index.cjs.map +1 -1
  34. package/lib/entry-editor.cjs +2 -0
  35. package/lib/entry-editor.cjs.map +1 -0
  36. package/lib/entry-subject.cjs +2 -0
  37. package/lib/entry-subject.cjs.map +1 -0
  38. package/lib/index.cjs +1 -1
  39. package/lib/subject/action.cjs +2 -2
  40. package/lib/subject/action.cjs.map +1 -1
  41. package/lib/subject/blank-fill.cjs +9 -9
  42. package/lib/subject/blank-fill.cjs.map +1 -1
  43. package/lib/subject/layout.cjs +4 -4
  44. package/lib/subject/layout.cjs.map +1 -1
  45. package/lib/subject/list.cjs +32 -32
  46. package/lib/subject/list.cjs.map +1 -1
  47. package/lib/subject/page-end.cjs +5 -5
  48. package/lib/subject/page-end.cjs.map +1 -1
  49. package/lib/subject/scale.cjs +10 -10
  50. package/lib/subject/scale.cjs.map +1 -1
  51. package/lib/subject/single.cjs +14 -14
  52. package/lib/subject/single.cjs.map +1 -1
  53. package/lib/subject/text-fill.cjs +40 -40
  54. package/lib/subject/text-fill.cjs.map +1 -1
  55. package/package.json +16 -1
  56. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.mjs +0 -7
  57. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.mjs.map +0 -1
  58. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs +0 -7
  59. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs.map +0 -1
  60. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs +0 -7
  61. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs.map +0 -1
  62. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.mjs +0 -7
  63. package/es/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.mjs.map +0 -1
  64. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs +0 -2
  65. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs.map +0 -1
  66. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs +0 -2
  67. package/es/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.mjs.map +0 -1
  68. package/es/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs +0 -2
  69. package/es/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs.map +0 -1
  70. package/es/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs +0 -2
  71. package/es/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.mjs.map +0 -1
  72. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.mjs +0 -7
  73. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.mjs.map +0 -1
  74. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.mjs +0 -7
  75. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.mjs.map +0 -1
  76. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.mjs +0 -7
  77. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.mjs.map +0 -1
  78. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.mjs +0 -7
  79. package/es/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.mjs.map +0 -1
  80. package/es/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.mjs +0 -2
  81. package/es/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.mjs.map +0 -1
  82. package/es/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.mjs +0 -2
  83. package/es/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.mjs.map +0 -1
  84. package/es/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.mjs +0 -2
  85. package/es/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.mjs.map +0 -1
  86. package/es/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.mjs +0 -2
  87. package/es/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.mjs.map +0 -1
  88. package/es/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.mjs +0 -2
  89. package/es/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.mjs.map +0 -1
  90. package/es/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.mjs +0 -2
  91. package/es/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.mjs.map +0 -1
  92. package/es/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.mjs +0 -2
  93. package/es/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.mjs.map +0 -1
  94. package/es/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.mjs +0 -2
  95. package/es/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.mjs.map +0 -1
  96. package/es/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.mjs +0 -2
  97. package/es/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.mjs.map +0 -1
  98. package/es/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.mjs +0 -2
  99. package/es/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.mjs.map +0 -1
  100. package/es/subject/rich-text.mjs +0 -27
  101. package/es/subject/rich-text.mjs.map +0 -1
  102. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.cjs +0 -7
  103. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.cjs.map +0 -1
  104. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs +0 -7
  105. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs.map +0 -1
  106. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs +0 -7
  107. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs.map +0 -1
  108. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.cjs +0 -7
  109. package/lib/node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/reactive-element.cjs.map +0 -1
  110. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs +0 -2
  111. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.19.0_@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs.map +0 -1
  112. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs +0 -2
  113. package/lib/node_modules/.pnpm/@tiptap_extension-placeholder@3.20.5_@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5_/node_modules/@tiptap/extension-placeholder/dist/index.cjs.map +0 -1
  114. package/lib/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs +0 -2
  115. package/lib/node_modules/.pnpm/@tiptap_extensions@3.19.0_@tiptap_core@3.19.0_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs.map +0 -1
  116. package/lib/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs +0 -2
  117. package/lib/node_modules/.pnpm/@tiptap_extensions@3.20.5_@tiptap_core@3.20.5_@tiptap_pm@3.20.5__@tiptap_pm@3.20.5/node_modules/@tiptap/extensions/dist/index.cjs.map +0 -1
  118. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.cjs +0 -7
  119. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive-helpers.cjs.map +0 -1
  120. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.cjs +0 -7
  121. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directive.cjs.map +0 -1
  122. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.cjs +0 -8
  123. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.cjs.map +0 -1
  124. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.cjs +0 -7
  125. package/lib/node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.cjs.map +0 -1
  126. package/lib/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.cjs +0 -2
  127. package/lib/node_modules/.pnpm/prosemirror-dropcursor@1.8.2/node_modules/prosemirror-dropcursor/dist/index.cjs.map +0 -1
  128. package/lib/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.cjs +0 -2
  129. package/lib/node_modules/.pnpm/prosemirror-gapcursor@1.4.1/node_modules/prosemirror-gapcursor/dist/index.cjs.map +0 -1
  130. package/lib/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.cjs +0 -2
  131. package/lib/node_modules/.pnpm/prosemirror-history@1.5.0/node_modules/prosemirror-history/dist/index.cjs.map +0 -1
  132. package/lib/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.cjs +0 -2
  133. package/lib/node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.cjs.map +0 -1
  134. package/lib/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.cjs +0 -2
  135. package/lib/node_modules/.pnpm/prosemirror-model@1.25.4/node_modules/prosemirror-model/dist/index.cjs.map +0 -1
  136. package/lib/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.cjs +0 -2
  137. package/lib/node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.cjs.map +0 -1
  138. package/lib/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.cjs +0 -2
  139. package/lib/node_modules/.pnpm/prosemirror-transform@1.11.0/node_modules/prosemirror-transform/dist/index.cjs.map +0 -1
  140. package/lib/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.cjs +0 -2
  141. package/lib/node_modules/.pnpm/prosemirror-view@1.41.7/node_modules/prosemirror-view/dist/index.cjs.map +0 -1
  142. package/lib/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.cjs +0 -2
  143. package/lib/node_modules/.pnpm/rope-sequence@1.3.4/node_modules/rope-sequence/dist/index.cjs.map +0 -1
  144. package/lib/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.cjs +0 -2
  145. package/lib/node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.cjs.map +0 -1
  146. package/lib/subject/rich-text.cjs +0 -27
  147. package/lib/subject/rich-text.cjs.map +0 -1
  148. package/types/base/define.d.ts +0 -1
  149. package/types/base/uid.d.ts +0 -1
  150. package/types/editor/blocksuite-editor.d.ts +0 -84
  151. package/types/editor/index.d.ts +0 -3
  152. package/types/index.d.ts +0 -4
  153. package/types/subject/action.d.ts +0 -23
  154. package/types/subject/blank-fill.d.ts +0 -49
  155. package/types/subject/index.d.ts +0 -20
  156. package/types/subject/layout.d.ts +0 -7
  157. package/types/subject/list.d.ts +0 -43
  158. package/types/subject/page-end.d.ts +0 -10
  159. package/types/subject/rich-text.d.ts +0 -30
  160. package/types/subject/scale.d.ts +0 -42
  161. package/types/subject/single.d.ts +0 -79
  162. package/types/subject/text-fill.d.ts +0 -54
  163. package/types/subject/type.d.ts +0 -7
@@ -1,8 +1,8 @@
1
- "use strict";var t=require("lit"),e=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),s=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),i=require("../base/define.cjs"),l=require("./single.cjs"),r=require("./types.cjs"),a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=(t,e,s,i)=>{for(var l,r=i>1?void 0:i?n(e,s):e,o=t.length-1;o>=0;o--)(l=t[o])&&(r=(i?l(e,s,r):l(r))||r);return i&&r&&a(e,s,r),r};const p=t.html`
1
+ "use strict";var t=require("lit"),e=require("lit/decorators.js"),s=require("../base/define.cjs"),i=require("./single.cjs"),l=require("./types.cjs"),r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=(t,e,s,i)=>{for(var l,n=i>1?void 0:i?a(e,s):e,o=t.length-1;o>=0;o--)(l=t[o])&&(n=(i?l(e,s,n):l(n))||n);return i&&n&&r(e,s,n),n};const o=t.html`
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>`;exports.QxsBlankFill=class extends t.LitElement{constructor(){super(...arguments),this.orderIndex=0,this.title="",this.customId="",this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAdd=!0,this.showAnswerSetting=!1,this.showAnalysis=!0,this.richTextContent="",this.analysis="",this.examAnswerRelationType=0,this.examExpand="",this.examAnswerSetting={isInOrder:!1,isIgnoreCase:!0},this.uploadImage=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this.answerList=[],this.modelValue="",this.useModel=!1,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}willUpdate(t){t.has("isEdit")&&this.isEdit&&this._syncProps(),!this.isEdit&&(t.has("title")||t.has("answerList")||t.has("analysis")||t.has("examAnswerSetting")||t.has("richTextContent"))&&this._syncProps(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue.replaceAll(/<filter><\/filter>/g," ______"))}_normalizeAnswerTitle(t){return String(t?.title??t?.answer??"")}_syncProps(){if(this._title=(this.title||"").replaceAll(/<filter><\/filter>/g," ______"),this._analysis=this.analysis||"",this.answerList?.length)this._answers=this.answerList.map(t=>({title:this._normalizeAnswerTitle(t),tag:"",showInput:!1}));else{const t=(this._title.match(/ ______/g)||[]).length||1;this._answers=Array.from({length:t},()=>({title:"",tag:"",showInput:!1}))}this.examAnswerSetting&&(this._isInOrder=!!this.examAnswerSetting.isInOrder,this._isIgnoreCase=!!this.examAnswerSetting.isIgnoreCase),this._richText=this.richTextContent||"",this._showRichText=!!this.richTextContent}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_addBlank(){this._title+=" ______",this._answers=[...this._answers,{title:"",tag:"",showInput:!1}],this.requestUpdate(),this._emitModelUpdate()}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value;const s=(this._title.match(/ ______/g)||[]).length;if(s!==this._answers.length)if(s>this._answers.length)for(let t=this._answers.length;t<s;t++)this._answers=[...this._answers,{title:"",tag:"",showInput:!1}];else this._answers=this._answers.slice(0,s);this._emitModelUpdate()}_emitModelUpdate(){if(this.useModel){const t=this._title.replaceAll(/ ______/g,"<filter></filter>");this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:t}))}}_handleAddTag(t){t.showInput=!1,t.tag&&(t.title=t.title?[t.title,t.tag].join(","):t.tag,t.tag=""),this.requestUpdate()}_closeTag(t,e){if(t){const s=e.title.split(","),i=s.findIndex(e=>e===t);i>-1&&(s.splice(i,1),e.title=s.join(",")),this.requestUpdate()}}async toJSON(){return new Promise((t,e)=>{const s={customId:this.customId||void 0,answerType:"blank_fill",orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title?.replaceAll(/<filter><\/filter>/g," ______")||"",a=this.isEdit?this._answers:(this.answerList||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)})),n=this.isEdit?this._analysis:this.analysis||"",o=this.isEdit?this._isInOrder:this.examAnswerSetting?.isInOrder??!1,p=this.isEdit?this._isIgnoreCase:this.examAnswerSetting?.isIgnoreCase??!0,h=this.isEdit?this._showRichText:!!this.richTextContent,d=this.isEdit?this._richText:this.richTextContent||"";if(!i)return void e(new l.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",s));if(a.length<1)return void e(new l.SubjectError("至少添加一个填空符!","NO_BLANK","answers",s));const c={answerType:r.SubjectType.BLANK_FILL,title:i.replaceAll(/ ______/g,"<filter></filter>"),answers:a.map(t=>({title:t.title,isCorrect:!0})),analysis:n,isSetCorrectAnswer:!0,isKey:this.isKey,examAnswerSettingBO:{isIgnoreCase:p,isInOrder:o},examRichTextContent:h?d:""};this.customId&&(c.customId=this.customId),t(c)})}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!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)}(t.message)}}validate(){const t=[],e={customId:this.customId||void 0,answerType:"blank_fill",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title?.replaceAll(/<filter><\/filter>/g," ______")||"",i=this.isEdit?this._answers:(this.answerList||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)}));return s||t.push(new l.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",e)),i.length<1&&t.push(new l.SubjectError("至少添加一个填空符!","NO_BLANK","answers",e)),t}_renderPreview(){const e=this.title.replaceAll(/<filter><\/filter>/g," ______"),s=this.isEdit?this._answers:(this.answerList||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)}));return t.html`
5
+ </svg>`;exports.QxsBlankFill=class extends t.LitElement{constructor(){super(...arguments),this.orderIndex=0,this.title="",this.customId="",this.isEdit=!1,this.isSave=!1,this.isSet=!1,this.isKey=!1,this.showAction=!0,this.showAdd=!0,this.showAnswerSetting=!1,this.showAnalysis=!0,this.richTextContent="",this.analysis="",this.examAnswerRelationType=0,this.examExpand="",this.examAnswerSetting={isInOrder:!1,isIgnoreCase:!0},this.uploadImage=async t=>new Promise((e,s)=>{const i=new FileReader;i.onload=t=>e(t.target?.result),i.onerror=s,i.readAsDataURL(t)}),this.answerList=[],this.modelValue="",this.useModel=!1,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}willUpdate(t){t.has("isEdit")&&this.isEdit&&this._syncProps(),!this.isEdit&&(t.has("title")||t.has("answerList")||t.has("analysis")||t.has("examAnswerSetting")||t.has("richTextContent"))&&this._syncProps(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue.replaceAll(/<filter><\/filter>/g," ______"))}_normalizeAnswerTitle(t){return String(t?.title??t?.answer??"")}_syncProps(){if(this._title=(this.title||"").replaceAll(/<filter><\/filter>/g," ______"),this._analysis=this.analysis||"",this.answerList?.length)this._answers=this.answerList.map(t=>({title:this._normalizeAnswerTitle(t),tag:"",showInput:!1}));else{const t=(this._title.match(/ ______/g)||[]).length||1;this._answers=Array.from({length:t},()=>({title:"",tag:"",showInput:!1}))}this.examAnswerSetting&&(this._isInOrder=!!this.examAnswerSetting.isInOrder,this._isIgnoreCase=!!this.examAnswerSetting.isIgnoreCase),this._richText=this.richTextContent||"",this._showRichText=!!this.richTextContent}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_addBlank(){this._title+=" ______",this._answers=[...this._answers,{title:"",tag:"",showInput:!1}],this.requestUpdate(),this._emitModelUpdate()}_onTitleInput(t){const e=t.target;e.value.length>this.TITLE_MAX&&(e.value=e.value.slice(0,this.TITLE_MAX)),this._title=e.value;const s=(this._title.match(/ ______/g)||[]).length;if(s!==this._answers.length)if(s>this._answers.length)for(let t=this._answers.length;t<s;t++)this._answers=[...this._answers,{title:"",tag:"",showInput:!1}];else this._answers=this._answers.slice(0,s);this._emitModelUpdate()}_emitModelUpdate(){if(this.useModel){const t=this._title.replaceAll(/ ______/g,"<filter></filter>");this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:t}))}}_handleAddTag(t){t.showInput=!1,t.tag&&(t.title=t.title?[t.title,t.tag].join(","):t.tag,t.tag=""),this.requestUpdate()}_closeTag(t,e){if(t){const s=e.title.split(","),i=s.findIndex(e=>e===t);i>-1&&(s.splice(i,1),e.title=s.join(",")),this.requestUpdate()}}async toJSON(){return new Promise((t,e)=>{const s={customId:this.customId||void 0,answerType:"blank_fill",orderIndex:this.orderIndex},r=this.isEdit?this._title:this.title?.replaceAll(/<filter><\/filter>/g," ______")||"",a=this.isEdit?this._answers:(this.answerList||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)})),n=this.isEdit?this._analysis:this.analysis||"",o=this.isEdit?this._isInOrder:this.examAnswerSetting?.isInOrder??!1,p=this.isEdit?this._isIgnoreCase:this.examAnswerSetting?.isIgnoreCase??!0,h=this.isEdit?this._showRichText:!!this.richTextContent,d=this.isEdit?this._richText:this.richTextContent||"";if(!r)return void e(new i.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",s));if(a.length<1)return void e(new i.SubjectError("至少添加一个填空符!","NO_BLANK","answers",s));const c={answerType:l.SubjectType.BLANK_FILL,title:r.replaceAll(/ ______/g,"<filter></filter>"),answers:a.map(t=>({title:t.title,isCorrect:!0})),analysis:n,isSetCorrectAnswer:!0,isKey:this.isKey,examAnswerSettingBO:{isIgnoreCase:p,isInOrder:o},examRichTextContent:h?d:""};this.customId&&(c.customId=this.customId),t(c)})}async _save(t){t?.stopImmediatePropagation();try{const t=await this.toJSON();this._emit("save",t)}catch(t){!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)}(t.message)}}validate(){const t=[],e={customId:this.customId||void 0,answerType:"blank_fill",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title?.replaceAll(/<filter><\/filter>/g," ______")||"",l=this.isEdit?this._answers:(this.answerList||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)}));return s||t.push(new i.SubjectError("题目标题不能为空!","EMPTY_TITLE","title",e)),l.length<1&&t.push(new i.SubjectError("至少添加一个填空符!","NO_BLANK","answers",e)),t}_renderPreview(){const e=this.title.replaceAll(/<filter><\/filter>/g," ______"),s=this.isEdit?this._answers:(this.answerList||[]).map(t=>({...t,title:this._normalizeAnswerTitle(t)}));return t.html`
6
6
  <div class="preview">
7
7
  <span class="title">${this.orderIndex+1}.${e}(填空题)</span>
8
8
  ${this.richTextContent?t.html`<div class="rich-text" .innerHTML=${this.richTextContent}></div>`:""}
@@ -69,7 +69,7 @@
69
69
  @blur=${()=>this._handleAddTag(e)} />
70
70
  `:t.html`
71
71
  <span class="el-button--small" @click=${()=>{e.showInput=!0,this.requestUpdate(),this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".el-input--small")?.focus()})}}>
72
- ${p}
72
+ ${o}
73
73
  <span>${e.title?"添加同义词":"添加答案"}</span>
74
74
  </span>
75
75
  `}
@@ -109,15 +109,15 @@
109
109
  </div>
110
110
  `:""}
111
111
  `}render(){return t.html`
112
- <qxs-subject-layout ?show-edit=${this.isEdit}>
112
+ <qxs-subject-layout .showEdit=${this.isEdit}>
113
113
  <div slot="preview">${this._renderPreview()}</div>
114
114
  <div slot="edit">${this._renderEdit()}</div>
115
115
  ${this.showAction?t.html`
116
116
  <qxs-subject-action
117
- ?is-edit=${this.isEdit}
118
- ?is-set=${this.isSet}
119
- ?show-add=${this.showAdd}
120
- ?show-rich-text=${this._showRichText}
117
+ .isEdit=${this.isEdit}
118
+ .isSet=${this.isSet}
119
+ .showAdd=${this.showAdd}
120
+ .showRichText=${this._showRichText}
121
121
  exam-answer-relation-type=${this.examAnswerRelationType}
122
122
  @delete=${()=>this._emit("delete")}
123
123
  @save=${this._save}
@@ -206,5 +206,5 @@
206
206
  .answer-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
207
207
  .answer-item .label { min-width: 70px; padding-top: 0; color: #909399; }
208
208
  .answer-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1; }
209
- `,o([e.property({type:Number,attribute:"order-index"})],exports.QxsBlankFill.prototype,"orderIndex",2),o([e.property({type:String})],exports.QxsBlankFill.prototype,"title",2),o([e.property({type:String,attribute:"custom-id"})],exports.QxsBlankFill.prototype,"customId",2),o([e.property({type:Boolean,attribute:"is-edit"})],exports.QxsBlankFill.prototype,"isEdit",2),o([e.property({type:Boolean,attribute:"is-save"})],exports.QxsBlankFill.prototype,"isSave",2),o([e.property({type:Boolean,attribute:"is-set"})],exports.QxsBlankFill.prototype,"isSet",2),o([e.property({type:Boolean,attribute:"is-key"})],exports.QxsBlankFill.prototype,"isKey",2),o([e.property({type:Boolean,attribute:"show-action"})],exports.QxsBlankFill.prototype,"showAction",2),o([e.property({type:Boolean,attribute:"show-add"})],exports.QxsBlankFill.prototype,"showAdd",2),o([e.property({type:Boolean,attribute:"show-answer-setting"})],exports.QxsBlankFill.prototype,"showAnswerSetting",2),o([e.property({type:Boolean,attribute:"show-analysis"})],exports.QxsBlankFill.prototype,"showAnalysis",2),o([e.property({type:String,attribute:"rich-text-content"})],exports.QxsBlankFill.prototype,"richTextContent",2),o([e.property({type:String})],exports.QxsBlankFill.prototype,"analysis",2),o([e.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsBlankFill.prototype,"examAnswerRelationType",2),o([e.property({type:String,attribute:"exam-expand"})],exports.QxsBlankFill.prototype,"examExpand",2),o([e.property({type:Object,attribute:"exam-answer-setting"})],exports.QxsBlankFill.prototype,"examAnswerSetting",2),o([e.property({type:Object})],exports.QxsBlankFill.prototype,"uploadImage",2),o([e.property({type:Array,attribute:"answer-list"})],exports.QxsBlankFill.prototype,"answerList",2),o([e.property({type:String,attribute:"model-value"})],exports.QxsBlankFill.prototype,"modelValue",2),o([e.property({type:Boolean,attribute:"use-model"})],exports.QxsBlankFill.prototype,"useModel",2),o([s.state()],exports.QxsBlankFill.prototype,"_title",2),o([s.state()],exports.QxsBlankFill.prototype,"_analysis",2),o([s.state()],exports.QxsBlankFill.prototype,"_answers",2),o([s.state()],exports.QxsBlankFill.prototype,"_isInOrder",2),o([s.state()],exports.QxsBlankFill.prototype,"_isIgnoreCase",2),o([s.state()],exports.QxsBlankFill.prototype,"_showRichText",2),o([s.state()],exports.QxsBlankFill.prototype,"_richText",2),exports.QxsBlankFill=o([i.safeCustomElement("qxs-blank-fill")],exports.QxsBlankFill);
209
+ `,n([e.property({type:Number,attribute:"order-index"})],exports.QxsBlankFill.prototype,"orderIndex",2),n([e.property({type:String})],exports.QxsBlankFill.prototype,"title",2),n([e.property({type:String,attribute:"custom-id"})],exports.QxsBlankFill.prototype,"customId",2),n([e.property({type:Boolean,attribute:"is-edit"})],exports.QxsBlankFill.prototype,"isEdit",2),n([e.property({type:Boolean,attribute:"is-save"})],exports.QxsBlankFill.prototype,"isSave",2),n([e.property({type:Boolean,attribute:"is-set"})],exports.QxsBlankFill.prototype,"isSet",2),n([e.property({type:Boolean,attribute:"is-key"})],exports.QxsBlankFill.prototype,"isKey",2),n([e.property({type:Boolean,attribute:"show-action"})],exports.QxsBlankFill.prototype,"showAction",2),n([e.property({type:Boolean,attribute:"show-add"})],exports.QxsBlankFill.prototype,"showAdd",2),n([e.property({type:Boolean,attribute:"show-answer-setting"})],exports.QxsBlankFill.prototype,"showAnswerSetting",2),n([e.property({type:Boolean,attribute:"show-analysis"})],exports.QxsBlankFill.prototype,"showAnalysis",2),n([e.property({type:String,attribute:"rich-text-content"})],exports.QxsBlankFill.prototype,"richTextContent",2),n([e.property({type:String})],exports.QxsBlankFill.prototype,"analysis",2),n([e.property({type:Number,attribute:"exam-answer-relation-type"})],exports.QxsBlankFill.prototype,"examAnswerRelationType",2),n([e.property({type:String,attribute:"exam-expand"})],exports.QxsBlankFill.prototype,"examExpand",2),n([e.property({type:Object,attribute:"exam-answer-setting"})],exports.QxsBlankFill.prototype,"examAnswerSetting",2),n([e.property({type:Object})],exports.QxsBlankFill.prototype,"uploadImage",2),n([e.property({type:Array,attribute:"answer-list"})],exports.QxsBlankFill.prototype,"answerList",2),n([e.property({type:String,attribute:"model-value"})],exports.QxsBlankFill.prototype,"modelValue",2),n([e.property({type:Boolean,attribute:"use-model"})],exports.QxsBlankFill.prototype,"useModel",2),n([e.state()],exports.QxsBlankFill.prototype,"_title",2),n([e.state()],exports.QxsBlankFill.prototype,"_analysis",2),n([e.state()],exports.QxsBlankFill.prototype,"_answers",2),n([e.state()],exports.QxsBlankFill.prototype,"_isInOrder",2),n([e.state()],exports.QxsBlankFill.prototype,"_isIgnoreCase",2),n([e.state()],exports.QxsBlankFill.prototype,"_showRichText",2),n([e.state()],exports.QxsBlankFill.prototype,"_richText",2),exports.QxsBlankFill=n([s.safeCustomElement("qxs-blank-fill")],exports.QxsBlankFill);
210
210
  //# sourceMappingURL=blank-fill.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"blank-fill.cjs","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'\nimport { SubjectError } from './single'\nimport { SubjectType } from './types'\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: String, attribute: 'custom-id' }) customId = ''\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-add' }) showAdd = true\n @property({ type: Boolean, attribute: 'show-answer-setting' }) showAnswerSetting = false\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = true\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 // 双向绑定支持\n @property({ type: String, attribute: 'model-value' }) modelValue = ''\n @property({ type: Boolean, attribute: 'use-model' }) useModel = false\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 willUpdate(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n if (!this.isEdit && (changed.has('title') || changed.has('answerList') || changed.has('analysis') || changed.has('examAnswerSetting') || changed.has('richTextContent'))) {\n this._syncProps()\n }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue.replaceAll(/<filter><\\/filter>/g, ' ______')\n }\n }\n\n private _normalizeAnswerTitle(answer: any) {\n return String(answer?.title ?? answer?.answer ?? '')\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: this._normalizeAnswerTitle(a), 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 this._richText = this.richTextContent || ''\n this._showRichText = !!this.richTextContent\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 this._emitModelUpdate()\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 this._emitModelUpdate()\n }\n\n // 双向绑定:通知外部更新\n private _emitModelUpdate() {\n if (this.useModel) {\n const modelValue = this._title.replaceAll(/ ______/g, '<filter></filter>')\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: modelValue,\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 async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'blank_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title?.replaceAll(/<filter><\\/filter>/g, ' ______') || ''\n const answers = this.isEdit ? this._answers : (this.answerList || []).map((answer: any) => ({ ...answer, title: this._normalizeAnswerTitle(answer) }))\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const isInOrder = this.isEdit ? this._isInOrder : this.examAnswerSetting?.isInOrder ?? false\n const isIgnoreCase = this.isEdit ? this._isIgnoreCase : this.examAnswerSetting?.isIgnoreCase ?? true\n const showRichText = this.isEdit ? this._showRichText : !!this.richTextContent\n const richText = this.isEdit ? this._richText : this.richTextContent || ''\n\n if (!title) {\n reject(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n return\n }\n if (answers.length < 1) {\n reject(new SubjectError('至少添加一个填空符!', 'NO_BLANK', 'answers', row))\n return\n }\n const result: any = {\n answerType: SubjectType.BLANK_FILL,\n title: title.replaceAll(/ ______/g, '<filter></filter>'),\n answers: answers.map((a: any) => ({ title: a.title, isCorrect: true })),\n analysis,\n isSetCorrectAnswer: true,\n isKey: this.isKey,\n examAnswerSettingBO: { isIgnoreCase, isInOrder },\n examRichTextContent: showRichText ? richText : '',\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private async _save(e?: Event) {\n e?.stopImmediatePropagation()\n try {\n const data = await this.toJSON()\n this._emit('save', data)\n }\n catch (err: any) {\n showToast(err.message)\n }\n }\n\n validate(): SubjectError[] {\n const errors: SubjectError[] = []\n const row = { customId: this.customId || undefined, answerType: 'blank_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title?.replaceAll(/<filter><\\/filter>/g, ' ______') || ''\n const answers = this.isEdit ? this._answers : (this.answerList || []).map((answer: any) => ({ ...answer, title: this._normalizeAnswerTitle(answer) }))\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n if (answers.length < 1) {\n errors.push(new SubjectError('至少添加一个填空符!', 'NO_BLANK', 'answers', row))\n }\n\n return errors\n }\n\n private _renderPreview() {\n const displayTitle = this.title.replaceAll(/<filter><\\/filter>/g, ' ______')\n const previewAnswers = this.isEdit ? this._answers : (this.answerList || []).map((answer: any) => ({ ...answer, title: this._normalizeAnswerTitle(answer) }))\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 ${previewAnswers.some(a => a.title)\n ? html`\n <div class=\"content flex flex-wrap\">\n <span>正确答案:</span>\n ${previewAnswers.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 ${this.showAnswerSetting\n ? html`\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 : ''}\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 ${!this.showAction\n ? html`\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 `\n : ''}\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-add=${this.showAdd}\n ?show-rich-text=${this._showRichText}\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=${() => {\n this._showRichText = !this._showRichText\n if (!this._showRichText) {\n this._richText = ''\n }\n }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","QxsBlankFill","LitElement","constructor","super","arguments","this","orderIndex","title","customId","isEdit","isSave","isSet","isKey","showAction","showAdd","showAnswerSetting","showAnalysis","richTextContent","analysis","examAnswerRelationType","examExpand","examAnswerSetting","isInOrder","isIgnoreCase","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","answerList","modelValue","useModel","_title","_analysis","_answers","tag","showInput","_isInOrder","_isIgnoreCase","_showRichText","_richText","TITLE_MAX","willUpdate","changed","has","_syncProps","replaceAll","_normalizeAnswerTitle","answer","String","length","map","a","blankCount","match","Array","from","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_addBlank","requestUpdate","_emitModelUpdate","_onTitleInput","el","value","slice","i","_handleAddTag","item","join","_closeTag","tags","split","idx","findIndex","t","splice","toJSON","row","answerType","answers","showRichText","richText","SubjectError","SubjectType","BLANK_FILL","isCorrect","isSetCorrectAnswer","examAnswerSettingBO","examRichTextContent","_save","stopImmediatePropagation","data","err","msg","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","push","_renderPreview","displayTitle","previewAnswers","some","_renderEdit","checked","filter","Boolean","key","updateComplete","then","shadowRoot","querySelector","focus","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","state","safeCustomElement"],"mappings":"kiBAQA,MAAMA,EAAWC,EAAAA,IAAA;;;;UAoBJC,QAAAA,aAAN,cAA2BC,EAAAA,WAA3BC,WAAAA,GAAAC,SAAAC,WAiFiDC,KAAAC,WAAa,EACvCD,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A,aAiGX+J,UAAA,oBAAA,GAEAL,EAAA,CADCC,EAAAA,SAAS,CAAEC,KAAM5C,UAlGPhH,QAAAA,aAmGX+J,UAAA,cAAA,GASqDL,EAAA,CAApDC,EAAAA,SAAS,CAAEC,KAAM5F,MAAO8F,UAAW,iBA5GzB9J,QAAAA,aA4G0C+J,UAAA,aAAA,GAGCL,EAAA,CAArDC,EAAAA,SAAS,CAAEC,KAAMlG,OAAQoG,UAAW,iBA/G1B9J,QAAAA,aA+G2C+J,UAAA,aAAA,GACDL,EAAA,CAApDC,EAAAA,SAAS,CAAEC,KAAMZ,QAASc,UAAW,eAhH3B9J,QAAAA,aAgH0C+J,UAAA,WAAA,GAEpCL,EAAA,CAAhBM,EAAAA,SAlHUhK,QAAAA,aAkHM+J,UAAA,SAAA,GACAL,EAAA,CAAhBM,EAAAA,SAnHUhK,QAAAA,aAmHM+J,UAAA,YAAA,GACAL,EAAA,CAAhBM,EAAAA,SApHUhK,QAAAA,aAoHM+J,UAAA,WAAA,GACAL,EAAA,CAAhBM,EAAAA,SArHUhK,QAAAA,aAqHM+J,UAAA,aAAA,GACAL,EAAA,CAAhBM,EAAAA,SAtHUhK,QAAAA,aAsHM+J,UAAA,gBAAA,GACAL,EAAA,CAAhBM,EAAAA,SAvHUhK,QAAAA,aAuHM+J,UAAA,gBAAA,GACAL,EAAA,CAAhBM,EAAAA,SAxHUhK,QAAAA,aAwHM+J,UAAA,YAAA,GAxHN/J,QAAAA,aAAN0J,EAAA,CADNO,EAAAA,kBAAkB,mBACNjK,QAAAA"}
1
+ {"version":3,"file":"blank-fill.cjs","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'\nimport { SubjectError } from './single'\nimport { SubjectType } from './types'\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: String, attribute: 'custom-id' }) customId = ''\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-add' }) showAdd = true\n @property({ type: Boolean, attribute: 'show-answer-setting' }) showAnswerSetting = false\n @property({ type: Boolean, attribute: 'show-analysis' }) showAnalysis = true\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 // 双向绑定支持\n @property({ type: String, attribute: 'model-value' }) modelValue = ''\n @property({ type: Boolean, attribute: 'use-model' }) useModel = false\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 willUpdate(changed: Map<string, unknown>) {\n if (changed.has('isEdit') && this.isEdit) { this._syncProps() }\n if (!this.isEdit && (changed.has('title') || changed.has('answerList') || changed.has('analysis') || changed.has('examAnswerSetting') || changed.has('richTextContent'))) {\n this._syncProps()\n }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue.replaceAll(/<filter><\\/filter>/g, ' ______')\n }\n }\n\n private _normalizeAnswerTitle(answer: any) {\n return String(answer?.title ?? answer?.answer ?? '')\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: this._normalizeAnswerTitle(a), 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 this._richText = this.richTextContent || ''\n this._showRichText = !!this.richTextContent\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 this._emitModelUpdate()\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 this._emitModelUpdate()\n }\n\n // 双向绑定:通知外部更新\n private _emitModelUpdate() {\n if (this.useModel) {\n const modelValue = this._title.replaceAll(/ ______/g, '<filter></filter>')\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: modelValue,\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 async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'blank_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title?.replaceAll(/<filter><\\/filter>/g, ' ______') || ''\n const answers = this.isEdit ? this._answers : (this.answerList || []).map((answer: any) => ({ ...answer, title: this._normalizeAnswerTitle(answer) }))\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const isInOrder = this.isEdit ? this._isInOrder : this.examAnswerSetting?.isInOrder ?? false\n const isIgnoreCase = this.isEdit ? this._isIgnoreCase : this.examAnswerSetting?.isIgnoreCase ?? true\n const showRichText = this.isEdit ? this._showRichText : !!this.richTextContent\n const richText = this.isEdit ? this._richText : this.richTextContent || ''\n\n if (!title) {\n reject(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n return\n }\n if (answers.length < 1) {\n reject(new SubjectError('至少添加一个填空符!', 'NO_BLANK', 'answers', row))\n return\n }\n const result: any = {\n answerType: SubjectType.BLANK_FILL,\n title: title.replaceAll(/ ______/g, '<filter></filter>'),\n answers: answers.map((a: any) => ({ title: a.title, isCorrect: true })),\n analysis,\n isSetCorrectAnswer: true,\n isKey: this.isKey,\n examAnswerSettingBO: { isIgnoreCase, isInOrder },\n examRichTextContent: showRichText ? richText : '',\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private async _save(e?: Event) {\n e?.stopImmediatePropagation()\n try {\n const data = await this.toJSON()\n this._emit('save', data)\n }\n catch (err: any) {\n showToast(err.message)\n }\n }\n\n validate(): SubjectError[] {\n const errors: SubjectError[] = []\n const row = { customId: this.customId || undefined, answerType: 'blank_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title?.replaceAll(/<filter><\\/filter>/g, ' ______') || ''\n const answers = this.isEdit ? this._answers : (this.answerList || []).map((answer: any) => ({ ...answer, title: this._normalizeAnswerTitle(answer) }))\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n if (answers.length < 1) {\n errors.push(new SubjectError('至少添加一个填空符!', 'NO_BLANK', 'answers', row))\n }\n\n return errors\n }\n\n private _renderPreview() {\n const displayTitle = this.title.replaceAll(/<filter><\\/filter>/g, ' ______')\n const previewAnswers = this.isEdit ? this._answers : (this.answerList || []).map((answer: any) => ({ ...answer, title: this._normalizeAnswerTitle(answer) }))\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 ${previewAnswers.some(a => a.title)\n ? html`\n <div class=\"content flex flex-wrap\">\n <span>正确答案:</span>\n ${previewAnswers.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 ${this.showAnswerSetting\n ? html`\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 : ''}\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 ${!this.showAction\n ? html`\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 `\n : ''}\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 .showEdit=${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 .isEdit=${this.isEdit}\n .isSet=${this.isSet}\n .showAdd=${this.showAdd}\n .showRichText=${this._showRichText}\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=${() => {\n this._showRichText = !this._showRichText\n if (!this._showRichText) {\n this._richText = ''\n }\n }}\n ></qxs-subject-action>\n `\n : ''}\n </qxs-subject-layout>\n `\n }\n}\n\nexport function register() {}\n"],"names":["iconPlus","html","QxsBlankFill","LitElement","constructor","super","arguments","this","orderIndex","title","customId","isEdit","isSave","isSet","isKey","showAction","showAdd","showAnswerSetting","showAnalysis","richTextContent","analysis","examAnswerRelationType","examExpand","examAnswerSetting","isInOrder","isIgnoreCase","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","answerList","modelValue","useModel","_title","_analysis","_answers","tag","showInput","_isInOrder","_isIgnoreCase","_showRichText","_richText","TITLE_MAX","willUpdate","changed","has","_syncProps","replaceAll","_normalizeAnswerTitle","answer","String","length","map","a","blankCount","match","Array","from","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_addBlank","requestUpdate","_emitModelUpdate","_onTitleInput","el","value","slice","i","_handleAddTag","item","join","_closeTag","tags","split","idx","findIndex","t","splice","toJSON","row","answerType","answers","showRichText","richText","SubjectError","SubjectType","BLANK_FILL","isCorrect","isSetCorrectAnswer","examAnswerSettingBO","examRichTextContent","_save","stopImmediatePropagation","data","err","msg","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","color","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","push","_renderPreview","displayTitle","previewAnswers","some","_renderEdit","checked","filter","Boolean","key","updateComplete","then","shadowRoot","querySelector","focus","render","styles","css","__decorateClass","property","type","Number","attribute","prototype","state","safeCustomElement"],"mappings":"gVAQA,MAAMA,EAAWC,EAAAA,IAAA;;;;UAoBJC,QAAAA,aAAN,cAA2BC,EAAAA,WAA3BC,WAAAA,GAAAC,SAAAC,WAiFiDC,KAAAC,WAAa,EACvCD,KAAAE,MAAQ,GACgBF,KAAAG,SAAW,GACZH,KAAAI,QAAS,EACTJ,KAAAK,QAAS,EACVL,KAAAM,OAAQ,EACRN,KAAAO,OAAQ,EACHP,KAAAQ,YAAa,EAChBR,KAAAS,SAAU,EACCT,KAAAU,mBAAoB,EAC1BV,KAAAW,cAAe,EACZX,KAAAY,gBAAkB,GAClDZ,KAAAa,SAAW,GAC6Bb,KAAAc,uBAAyB,EACvCd,KAAAe,WAAa,GAEnEf,KAAAgB,kBAAmE,CAAEC,WAAW,EAAOC,cAAc,GAErGlB,KAAAmB,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AAEC,KAAMZ,QAASc,UAAW,eAhH3B9J,QAAAA,aAgH0C+J,UAAA,WAAA,GAEpCL,EAAA,CAAhBM,EAAAA,SAlHUhK,QAAAA,aAkHM+J,UAAA,SAAA,GACAL,EAAA,CAAhBM,EAAAA,SAnHUhK,QAAAA,aAmHM+J,UAAA,YAAA,GACAL,EAAA,CAAhBM,EAAAA,SApHUhK,QAAAA,aAoHM+J,UAAA,WAAA,GACAL,EAAA,CAAhBM,EAAAA,SArHUhK,QAAAA,aAqHM+J,UAAA,aAAA,GACAL,EAAA,CAAhBM,EAAAA,SAtHUhK,QAAAA,aAsHM+J,UAAA,gBAAA,GACAL,EAAA,CAAhBM,EAAAA,SAvHUhK,QAAAA,aAuHM+J,UAAA,gBAAA,GACAL,EAAA,CAAhBM,EAAAA,SAxHUhK,QAAAA,aAwHM+J,UAAA,YAAA,GAxHN/J,QAAAA,aAAN0J,EAAA,CADNO,EAAAA,kBAAkB,mBACNjK,QAAAA"}
@@ -1,21 +1,21 @@
1
- "use strict";var e=require("lit"),t=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),s=require("../base/define.cjs"),o=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=(e,t,s,i)=>{for(var a,l=i>1?void 0:i?r(t,s):t,p=e.length-1;p>=0;p--)(a=e[p])&&(l=(i?a(t,s,l):a(l))||l);return i&&l&&o(t,s,l),l};exports.QxsSubjectLayout=class extends e.LitElement{constructor(){super(...arguments),this.showEdit=!1}render(){return this.showEdit?e.html`
1
+ "use strict";var t=require("lit"),e=require("lit/decorators.js"),s=require("../base/define.cjs"),o=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=(t,e,s,i)=>{for(var a,l=i>1?void 0:i?r(e,s):e,p=t.length-1;p>=0;p--)(a=t[p])&&(l=(i?a(e,s,l):a(l))||l);return i&&l&&o(e,s,l),l};exports.QxsSubjectLayout=class extends t.LitElement{constructor(){super(...arguments),this.showEdit=!1}render(){return this.showEdit?t.html`
2
2
  <div class="layout">
3
3
  <div class="edit">
4
4
  <slot name="edit"></slot>
5
5
  <slot></slot>
6
6
  </div>
7
7
  </div>
8
- `:e.html`
8
+ `:t.html`
9
9
  <div class="layout">
10
10
  <div class="preview">
11
11
  <slot name="preview"></slot>
12
12
  <slot></slot>
13
13
  </div>
14
14
  </div>
15
- `}},exports.QxsSubjectLayout.styles=e.css`
15
+ `}},exports.QxsSubjectLayout.styles=t.css`
16
16
  :host { display: block; width: 100%; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
17
17
  .layout { }
18
18
  .preview { padding: 12px 10px 10px; }
19
19
  .edit { position: relative; padding: 12px 10px 10px; background-color: #fff; border-radius: 6px; }
20
- `,i([t.property({type:Boolean,attribute:"show-edit"})],exports.QxsSubjectLayout.prototype,"showEdit",2),exports.QxsSubjectLayout=i([s.safeCustomElement("qxs-subject-layout")],exports.QxsSubjectLayout);
20
+ `,i([e.property({type:Boolean,attribute:"show-edit"})],exports.QxsSubjectLayout.prototype,"showEdit",2),exports.QxsSubjectLayout=i([s.safeCustomElement("qxs-subject-layout")],exports.QxsSubjectLayout);
21
21
  //# sourceMappingURL=layout.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout.cjs","sources":["../../../../packages/components-wc/src/subject/layout.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\n@safeCustomElement('qxs-subject-layout')\nexport class QxsSubjectLayout extends LitElement {\n static styles = css`\n :host { display: block; width: 100%; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n .layout { }\n .preview { padding: 12px 10px 10px; }\n .edit { position: relative; padding: 12px 10px 10px; background-color: #fff; border-radius: 6px; }\n `\n\n @property({ type: Boolean, attribute: 'show-edit' }) showEdit = false\n\n render() {\n if (this.showEdit) {\n return html`\n <div class=\"layout\">\n <div class=\"edit\">\n <slot name=\"edit\"></slot>\n <slot></slot>\n </div>\n </div>\n `\n }\n return html`\n <div class=\"layout\">\n <div class=\"preview\">\n <slot name=\"preview\"></slot>\n <slot></slot>\n </div>\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["QxsSubjectLayout","LitElement","constructor","super","arguments","this","showEdit","render","html","styles","css","__decorateClass","property","type","Boolean","attribute","prototype","safeCustomElement"],"mappings":"wXAKaA,QAAAA,iBAAN,cAA+BC,EAAAA,WAA/BC,WAAAA,GAAAC,SAAAC,WAQgDC,KAAAC,UAAW,CAAA,CAEhEC,MAAAA,GACE,OAAIF,KAAKC,SACAE,EAAAA,IAAA;;;;;;;QASFA,EAAAA,IAAA;;;;;;;KAQT,GA7BWR,QAAAA,iBACJS,OAASC,EAAAA,GAAA;;;;;IAOqCC,EAAA,CAApDC,EAAAA,SAAS,CAAEC,KAAMC,QAASC,UAAW,eAR3Bf,QAAAA,iBAQ0CgB,UAAA,WAAA,GAR1ChB,QAAAA,iBAANW,EAAA,CADNM,EAAAA,kBAAkB,uBACNjB,QAAAA"}
1
+ {"version":3,"file":"layout.cjs","sources":["../../../../packages/components-wc/src/subject/layout.ts"],"sourcesContent":["import { css, html, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { safeCustomElement } from '../base/define'\n\n@safeCustomElement('qxs-subject-layout')\nexport class QxsSubjectLayout extends LitElement {\n static styles = css`\n :host { display: block; width: 100%; font-family: system-ui, -apple-system, \"PingFang SC\", \"Microsoft YaHei\", sans-serif; font-size: 12px; color: #5a5a5a; }\n .layout { }\n .preview { padding: 12px 10px 10px; }\n .edit { position: relative; padding: 12px 10px 10px; background-color: #fff; border-radius: 6px; }\n `\n\n @property({ type: Boolean, attribute: 'show-edit' }) showEdit = false\n\n render() {\n if (this.showEdit) {\n return html`\n <div class=\"layout\">\n <div class=\"edit\">\n <slot name=\"edit\"></slot>\n <slot></slot>\n </div>\n </div>\n `\n }\n return html`\n <div class=\"layout\">\n <div class=\"preview\">\n <slot name=\"preview\"></slot>\n <slot></slot>\n </div>\n </div>\n `\n }\n}\n\nexport function register() {}\n"],"names":["QxsSubjectLayout","LitElement","constructor","super","arguments","this","showEdit","render","html","styles","css","__decorateClass","property","type","Boolean","attribute","prototype","safeCustomElement"],"mappings":"6RAKaA,QAAAA,iBAAN,cAA+BC,EAAAA,WAA/BC,WAAAA,GAAAC,SAAAC,WAQgDC,KAAAC,UAAW,CAAA,CAEhEC,MAAAA,GACE,OAAIF,KAAKC,SACAE,EAAAA,IAAA;;;;;;;QASFA,EAAAA,IAAA;;;;;;;KAQT,GA7BWR,QAAAA,iBACJS,OAASC,EAAAA,GAAA;;;;;IAOqCC,EAAA,CAApDC,EAAAA,SAAS,CAAEC,KAAMC,QAASC,UAAW,eAR3Bf,QAAAA,iBAQ0CgB,UAAA,WAAA,GAR1ChB,QAAAA,iBAANW,EAAA,CADNM,EAAAA,kBAAkB,uBACNjB,QAAAA"}
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("lit"),t=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),s=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),i=require("../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/repeat.cjs"),r=require("sortablejs"),a=require("../base/define.cjs"),o=require("../base/uid.cjs"),n=require("./single.cjs"),l=require("./types.cjs");require("./action.cjs"),require("./blank-fill.cjs"),require("./layout.cjs"),require("./text-fill.cjs"),require("./scale.cjs"),require("./page-end.cjs"),require("./type.cjs");var d=Object.defineProperty,h=Object.getOwnPropertyDescriptor,c=(e,t,s,i)=>{for(var r,a=i>1?void 0:i?h(t,s):t,o=e.length-1;o>=0;o--)(r=e[o])&&(a=(i?r(t,s,a):r(a))||a);return i&&a&&d(t,s,a),a};l.SubjectType.SINGLE,l.SubjectType.MULTIPLE,l.SubjectType.SORT,l.SubjectType.BLANK_FILL,l.SubjectType.TEXT_FILL,l.SubjectType.SCALE,exports.QxsSubjectList=class extends e.LitElement{constructor(){super(...arguments),this.isPreview=!1,this.useModelAttr=null,this._modelValueAttr="",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.categoryList=[],this.showTag=!1,this.showCategory=!1,this.showAi=!1,this.showResource=!1,this.showJump=!1,this.showAdd=!0,this.showAnswerSetting=!1,this.showKey=!1,this.searchApi="",this._list=[],this._sortMode=!1,this._sortable=null,this._initialDataProcessed=!1}get modelValue(){return JSON.stringify(this._list)}set modelValue(e){if(e&&e!==this._modelValueAttr){this._modelValueAttr=e;try{const t=JSON.parse(e);Array.isArray(t)&&(this._list=this._normalizeIncomingList(t),this.requestUpdate())}catch{}}}get _useModel(){return"true"===this.useModelAttr||""===this.useModelAttr||this.hasAttribute("use-model")}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=this._normalizeIncomingList(e),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=this._normalizeIncomingList(e),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=this._normalizeIncomingList(t),this.requestUpdate())}catch{}}_normalizeAnswer(e){return{...e,title:String(e?.title??e?.answer??""),answerId:e?.answerId??e?.examAnswerId}}_normalizeItem(e){const t=e?.answerType||(e?.richTextContent?e?.answerType:e?.examTypeEnum),s=Array.isArray(e?.answers)?e.answers.map(e=>this._normalizeAnswer(e)):[];return{...e,customId:e?.customId||o.uid(),...t?{answerType:t}:{},...s.length||Array.isArray(e?.answers)?{answers:s}:{}}}_rebuildPageEndMarkers(e){if(!e.length)return e;if(e.some(e=>"page_end"===e?.answerType))return e;if(!e.some(e=>Number(e?.pageIndex)>1))return e;let t=1;const s=[];return e.forEach(e=>{const i=Number(e?.pageIndex)||1;if(i>t)if(s.length>0)for(;t<i;)s.push({customId:o.uid(),answerType:"page_end"}),t++;else t=i;s.push(e)}),s}_normalizeIncomingList(e){const t=e.map(e=>this._normalizeItem(e));return this._rebuildPageEndMarkers(t)}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;this.renderRoot.querySelector(".sort-list")&&(this._sortable&&(this._sortable.destroy(),this._sortable=null),requestAnimationFrame(()=>{const e=this.renderRoot.querySelector(".sort-list");e&&!this._sortable&&(this._sortable=r.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],[r]=i.splice(t,1);i.splice(s,0,r),this._list=i,this._emitListChange()}}))}))}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_emitListChange(){this._emit("change",this._list),this._useModel&&(this._modelValueAttr=JSON.stringify(this._list),this._emit("list-change",this._list))}_withPageIndex(e){const t=[];let s=1,i=!1;return e.forEach(e=>{e&&("page_end"!==e.answerType?(i&&(s+=1,i=!1),t.push({...e,pageIndex:s})):t.length>0&&(i=!0))}),t}async toJSON(){const e=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end, qxs-subject-rich-text");if(!e||0===e.length)return[];const t=[],s=[];for(const i of e)if("function"==typeof i.toJSON)try{const e=await i.toJSON();t.push(e)}catch(e){e instanceof n.SubjectError?s.push(e):s.push(new n.SubjectError(e.message||"未知错误","UNKNOWN","unknown"))}if(s.length>0)throw s;return this._withPageIndex(t)}async validate(){const e=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end");if(!e||0===e.length)return{valid:!0,errors:[]};const t=[];for(const s of e)if("function"==typeof s.validate){const e=s.validate();e?.length&&t.push(...e)}return{valid:0===t.length,errors:t}}get currentList(){return this._list}addSubject(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if("page_end"===e){const e={customId:o.uid(),answerType:"page_end"},s=[...this._list];return"number"==typeof t&&t>=0?s.splice(t+1,0,e):s.push(e),this._list=s,this.requestUpdate(),void this._emitListChange()}const i={customId:o.uid(),answerType:e,title:"",answers:[],analysis:"",scaleQuestionList:[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1,isKey:!1,answerCheckType:1,examAnswerRelationType:s??0},r=[...this._list];"number"==typeof t&&t>=0?r.splice(t+1,0,i):r.push(i),this._list=r,this.requestUpdate(),this._emitListChange()}addExam(e){const t=this._normalizeIncomingList(e).map(e=>({...e,isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1}));this._list=[...this._list,...t],this._emitListChange()}uploadExcel(e){this._list=[...this._list,...this._normalizeIncomingList(e).map(e=>({...e,isRealCanDel:!0}))],this._emitListChange()}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._emitListChange()}setTagList(e,t){const s=this._list.find(e=>e.customId===t);if(s)return s.tagInfos=Array.isArray(e)?e:[],s.memberTagInfo=Array.isArray(e)?e:[],this._list=[...this._list],void this._emitListChange();this.requestUpdate()}_orderIndex(e){let t=0,s=0;return this._list.forEach(i=>{t++,i.customId===e&&(s=t)}),s-1}_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._emitListChange()}_save(e,t){this._list=this._list.map((s,i)=>i===e?{...s,...t.detail,isEdit:!1,isSave:!0}:s),this._emitListChange()}_deleteByCustomId(e){this._list=this._list.filter(t=>t.customId!==e),this._emitListChange()}_delete(e){const t=[...this._list];t.splice(e,1),this._list=t,this._emitListChange()}_setEdit(e,t){this._list=this._list.map((s,i)=>i===e?{...s,isEdit:t}:s)}_pageEndTotal(){return this._list.filter(e=>"page_end"===e.answerType).length+1}_pageEndIndex(e){return this._list.slice(0,e+1).filter(e=>"page_end"===e.answerType).length}_syncRelationAnswer(e,t){const s=this._list[e];if(!s||!Array.isArray(s.answers)||!t?.answer)return;const i=[...s.answers],r=t.answer;let a="number"==typeof t.answerIndex?t.answerIndex:-1;(a<0||a>=i.length)&&(a=i.findIndex((e,t)=>String(e.customAnswerId||"")===String(r.customAnswerId||"")||String(e.answerId||"")===String(r.answerId||"")||String(e.orderIndex||t+1)===String(r.orderIndex||""))),a<0||(i[a]={...i[a],customAnswerId:r.customAnswerId||i[a].customAnswerId||r.answerId},this._list[e]={...s,answers:i},this._list=[...this._list])}_renderItem(t,s){const i=this._orderIndex(t.customId),r=(t.isEdit,t.hasSet,t.isRealCanDel,this._isPreviewValue,t.examAnswerRelationType,e=>this._move(s,e.detail)),a=()=>this._deleteByCustomId(t.customId),o=e=>this._save(s,e),n=()=>this._setEdit(s,!0),d=e=>this.addSubject(e.detail?.type??e.detail,s);return[l.SubjectType.SINGLE,l.SubjectType.MULTIPLE,l.SubjectType.SORT].includes(t.answerType)?e.html`<qxs-subject-single
1
+ "use strict";var e=require("lit"),t=require("lit/decorators.js"),s=require("sortablejs"),i=require("../base/define.cjs"),r=require("../base/uid.cjs"),o=require("./single.cjs"),a=require("./types.cjs");require("./action.cjs"),require("./blank-fill.cjs"),require("./layout.cjs"),require("./text-fill.cjs"),require("./scale.cjs"),require("./page-end.cjs"),require("./type.cjs");var n=Object.defineProperty,l=Object.getOwnPropertyDescriptor,h=(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};a.SubjectType.SINGLE,a.SubjectType.MULTIPLE,a.SubjectType.SORT,a.SubjectType.BLANK_FILL,a.SubjectType.TEXT_FILL,a.SubjectType.SCALE,exports.QxsSubjectList=class extends e.LitElement{constructor(){super(...arguments),this.isPreview=!1,this.useModelAttr=null,this._modelValueAttr="",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.categoryList=[],this.showTag=!1,this.showCategory=!1,this.showAi=!1,this.showResource=!1,this.showJump=!1,this.showAdd=!0,this.showAnswerSetting=!1,this.showKey=!1,this.searchApi="",this._list=[],this._sortMode=!1,this._sortable=null,this._initialDataProcessed=!1}get modelValue(){return JSON.stringify(this._list)}set modelValue(e){if(e&&e!==this._modelValueAttr){this._modelValueAttr=e;try{const t=JSON.parse(e);Array.isArray(t)&&(this._list=this._normalizeIncomingList(t),this.requestUpdate())}catch{}}}get _useModel(){return"true"===this.useModelAttr||""===this.useModelAttr||this.hasAttribute("use-model")}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=this._normalizeIncomingList(e),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=this._normalizeIncomingList(e),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=this._normalizeIncomingList(t),this.requestUpdate())}catch{}}_normalizeAnswer(e){return{...e,title:String(e?.title??e?.answer??""),answerId:e?.answerId??e?.examAnswerId}}_normalizeItem(e){const t=e?.answerType||(e?.richTextContent?e?.answerType:e?.examTypeEnum),s=Array.isArray(e?.answers)?e.answers.map(e=>this._normalizeAnswer(e)):[];return{...e,customId:e?.customId||r.uid(),...t?{answerType:t}:{},...s.length||Array.isArray(e?.answers)?{answers:s}:{}}}_rebuildPageEndMarkers(e){if(!e.length)return e;if(e.some(e=>"page_end"===e?.answerType))return e;if(!e.some(e=>Number(e?.pageIndex)>1))return e;let t=1;const s=[];return e.forEach(e=>{const i=Number(e?.pageIndex)||1;if(i>t)if(s.length>0)for(;t<i;)s.push({customId:r.uid(),answerType:"page_end"}),t++;else t=i;s.push(e)}),s}_normalizeIncomingList(e){const t=e.map(e=>this._normalizeItem(e));return this._rebuildPageEndMarkers(t)}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;this.renderRoot.querySelector(".sort-list")&&(this._sortable&&(this._sortable.destroy(),this._sortable=null),requestAnimationFrame(()=>{const e=this.renderRoot.querySelector(".sort-list");e&&!this._sortable&&(this._sortable=s.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],[r]=i.splice(t,1);i.splice(s,0,r),this._list=i,this._emitListChange()}}))}))}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_emitListChange(){this._emit("change",this._list),this._useModel&&(this._modelValueAttr=JSON.stringify(this._list),this._emit("list-change",this._list))}_withPageIndex(e){const t=[];let s=1,i=!1;return e.forEach(e=>{e&&("page_end"!==e.answerType?(i&&(s+=1,i=!1),t.push({...e,pageIndex:s})):t.length>0&&(i=!0))}),t}async toJSON(){const e=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end, qxs-subject-rich-text");if(!e||0===e.length)return[];const t=[],s=[];for(const i of e)if("function"==typeof i.toJSON)try{const e=await i.toJSON();t.push(e)}catch(e){e instanceof o.SubjectError?s.push(e):s.push(new o.SubjectError(e.message||"未知错误","UNKNOWN","unknown"))}if(s.length>0)throw s;return this._withPageIndex(t)}async validate(){const e=this.renderRoot.querySelectorAll("qxs-subject-single, qxs-blank-fill, qxs-text-fill, qxs-scale, qxs-page-end");if(!e||0===e.length)return{valid:!0,errors:[]};const t=[];for(const s of e)if("function"==typeof s.validate){const e=s.validate();e?.length&&t.push(...e)}return{valid:0===t.length,errors:t}}get currentList(){return this._list}addSubject(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if("page_end"===e){const e={customId:r.uid(),answerType:"page_end"},s=[...this._list];return"number"==typeof t&&t>=0?s.splice(t+1,0,e):s.push(e),this._list=s,this.requestUpdate(),void this._emitListChange()}const i={customId:r.uid(),answerType:e,title:"",answers:[],analysis:"",scaleQuestionList:[],isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1,isKey:!1,answerCheckType:1,examAnswerRelationType:s??0},o=[...this._list];"number"==typeof t&&t>=0?o.splice(t+1,0,i):o.push(i),this._list=o,this.requestUpdate(),this._emitListChange()}addExam(e){const t=this._normalizeIncomingList(e).map(e=>({...e,isEdit:!0,isSave:!1,isRealCanDel:!0,hasSet:!1}));this._list=[...this._list,...t],this._emitListChange()}uploadExcel(e){this._list=[...this._list,...this._normalizeIncomingList(e).map(e=>({...e,isRealCanDel:!0}))],this._emitListChange()}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._emitListChange()}setTagList(e,t){const s=this._list.find(e=>e.customId===t);if(s)return s.tagInfos=Array.isArray(e)?e:[],s.memberTagInfo=Array.isArray(e)?e:[],this._list=[...this._list],void this._emitListChange();this.requestUpdate()}_orderIndex(e){let t=0,s=0;return this._list.forEach(i=>{t++,i.customId===e&&(s=t)}),s-1}_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._emitListChange()}_save(e,t){this._list=this._list.map((s,i)=>i===e?{...s,...t.detail,isEdit:!1,isSave:!0}:s),this._emitListChange()}_deleteByCustomId(e){this._list=this._list.filter(t=>t.customId!==e),this._emitListChange()}_delete(e){const t=[...this._list];t.splice(e,1),this._list=t,this._emitListChange()}_setEdit(e,t){this._list=this._list.map((s,i)=>i===e?{...s,isEdit:t}:s)}_pageEndTotal(){return this._list.filter(e=>"page_end"===e.answerType).length+1}_pageEndIndex(e){return this._list.slice(0,e+1).filter(e=>"page_end"===e.answerType).length}_syncRelationAnswer(e,t){const s=this._list[e];if(!s||!Array.isArray(s.answers)||!t?.answer)return;const i=[...s.answers],r=t.answer;let o="number"==typeof t.answerIndex?t.answerIndex:-1;(o<0||o>=i.length)&&(o=i.findIndex((e,t)=>String(e.customAnswerId||"")===String(r.customAnswerId||"")||String(e.answerId||"")===String(r.answerId||"")||String(e.orderIndex||t+1)===String(r.orderIndex||""))),o<0||(i[o]={...i[o],customAnswerId:r.customAnswerId||i[o].customAnswerId||r.answerId},this._list[e]={...s,answers:i},this._list=[...this._list])}_renderItem(t,s){const i=this._orderIndex(t.customId),r=(t.isEdit,t.hasSet,t.isRealCanDel,this._isPreviewValue,t.examAnswerRelationType,e=>this._move(s,e.detail)),o=()=>this._deleteByCustomId(t.customId),n=e=>this._save(s,e),l=()=>this._setEdit(s,!0),h=e=>this.addSubject(e.detail?.type??e.detail,s);return[a.SubjectType.SINGLE,a.SubjectType.MULTIPLE,a.SubjectType.SORT].includes(t.answerType)?e.html`<qxs-subject-single
2
2
  .title=${t.title||""}
3
3
  .answerList=${t.answers||[]}
4
4
  .tagList=${t.tagInfos||t.memberTagInfo||[]}
@@ -7,19 +7,19 @@
7
7
  .searchHandler=${this.searchHandler}
8
8
  .uploadImage=${this.uploadImage}
9
9
  order-index=${i}
10
- ?is-edit=${t.isEdit}
11
- ?is-set=${t.hasSet}
12
- ?is-save=${!t.isRealCanDel}
13
- ?show-action=${!this._isPreviewValue}
14
- ?show-add=${this.showAdd}
15
- ?show-answer-setting=${this.showAnswerSetting}
16
- ?show-key=${this.showKey}
17
- ?show-tag=${this.showTag}
18
- ?show-category=${this.showCategory}
19
- ?show-ai=${this.showAi}
20
- ?show-resource=${this.showResource}
21
- ?show-jump=${this.showJump}
22
- ?is-key=${t.isKey}
10
+ .isEdit=${!!t.isEdit}
11
+ .isSet=${!!t.hasSet}
12
+ .isSave=${!t.isRealCanDel}
13
+ .showAction=${!this._isPreviewValue}
14
+ .showAdd=${this.showAdd}
15
+ .showAnswerSetting=${this.showAnswerSetting}
16
+ .showKey=${this.showKey}
17
+ .showTag=${this.showTag}
18
+ .showCategory=${this.showCategory}
19
+ .showAi=${this.showAi}
20
+ .showResource=${this.showResource}
21
+ .showJump=${this.showJump}
22
+ .isKey=${!!t.isKey}
23
23
  question-type=${String(t.answerType)}
24
24
  answer-check-type=${t.answerCheckType??1}
25
25
  exam-answer-relation-type=${t.examAnswerRelationType??0}
@@ -32,7 +32,7 @@
32
32
  search-api=${this.searchApi}
33
33
  custom-id=${t.customId||""}
34
34
  exam-id=${t.examId??0}
35
- @move=${r} @delete=${a} @save=${o} @edit=${n} @add=${d}
35
+ @move=${r} @delete=${o} @save=${n} @edit=${l} @add=${h}
36
36
  @set-key=${e=>{this._list[s].isKey=e.detail.value,this.requestUpdate()}}
37
37
  @title-select=${e=>this._emit("title-select",e.detail)}
38
38
  @choose-tag=${e=>this._emit("choose-tag",{...e.detail,item:this._list[s]})}
@@ -40,57 +40,57 @@
40
40
  @category-change=${e=>{this._list[s].categoryId=e.detail.value,this.requestUpdate()}}
41
41
  @jump=${e=>this._emit("jump",{...e.detail,item:this._list[s]})}
42
42
  @set-relation=${e=>{this._syncRelationAnswer(s,e.detail),this._emit("set-relation",{...e.detail,item:this._list[s]})}}
43
- ></qxs-subject-single>`:t.answerType===l.SubjectType.BLANK_FILL?e.html`<qxs-blank-fill
43
+ ></qxs-subject-single>`:t.answerType===a.SubjectType.BLANK_FILL?e.html`<qxs-blank-fill
44
44
  .title=${t.title||""}
45
45
  .answerList=${t.answers||[]}
46
46
  .examAnswerSetting=${t.examAnswerSettingBO||t.examAnswerSettingVO||{}}
47
47
  .uploadImage=${this.uploadImage}
48
48
  order-index=${i}
49
- ?is-edit=${t.isEdit} ?is-set=${t.hasSet} ?is-save=${!t.isRealCanDel} ?show-action=${!this._isPreviewValue} ?show-add=${this.showAdd}
50
- ?show-answer-setting=${this.showAnswerSetting}
49
+ .isEdit=${!!t.isEdit} .isSet=${!!t.hasSet} .isSave=${!t.isRealCanDel} .showAction=${!this._isPreviewValue} .showAdd=${this.showAdd}
50
+ .showAnswerSetting=${this.showAnswerSetting}
51
51
  exam-answer-relation-type=${t.examAnswerRelationType??0}
52
52
  exam-expand=${t.examExpand||""}
53
53
  rich-text-content=${t.examRichTextContent||""}
54
54
  analysis=${t.analysis||""}
55
55
  custom-id=${t.customId||""}
56
- @move=${r} @delete=${a} @save=${o} @edit=${n} @add=${d}
57
- ></qxs-blank-fill>`:t.answerType===l.SubjectType.TEXT_FILL?e.html`<qxs-text-fill
56
+ @move=${r} @delete=${o} @save=${n} @edit=${l} @add=${h}
57
+ ></qxs-blank-fill>`:t.answerType===a.SubjectType.TEXT_FILL?e.html`<qxs-text-fill
58
58
  .title=${t.title||""}
59
59
  .answerList=${t.answers||[]}
60
60
  .examAnswerSetting=${t.examAnswerSettingBO||t.examAnswerSettingVO||{}}
61
61
  .uploadImage=${this.uploadImage}
62
62
  order-index=${i}
63
- ?is-edit=${t.isEdit} ?is-set=${t.hasSet} ?is-save=${!t.isRealCanDel} ?show-action=${!this._isPreviewValue} ?show-add=${this.showAdd}
64
- ?show-answer-setting=${this.showAnswerSetting}
63
+ .isEdit=${!!t.isEdit} .isSet=${!!t.hasSet} .isSave=${!t.isRealCanDel} .showAction=${!this._isPreviewValue} .showAdd=${this.showAdd}
64
+ .showAnswerSetting=${this.showAnswerSetting}
65
65
  exam-answer-relation-type=${t.examAnswerRelationType??0}
66
66
  exam-expand=${t.examExpand||""}
67
67
  rich-text-content=${t.examRichTextContent||""}
68
68
  analysis=${t.analysis||""}
69
69
  custom-id=${t.customId||""}
70
- @move=${r} @delete=${a} @save=${o} @edit=${n} @add=${d}
71
- ></qxs-text-fill>`:t.answerType===l.SubjectType.SCALE?e.html`<qxs-scale
70
+ @move=${r} @delete=${o} @save=${n} @edit=${l} @add=${h}
71
+ ></qxs-text-fill>`:t.answerType===a.SubjectType.SCALE?e.html`<qxs-scale
72
72
  .title=${t.title||""}
73
73
  .answerList=${t.answers||[]}
74
74
  .scaleQuestions=${t.scaleQuestionList||[]}
75
75
  .uploadImage=${this.uploadImage}
76
76
  order-index=${i}
77
- ?is-edit=${t.isEdit} ?is-set=${t.hasSet} ?is-save=${!t.isRealCanDel} ?show-action=${!this._isPreviewValue} ?show-add=${this.showAdd}
77
+ .isEdit=${!!t.isEdit} .isSet=${!!t.hasSet} .isSave=${!t.isRealCanDel} .showAction=${!this._isPreviewValue} .showAdd=${this.showAdd}
78
78
  exam-answer-relation-type=${t.examAnswerRelationType??0}
79
79
  rich-text-content=${t.examRichTextContent||""}
80
80
  analysis=${t.analysis||""}
81
81
  custom-id=${t.customId||""}
82
- @move=${r} @delete=${a} @save=${o} @edit=${n} @add=${d}
82
+ @move=${r} @delete=${o} @save=${n} @edit=${l} @add=${h}
83
83
  ></qxs-scale>`:"page_end"===t.answerType?e.html`<qxs-page-end
84
84
  current-page-index=${t.currentPageIndex||this._pageEndIndex(s)}
85
85
  total-page=${t.totalPage||this._pageEndTotal()}
86
- ?show-action=${!this._isPreviewValue}
87
- ?show-add=${this.showAdd}
86
+ .showAction=${!this._isPreviewValue}
87
+ .showAdd=${this.showAdd}
88
88
  custom-id=${t.customId||""}
89
- @delete=${a}
90
- @add=${d}
89
+ @delete=${o}
90
+ @add=${h}
91
91
  ></qxs-page-end>`:e.html`<div style="color:#909399;padding:8px">未知题型: ${t.answerType}</div>`}render(){return e.html`
92
92
  <div class="subject-list">
93
- ${i.repeat(this._list,e=>e.customId||`${e.answerType}-${e.examId||e.orderIndex||""}`,(e,t)=>this._renderItem(e,t))}
93
+ ${this._list.map((e,t)=>this._renderItem(e,t))}
94
94
  </div>
95
95
  `}},exports.QxsSubjectList.styles=e.css`
96
96
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 13px; }
@@ -114,5 +114,5 @@
114
114
  .sort-index { font-size: 13px; color: #606266; font-weight: 500; margin-right: 8px; min-width: 24px; flex-shrink: 0; }
115
115
  .sort-title { flex: 1; font-size: 14px; color: #303133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
116
116
  .sort-type { font-size: 12px; color: #909399; margin-left: 12px; padding: 2px 8px; background: #f0f0f0; border-radius: 4px; flex-shrink: 0; }
117
- `,c([t.property({attribute:"is-preview"})],exports.QxsSubjectList.prototype,"isPreview",2),c([t.property({attribute:"use-model"})],exports.QxsSubjectList.prototype,"useModelAttr",2),c([t.property({attribute:"model-value"})],exports.QxsSubjectList.prototype,"modelValue",1),c([t.property({type:Object})],exports.QxsSubjectList.prototype,"uploadImage",2),c([t.property({type:Array,attribute:"category-list"})],exports.QxsSubjectList.prototype,"categoryList",2),c([t.property({type:Boolean,attribute:"show-tag"})],exports.QxsSubjectList.prototype,"showTag",2),c([t.property({type:Boolean,attribute:"show-category"})],exports.QxsSubjectList.prototype,"showCategory",2),c([t.property({type:Boolean,attribute:"show-ai"})],exports.QxsSubjectList.prototype,"showAi",2),c([t.property({type:Boolean,attribute:"show-resource"})],exports.QxsSubjectList.prototype,"showResource",2),c([t.property({type:Boolean,attribute:"show-jump"})],exports.QxsSubjectList.prototype,"showJump",2),c([t.property({type:Boolean,attribute:"show-add"})],exports.QxsSubjectList.prototype,"showAdd",2),c([t.property({type:Boolean,attribute:"show-answer-setting"})],exports.QxsSubjectList.prototype,"showAnswerSetting",2),c([t.property({type:Boolean,attribute:"show-key"})],exports.QxsSubjectList.prototype,"showKey",2),c([t.property({type:String,attribute:"search-api"})],exports.QxsSubjectList.prototype,"searchApi",2),c([t.property({type:Object})],exports.QxsSubjectList.prototype,"searchHandler",2),c([t.property({type:Array})],exports.QxsSubjectList.prototype,"subjectList",1),c([s.state()],exports.QxsSubjectList.prototype,"_list",2),c([s.state()],exports.QxsSubjectList.prototype,"_sortMode",2),exports.QxsSubjectList=c([a.safeCustomElement("qxs-subject-list")],exports.QxsSubjectList);
117
+ `,h([t.property({attribute:"is-preview"})],exports.QxsSubjectList.prototype,"isPreview",2),h([t.property({attribute:"use-model"})],exports.QxsSubjectList.prototype,"useModelAttr",2),h([t.property({attribute:"model-value"})],exports.QxsSubjectList.prototype,"modelValue",1),h([t.property({type:Object})],exports.QxsSubjectList.prototype,"uploadImage",2),h([t.property({type:Array,attribute:"category-list"})],exports.QxsSubjectList.prototype,"categoryList",2),h([t.property({type:Boolean,attribute:"show-tag"})],exports.QxsSubjectList.prototype,"showTag",2),h([t.property({type:Boolean,attribute:"show-category"})],exports.QxsSubjectList.prototype,"showCategory",2),h([t.property({type:Boolean,attribute:"show-ai"})],exports.QxsSubjectList.prototype,"showAi",2),h([t.property({type:Boolean,attribute:"show-resource"})],exports.QxsSubjectList.prototype,"showResource",2),h([t.property({type:Boolean,attribute:"show-jump"})],exports.QxsSubjectList.prototype,"showJump",2),h([t.property({type:Boolean,attribute:"show-add"})],exports.QxsSubjectList.prototype,"showAdd",2),h([t.property({type:Boolean,attribute:"show-answer-setting"})],exports.QxsSubjectList.prototype,"showAnswerSetting",2),h([t.property({type:Boolean,attribute:"show-key"})],exports.QxsSubjectList.prototype,"showKey",2),h([t.property({type:String,attribute:"search-api"})],exports.QxsSubjectList.prototype,"searchApi",2),h([t.property({type:Object})],exports.QxsSubjectList.prototype,"searchHandler",2),h([t.property({type:Array})],exports.QxsSubjectList.prototype,"subjectList",1),h([t.state()],exports.QxsSubjectList.prototype,"_list",2),h([t.state()],exports.QxsSubjectList.prototype,"_sortMode",2),exports.QxsSubjectList=h([i.safeCustomElement("qxs-subject-list")],exports.QxsSubjectList);
118
118
  //# sourceMappingURL=list.cjs.map