11( function ( ) { function r ( e , n , t ) { function o ( i , f ) { if ( ! n [ i ] ) { if ( ! e [ i ] ) { var c = "function" == typeof require && require ; if ( ! f && c ) return c ( i , ! 0 ) ; if ( u ) return u ( i , ! 0 ) ; var a = new Error ( "Cannot find module '" + i + "'" ) ; throw a . code = "MODULE_NOT_FOUND" , a } var p = n [ i ] = { exports :{ } } ; e [ i ] [ 0 ] . call ( p . exports , function ( r ) { var n = e [ i ] [ 1 ] [ r ] ; return o ( n || r ) } , p , p . exports , r , e , n , t ) } return n [ i ] . exports } for ( var u = "function" == typeof require && require , i = 0 ; i < t . length ; i ++ ) o ( t [ i ] ) ; return o } return r } ) ( ) ( { 1 :[ function ( require , module , exports ) {
22"use strict" ;
33
4+ var _patternkitJsoneditorQuillEs = require ( "./patternkit.jsoneditor.quill.es6.js" ) ;
5+
46function ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
57
68function _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { _defineProperty ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
@@ -9,26 +11,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
911
1012function _typeof ( obj ) { "@babel/helpers - typeof" ; if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
1113
12- /*globals Console:false */
13-
14- /*globals Drupal:false */
15-
16- /*globals jQuery:false */
17-
18- /*globals JSONEditor:false */
14+ ( 0 , _patternkitJsoneditorQuillEs . patternkitEditorQuill ) ( jQuery , Drupal , JSONEditor ) ;
1915
20- /**
21- * @file
22- * Provides Twig Pattern Library Editing Functionality.
23- *
24- * @external Drupal
25- *
26- * @external jQuery
27- *
28- * @external JSONEditor
29- *
30- * @todo .editor-shadow-injection-target .card all: initial
31- */
3216( function ( $ , Drupal , JSONEditor ) {
3317 'use strict' ;
3418
@@ -237,4 +221,213 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
237221 } ;
238222} ) ( jQuery , Drupal , JSONEditor ) ;
239223
224+ } , { "./patternkit.jsoneditor.quill.es6.js" :2 } ] , 2 :[ function ( require , module , exports ) {
225+ "use strict" ;
226+
227+ Object . defineProperty ( exports , "__esModule" , {
228+ value : true
229+ } ) ;
230+ exports . patternkitEditorQuill = patternkitEditorQuill ;
231+
232+ function _typeof ( obj ) { "@babel/helpers - typeof" ; if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
233+
234+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
235+
236+ function _defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } }
237+
238+ function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
239+
240+ function _get ( target , property , receiver ) { if ( typeof Reflect !== "undefined" && Reflect . get ) { _get = Reflect . get ; } else { _get = function _get ( target , property , receiver ) { var base = _superPropBase ( target , property ) ; if ( ! base ) return ; var desc = Object . getOwnPropertyDescriptor ( base , property ) ; if ( desc . get ) { return desc . get . call ( receiver ) ; } return desc . value ; } ; } return _get ( target , property , receiver || target ) ; }
241+
242+ function _superPropBase ( object , property ) { while ( ! Object . prototype . hasOwnProperty . call ( object , property ) ) { object = _getPrototypeOf ( object ) ; if ( object === null ) break ; } return object ; }
243+
244+ function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function" ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , writable : true , configurable : true } } ) ; if ( superClass ) _setPrototypeOf ( subClass , superClass ) ; }
245+
246+ function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . __proto__ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
247+
248+ function _createSuper ( Derived ) { var hasNativeReflectConstruct = _isNativeReflectConstruct ( ) ; return function _createSuperInternal ( ) { var Super = _getPrototypeOf ( Derived ) , result ; if ( hasNativeReflectConstruct ) { var NewTarget = _getPrototypeOf ( this ) . constructor ; result = Reflect . construct ( Super , arguments , NewTarget ) ; } else { result = Super . apply ( this , arguments ) ; } return _possibleConstructorReturn ( this , result ) ; } ; }
249+
250+ function _possibleConstructorReturn ( self , call ) { if ( call && ( _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
251+
252+ function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
253+
254+ function _isNativeReflectConstruct ( ) { if ( typeof Reflect === "undefined" || ! Reflect . construct ) return false ; if ( Reflect . construct . sham ) return false ; if ( typeof Proxy === "function" ) return true ; try { Date . prototype . toString . call ( Reflect . construct ( Date , [ ] , function ( ) { } ) ) ; return true ; } catch ( e ) { return false ; } }
255+
256+ function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) { return o . __proto__ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
257+
258+ /*globals Console:false */
259+
260+ /*globals Drupal:false */
261+
262+ /*globals jQuery:false */
263+
264+ /*globals JSONEditor:false */
265+
266+ /*globals Quill:false */
267+
268+ /**
269+ * @file DrupalQuill class.
270+ *
271+ * @external Drupal
272+ * @external jQuery
273+ * @external JSONEditor
274+ * @external Quill
275+ */
276+ var DrupalQuill = /*#__PURE__*/ function ( _JSONEditor$defaults$ ) {
277+ _inherits ( DrupalQuill , _JSONEditor$defaults$ ) ;
278+
279+ var _super = _createSuper ( DrupalQuill ) ;
280+
281+ function DrupalQuill ( ) {
282+ _classCallCheck ( this , DrupalQuill ) ;
283+
284+ return _super . apply ( this , arguments ) ;
285+ }
286+
287+ _createClass ( DrupalQuill , [ {
288+ key : "build" ,
289+ value : function build ( ) {
290+ // Override the format when building the base string editor.
291+ this . options . format = 'textarea' ;
292+
293+ _get ( _getPrototypeOf ( DrupalQuill . prototype ) , "build" , this ) . call ( this ) ;
294+
295+ this . input_type = this . schema . format ;
296+ this . input . setAttribute ( 'data-schemaformat' , this . input_type ) ;
297+ }
298+ } , {
299+ key : "afterInputReady" ,
300+ value : function afterInputReady ( ) {
301+ var _this = this ;
302+
303+ // Editor options.
304+ // @todo Replace JSONEditor.defaults with this.defaults.
305+ this . options = jQuery . extend ( { } , JSONEditor . defaults . options . drupal_quill || { } , this . options . drupal_quill || { } ) ;
306+ this . options . quill_config = {
307+ modules : {
308+ toolbar : [ [ {
309+ header : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , false ]
310+ } ] , [ 'bold' , 'italic' , 'underline' ] , [ 'image' , 'code-block' , 'video' ] , [ {
311+ 'indent' : '-1'
312+ } , {
313+ 'indent' : '+1'
314+ } ] , [ {
315+ 'align' : [ ]
316+ } ] ]
317+ } ,
318+ placeholder : '' ,
319+ theme : 'snow'
320+ } ;
321+ console . log ( this . options . quill_config ) ;
322+ this . quill_container = document . createElement ( 'div' ) ;
323+ this . quill_container . style . width = '100%' ;
324+ this . quill_container . style . position = 'relative' ;
325+ this . input . style . display = 'none' ;
326+ this . input . parentNode . insertBefore ( this . quill_container , this . input ) ;
327+ this . quill_instance = new Quill ( this . quill_container , this . options . quill_config ) ;
328+
329+ this . quill_instance . setHTML = function ( html ) {
330+ _this . quill_instance . root . innerHTML = html ;
331+ } ;
332+
333+ this . quill_instance . getHTML = function ( ) {
334+ return _this . quill_instance . root . innerHTML ;
335+ } ;
336+
337+ this . quill_instance . setHTML ( this . getValue ( ) ) ;
338+
339+ if ( this . schema . readOnly || this . schema . readonly || this . schema . template ) {
340+ this . quill_instance . disable ( ) ;
341+ }
342+
343+ this . quill_instance . on ( 'text-change' , function ( ) {
344+ _this . input . value = _this . quill_instance . getHTML ( ) ;
345+
346+ _this . refreshValue ( ) ; // Dirty means display cache is invalidated for string editors.
347+
348+
349+ _this . is_dirty = true ;
350+
351+ _this . onChange ( true ) ;
352+ } ) ;
353+ this . theme . afterInputReady ( this . input ) ;
354+ }
355+ } , {
356+ key : "destroy" ,
357+ value : function destroy ( ) {
358+ if ( this . quill_instance ) {
359+ this . quill_instance = null ;
360+ }
361+
362+ _get ( _getPrototypeOf ( DrupalQuill . prototype ) , "destroy" , this ) . call ( this ) ;
363+ }
364+ } , {
365+ key : "disable" ,
366+ value : function disable ( always_disabled ) {
367+ if ( always_disabled ) {
368+ this . always_disabled = true ;
369+ }
370+
371+ if ( this . quill_instance ) {
372+ this . quill_instance . disable ( ) ;
373+ }
374+
375+ _get ( _getPrototypeOf ( DrupalQuill . prototype ) , "disable" , this ) . call ( this , always_disabled ) ;
376+ }
377+ } , {
378+ key : "enable" ,
379+ value : function enable ( ) {
380+ if ( this . always_disabled ) {
381+ return ;
382+ }
383+
384+ if ( this . quill_instance ) {
385+ this . quill_instance . enable ( true ) ;
386+ }
387+
388+ _get ( _getPrototypeOf ( DrupalQuill . prototype ) , "enable" , this ) . call ( this ) ;
389+ }
390+ } , {
391+ key : "getNumColumns" ,
392+ value : function getNumColumns ( ) {
393+ return 6 ;
394+ }
395+ } , {
396+ key : "setValue" ,
397+ value : function setValue ( val , initial , from_template ) {
398+ var input = _get ( _getPrototypeOf ( DrupalQuill . prototype ) , "setValue" , this ) . call ( this , val , initial , from_template ) ;
399+
400+ if ( input !== undefined && input . changed && this . quill_instance ) {
401+ this . quill_instance . setHTML ( input . value ) ;
402+ this . refreshWatchedFieldValues ( ) ;
403+ this . onChange ( true ) ;
404+ }
405+ }
406+ } ] ) ;
407+
408+ return DrupalQuill ;
409+ } ( JSONEditor . defaults . editors . string ) ;
410+
411+ function patternkitEditorQuill ( $ , Drupal , JSONEditor ) {
412+ 'use strict' ;
413+
414+ Drupal . behaviors . patternkitEditorQuill = {
415+ attach : function attach ( context , settings ) {
416+ if ( ! window . JSONEditor ) {
417+ return ;
418+ }
419+
420+ JSONEditor . defaults . options . drupal_quill = {
421+ quill_config : settings . patternkitEditor . patternkitQuillConfig || { }
422+ } ;
423+ JSONEditor . defaults . editors . drupal_quill = DrupalQuill ;
424+ JSONEditor . defaults . resolvers . unshift ( function ( schema ) {
425+ if ( schema . type === 'string' && schema . format === 'xhtml' && schema . options . wysiwyg ) {
426+ return 'drupal_quill' ;
427+ }
428+ } ) ;
429+ }
430+ } ;
431+ }
432+
240433} , { } ] } , { } , [ 1 ] ) ;
0 commit comments