32
32
* See the documentation for more details.
33
33
*
34
34
* @author Paweł Bizley Brzozowski
35
- * @version 3.1 .0
35
+ * @version 3.2 .0
36
36
* @license Apache 2.0
37
37
* https://github.com/bizley/yii2-quill
38
38
*
@@ -49,8 +49,8 @@ class Quill extends InputWidget
49
49
public const TOOLBAR_BASIC = 'BASIC ' ;
50
50
51
51
public const QUILL_VERSION = '1.3.7 ' ;
52
- public const KATEX_VERSION = '0.11.1 ' ;
53
- public const HIGHLIGHTJS_VERSION = '9.18.1 ' ;
52
+ public const KATEX_VERSION = '0.12.0 ' ;
53
+ public const HIGHLIGHTJS_VERSION = '10.2.0 ' ;
54
54
55
55
/** {@inheritdoc} */
56
56
public static $ autoIdPrefix = 'quill- ' ;
@@ -182,12 +182,6 @@ class Quill extends InputWidget
182
182
*/
183
183
public $ highlightStyle = 'default ' ;
184
184
185
- /**
186
- * @var array HTML attributes for the input tag (editor box).
187
- * @see Html::renderTagAttributes() for details on how attributes are being rendered.
188
- */
189
- public $ options = ['style ' => 'min-height:150px; ' ];
190
-
191
185
/**
192
186
* @var array HTML attributes for the hidden input tag (field keeping raw HTML text).
193
187
* @see Html::renderTagAttributes() for details on how attributes are being rendered.
@@ -207,6 +201,12 @@ class Quill extends InputWidget
207
201
*/
208
202
public $ localAssets = false ;
209
203
204
+ /**
205
+ * @var bool Whether to allow resizing the editor box.
206
+ * @since 3.2.0
207
+ */
208
+ public $ allowResize = false ;
209
+
210
210
/** @var string ID of the editor */
211
211
protected $ _fieldId ;
212
212
@@ -245,6 +245,10 @@ public function init(): void
245
245
$ this ->_fieldId = $ this ->options ['id ' ];
246
246
$ this ->options ['id ' ] = 'editor- ' . $ this ->id ;
247
247
248
+ if (!$ this ->allowResize && !isset ($ this ->options ['style ' ])) {
249
+ $ this ->options ['style ' ] = 'min-height:150px; ' ;
250
+ }
251
+
248
252
$ this ->prepareOptions ();
249
253
}
250
254
@@ -523,13 +527,29 @@ public function renderToolbar()
523
527
return $ this ->toolbarOptions ;
524
528
}
525
529
530
+ private function removeFormControlClass (): void
531
+ {
532
+ if (isset ($ this ->options ['class ' ])) {
533
+ $ oldClasses = explode (' ' , $ this ->options ['class ' ]);
534
+ $ newClasses = [];
535
+ foreach ($ oldClasses as $ class ) {
536
+ if ($ class !== 'form-control ' ) {
537
+ $ newClasses [] = $ class ;
538
+ }
539
+ }
540
+ $ this ->options ['class ' ] = implode (' ' , $ newClasses );
541
+ }
542
+ }
543
+
526
544
/** {@inheritdoc} */
527
545
public function run (): string
528
546
{
529
547
$ this ->registerClientScript ();
530
548
531
549
$ hiddenOptions = array_merge ($ this ->hiddenOptions , ['id ' => $ this ->_fieldId ]);
532
550
551
+ $ this ->removeFormControlClass ();
552
+
533
553
if ($ this ->hasModel ()) {
534
554
return Html::activeHiddenInput ($ this ->model , $ this ->attribute , $ hiddenOptions )
535
555
. Html::tag ($ this ->tag , $ this ->model ->{$ this ->attribute }, $ this ->options );
@@ -547,6 +567,10 @@ public function registerClientScript(): void
547
567
{
548
568
$ view = $ this ->view ;
549
569
570
+ if ($ this ->allowResize ) {
571
+ $ view ->registerCss ('.ql-editor{resize:vertical;overflow-y:scroll} ' );
572
+ }
573
+
550
574
if ($ this ->localAssets ) {
551
575
if ($ this ->isKatex ()) {
552
576
KatexLocalAsset::register ($ view );
0 commit comments