@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,15 +1,15 @@
1
- import{css as e,LitElement as t,html as i}from"lit";import{property as s}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.mjs";import{state as r}from"../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.mjs";import{safeCustomElement as o}from"../base/define.mjs";import{SubjectError as n}from"./single.mjs";import{SubjectType as a}from"./types.mjs";var l=Object.defineProperty,d=Object.getOwnPropertyDescriptor,p=(e,t,i,s)=>{for(var r,o=s>1?void 0:s?d(t,i):t,n=e.length-1;n>=0;n--)(r=e[n])&&(o=(s?r(t,i,o):r(o))||o);return s&&o&&l(t,i,o),o};const h=[{bg:"#ecf5ff",color:"#3D61E3",border:"#d9ecff"},{bg:"#f0f9eb",color:"#67c23a",border:"#c2e7b0"},{bg:"#fdf6ec",color:"#e6a23c",border:"#faecd8"},{bg:"#fef0f0",color:"#f56c6c",border:"#fde2e2"},{bg:"#f4f4f5",color:"#909399",border:"#e9e9eb"}];let c=class extends t{constructor(){super(...arguments),this._iconPlus=i`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,this._iconRemove=i`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`,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:!0,isIgnoreCase:!0,keywordCount:1},this.uploadImage=async e=>new Promise((t,i)=>{const s=new FileReader;s.onload=e=>t(e.target?.result),s.onerror=i,s.readAsDataURL(e)}),this.answerList=[],this.modelValue="",this.useModel=!1,this._answers=[{title:"",tag:"",showInput:!1}],this._title="",this._analysis="",this._isInOrder=!0,this._isIgnoreCase=!0,this._keywordCount=1,this._correct="",this._showRichText=!1,this._richText="",this.TITLE_MAX=200}willUpdate(e){e.has("isEdit")&&this.isEdit&&this._syncProps(),!this.isEdit&&(e.has("title")||e.has("answerList")||e.has("analysis")||e.has("examAnswerSetting")||e.has("richTextContent")||e.has("examExpand"))&&this._syncProps(),e.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_normalizeAnswerTitle(e){return String(e?.title??e?.answer??"")}_normalizedAnswerList(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(Array.isArray(e)?e:[]).map(e=>({...e,answerId:e?.answerId??e?.examAnswerId,title:this._normalizeAnswerTitle(e)}))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this.answerList?.length?this._answers=this._normalizedAnswerList(this.answerList).map(e=>({title:e.title||"",tag:"",showInput:!1,answerId:e.answerId,customAnswerId:e.customAnswerId})):this._answers=[{title:"",tag:"",showInput:!1}],this.examAnswerSetting&&(this._isInOrder=!!this.examAnswerSetting.isInOrder,this._isIgnoreCase=!!this.examAnswerSetting.isIgnoreCase,this._keywordCount=this.examAnswerSetting.keywordCount||1),this._richText=this.richTextContent||"",this._showRichText=!!this.richTextContent,this._correct=this.examExpand||""}_emit(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t??null}))}_onTitleInput(e){const t=e.target;t.value.length>this.TITLE_MAX&&(t.value=t.value.slice(0,this.TITLE_MAX)),this._title=t.value,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_addTag(e){const t={...this._answers[e]};t.tag&&(t.title=t.title?[t.title,t.tag].join(","):t.tag,t.tag=""),t.showInput=!1,this._answers=this._answers.map((i,s)=>s===e?t:i)}_closeTag(e,t){const i={...this._answers[t]};i.title=i.title.split(",").filter(t=>t!==e).join(","),this._answers=this._answers.map((e,s)=>s===t?i:e)}async toJSON(){return new Promise((e,t)=>{const i={customId:this.customId||void 0,answerType:"text_fill",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this._normalizedAnswerList(this.answerList||[]),o=this.isEdit?this._analysis:this.analysis||"",l=this.isEdit?this._correct:this.examExpand||"",d=this.isEdit?this._keywordCount:this.examAnswerSetting?.keywordCount||1,p=this.isEdit?this._isInOrder:this.examAnswerSetting?.isInOrder??!0,h=this.isEdit?this._isIgnoreCase:this.examAnswerSetting?.isIgnoreCase??!0,c=this.isEdit?this._showRichText:!!this.richTextContent,x=this.isEdit?this._richText:this.richTextContent||"";if(!s)return void t(new n("题目标题不能为空!","EMPTY_TITLE","title",i));if(d||l){if(!d)return void t(new n("请完善答题设置!","NO_KEYWORD_COUNT","keywordCount",i));if(!l)return void t(new n("请输入问题正确答案!","NO_CORRECT_ANSWER","correct",i));if(r.length!==d)return void t(new n("关键词个数设置有误!","KEYWORD_COUNT_MISMATCH","answers",i));const e=[];if(r.forEach((t,i)=>{this._normalizeAnswerTitle(t)||e.push(`关键词${i+1}未设置`)}),e.length)return void t(new n(e.join(","),"KEYWORD_EMPTY","answers",i))}const w={answerType:a.TEXT_FILL,title:s,answers:r.filter(e=>this._normalizeAnswerTitle(e)).map(e=>({title:this._normalizeAnswerTitle(e),...e.answerId?{answerId:e.answerId}:{},...e.customAnswerId?{customAnswerId:e.customAnswerId}:{}})),analysis:o,isSetCorrectAnswer:!!l,isKey:this.isKey,examExpand:l,examAnswerSettingBO:{isIgnoreCase:h,isInOrder:p,keywordCount:d},examRichTextContent:c?x:""};this.customId&&(w.customId=this.customId),e(w)})}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",tag:"",showInput:!1}])}_deleteAnswer(e){this._answers.length<2||this.isSave||(this._answers=this._answers.filter((t,i)=>i!==e))}async _save(e){e?.stopImmediatePropagation();try{const e=await this.toJSON();this._emit("save",e)}catch(e){!function(e){const t=document.createElement("div");t.textContent=e,Object.assign(t.style,{position:"fixed",top:"20px",left:"50%",transform:"translateX(-50%)",padding:"10px 20px",borderRadius:"4px",fontSize:"13px",color:"#fff",background:"#f56c6c",zIndex:"99999",boxShadow:"0 4px 12px rgba(0,0,0,.15)",transition:"opacity .3s",opacity:"1"}),document.body.appendChild(t),setTimeout(()=>{t.style.opacity="0",setTimeout(()=>t.remove(),300)},2500)}(e.message)}}validate(){const e=[],t={customId:this.customId||void 0,answerType:"text_fill",orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",s=this.isEdit?this._answers:this._normalizedAnswerList(this.answerList||[]),r=this.isEdit?this._correct:this.examExpand||"",o=this.isEdit?this._keywordCount:this.examAnswerSetting?.keywordCount||1;return i||e.push(new n("题目标题不能为空!","EMPTY_TITLE","title",t)),(o||r)&&(o||e.push(new n("请完善答题设置!","NO_KEYWORD_COUNT","keywordCount",t)),r||e.push(new n("请输入问题正确答案!","NO_CORRECT_ANSWER","correct",t)),s.length!==o&&e.push(new n("关键词个数设置有误!","KEYWORD_COUNT_MISMATCH","answers",t)),s.forEach((i,s)=>{this._normalizeAnswerTitle(i)||e.push(new n(`关键词${s+1}未设置`,"KEYWORD_EMPTY","answers",t))})),e}_renderPreview(){const e=this.isEdit?this._answers:this._normalizedAnswerList(this.answerList||[]),t=this.isEdit?this._correct:this.examExpand||"";return i`
1
+ import{css as t,LitElement as e,html as i}from"lit";import{property as s,state as r}from"lit/decorators.js";import{safeCustomElement as o}from"../base/define.mjs";import{SubjectError as n}from"./single.mjs";import{SubjectType as a}from"./types.mjs";var l=Object.defineProperty,d=Object.getOwnPropertyDescriptor,p=(t,e,i,s)=>{for(var r,o=s>1?void 0:s?d(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(o=(s?r(e,i,o):r(o))||o);return s&&o&&l(e,i,o),o};const h=[{bg:"#ecf5ff",color:"#3D61E3",border:"#d9ecff"},{bg:"#f0f9eb",color:"#67c23a",border:"#c2e7b0"},{bg:"#fdf6ec",color:"#e6a23c",border:"#faecd8"},{bg:"#fef0f0",color:"#f56c6c",border:"#fde2e2"},{bg:"#f4f4f5",color:"#909399",border:"#e9e9eb"}];let c=class extends e{constructor(){super(...arguments),this._iconPlus=i`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>`,this._iconRemove=i`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="5" y1="12" x2="19" y2="12"/></svg>`,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:!0,isIgnoreCase:!0,keywordCount:1},this.uploadImage=async t=>new Promise((e,i)=>{const s=new FileReader;s.onload=t=>e(t.target?.result),s.onerror=i,s.readAsDataURL(t)}),this.answerList=[],this.modelValue="",this.useModel=!1,this._answers=[{title:"",tag:"",showInput:!1}],this._title="",this._analysis="",this._isInOrder=!0,this._isIgnoreCase=!0,this._keywordCount=1,this._correct="",this._showRichText=!1,this._richText="",this.TITLE_MAX=200}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")||t.has("examExpand"))&&this._syncProps(),t.has("modelValue")&&this.useModel&&(this._title=this.modelValue)}_normalizeAnswerTitle(t){return String(t?.title??t?.answer??"")}_normalizedAnswerList(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(Array.isArray(t)?t:[]).map(t=>({...t,answerId:t?.answerId??t?.examAnswerId,title:this._normalizeAnswerTitle(t)}))}_syncProps(){this._title=this.title||"",this._analysis=this.analysis||"",this.answerList?.length?this._answers=this._normalizedAnswerList(this.answerList).map(t=>({title:t.title||"",tag:"",showInput:!1,answerId:t.answerId,customAnswerId:t.customAnswerId})):this._answers=[{title:"",tag:"",showInput:!1}],this.examAnswerSetting&&(this._isInOrder=!!this.examAnswerSetting.isInOrder,this._isIgnoreCase=!!this.examAnswerSetting.isIgnoreCase,this._keywordCount=this.examAnswerSetting.keywordCount||1),this._richText=this.richTextContent||"",this._showRichText=!!this.richTextContent,this._correct=this.examExpand||""}_emit(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e??null}))}_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,this.useModel&&this.dispatchEvent(new CustomEvent("update:modelValue",{bubbles:!0,composed:!0,detail:this._title}))}_addTag(t){const e={...this._answers[t]};e.tag&&(e.title=e.title?[e.title,e.tag].join(","):e.tag,e.tag=""),e.showInput=!1,this._answers=this._answers.map((i,s)=>s===t?e:i)}_closeTag(t,e){const i={...this._answers[e]};i.title=i.title.split(",").filter(e=>e!==t).join(","),this._answers=this._answers.map((t,s)=>s===e?i:t)}async toJSON(){return new Promise((t,e)=>{const i={customId:this.customId||void 0,answerType:"text_fill",orderIndex:this.orderIndex},s=this.isEdit?this._title:this.title||"",r=this.isEdit?this._answers:this._normalizedAnswerList(this.answerList||[]),o=this.isEdit?this._analysis:this.analysis||"",l=this.isEdit?this._correct:this.examExpand||"",d=this.isEdit?this._keywordCount:this.examAnswerSetting?.keywordCount||1,p=this.isEdit?this._isInOrder:this.examAnswerSetting?.isInOrder??!0,h=this.isEdit?this._isIgnoreCase:this.examAnswerSetting?.isIgnoreCase??!0,c=this.isEdit?this._showRichText:!!this.richTextContent,x=this.isEdit?this._richText:this.richTextContent||"";if(!s)return void e(new n("题目标题不能为空!","EMPTY_TITLE","title",i));if(d||l){if(!d)return void e(new n("请完善答题设置!","NO_KEYWORD_COUNT","keywordCount",i));if(!l)return void e(new n("请输入问题正确答案!","NO_CORRECT_ANSWER","correct",i));if(r.length!==d)return void e(new n("关键词个数设置有误!","KEYWORD_COUNT_MISMATCH","answers",i));const t=[];if(r.forEach((e,i)=>{this._normalizeAnswerTitle(e)||t.push(`关键词${i+1}未设置`)}),t.length)return void e(new n(t.join(","),"KEYWORD_EMPTY","answers",i))}const w={answerType:a.TEXT_FILL,title:s,answers:r.filter(t=>this._normalizeAnswerTitle(t)).map(t=>({title:this._normalizeAnswerTitle(t),...t.answerId?{answerId:t.answerId}:{},...t.customAnswerId?{customAnswerId:t.customAnswerId}:{}})),analysis:o,isSetCorrectAnswer:!!l,isKey:this.isKey,examExpand:l,examAnswerSettingBO:{isIgnoreCase:h,isInOrder:p,keywordCount:d},examRichTextContent:c?x:""};this.customId&&(w.customId=this.customId),t(w)})}_addAnswer(){this.isSave||(this._answers=[...this._answers,{title:"",tag:"",showInput:!1}])}_deleteAnswer(t){this._answers.length<2||this.isSave||(this._answers=this._answers.filter((e,i)=>i!==t))}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:"text_fill",orderIndex:this.orderIndex},i=this.isEdit?this._title:this.title||"",s=this.isEdit?this._answers:this._normalizedAnswerList(this.answerList||[]),r=this.isEdit?this._correct:this.examExpand||"",o=this.isEdit?this._keywordCount:this.examAnswerSetting?.keywordCount||1;return i||t.push(new n("题目标题不能为空!","EMPTY_TITLE","title",e)),(o||r)&&(o||t.push(new n("请完善答题设置!","NO_KEYWORD_COUNT","keywordCount",e)),r||t.push(new n("请输入问题正确答案!","NO_CORRECT_ANSWER","correct",e)),s.length!==o&&t.push(new n("关键词个数设置有误!","KEYWORD_COUNT_MISMATCH","answers",e)),s.forEach((i,s)=>{this._normalizeAnswerTitle(i)||t.push(new n(`关键词${s+1}未设置`,"KEYWORD_EMPTY","answers",e))})),t}_renderPreview(){const t=this.isEdit?this._answers:this._normalizedAnswerList(this.answerList||[]),e=this.isEdit?this._correct:this.examExpand||"";return i`
2
2
  <div class="preview">
3
3
  <span class="title">${this.orderIndex+1}.${this.title}(问答题)</span>
4
4
  ${this.richTextContent?i`<div class="rich-text" .innerHTML=${this.richTextContent}></div>`:""}
5
- ${e.some(e=>e.title)?i`
5
+ ${t.some(t=>t.title)?i`
6
6
  <div style="margin-top:8px;color:#a8abb2">
7
- ${e.map((e,t)=>e.title?i`
8
- <span style="margin-right:10px">关键词${t+1}: ${e.title}</span>
7
+ ${t.map((t,e)=>t.title?i`
8
+ <span style="margin-right:10px">关键词${e+1}: ${t.title}</span>
9
9
  `:"")}
10
10
  </div>
11
11
  `:""}
12
- ${t?i`<div style="margin-top:8px;color:#a8abb2">正确答案:${t}</div>`:""}
12
+ ${e?i`<div style="margin-top:8px;color:#a8abb2">正确答案:${e}</div>`:""}
13
13
  ${this.analysis?i`<div style="color:#909399;font-size:12px;margin-top:8px">解析: ${this.analysis}</div>`:""}
14
14
  </div>
15
15
  `}_renderEdit(){return i`
@@ -19,7 +19,7 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s}from"..
19
19
  <div class="el-input">
20
20
  <textarea rows="2" .value=${this._title} ?disabled=${this.isSave}
21
21
  maxlength=${this.TITLE_MAX}
22
- @input=${e=>this._onTitleInput(e)}
22
+ @input=${t=>this._onTitleInput(t)}
23
23
  placeholder="【问答题】请输入问题"></textarea>
24
24
  <span class="char-counter">${this._title.length}/${this.TITLE_MAX}</span>
25
25
  </div>
@@ -33,16 +33,16 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s}from"..
33
33
  <span style="font-size:13px;color:#606266">共答对</span>
34
34
  <input type="number" style="width:60px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:13px"
35
35
  .value=${String(this._keywordCount)} min="1"
36
- @change=${e=>{this._keywordCount=Number(e.target.value)}} />
36
+ @change=${t=>{this._keywordCount=Number(t.target.value)}} />
37
37
  <span style="font-size:13px;color:#606266">个关键词,算是正确的</span>
38
38
  <label style="display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266">
39
39
  <input type="checkbox" .checked=${this._isInOrder}
40
- @change=${e=>{this._isInOrder=e.target.checked}} />
40
+ @change=${t=>{this._isInOrder=t.target.checked}} />
41
41
  答案不分顺序
42
42
  </label>
43
43
  <label style="display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266">
44
44
  <input type="checkbox" .checked=${this._isIgnoreCase}
45
- @change=${e=>{this._isIgnoreCase=e.target.checked}} />
45
+ @change=${t=>{this._isIgnoreCase=t.target.checked}} />
46
46
  忽略大小写
47
47
  </label>
48
48
  </div>
@@ -55,7 +55,7 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s}from"..
55
55
  <div class="el-input">
56
56
  <textarea rows="2" .value=${this._correct} ?disabled=${this.isSave}
57
57
  maxlength="200"
58
- @input=${e=>{this._correct=e.target.value}}
58
+ @input=${t=>{this._correct=t.target.value}}
59
59
  placeholder="请输入正确答案"></textarea>
60
60
  <span class="char-counter">${this._correct.length}/200</span>
61
61
  </div>
@@ -64,32 +64,32 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s}from"..
64
64
 
65
65
  <div class="answer-list" style="margin-top:12px">
66
66
  <span style="padding-left:60px;font-size:12px;color:#909399">*如遇包含特殊字符的关键词,需添加多个同义词,例:'CO₂'需添加同义词'CO2'</span>
67
- ${this._answers.map((e,t)=>i`
67
+ ${this._answers.map((t,e)=>i`
68
68
  <div class="answer-item">
69
- <span class="label">关键词${t+1}:</span>
69
+ <span class="label">关键词${e+1}:</span>
70
70
  <div class="answer-tags" style="display:flex;flex-wrap:wrap;gap:5px;align-items:center;flex:1;max-width:360px">
71
- ${e.title.split(",").filter(Boolean).map(e=>{const s=h[t%h.length];return i`
71
+ ${t.title.split(",").filter(Boolean).map(t=>{const s=h[e%h.length];return i`
72
72
  <span style="display:inline-flex;align-items:center;background:${s.bg};color:${s.color};border:1px solid ${s.border};border-radius:3px;padding:2px 8px;font-size:12px;line-height:16px">
73
- ${e}
74
- ${this.isSave?"":i`<span style="cursor:pointer;margin-left:4px;color:#909399" @click=${()=>this._closeTag(e,t)}>×</span>`}
73
+ ${t}
74
+ ${this.isSave?"":i`<span style="cursor:pointer;margin-left:4px;color:#909399" @click=${()=>this._closeTag(t,e)}>×</span>`}
75
75
  </span>
76
76
  `})}
77
77
  ${this.isSave?"":i`
78
- ${e.showInput?i`
78
+ ${t.showInput?i`
79
79
  <input type="text" style="width:80px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:12px"
80
- @keydown=${e=>{"Enter"===e.key&&this._addTag(t)}}
81
- @input=${t=>{e.tag=t.target.value}}
82
- @blur=${()=>this._addTag(t)} />
83
- <button class="el-link" @click=${()=>this._addTag(t)}>确认</button>
80
+ @keydown=${t=>{"Enter"===t.key&&this._addTag(e)}}
81
+ @input=${e=>{t.tag=e.target.value}}
82
+ @blur=${()=>this._addTag(e)} />
83
+ <button class="el-link" @click=${()=>this._addTag(e)}>确认</button>
84
84
  `:i`
85
- <button class="link" @click=${()=>{this._answers=this._answers.map((e,i)=>i===t?{...e,showInput:!0}:e),this.updateComplete.then(()=>{this.shadowRoot?.querySelector('input[style*="width:80px"]')?.focus()})}}>
86
- ${e.title?"添加同义词":"添加关键词"}
85
+ <button class="link" @click=${()=>{this._answers=this._answers.map((t,i)=>i===e?{...t,showInput:!0}:t),this.updateComplete.then(()=>{this.shadowRoot?.querySelector('input[style*="width:80px"]')?.focus()})}}>
86
+ ${t.title?"添加同义词":"添加关键词"}
87
87
  </button>
88
88
  `}
89
89
  `}
90
90
  </div>
91
91
  <span class="icon ${this.isSave?"disabled":""}" @click=${()=>this._addAnswer()}>${this._iconPlus}</span>
92
- <span class="icon ${this.isSave||this._answers.length<2?"disabled":""}" @click=${()=>this._deleteAnswer(t)}>${this._iconRemove}</span>
92
+ <span class="icon ${this.isSave||this._answers.length<2?"disabled":""}" @click=${()=>this._deleteAnswer(e)}>${this._iconRemove}</span>
93
93
  </div>
94
94
  `)}
95
95
  </div>
@@ -114,33 +114,33 @@ import{css as e,LitElement as t,html as i}from"lit";import{property as s}from"..
114
114
  <div style="flex:1">
115
115
  <div class="el-input">
116
116
  <textarea rows="2" .value=${this._analysis}
117
- @input=${e=>{this._analysis=e.target.value}}
117
+ @input=${t=>{this._analysis=t.target.value}}
118
118
  placeholder="请输入题目解析"></textarea>
119
119
  </div>
120
120
  </div>
121
121
  </div>
122
122
  `:""}
123
123
  `}render(){return i`
124
- <qxs-subject-layout ?show-edit=${this.isEdit}>
124
+ <qxs-subject-layout .showEdit=${this.isEdit}>
125
125
  <div slot="preview">${this._renderPreview()}</div>
126
126
  <div slot="edit">${this._renderEdit()}</div>
127
127
  ${this.showAction?i`
128
128
  <qxs-subject-action
129
- ?is-edit=${this.isEdit}
130
- ?is-set=${this.isSet}
131
- ?show-add=${this.showAdd}
132
- ?show-rich-text=${this._showRichText}
129
+ .isEdit=${this.isEdit}
130
+ .isSet=${this.isSet}
131
+ .showAdd=${this.showAdd}
132
+ .showRichText=${this._showRichText}
133
133
  exam-answer-relation-type=${this.examAnswerRelationType}
134
134
  @delete=${()=>this._emit("delete")}
135
135
  @save=${this._save}
136
136
  @edit=${()=>this._emit("edit")}
137
- @add=${e=>this._emit("add",e.detail)}
138
- @set-key=${e=>{this._emit("set-key",e.detail)}}
137
+ @add=${t=>this._emit("add",t.detail)}
138
+ @set-key=${t=>{this._emit("set-key",t.detail)}}
139
139
  @on-show-rich-text=${()=>{this._showRichText=!this._showRichText,this._showRichText||(this._richText="")}}
140
140
  ></qxs-subject-action>
141
141
  `:""}
142
142
  </qxs-subject-layout>
143
- `}};c.styles=e`
143
+ `}};c.styles=t`
144
144
  :host { display: block; font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; color: #5a5a5a; }
145
145
  *, ::before, ::after { box-sizing: border-box; }
146
146
 
@@ -1 +1 @@
1
- {"version":3,"file":"text-fill.mjs","sources":["../../../../packages/components-wc/src/subject/text-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 TextAnswer {\n title: string\n tag: string\n showInput: boolean\n answerId?: string | number\n customAnswerId?: string | number\n}\n\nconst TAG_COLORS = [\n { bg: '#ecf5ff', color: '#3D61E3', border: '#d9ecff' }, // primary\n { bg: '#f0f9eb', color: '#67c23a', border: '#c2e7b0' }, // success\n { bg: '#fdf6ec', color: '#e6a23c', border: '#faecd8' }, // warning\n { bg: '#fef0f0', color: '#f56c6c', border: '#fde2e2' }, // danger\n { bg: '#f4f4f5', color: '#909399', border: '#e9e9eb' }, // info\n]\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-text-fill')\nexport class QxsTextFill extends LitElement {\n private readonly _iconPlus = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n private readonly _iconRemove = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n\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-answer { display: flex; flex-direction: column; margin-top: 12px; }\n .preview-answer .radio { margin-top: 8px; padding-left: 8px; display: flex; align-items: center; gap: 6px; }\n .preview-answer .order { color: #909399; }\n .preview-answer .correct { color: #67c23a; }\n .preview-answer .result-info { color: #909399; }\n\n .flex { display: flex; }\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: 60px; 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 .answer-list { margin-top: 12px; }\n .answer-item { display: flex; align-items: center; margin-top: 6px; border-radius: 4px; }\n .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }\n .answer-item .input { flex: 1; max-width: 360px; position: relative; display: block; }\n .answer-item .input input {\n height: 32px; padding: 0 50px 0 8px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n transition: border-color .2s; box-sizing: border-box;\n }\n .answer-item .input input:focus { border-color: #3D61E3; outline: none; }\n .answer-item .input input:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n .answer-item .input .char-counter {\n position: absolute; right: 8px; top: 50%; transform: translateY(-50%);\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n .answer-item .correct { margin: 0 10px; color: #909399; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }\n .answer-item .correct:hover { color: #3D61E3; }\n .answer-item .correct.is-correct { color: #67c23a; }\n .answer-item .correct input { width: 14px; height: 14px; cursor: pointer; accent-color: #3D61E3; }\n\n .answer-item .icon {\n margin-left: 6px; cursor: pointer; display: inline-flex;\n align-items: center; justify-content: center;\n width: 24px; height: 24px; border-radius: 4px;\n border: 1px solid #dcdfe6; background: #fff; color: #909399;\n transition: all 0.2s;\n }\n .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }\n\n .answer-item .link { margin-left: 8px; color: #3D61E3; cursor: pointer; font-size: 12px; white-space: nowrap; }\n .answer-item .link:hover { color: #2D4CB8; }\n\n .answer-item .link { color: #3D61E3; cursor: pointer; font-size: 12px; white-space: nowrap; background: none; border: none; padding: 0; margin: 0; font-family: inherit; }\n .answer-item .link:hover { color: #2D4CB8; }\n\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; background: none; border: none; padding: 0; margin: 0; font-family: inherit; line-height: 1; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.danger { color: #f56c6c; }\n\n .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9000; display: flex; align-items: center; justify-content: center; }\n .modal { background: #fff; border-radius: 6px; width: 520px; max-width: 90vw; box-shadow: 0 12px 32px rgba(0,0,0,.12); display: flex; flex-direction: column; }\n .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid #e4e7ed; }\n .modal-title { font-size: 14px; font-weight: 600; color: #303133; }\n .modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #909399; padding: 0; line-height: 1; }\n .modal-close:hover { color: #3D61E3; }\n .modal-body { padding: 20px; }\n .modal-body textarea { min-height: 120px; }\n .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4e7ed; }\n .modal-footer button { padding: 6px 16px; font-size: 12px; border-radius: 3px; cursor: pointer; border: 1px solid #dcdfe6; background: #fff; color: #606266; }\n .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }\n .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n `\n\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, keywordCount: number } = { isInOrder: true, isIgnoreCase: true, keywordCount: 1 }\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 _answers: TextAnswer[] = [{ title: '', tag: '', showInput: false }]\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _isInOrder = true\n @state() private _isIgnoreCase = true\n @state() private _keywordCount = 1\n @state() private _correct = ''\n @state() private _showRichText = false\n @state() private _richText = ''\n\n private readonly TITLE_MAX = 200\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') || changed.has('examExpand'))) {\n this._syncProps()\n }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue\n }\n }\n\n private _normalizeAnswerTitle(answer: any) {\n return String(answer?.title ?? answer?.answer ?? '')\n }\n\n private _normalizedAnswerList(source: any[] = []) {\n return (Array.isArray(source) ? source : []).map((answer: any) => ({\n ...answer,\n answerId: answer?.answerId ?? answer?.examAnswerId,\n title: this._normalizeAnswerTitle(answer),\n }))\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._analysis = this.analysis || ''\n if (this.answerList?.length) {\n this._answers = this._normalizedAnswerList(this.answerList).map((a: any) => ({\n title: a.title || '',\n tag: '',\n showInput: false,\n answerId: a.answerId,\n customAnswerId: a.customAnswerId,\n }))\n }\n else {\n this._answers = [{ title: '', tag: '', showInput: false }]\n }\n if (this.examAnswerSetting) {\n this._isInOrder = !!this.examAnswerSetting.isInOrder\n this._isIgnoreCase = !!this.examAnswerSetting.isIgnoreCase\n this._keywordCount = this.examAnswerSetting.keywordCount || 1\n }\n this._richText = this.richTextContent || ''\n this._showRichText = !!this.richTextContent\n this._correct = this.examExpand || ''\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 _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 // 双向绑定:通知外部更新\n if (this.useModel) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private _addTag(i: number) {\n const a = { ...this._answers[i] }\n if (a.tag) {\n a.title = a.title ? [a.title, a.tag].join(',') : a.tag\n a.tag = ''\n }\n a.showInput = false\n this._answers = this._answers.map((x, j) => j === i ? a : x)\n }\n\n private _closeTag(tag: string, i: number) {\n const a = { ...this._answers[i] }\n a.title = a.title.split(',').filter(t => t !== tag).join(',')\n this._answers = this._answers.map((x, j) => j === i ? a : x)\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'text_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : this._normalizedAnswerList(this.answerList || [])\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const correct = this.isEdit ? this._correct : (this as any).examExpand || ''\n const keywordCount = this.isEdit ? this._keywordCount : this.examAnswerSetting?.keywordCount || 1\n const isInOrder = this.isEdit ? this._isInOrder : this.examAnswerSetting?.isInOrder ?? true\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 (keywordCount || correct) {\n if (!keywordCount) {\n reject(new SubjectError('请完善答题设置!', 'NO_KEYWORD_COUNT', 'keywordCount', row))\n return\n }\n if (!correct) {\n reject(new SubjectError('请输入问题正确答案!', 'NO_CORRECT_ANSWER', 'correct', row))\n return\n }\n if (answers.length !== keywordCount) {\n reject(new SubjectError('关键词个数设置有误!', 'KEYWORD_COUNT_MISMATCH', 'answers', row))\n return\n }\n const msg: string[] = []\n answers.forEach((item: any, i: number) => {\n if (!this._normalizeAnswerTitle(item)) { msg.push(`关键词${i + 1}未设置`) }\n })\n if (msg.length) {\n reject(new SubjectError(msg.join(','), 'KEYWORD_EMPTY', 'answers', row))\n return\n }\n }\n const result: any = {\n answerType: SubjectType.TEXT_FILL,\n title,\n answers: answers\n .filter((a: any) => this._normalizeAnswerTitle(a))\n .map((a: any) => ({\n title: this._normalizeAnswerTitle(a),\n ...(a.answerId ? { answerId: a.answerId } : {}),\n ...(a.customAnswerId ? { customAnswerId: a.customAnswerId } : {}),\n })),\n analysis,\n isSetCorrectAnswer: !!correct,\n isKey: this.isKey,\n examExpand: correct,\n examAnswerSettingBO: { isIgnoreCase, isInOrder, keywordCount },\n examRichTextContent: showRichText ? richText : '',\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private _addAnswer() {\n if (this.isSave) { return }\n this._answers = [...this._answers, { title: '', tag: '', showInput: false }]\n }\n\n private _deleteAnswer(index: number) {\n if (this._answers.length < 2 || this.isSave) { return }\n this._answers = this._answers.filter((_, i) => i !== index)\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: 'text_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : this._normalizedAnswerList(this.answerList || [])\n const correct = this.isEdit ? this._correct : (this as any).examExpand || ''\n const keywordCount = this.isEdit ? this._keywordCount : this.examAnswerSetting?.keywordCount || 1\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n if (keywordCount || correct) {\n if (!keywordCount) {\n errors.push(new SubjectError('请完善答题设置!', 'NO_KEYWORD_COUNT', 'keywordCount', row))\n }\n if (!correct) {\n errors.push(new SubjectError('请输入问题正确答案!', 'NO_CORRECT_ANSWER', 'correct', row))\n }\n if (answers.length !== keywordCount) {\n errors.push(new SubjectError('关键词个数设置有误!', 'KEYWORD_COUNT_MISMATCH', 'answers', row))\n }\n answers.forEach((item: any, i: number) => {\n if (!this._normalizeAnswerTitle(item)) {\n errors.push(new SubjectError(`关键词${i + 1}未设置`, 'KEYWORD_EMPTY', 'answers', row))\n }\n })\n }\n\n return errors\n }\n\n private _renderPreview() {\n const previewAnswers = this.isEdit ? this._answers : this._normalizedAnswerList(this.answerList || [])\n const previewCorrect = this.isEdit ? this._correct : (this.examExpand || '')\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${this.title}(问答题)</span>\n ${this.richTextContent ? html`<div class=\"rich-text\" .innerHTML=${this.richTextContent}></div>` : ''}\n ${previewAnswers.some(a => a.title)\n ? html`\n <div style=\"margin-top:8px;color:#a8abb2\">\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 ${previewCorrect ? html`<div style=\"margin-top:8px;color:#a8abb2\">正确答案:${previewCorrect}</div>` : ''}\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-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .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 ${this.showAnswerSetting\n ? html`\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>答题设置:</span></div>\n <div style=\"flex:1;display:flex;align-items:center;flex-wrap:wrap;gap:8px\">\n <span style=\"font-size:13px;color:#606266\">共答对</span>\n <input type=\"number\" style=\"width:60px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:13px\"\n .value=${String(this._keywordCount)} min=\"1\"\n @change=${(e: Event) => { this._keywordCount = Number((e.target as HTMLInputElement).value) }} />\n <span style=\"font-size:13px;color:#606266\">个关键词,算是正确的</span>\n <label style=\"display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266\">\n <input type=\"checkbox\" .checked=${this._isInOrder}\n @change=${(e: Event) => { this._isInOrder = (e.target as HTMLInputElement).checked }} />\n 答案不分顺序\n </label>\n <label style=\"display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266\">\n <input type=\"checkbox\" .checked=${this._isIgnoreCase}\n @change=${(e: Event) => { this._isIgnoreCase = (e.target as HTMLInputElement).checked }} />\n 忽略大小写\n </label>\n </div>\n </div>\n `\n : ''}\n\n <div class=\"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._correct} ?disabled=${this.isSave}\n maxlength=\"200\"\n @input=${(e: Event) => { this._correct = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入正确答案\"></textarea>\n <span class=\"char-counter\">${this._correct.length}/200</span>\n </div>\n </div>\n </div>\n\n <div class=\"answer-list\" style=\"margin-top:12px\">\n <span style=\"padding-left:60px;font-size:12px;color:#909399\">*如遇包含特殊字符的关键词,需添加多个同义词,例:'CO₂'需添加同义词'CO2'</span>\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\">\n <span class=\"label\">关键词${i + 1}:</span>\n <div class=\"answer-tags\" style=\"display:flex;flex-wrap:wrap;gap:5px;align-items:center;flex:1;max-width:360px\">\n ${a.title.split(',').filter(Boolean).map((tag) => {\n const c = TAG_COLORS[i % TAG_COLORS.length]; return html`\n <span style=\"display:inline-flex;align-items:center;background:${c.bg};color:${c.color};border:1px solid ${c.border};border-radius:3px;padding:2px 8px;font-size:12px;line-height:16px\">\n ${tag}\n ${!this.isSave ? html`<span style=\"cursor:pointer;margin-left:4px;color:#909399\" @click=${() => this._closeTag(tag, i)}>×</span>` : ''}\n </span>\n `\n })}\n ${!this.isSave\n ? html`\n ${a.showInput\n ? html`\n <input type=\"text\" style=\"width:80px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:12px\"\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') { this._addTag(i) }\n }}\n @input=${(e: Event) => { a.tag = (e.target as HTMLInputElement).value }}\n @blur=${() => this._addTag(i)} />\n <button class=\"el-link\" @click=${() => this._addTag(i)}>确认</button>\n `\n : html`\n <button class=\"link\" @click=${() => { this._answers = this._answers.map((x, j) => j === i ? { ...x, showInput: true } : x); this.updateComplete.then(() => { (this.shadowRoot?.querySelector(`input[style*=\"width:80px\"]`) as HTMLInputElement)?.focus() }) }}>\n ${a.title ? '添加同义词' : '添加关键词'}\n </button>\n `}\n `\n : ''}\n </div>\n <span class=\"icon ${this.isSave ? 'disabled' : ''}\" @click=${() => this._addAnswer()}>${this._iconPlus}</span>\n <span class=\"icon ${this.isSave || this._answers.length < 2 ? 'disabled' : ''}\" @click=${() => this._deleteAnswer(i)}>${this._iconRemove}</span>\n </div>\n `)}\n </div>\n\n ${this._showRichText\n ? html`\n <div class=\"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`<div class=\"flex-justify-end\" style=\"margin-top:8px\"><span class=\"el-link danger\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span></div>`\n : ''}\n </div>\n </div>\n `\n : ''}\n\n ${this.showAnalysis\n ? html`\n <div class=\"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":["TAG_COLORS","bg","color","border","QxsTextFill","LitElement","constructor","super","arguments","this","_iconPlus","html","_iconRemove","orderIndex","title","customId","isEdit","isSave","isSet","isKey","showAction","showAdd","showAnswerSetting","showAnalysis","richTextContent","analysis","examAnswerRelationType","examExpand","examAnswerSetting","isInOrder","isIgnoreCase","keywordCount","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","answerList","modelValue","useModel","_answers","tag","showInput","_title","_analysis","_isInOrder","_isIgnoreCase","_keywordCount","_correct","_showRichText","_richText","TITLE_MAX","willUpdate","changed","has","_syncProps","_normalizeAnswerTitle","answer","String","_normalizedAnswerList","source","length","undefined","Array","isArray","map","answerId","examAnswerId","a","customAnswerId","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","value","slice","_addTag","i","join","x","j","_closeTag","split","filter","t","toJSON","row","answerType","answers","correct","showRichText","richText","SubjectError","msg","forEach","item","push","SubjectType","TEXT_FILL","isSetCorrectAnswer","examAnswerSettingBO","examRichTextContent","_addAnswer","_deleteAnswer","index","_","_save","stopImmediatePropagation","data","err","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","_renderPreview","previewAnswers","previewCorrect","some","_renderEdit","Number","checked","Boolean","c","key","updateComplete","then","shadowRoot","querySelector","focus","render","styles","css","__decorateClass","property","type","attribute","prototype","state","safeCustomElement"],"mappings":"2oBAcA,MAAMA,EAAa,CACjB,CAAEC,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,YAiBtC,IA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EA4GyDwK,UAAA,yBAAA,GACdJ,EAAA,CAArDC,EAAS,CAAEC,KAAMvG,OAAQwG,UAAW,iBA7G1BvK,EA6G2CwK,UAAA,aAAA,GAEtDJ,EAAA,CADCC,EAAS,CAAEC,KAAM3C,OAAQ4C,UAAW,yBA9G1BvK,EA+GXwK,UAAA,oBAAA,GAEAJ,EAAA,CADCC,EAAS,CAAEC,KAAM3C,UAhHP3H,EAiHXwK,UAAA,cAAA,GASqDJ,EAAA,CAApDC,EAAS,CAAEC,KAAMlG,MAAOmG,UAAW,iBA1HzBvK,EA0H0CwK,UAAA,aAAA,GAGCJ,EAAA,CAArDC,EAAS,CAAEC,KAAMvG,OAAQwG,UAAW,iBA7H1BvK,EA6H2CwK,UAAA,aAAA,GACDJ,EAAA,CAApDC,EAAS,CAAEC,KAAMb,QAASc,UAAW,eA9H3BvK,EA8H0CwK,UAAA,WAAA,GAEpCJ,EAAA,CAAhBK,KAhIUzK,EAgIMwK,UAAA,WAAA,GACAJ,EAAA,CAAhBK,KAjIUzK,EAiIMwK,UAAA,SAAA,GACAJ,EAAA,CAAhBK,KAlIUzK,EAkIMwK,UAAA,YAAA,GACAJ,EAAA,CAAhBK,KAnIUzK,EAmIMwK,UAAA,aAAA,GACAJ,EAAA,CAAhBK,KApIUzK,EAoIMwK,UAAA,gBAAA,GACAJ,EAAA,CAAhBK,KArIUzK,EAqIMwK,UAAA,gBAAA,GACAJ,EAAA,CAAhBK,KAtIUzK,EAsIMwK,UAAA,WAAA,GACAJ,EAAA,CAAhBK,KAvIUzK,EAuIMwK,UAAA,gBAAA,GACAJ,EAAA,CAAhBK,KAxIUzK,EAwIMwK,UAAA,YAAA,GAxINxK,EAANoK,EAAA,CADNM,EAAkB,kBACN1K"}
1
+ {"version":3,"file":"text-fill.mjs","sources":["../../../../packages/components-wc/src/subject/text-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 TextAnswer {\n title: string\n tag: string\n showInput: boolean\n answerId?: string | number\n customAnswerId?: string | number\n}\n\nconst TAG_COLORS = [\n { bg: '#ecf5ff', color: '#3D61E3', border: '#d9ecff' }, // primary\n { bg: '#f0f9eb', color: '#67c23a', border: '#c2e7b0' }, // success\n { bg: '#fdf6ec', color: '#e6a23c', border: '#faecd8' }, // warning\n { bg: '#fef0f0', color: '#f56c6c', border: '#fde2e2' }, // danger\n { bg: '#f4f4f5', color: '#909399', border: '#e9e9eb' }, // info\n]\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-text-fill')\nexport class QxsTextFill extends LitElement {\n private readonly _iconPlus = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n private readonly _iconRemove = html`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>`\n\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-answer { display: flex; flex-direction: column; margin-top: 12px; }\n .preview-answer .radio { margin-top: 8px; padding-left: 8px; display: flex; align-items: center; gap: 6px; }\n .preview-answer .order { color: #909399; }\n .preview-answer .correct { color: #67c23a; }\n .preview-answer .result-info { color: #909399; }\n\n .flex { display: flex; }\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: 60px; 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 .answer-list { margin-top: 12px; }\n .answer-item { display: flex; align-items: center; margin-top: 6px; border-radius: 4px; }\n .answer-item .label { min-width: 60px; font-size: 13px; color: #909399; }\n .answer-item .input { flex: 1; max-width: 360px; position: relative; display: block; }\n .answer-item .input input {\n height: 32px; padding: 0 50px 0 8px;\n font-size: 13px; line-height: 32px;\n border: 1px solid #dcdfe6; border-radius: 3px; width: 100%;\n transition: border-color .2s; box-sizing: border-box;\n }\n .answer-item .input input:focus { border-color: #3D61E3; outline: none; }\n .answer-item .input input:disabled { background: #f5f7fa; color: #c0c4cc; cursor: not-allowed; }\n .answer-item .input .char-counter {\n position: absolute; right: 8px; top: 50%; transform: translateY(-50%);\n font-size: 12px; color: #909399; line-height: 1; pointer-events: none;\n }\n\n .answer-item .correct { margin: 0 10px; color: #909399; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }\n .answer-item .correct:hover { color: #3D61E3; }\n .answer-item .correct.is-correct { color: #67c23a; }\n .answer-item .correct input { width: 14px; height: 14px; cursor: pointer; accent-color: #3D61E3; }\n\n .answer-item .icon {\n margin-left: 6px; cursor: pointer; display: inline-flex;\n align-items: center; justify-content: center;\n width: 24px; height: 24px; border-radius: 4px;\n border: 1px solid #dcdfe6; background: #fff; color: #909399;\n transition: all 0.2s;\n }\n .answer-item .icon:hover { color: #3D61E3; border-color: #3D61E3; background: #ecf5ff; }\n .answer-item .icon.disabled { color: #e4e7ed; border-color: #e4e7ed; cursor: not-allowed; }\n\n .answer-item .link { margin-left: 8px; color: #3D61E3; cursor: pointer; font-size: 12px; white-space: nowrap; }\n .answer-item .link:hover { color: #2D4CB8; }\n\n .answer-item .link { color: #3D61E3; cursor: pointer; font-size: 12px; white-space: nowrap; background: none; border: none; padding: 0; margin: 0; font-family: inherit; }\n .answer-item .link:hover { color: #2D4CB8; }\n\n .el-link { color: #3D61E3; cursor: pointer; font-size: 12px; background: none; border: none; padding: 0; margin: 0; font-family: inherit; line-height: 1; }\n .el-link:hover { color: #2D4CB8; }\n .el-link.danger { color: #f56c6c; }\n\n .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9000; display: flex; align-items: center; justify-content: center; }\n .modal { background: #fff; border-radius: 6px; width: 520px; max-width: 90vw; box-shadow: 0 12px 32px rgba(0,0,0,.12); display: flex; flex-direction: column; }\n .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 12px; border-bottom: 1px solid #e4e7ed; }\n .modal-title { font-size: 14px; font-weight: 600; color: #303133; }\n .modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #909399; padding: 0; line-height: 1; }\n .modal-close:hover { color: #3D61E3; }\n .modal-body { padding: 20px; }\n .modal-body textarea { min-height: 120px; }\n .modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4e7ed; }\n .modal-footer button { padding: 6px 16px; font-size: 12px; border-radius: 3px; cursor: pointer; border: 1px solid #dcdfe6; background: #fff; color: #606266; }\n .modal-footer button:hover { color: #3D61E3; border-color: #a0cfff; }\n .modal-footer button.primary { background: #3D61E3; border-color: #3D61E3; color: #fff; }\n .modal-footer button.primary:hover { background: #2D4CB8; border-color: #2D4CB8; }\n `\n\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, keywordCount: number } = { isInOrder: true, isIgnoreCase: true, keywordCount: 1 }\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 _answers: TextAnswer[] = [{ title: '', tag: '', showInput: false }]\n @state() private _title = ''\n @state() private _analysis = ''\n @state() private _isInOrder = true\n @state() private _isIgnoreCase = true\n @state() private _keywordCount = 1\n @state() private _correct = ''\n @state() private _showRichText = false\n @state() private _richText = ''\n\n private readonly TITLE_MAX = 200\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') || changed.has('examExpand'))) {\n this._syncProps()\n }\n // 当外部 modelValue 变化时同步内部状态\n if (changed.has('modelValue') && this.useModel) {\n this._title = this.modelValue\n }\n }\n\n private _normalizeAnswerTitle(answer: any) {\n return String(answer?.title ?? answer?.answer ?? '')\n }\n\n private _normalizedAnswerList(source: any[] = []) {\n return (Array.isArray(source) ? source : []).map((answer: any) => ({\n ...answer,\n answerId: answer?.answerId ?? answer?.examAnswerId,\n title: this._normalizeAnswerTitle(answer),\n }))\n }\n\n private _syncProps() {\n this._title = this.title || ''\n this._analysis = this.analysis || ''\n if (this.answerList?.length) {\n this._answers = this._normalizedAnswerList(this.answerList).map((a: any) => ({\n title: a.title || '',\n tag: '',\n showInput: false,\n answerId: a.answerId,\n customAnswerId: a.customAnswerId,\n }))\n }\n else {\n this._answers = [{ title: '', tag: '', showInput: false }]\n }\n if (this.examAnswerSetting) {\n this._isInOrder = !!this.examAnswerSetting.isInOrder\n this._isIgnoreCase = !!this.examAnswerSetting.isIgnoreCase\n this._keywordCount = this.examAnswerSetting.keywordCount || 1\n }\n this._richText = this.richTextContent || ''\n this._showRichText = !!this.richTextContent\n this._correct = this.examExpand || ''\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 _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 // 双向绑定:通知外部更新\n if (this.useModel) {\n this.dispatchEvent(new CustomEvent('update:modelValue', {\n bubbles: true,\n composed: true,\n detail: this._title,\n }))\n }\n }\n\n private _addTag(i: number) {\n const a = { ...this._answers[i] }\n if (a.tag) {\n a.title = a.title ? [a.title, a.tag].join(',') : a.tag\n a.tag = ''\n }\n a.showInput = false\n this._answers = this._answers.map((x, j) => j === i ? a : x)\n }\n\n private _closeTag(tag: string, i: number) {\n const a = { ...this._answers[i] }\n a.title = a.title.split(',').filter(t => t !== tag).join(',')\n this._answers = this._answers.map((x, j) => j === i ? a : x)\n }\n\n async toJSON(): Promise<any> {\n return new Promise((resolve, reject) => {\n const row = { customId: this.customId || undefined, answerType: 'text_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : this._normalizedAnswerList(this.answerList || [])\n const analysis = this.isEdit ? this._analysis : this.analysis || ''\n const correct = this.isEdit ? this._correct : (this as any).examExpand || ''\n const keywordCount = this.isEdit ? this._keywordCount : this.examAnswerSetting?.keywordCount || 1\n const isInOrder = this.isEdit ? this._isInOrder : this.examAnswerSetting?.isInOrder ?? true\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 (keywordCount || correct) {\n if (!keywordCount) {\n reject(new SubjectError('请完善答题设置!', 'NO_KEYWORD_COUNT', 'keywordCount', row))\n return\n }\n if (!correct) {\n reject(new SubjectError('请输入问题正确答案!', 'NO_CORRECT_ANSWER', 'correct', row))\n return\n }\n if (answers.length !== keywordCount) {\n reject(new SubjectError('关键词个数设置有误!', 'KEYWORD_COUNT_MISMATCH', 'answers', row))\n return\n }\n const msg: string[] = []\n answers.forEach((item: any, i: number) => {\n if (!this._normalizeAnswerTitle(item)) { msg.push(`关键词${i + 1}未设置`) }\n })\n if (msg.length) {\n reject(new SubjectError(msg.join(','), 'KEYWORD_EMPTY', 'answers', row))\n return\n }\n }\n const result: any = {\n answerType: SubjectType.TEXT_FILL,\n title,\n answers: answers\n .filter((a: any) => this._normalizeAnswerTitle(a))\n .map((a: any) => ({\n title: this._normalizeAnswerTitle(a),\n ...(a.answerId ? { answerId: a.answerId } : {}),\n ...(a.customAnswerId ? { customAnswerId: a.customAnswerId } : {}),\n })),\n analysis,\n isSetCorrectAnswer: !!correct,\n isKey: this.isKey,\n examExpand: correct,\n examAnswerSettingBO: { isIgnoreCase, isInOrder, keywordCount },\n examRichTextContent: showRichText ? richText : '',\n }\n if (this.customId) { result.customId = this.customId }\n resolve(result)\n })\n }\n\n private _addAnswer() {\n if (this.isSave) { return }\n this._answers = [...this._answers, { title: '', tag: '', showInput: false }]\n }\n\n private _deleteAnswer(index: number) {\n if (this._answers.length < 2 || this.isSave) { return }\n this._answers = this._answers.filter((_, i) => i !== index)\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: 'text_fill', orderIndex: this.orderIndex }\n\n const title = this.isEdit ? this._title : this.title || ''\n const answers = this.isEdit ? this._answers : this._normalizedAnswerList(this.answerList || [])\n const correct = this.isEdit ? this._correct : (this as any).examExpand || ''\n const keywordCount = this.isEdit ? this._keywordCount : this.examAnswerSetting?.keywordCount || 1\n\n if (!title) {\n errors.push(new SubjectError('题目标题不能为空!', 'EMPTY_TITLE', 'title', row))\n }\n if (keywordCount || correct) {\n if (!keywordCount) {\n errors.push(new SubjectError('请完善答题设置!', 'NO_KEYWORD_COUNT', 'keywordCount', row))\n }\n if (!correct) {\n errors.push(new SubjectError('请输入问题正确答案!', 'NO_CORRECT_ANSWER', 'correct', row))\n }\n if (answers.length !== keywordCount) {\n errors.push(new SubjectError('关键词个数设置有误!', 'KEYWORD_COUNT_MISMATCH', 'answers', row))\n }\n answers.forEach((item: any, i: number) => {\n if (!this._normalizeAnswerTitle(item)) {\n errors.push(new SubjectError(`关键词${i + 1}未设置`, 'KEYWORD_EMPTY', 'answers', row))\n }\n })\n }\n\n return errors\n }\n\n private _renderPreview() {\n const previewAnswers = this.isEdit ? this._answers : this._normalizedAnswerList(this.answerList || [])\n const previewCorrect = this.isEdit ? this._correct : (this.examExpand || '')\n return html`\n <div class=\"preview\">\n <span class=\"title\">${this.orderIndex + 1}.${this.title}(问答题)</span>\n ${this.richTextContent ? html`<div class=\"rich-text\" .innerHTML=${this.richTextContent}></div>` : ''}\n ${previewAnswers.some(a => a.title)\n ? html`\n <div style=\"margin-top:8px;color:#a8abb2\">\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 ${previewCorrect ? html`<div style=\"margin-top:8px;color:#a8abb2\">正确答案:${previewCorrect}</div>` : ''}\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-items-start\">\n <div class=\"label\"><span>题目:</span></div>\n <div style=\"flex:1\">\n <div class=\"el-input\">\n <textarea rows=\"2\" .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 ${this.showAnswerSetting\n ? html`\n <div class=\"flex-items-start\" style=\"margin-top:12px\">\n <div class=\"label\"><span>答题设置:</span></div>\n <div style=\"flex:1;display:flex;align-items:center;flex-wrap:wrap;gap:8px\">\n <span style=\"font-size:13px;color:#606266\">共答对</span>\n <input type=\"number\" style=\"width:60px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:13px\"\n .value=${String(this._keywordCount)} min=\"1\"\n @change=${(e: Event) => { this._keywordCount = Number((e.target as HTMLInputElement).value) }} />\n <span style=\"font-size:13px;color:#606266\">个关键词,算是正确的</span>\n <label style=\"display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266\">\n <input type=\"checkbox\" .checked=${this._isInOrder}\n @change=${(e: Event) => { this._isInOrder = (e.target as HTMLInputElement).checked }} />\n 答案不分顺序\n </label>\n <label style=\"display:inline-flex;align-items:center;gap:4px;cursor:pointer;font-size:12px;color:#606266\">\n <input type=\"checkbox\" .checked=${this._isIgnoreCase}\n @change=${(e: Event) => { this._isIgnoreCase = (e.target as HTMLInputElement).checked }} />\n 忽略大小写\n </label>\n </div>\n </div>\n `\n : ''}\n\n <div class=\"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._correct} ?disabled=${this.isSave}\n maxlength=\"200\"\n @input=${(e: Event) => { this._correct = (e.target as HTMLTextAreaElement).value }}\n placeholder=\"请输入正确答案\"></textarea>\n <span class=\"char-counter\">${this._correct.length}/200</span>\n </div>\n </div>\n </div>\n\n <div class=\"answer-list\" style=\"margin-top:12px\">\n <span style=\"padding-left:60px;font-size:12px;color:#909399\">*如遇包含特殊字符的关键词,需添加多个同义词,例:'CO₂'需添加同义词'CO2'</span>\n ${this._answers.map((a, i) => html`\n <div class=\"answer-item\">\n <span class=\"label\">关键词${i + 1}:</span>\n <div class=\"answer-tags\" style=\"display:flex;flex-wrap:wrap;gap:5px;align-items:center;flex:1;max-width:360px\">\n ${a.title.split(',').filter(Boolean).map((tag) => {\n const c = TAG_COLORS[i % TAG_COLORS.length]; return html`\n <span style=\"display:inline-flex;align-items:center;background:${c.bg};color:${c.color};border:1px solid ${c.border};border-radius:3px;padding:2px 8px;font-size:12px;line-height:16px\">\n ${tag}\n ${!this.isSave ? html`<span style=\"cursor:pointer;margin-left:4px;color:#909399\" @click=${() => this._closeTag(tag, i)}>×</span>` : ''}\n </span>\n `\n })}\n ${!this.isSave\n ? html`\n ${a.showInput\n ? html`\n <input type=\"text\" style=\"width:80px;height:24px;border:1px solid #dcdfe6;border-radius:3px;padding:0 8px;font-size:12px\"\n @keydown=${(e: KeyboardEvent) => {\n if (e.key === 'Enter') { this._addTag(i) }\n }}\n @input=${(e: Event) => { a.tag = (e.target as HTMLInputElement).value }}\n @blur=${() => this._addTag(i)} />\n <button class=\"el-link\" @click=${() => this._addTag(i)}>确认</button>\n `\n : html`\n <button class=\"link\" @click=${() => { this._answers = this._answers.map((x, j) => j === i ? { ...x, showInput: true } : x); this.updateComplete.then(() => { (this.shadowRoot?.querySelector(`input[style*=\"width:80px\"]`) as HTMLInputElement)?.focus() }) }}>\n ${a.title ? '添加同义词' : '添加关键词'}\n </button>\n `}\n `\n : ''}\n </div>\n <span class=\"icon ${this.isSave ? 'disabled' : ''}\" @click=${() => this._addAnswer()}>${this._iconPlus}</span>\n <span class=\"icon ${this.isSave || this._answers.length < 2 ? 'disabled' : ''}\" @click=${() => this._deleteAnswer(i)}>${this._iconRemove}</span>\n </div>\n `)}\n </div>\n\n ${this._showRichText\n ? html`\n <div class=\"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`<div class=\"flex-justify-end\" style=\"margin-top:8px\"><span class=\"el-link danger\" @click=${() => { this._showRichText = false; this._richText = '' }}>删除富文本</span></div>`\n : ''}\n </div>\n </div>\n `\n : ''}\n\n ${this.showAnalysis\n ? html`\n <div class=\"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":["TAG_COLORS","bg","color","border","QxsTextFill","LitElement","constructor","super","arguments","this","_iconPlus","html","_iconRemove","orderIndex","title","customId","isEdit","isSave","isSet","isKey","showAction","showAdd","showAnswerSetting","showAnalysis","richTextContent","analysis","examAnswerRelationType","examExpand","examAnswerSetting","isInOrder","isIgnoreCase","keywordCount","uploadImage","async","Promise","resolve","reject","reader","FileReader","onload","e","target","result","onerror","readAsDataURL","file","answerList","modelValue","useModel","_answers","tag","showInput","_title","_analysis","_isInOrder","_isIgnoreCase","_keywordCount","_correct","_showRichText","_richText","TITLE_MAX","willUpdate","changed","has","_syncProps","_normalizeAnswerTitle","answer","String","_normalizedAnswerList","source","length","undefined","Array","isArray","map","answerId","examAnswerId","a","customAnswerId","_emit","name","detail","dispatchEvent","CustomEvent","bubbles","composed","_onTitleInput","el","value","slice","_addTag","i","join","x","j","_closeTag","split","filter","t","toJSON","row","answerType","answers","correct","showRichText","richText","SubjectError","msg","forEach","item","push","SubjectType","TEXT_FILL","isSetCorrectAnswer","examAnswerSettingBO","examRichTextContent","_addAnswer","_deleteAnswer","index","_","_save","stopImmediatePropagation","data","err","document","createElement","textContent","Object","assign","style","position","top","left","transform","padding","borderRadius","fontSize","background","zIndex","boxShadow","transition","opacity","body","appendChild","setTimeout","remove","showToast","message","validate","errors","_renderPreview","previewAnswers","previewCorrect","some","_renderEdit","Number","checked","Boolean","c","key","updateComplete","then","shadowRoot","querySelector","focus","render","styles","css","__decorateClass","property","type","attribute","prototype","state","safeCustomElement"],"mappings":"ybAcA,MAAMA,EAAa,CACjB,CAAEC,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,WAC3C,CAAEF,GAAI,UAAWC,MAAO,UAAWC,OAAQ,YAiBtC,IAAMC,EAAN,cAA0BC,EAA1BC,WAAAA,GAAAC,SAAAC,WACLC,KAAiBC,UAAYC,CAAA,2NAC7BF,KAAiBG,YAAcD,CAAA,qLA6FuBF,KAAAI,WAAa,EACvCJ,KAAAK,MAAQ,GACgBL,KAAAM,SAAW,GACZN,KAAAO,QAAS,EACTP,KAAAQ,QAAS,EACVR,KAAAS,OAAQ,EACRT,KAAAU,OAAQ,EACHV,KAAAW,YAAa,EAChBX,KAAAY,SAAU,EACCZ,KAAAa,mBAAoB,EAC1Bb,KAAAc,cAAe,EACZd,KAAAe,gBAAkB,GAClDf,KAAAgB,SAAW,GAC6BhB,KAAAiB,uBAAyB,EACvCjB,KAAAkB,WAAa,GAEnElB,KAAAmB,kBAAyF,CAAEC,WAAW,EAAMC,cAAc,EAAMC,aAAc,GAE9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Mb,QAASc,UAAW,eA9H3BvK,EA8H0CwK,UAAA,WAAA,GAEpCJ,EAAA,CAAhBK,KAhIUzK,EAgIMwK,UAAA,WAAA,GACAJ,EAAA,CAAhBK,KAjIUzK,EAiIMwK,UAAA,SAAA,GACAJ,EAAA,CAAhBK,KAlIUzK,EAkIMwK,UAAA,YAAA,GACAJ,EAAA,CAAhBK,KAnIUzK,EAmIMwK,UAAA,aAAA,GACAJ,EAAA,CAAhBK,KApIUzK,EAoIMwK,UAAA,gBAAA,GACAJ,EAAA,CAAhBK,KArIUzK,EAqIMwK,UAAA,gBAAA,GACAJ,EAAA,CAAhBK,KAtIUzK,EAsIMwK,UAAA,WAAA,GACAJ,EAAA,CAAhBK,KAvIUzK,EAuIMwK,UAAA,gBAAA,GACAJ,EAAA,CAAhBK,KAxIUzK,EAwIMwK,UAAA,YAAA,GAxINxK,EAANoK,EAAA,CADNM,EAAkB,kBACN1K"}
@@ -1,2 +1,2 @@
1
- "use strict";exports.safeCustomElement=function(e){return function(t){return customElements.get(e)||customElements.define(e,t),t}};
1
+ "use strict";exports.safeCustomElement=function(e){return function(t){return"undefined"==typeof customElements||customElements.get(e)||customElements.define(e,t),t}};
2
2
  //# sourceMappingURL=define.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"define.cjs","sources":["../../../../packages/components-wc/src/base/define.ts"],"sourcesContent":["export function safeCustomElement(tagName: string) {\n return function (target: any) {\n if (!customElements.get(tagName)) {\n customElements.define(tagName, target)\n }\n return target\n }\n}\n"],"names":["tagName","target","customElements","get","define"],"mappings":"uCAAO,SAA2BA,GAChC,OAAO,SAAUC,GAIf,OAHKC,eAAeC,IAAIH,IACtBE,eAAeE,OAAOJ,EAASC,GAE1BA,CACT,CACF"}
1
+ {"version":3,"file":"define.cjs","sources":["../../../../packages/components-wc/src/base/define.ts"],"sourcesContent":["export function safeCustomElement(tagName: string) {\n return function (target: any) {\n if (typeof customElements === 'undefined') {\n return target\n }\n\n if (!customElements.get(tagName)) {\n customElements.define(tagName, target)\n }\n return target\n }\n}\n"],"names":["tagName","target","customElements","get","define"],"mappings":"uCAAO,SAA2BA,GAChC,OAAO,SAAUC,GACf,MAA8B,oBAAnBC,gBAINA,eAAeC,IAAIH,IACtBE,eAAeE,OAAOJ,EAASC,GAJxBA,CAOX,CACF"}
@@ -1,4 +1,4 @@
1
- "use strict";var e=require("@tiptap/core"),t=require("@tiptap/extension-blockquote"),i=require("@tiptap/extension-bold"),o=require("@tiptap/extension-bullet-list"),r=require("@tiptap/extension-code"),l=require("@tiptap/extension-document"),s=require("@tiptap/extension-heading"),n=require("@tiptap/extension-history"),a=require("@tiptap/extension-horizontal-rule"),d=require("@tiptap/extension-image"),c=require("@tiptap/extension-italic"),h=require("@tiptap/extension-link"),b=require("@tiptap/extension-list-item"),p=require("@tiptap/extension-ordered-list"),u=require("@tiptap/extension-paragraph"),g=require("@tiptap/extension-strike"),x=require("@tiptap/extension-table"),m=require("@tiptap/extension-table-cell"),v=require("@tiptap/extension-table-header"),y=require("@tiptap/extension-table-row"),f=require("@tiptap/extension-text"),_=require("@tiptap/extension-text-align"),w=require("@tiptap/extension-underline"),k=require("@tiptap/extension-placeholder"),C=require("lit"),M=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/property.cjs"),T=require("../node_modules/.pnpm/@lit_reactive-element@2.1.2/node_modules/@lit/reactive-element/decorators/state.cjs"),A=require("../base/define.cjs"),$=Object.defineProperty,B=Object.getOwnPropertyDescriptor,q=(e,t,i,o)=>{for(var r,l=o>1?void 0:o?B(t,i):t,s=e.length-1;s>=0;s--)(r=e[s])&&(l=(o?r(t,i,l):r(l))||l);return o&&l&&$(t,i,l),l};exports.QxsBlocksuiteEditor=class extends C.LitElement{constructor(){super(...arguments),this.content="",this.modelValue="",this.placeholder="输入 / 唤出快捷命令",this.useModelAttr="false",this.readonlyAttr="false",this.previewAttr="false",this.customStylesAttr="",this._injectedStyleEl=null,this.uploadImage=async e=>new Promise((t,i)=>{const o=new FileReader;o.onload=e=>t(e.target?.result),o.onerror=i,o.readAsDataURL(e)}),this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._imageToolbar={x:0,y:0,visible:!1},this._imageMoreMenuVisible=!1,this._hasSlashCommand=!1,this._isUpdating=!1,this._tableEdgeDetectionSetup=!1}_injectCustomStyles(){const e=this.shadowRoot;if(!e)return;if(this._injectedStyleEl&&(this._injectedStyleEl.remove(),this._injectedStyleEl=null),!this.customStylesAttr)return;const t=document.createElement("style");t.textContent=this.customStylesAttr,e.appendChild(t),this._injectedStyleEl=t}get useModel(){return"true"===this.useModelAttr||""===this.useModelAttr||this.hasAttribute("use-model")}set useModel(e){this.useModelAttr=String(e)}get readonly(){return"false"!==this.readonlyAttr}set readonly(e){this.readonlyAttr=String(e)}get preview(){return"false"!==this.previewAttr}set preview(e){this.previewAttr=String(e)}_initEditor(){if(this._editor)return;const C=this.shadowRoot?.querySelector(".editor-content");if(!C)return void requestAnimationFrame(()=>this._initEditor());for(;C.firstChild;)C.removeChild(C.firstChild);const M=this.useModel||this.hasAttribute("use-model"),T=this.getAttribute("model-value")??this.modelValue,A=this.content,$=M?(this._pendingContent??T)||"<p></p>":(this._pendingContent??A)||"<p></p>",B=[l,u,f,i,c,w,g,r,s.configure({levels:[1,2,3]}),o,p,b,t,a,n,d.configure({inline:!1,allowBase64:!0}),h.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),_.configure({types:["heading","paragraph"]}),x.Table.configure({resizable:!0}),y.TableRow,m.TableCell,v.TableHeader,k.configure({placeholder:this.placeholder}),e.Extension.create({name:"clearMarksOnEnter",addKeyboardShortcuts(){return{Enter:()=>(this.editor.chain().focus().unsetAllMarks().clearNodes().run(),!1)}}})];this._editor=new e.Editor({element:C,extensions:B,editable:!this.readonly,content:$}),this._pendingContent=null,this._editor.on("selectionUpdate",()=>{this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar();const e=this._editor;if(e){const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()}}),this._editor.on("transaction",()=>{this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._setupTableEdgeDetection()}),this._editor.on("update",()=>{this._emitContentChange()})}_emitContentChange(){if(!this._editor)return;const e=this._editor.getHTML();this.dispatchEvent(new CustomEvent("content-change",{detail:e,bubbles:!0,composed:!0}))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content"),t=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||this._tableEdgeDetectionSetup)return;this._tableEdgeDetectionSetup=!0;const i=()=>{this._editor?.chain().focus().run()};e.addEventListener("click",i),t?.addEventListener("click",i)}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state,t=this._editor.state.doc.textBetween(Math.max(0,e.from-10),e.from," ");this._hasSlashCommand=t.endsWith("/")}firstUpdated(){this._injectCustomStyles(),this._initEditor()}updated(e){if(e.has("customStylesAttr")&&this._injectCustomStyles(),this._editor){if(e.has("content")||e.has("modelValue")&&this.useModel){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}e.has("readonly")&&this._editor.setEditable(!this.readonly)}else e.has("content")&&(this._pendingContent=this.content),e.has("modelValue")&&this.useModel&&(this._pendingContent=this.modelValue)}disconnectedCallback(){super.disconnectedCallback(),this._editor?.destroy(),this._editor=null}getContent(){return this._editor?.getHTML()??""}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}}_applyFormat(e){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}e()}_toggleBold(){this._applyFormat(()=>this._editor?.chain().focus().toggleBold().run())}_toggleItalic(){this._applyFormat(()=>this._editor?.chain().focus().toggleItalic().run())}_toggleUnderline(){this._applyFormat(()=>this._editor?.chain().focus().toggleUnderline().run())}_toggleStrike(){this._applyFormat(()=>this._editor?.chain().focus().toggleStrike().run())}_toggleCode(){this._applyFormat(()=>this._editor?.chain().focus().toggleCode().run())}_setHeading(e){this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleBlockquote(){this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_setLink(){const e=window.prompt("请输入链接地址:");e&&this._applyFormat(()=>this._editor?.chain().focus().setLink({href:e}).run())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i)try{const e=await this.uploadImage(i);this._editor?.chain().focus().setImage({src:e}).run()}catch(e){}t.value=""}_triggerImageUpload(){const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_showTableCellToolbar(){if(!this._editor?.isActive("table"))return;const{state:e}=this._editor,{selection:t}=e,i=this._editor.view.coordsAtPos(t.from),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),l=this._getTableCellRow(),s=this._getTableCellCol();(0===l||0===s)&&requestAnimationFrame(()=>{this._tableCellToolbar={x:i.left-r.left,y:i.bottom-r.top+8,visible:!0,cellRow:l,cellCol:s}})}_getTableCellRow(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e-1)}return 0}_getTableCellCol(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e)}return 0}_hideTableCellToolbar(){requestAnimationFrame(()=>{this._tableCellToolbar={...this._tableCellToolbar,visible:!1}})}_addTableRowAbove(){this._editor?.chain().focus().addRowBefore().run(),this._hideTableCellToolbar()}_addTableRowBelow(){this._editor?.chain().focus().addRowAfter().run(),this._hideTableCellToolbar()}_addTableColumnLeft(){this._editor?.chain().focus().addColumnBefore().run(),this._hideTableCellToolbar()}_addTableColumnRight(){this._editor?.chain().focus().addColumnAfter().run(),this._hideTableCellToolbar()}_deleteTableRow(){this._editor?.chain().focus().deleteRow().run(),this._hideTableCellToolbar()}_deleteTableColumn(){this._editor?.chain().focus().deleteColumn().run(),this._hideTableCellToolbar()}_deleteTable(){this._editor?.chain().focus().deleteTable().run(),this._hideTableCellToolbar()}_showImageToolbar(e){requestAnimationFrame(()=>{this._imageToolbar={x:e.x,y:e.y,visible:!0},this._imageMoreMenuVisible=!1})}_hideImageToolbar(){requestAnimationFrame(()=>{this._imageToolbar={...this._imageToolbar,visible:!1},this._imageMoreMenuVisible=!1})}_toggleImageMoreMenu(){this._imageMoreMenuVisible=!this._imageMoreMenuVisible}_deleteImage(){this._editor?.chain().focus().deleteNode("image").run(),this._hideImageToolbar()}_insertImageAfter(){this._triggerImageUpload(),this._imageMoreMenuVisible=!1}_setImageAlignLeft(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto 0 0")}this._imageMoreMenuVisible=!1}_setImageAlignCenter(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto")}this._imageMoreMenuVisible=!1}_setImageAlignRight(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 0 0 auto")}this._imageMoreMenuVisible=!1}_getTextLabel(){const e=this._editor;return e?e.isActive("heading",{level:1})?"标题 1":e.isActive("heading",{level:2})?"标题 2":e.isActive("heading",{level:3})?"标题 3":"正文":"正文"}_getAlignLabel(){const e=this._editor;return e?e.isActive({textAlign:"center"})?"居中":e.isActive({textAlign:"right"})?"右对齐":"左对齐":"对齐"}_updateBubbleMenuPosition(){requestAnimationFrame(()=>{const e=this.shadowRoot?.querySelector(".bubble-menu"),t=this.shadowRoot?.querySelector(".ProseMirror"),i=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||!t||!i)return;const o=this._editor,r=o?.isActive("table")??!1,{selection:l}=o?.state??{selection:null};if(r&&l&&!l.empty&&o){const{from:t,to:i}=l,r=o.state.doc.resolve(t),s=o.state.doc.resolve(i);let n=!1;for(let e=r.depth;e>=0;e--)if("table"===r.node(e).type.name){n=!0;break}const a=r.node(r.depth),d=s.node(s.depth);if("table"!==a.type.name&&"table"!==d.type.name||(n=!0),n)return e.style.opacity="0",void(e.style.visibility="hidden")}if(l&&!l.empty);else if(!l||l.empty&&!this._hasSlashCommand)return e.style.opacity="0",void(e.style.visibility="hidden");const s=i.getBoundingClientRect(),n=e.getBoundingClientRect(),{from:a}=l,d=this._editor?.view.coordsAtPos(a);if(!d)return;let c=d.left-s.left,h=d.top-s.top-40;c+n.width>s.width&&(c=s.width-n.width-8),c<0&&(c=8),h<0&&(h=d.bottom-s.top+8),e.style.left=`${c}px`,e.style.top=`${h}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor;return C.html`
1
+ "use strict";var e=require("@tiptap/core"),t=require("@tiptap/extension-blockquote"),i=require("@tiptap/extension-bold"),o=require("@tiptap/extension-bullet-list"),r=require("@tiptap/extension-code"),l=require("@tiptap/extension-document"),s=require("@tiptap/extension-heading"),n=require("@tiptap/extension-history"),a=require("@tiptap/extension-horizontal-rule"),d=require("@tiptap/extension-image"),c=require("@tiptap/extension-italic"),h=require("@tiptap/extension-link"),b=require("@tiptap/extension-list-item"),p=require("@tiptap/extension-ordered-list"),u=require("@tiptap/extension-paragraph"),g=require("@tiptap/extension-strike"),x=require("@tiptap/extension-table"),m=require("@tiptap/extension-table-cell"),v=require("@tiptap/extension-table-header"),y=require("@tiptap/extension-table-row"),f=require("@tiptap/extension-text"),_=require("@tiptap/extension-text-align"),w=require("@tiptap/extension-underline"),k=require("@tiptap/extension-placeholder"),C=require("lit"),M=require("lit/decorators.js"),T=require("../base/define.cjs"),A=Object.defineProperty,$=Object.getOwnPropertyDescriptor,B=(e,t,i,o)=>{for(var r,l=o>1?void 0:o?$(t,i):t,s=e.length-1;s>=0;s--)(r=e[s])&&(l=(o?r(t,i,l):r(l))||l);return o&&l&&A(t,i,l),l};exports.QxsBlocksuiteEditor=class extends C.LitElement{constructor(){super(...arguments),this.content="",this.modelValue="",this.placeholder="输入 / 唤出快捷命令",this.useModelAttr="false",this.readonlyAttr="false",this.previewAttr="false",this.customStylesAttr="",this._injectedStyleEl=null,this.uploadImage=async e=>new Promise((t,i)=>{const o=new FileReader;o.onload=e=>t(e.target?.result),o.onerror=i,o.readAsDataURL(e)}),this._editor=null,this._pendingContent=null,this._tableRows=3,this._tableCols=3,this._hoverRow=0,this._hoverCol=0,this._tableDropdownOpen=!1,this._tableCellToolbar={x:0,y:0,visible:!1,cellRow:0,cellCol:0},this._imageToolbar={x:0,y:0,visible:!1},this._imageMoreMenuVisible=!1,this._hasSlashCommand=!1,this._isUpdating=!1,this._tableEdgeDetectionSetup=!1}_injectCustomStyles(){const e=this.shadowRoot;if(!e)return;if(this._injectedStyleEl&&(this._injectedStyleEl.remove(),this._injectedStyleEl=null),!this.customStylesAttr)return;const t=document.createElement("style");t.textContent=this.customStylesAttr,e.appendChild(t),this._injectedStyleEl=t}get useModel(){return"true"===this.useModelAttr||""===this.useModelAttr||this.hasAttribute("use-model")}set useModel(e){this.useModelAttr=String(e)}get readonly(){return"false"!==this.readonlyAttr}set readonly(e){this.readonlyAttr=String(e)}get preview(){return"false"!==this.previewAttr}set preview(e){this.previewAttr=String(e)}_initEditor(){if(this._editor)return;const C=this.shadowRoot?.querySelector(".editor-content");if(!C)return void requestAnimationFrame(()=>this._initEditor());for(;C.firstChild;)C.removeChild(C.firstChild);const M=this.useModel||this.hasAttribute("use-model"),T=this.getAttribute("model-value")??this.modelValue,A=this.content,$=M?(this._pendingContent??T)||"<p></p>":(this._pendingContent??A)||"<p></p>",B=[l,u,f,i,c,w,g,r,s.configure({levels:[1,2,3]}),o,p,b,t,a,n,d.configure({inline:!1,allowBase64:!0}),h.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer"}}),_.configure({types:["heading","paragraph"]}),x.Table.configure({resizable:!0}),y.TableRow,m.TableCell,v.TableHeader,k.configure({placeholder:this.placeholder}),e.Extension.create({name:"clearMarksOnEnter",addKeyboardShortcuts(){return{Enter:()=>(this.editor.chain().focus().unsetAllMarks().clearNodes().run(),!1)}}})];this._editor=new e.Editor({element:C,extensions:B,editable:!this.readonly,content:$}),this._pendingContent=null,this._editor.on("selectionUpdate",()=>{this._updateBubbleMenuPosition(),this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar();const e=this._editor;if(e){const{selection:t}=e.state,{$from:i}=t;if("image"===i.node(i.depth).type.name){const t=e.view.coordsAtPos(i.start()),o=this.shadowRoot?.querySelector(".editor-wrapper")?.getBoundingClientRect();if(o){const e=t.left-o.left+(t.right-t.left)/2,i=t.top-o.top-40;this._showImageToolbar({x:e,y:i})}}else this._hideImageToolbar()}}),this._editor.on("transaction",()=>{this._editor?.isActive("table")?this._showTableCellToolbar():this._hideTableCellToolbar(),this._checkSlashCommand(),this._setupTableEdgeDetection()}),this._editor.on("update",()=>{this._emitContentChange()})}_emitContentChange(){if(!this._editor)return;const e=this._editor.getHTML();this.dispatchEvent(new CustomEvent("content-change",{detail:e,bubbles:!0,composed:!0}))}_setupTableEdgeDetection(){const e=this.shadowRoot?.querySelector(".editor-content"),t=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||this._tableEdgeDetectionSetup)return;this._tableEdgeDetectionSetup=!0;const i=()=>{this._editor?.chain().focus().run()};e.addEventListener("click",i),t?.addEventListener("click",i)}_checkSlashCommand(){if(!this._editor)return;const{selection:e}=this._editor.state,t=this._editor.state.doc.textBetween(Math.max(0,e.from-10),e.from," ");this._hasSlashCommand=t.endsWith("/")}firstUpdated(){this._injectCustomStyles(),this._initEditor()}updated(e){if(e.has("customStylesAttr")&&this._injectCustomStyles(),this._editor){if(e.has("content")||e.has("modelValue")&&this.useModel){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}e.has("readonly")&&this._editor.setEditable(!this.readonly)}else e.has("content")&&(this._pendingContent=this.content),e.has("modelValue")&&this.useModel&&(this._pendingContent=this.modelValue)}disconnectedCallback(){super.disconnectedCallback(),this._editor?.destroy(),this._editor=null}getContent(){return this._editor?.getHTML()??""}forceUpdate(){if(this.requestUpdate(),this._editor){const e=this.useModel?this.modelValue:this.content;e!==this._editor.getHTML()&&this._editor.commands.setContent(e||"<p></p>")}}_applyFormat(e){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}e()}_toggleBold(){this._applyFormat(()=>this._editor?.chain().focus().toggleBold().run())}_toggleItalic(){this._applyFormat(()=>this._editor?.chain().focus().toggleItalic().run())}_toggleUnderline(){this._applyFormat(()=>this._editor?.chain().focus().toggleUnderline().run())}_toggleStrike(){this._applyFormat(()=>this._editor?.chain().focus().toggleStrike().run())}_toggleCode(){this._applyFormat(()=>this._editor?.chain().focus().toggleCode().run())}_setHeading(e){this._applyFormat(()=>this._editor?.chain().focus().toggleHeading({level:e}).run())}_setParagraph(){this._applyFormat(()=>this._editor?.chain().focus().setParagraph().run())}_toggleBulletList(){this._applyFormat(()=>this._editor?.chain().focus().toggleBulletList().run())}_toggleOrderedList(){this._applyFormat(()=>this._editor?.chain().focus().toggleOrderedList().run())}_toggleBlockquote(){this._applyFormat(()=>this._editor?.chain().focus().toggleBlockquote().run())}_setTextAlign(e){this._applyFormat(()=>this._editor?.chain().focus().setTextAlign(e).run())}_setLink(){const e=window.prompt("请输入链接地址:");e&&this._applyFormat(()=>this._editor?.chain().focus().setLink({href:e}).run())}_insertTable(e,t){this._editor?.chain().focus().insertTable({rows:e??this._tableRows,cols:t??this._tableCols,withHeaderRow:!0}).run()}async _handleImageUpload(e){const t=e.target,i=t.files?.[0];if(i)try{const e=await this.uploadImage(i);this._editor?.chain().focus().setImage({src:e}).run()}catch(e){}t.value=""}_triggerImageUpload(){const e=this.shadowRoot?.querySelector(".image-input");e?.click()}_insertTableByClick(e,t){if(this._hasSlashCommand&&this._editor){const{selection:e}=this._editor.state;this._editor.chain().focus().deleteRange({from:e.from-1,to:e.from}).run(),this._hasSlashCommand=!1}this._tableRows=e,this._tableCols=t,this._insertTable(e,t)}_showTableCellToolbar(){if(!this._editor?.isActive("table"))return;const{state:e}=this._editor,{selection:t}=e,i=this._editor.view.coordsAtPos(t.from),o=this.shadowRoot?.querySelector(".editor-wrapper");if(!o)return;const r=o.getBoundingClientRect(),l=this._getTableCellRow(),s=this._getTableCellCol();(0===l||0===s)&&requestAnimationFrame(()=>{this._tableCellToolbar={x:i.left-r.left,y:i.bottom-r.top+8,visible:!0,cellRow:l,cellCol:s}})}_getTableCellRow(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e-1)}return 0}_getTableCellCol(){if(!this._editor)return 0;const{selection:e}=this._editor.state,t=this._editor.state.doc.resolve(e.from);for(let e=t.depth;e>0;e--){if("tableCell"===t.node(e).type.name)return t.index(e)}return 0}_hideTableCellToolbar(){requestAnimationFrame(()=>{this._tableCellToolbar={...this._tableCellToolbar,visible:!1}})}_addTableRowAbove(){this._editor?.chain().focus().addRowBefore().run(),this._hideTableCellToolbar()}_addTableRowBelow(){this._editor?.chain().focus().addRowAfter().run(),this._hideTableCellToolbar()}_addTableColumnLeft(){this._editor?.chain().focus().addColumnBefore().run(),this._hideTableCellToolbar()}_addTableColumnRight(){this._editor?.chain().focus().addColumnAfter().run(),this._hideTableCellToolbar()}_deleteTableRow(){this._editor?.chain().focus().deleteRow().run(),this._hideTableCellToolbar()}_deleteTableColumn(){this._editor?.chain().focus().deleteColumn().run(),this._hideTableCellToolbar()}_deleteTable(){this._editor?.chain().focus().deleteTable().run(),this._hideTableCellToolbar()}_showImageToolbar(e){requestAnimationFrame(()=>{this._imageToolbar={x:e.x,y:e.y,visible:!0},this._imageMoreMenuVisible=!1})}_hideImageToolbar(){requestAnimationFrame(()=>{this._imageToolbar={...this._imageToolbar,visible:!1},this._imageMoreMenuVisible=!1})}_toggleImageMoreMenu(){this._imageMoreMenuVisible=!this._imageMoreMenuVisible}_deleteImage(){this._editor?.chain().focus().deleteNode("image").run(),this._hideImageToolbar()}_insertImageAfter(){this._triggerImageUpload(),this._imageMoreMenuVisible=!1}_setImageAlignLeft(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto 0 0")}this._imageMoreMenuVisible=!1}_setImageAlignCenter(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 auto")}this._imageMoreMenuVisible=!1}_setImageAlignRight(){const e=this._editor;if(e){const{selection:t}=e.state,i=t.from;e.chain().focus().setNodeSelection(i).run();const o=this.shadowRoot?.querySelector(".ProseMirror img.ProseMirror-selectednode");o&&(o.style.display="block",o.style.margin="0 0 0 auto")}this._imageMoreMenuVisible=!1}_getTextLabel(){const e=this._editor;return e?e.isActive("heading",{level:1})?"标题 1":e.isActive("heading",{level:2})?"标题 2":e.isActive("heading",{level:3})?"标题 3":"正文":"正文"}_getAlignLabel(){const e=this._editor;return e?e.isActive({textAlign:"center"})?"居中":e.isActive({textAlign:"right"})?"右对齐":"左对齐":"对齐"}_updateBubbleMenuPosition(){requestAnimationFrame(()=>{const e=this.shadowRoot?.querySelector(".bubble-menu"),t=this.shadowRoot?.querySelector(".ProseMirror"),i=this.shadowRoot?.querySelector(".editor-wrapper");if(!e||!t||!i)return;const o=this._editor,r=o?.isActive("table")??!1,{selection:l}=o?.state??{selection:null};if(r&&l&&!l.empty&&o){const{from:t,to:i}=l,r=o.state.doc.resolve(t),s=o.state.doc.resolve(i);let n=!1;for(let e=r.depth;e>=0;e--)if("table"===r.node(e).type.name){n=!0;break}const a=r.node(r.depth),d=s.node(s.depth);if("table"!==a.type.name&&"table"!==d.type.name||(n=!0),n)return e.style.opacity="0",void(e.style.visibility="hidden")}if(l&&!l.empty);else if(!l||l.empty&&!this._hasSlashCommand)return e.style.opacity="0",void(e.style.visibility="hidden");const s=i.getBoundingClientRect(),n=e.getBoundingClientRect(),{from:a}=l,d=this._editor?.view.coordsAtPos(a);if(!d)return;let c=d.left-s.left,h=d.top-s.top-40;c+n.width>s.width&&(c=s.width-n.width-8),c<0&&(c=8),h<0&&(h=d.bottom-s.top+8),e.style.left=`${c}px`,e.style.top=`${h}px`,e.style.opacity="1",e.style.visibility="visible"})}render(){const e=this._editor;return C.html`
2
2
  <div class="editor-wrapper ${e?"":"loading"} ${this.preview?"preview":""}">
3
3
  ${e?"":C.html`
4
4
  <div class="loading-placeholder">
@@ -888,5 +888,5 @@
888
888
  outline: 2px solid var(--qxs-color-primary, #3D61E3);
889
889
  outline-offset: 2px;
890
890
  }
891
- `,q([M.property({type:String,attribute:"content"})],exports.QxsBlocksuiteEditor.prototype,"content",2),q([M.property({type:String,attribute:"model-value"})],exports.QxsBlocksuiteEditor.prototype,"modelValue",2),q([M.property({type:String,attribute:"placeholder"})],exports.QxsBlocksuiteEditor.prototype,"placeholder",2),q([M.property({type:String,attribute:"use-model"})],exports.QxsBlocksuiteEditor.prototype,"useModelAttr",2),q([M.property({type:String,attribute:"readonly"})],exports.QxsBlocksuiteEditor.prototype,"readonlyAttr",2),q([M.property({type:String,attribute:"preview"})],exports.QxsBlocksuiteEditor.prototype,"previewAttr",2),q([M.property({type:String,attribute:"custom-styles"})],exports.QxsBlocksuiteEditor.prototype,"customStylesAttr",2),q([M.property({type:Object,attribute:"upload-image"})],exports.QxsBlocksuiteEditor.prototype,"uploadImage",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_editor",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_pendingContent",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_hoverRow",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_hoverCol",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_tableDropdownOpen",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_tableCellToolbar",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_imageToolbar",2),q([T.state()],exports.QxsBlocksuiteEditor.prototype,"_imageMoreMenuVisible",2),exports.QxsBlocksuiteEditor=q([A.safeCustomElement("qxs-blocksuite-editor")],exports.QxsBlocksuiteEditor),exports.register=function(){};
891
+ `,B([M.property({type:String,attribute:"content"})],exports.QxsBlocksuiteEditor.prototype,"content",2),B([M.property({type:String,attribute:"model-value"})],exports.QxsBlocksuiteEditor.prototype,"modelValue",2),B([M.property({type:String,attribute:"placeholder"})],exports.QxsBlocksuiteEditor.prototype,"placeholder",2),B([M.property({type:String,attribute:"use-model"})],exports.QxsBlocksuiteEditor.prototype,"useModelAttr",2),B([M.property({type:String,attribute:"readonly"})],exports.QxsBlocksuiteEditor.prototype,"readonlyAttr",2),B([M.property({type:String,attribute:"preview"})],exports.QxsBlocksuiteEditor.prototype,"previewAttr",2),B([M.property({type:String,attribute:"custom-styles"})],exports.QxsBlocksuiteEditor.prototype,"customStylesAttr",2),B([M.property({type:Object,attribute:"upload-image"})],exports.QxsBlocksuiteEditor.prototype,"uploadImage",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_editor",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_pendingContent",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_hoverRow",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_hoverCol",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_tableDropdownOpen",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_tableCellToolbar",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_imageToolbar",2),B([M.state()],exports.QxsBlocksuiteEditor.prototype,"_imageMoreMenuVisible",2),exports.QxsBlocksuiteEditor=B([T.safeCustomElement("qxs-blocksuite-editor")],exports.QxsBlocksuiteEditor);
892
892
  //# sourceMappingURL=blocksuite-editor.cjs.map