@@ -28,8 +28,9 @@ export class Block {
2828 questionEditor ! : Editor ;
2929 questionSpaceSize ! : HTMLInputElement ;
3030 answerEditor ! : Editor ;
31- showAnswerCheckbox ! : HTMLInputElement ;
31+ showSolutionCheckbox ! : HTMLInputElement ;
3232 blankSpaceSize ! : HTMLInputElement ;
33+ paragraphEditor ! : Editor ;
3334
3435 constructor ( block : WorksheetBlock ) {
3536 this . id = block . id ;
@@ -65,25 +66,29 @@ export class Block {
6566 Delete
6667 </div>
6768 </button>
68- <label class="checkbox circle icon small primary small-padding right-round">
69+ <label class="checkbox circle icon small primary small-padding right-round" style="max-width: 32px;" >
6970 <input type="checkbox" id="${ id } -hidden">
7071 <span class="on-primary">
71- <i class="large " style="color: var(--on-primary);">expand_less</i>
72- <i class="large " style="color: var(--on-primary);">expand_more</i>
72+ <i class="extra " style="color: var(--on-primary); font-size: 24px ;">expand_less</i>
73+ <i class="extra " style="color: var(--on-primary); font-size: 24px ;">expand_more</i>
7374 </span>
7475 </label>
7576 </nav>
7677 </div>
7778 <div id="${ id } -content" class="block-content">
7879 <nav class="margin max toolbar round scroll surface-container-high" id="${ id } -block-type">
79- <a class="active" data-ui="#${ id } -question">
80- <i>help</i>
81- <span class="l">Question</span>
82- </a>
8380 <a data-ui="#${ id } -header">
8481 <i>format_h1</i>
8582 <span class="l">Header</span>
8683 </a>
84+ <a data-ui="#${ id } -paragraph">
85+ <i>text_fields</i>
86+ <span class="l">Text</span>
87+ </a>
88+ <a class="active" data-ui="#${ id } -question">
89+ <i>help</i>
90+ <span class="l">Question</span>
91+ </a>
8792 <a data-ui="#${ id } -divider">
8893 <i>horizontal_rule</i>
8994 <span class="l">Divider</span>
@@ -110,16 +115,20 @@ export class Block {
110115 <label>Question Space Size</label>
111116 </div>
112117 </div>
113- <h6 >Question</h6 >
118+ <div class="large-text top-margin" >Question</div >
114119 <div id="${ id } -question-container"></div>
115- <h6>Answer (Optional)</h6 >
116- <div id="${ id } -answer -container"></div>
120+ <div class="large-text top-margin">Solution</div >
121+ <div id="${ id } -solution -container"></div>
117122 <label class="checkbox">
118- <input type="checkbox" id="${ id } -show-answer ">
119- <span>Show Answer </span>
123+ <input type="checkbox" id="${ id } -show-solution ">
124+ <span>Show Solution </span>
120125 </label>
121126 </div>
122127
128+ <div class="page padding" id="${ id } -paragraph">
129+ <div id="${ id } -paragraph-container"></div>
130+ </div>
131+
123132 <div class="page padding" id="${ id } -header">
124133 <div class="field label suffix border round">
125134 <select id="${ id } -header-type">
@@ -203,11 +212,11 @@ export class Block {
203212 this . emitChanged ( { title : this . block . title } , "title" ) ;
204213 } ) ;
205214
206- this . showAnswerCheckbox = this . element . querySelector ( `#${ this . id } -show-answer ` ) as HTMLInputElement ;
207- this . showAnswerCheckbox . checked = this . block . showAnswer || false ;
208- this . showAnswerCheckbox . addEventListener ( "change" , ( ) => {
209- this . block . showAnswer = this . showAnswerCheckbox . checked ;
210- this . emitChanged ( { showAnswer : this . block . showAnswer } , "showAnswer " ) ;
215+ this . showSolutionCheckbox = this . element . querySelector ( `#${ this . id } -show-solution ` ) as HTMLInputElement ;
216+ this . showSolutionCheckbox . checked = this . block . showSolution || false ;
217+ this . showSolutionCheckbox . addEventListener ( "change" , ( ) => {
218+ this . block . showSolution = this . showSolutionCheckbox . checked ;
219+ this . emitChanged ( { showSolution : this . block . showSolution } , "showSolution " ) ;
211220 } ) ;
212221
213222 this . blankSpaceSize = this . element . querySelector ( `#${ this . id } -blank-space-size` ) as HTMLInputElement ;
@@ -265,7 +274,8 @@ export class Block {
265274 this . setHidden ( this . hiddenCheckbox . checked ) ;
266275
267276 const questionEl = this . element . querySelector ( `#${ this . id } -question-container` ) as HTMLElement ;
268- const answerEl = this . element . querySelector ( `#${ this . id } -answer-container` ) as HTMLElement ;
277+ const solutionEl = this . element . querySelector ( `#${ this . id } -solution-container` ) as HTMLElement ;
278+ const paragraphEl = this . element . querySelector ( `#${ this . id } -paragraph-container` ) as HTMLElement ;
269279
270280 // Prevent double-init if Swapy re-attaches elements
271281 if ( ! this . questionEditor ) {
@@ -287,7 +297,7 @@ export class Block {
287297
288298 if ( ! this . answerEditor ) {
289299 this . answerEditor = new Editor ( {
290- el : answerEl ,
300+ el : solutionEl ,
291301 previewStyle : "vertical" ,
292302 height : "150px" ,
293303 initialEditType : "wysiwyg" ,
@@ -301,8 +311,25 @@ export class Block {
301311 } ) ;
302312 this . answerEditor ?. on ( "focus" , ( ) => setPreviewActiveBlock ( this . id ) ) ;
303313 }
314+ if ( ! this . paragraphEditor ) {
315+ this . paragraphEditor = new Editor ( {
316+ el : paragraphEl ,
317+ previewStyle : "vertical" ,
318+ height : "250px" ,
319+ initialEditType : "wysiwyg" ,
320+ usageStatistics : true ,
321+ } ) ;
322+ this . paragraphEditor . setMarkdown ( this . block . paragraphMarkdown ?. replaceAll ( "$$" , "\\$\\$" ) || "" ) ;
323+ this . paragraphEditor . on ( "change" , ( ) => {
324+ this . block . paragraphMarkdown = this . paragraphEditor . getMarkdown ( ) ;
325+ this . emitChanged ( { paragraphMarkdown : this . block . paragraphMarkdown } , "paragraphMarkdown" ) ;
326+ setPreviewActiveBlock ( this . id , false )
327+ } ) ;
328+ this . paragraphEditor ?. on ( "focus" , ( ) => setPreviewActiveBlock ( this . id ) ) ;
329+ }
304330
305331 this . element . addEventListener ( "dblclick" , ( ) => {
332+ if ( ! this . hiddenCheckbox . checked ) return ;
306333 this . hiddenCheckbox . checked = ! this . hiddenCheckbox . checked ;
307334 this . setHidden ( this . hiddenCheckbox . checked ) ;
308335 } )
0 commit comments