@@ -13,7 +13,6 @@ var FormConstructor = ( function($) {
1313
1414 function FormConstructor ( options ) {
1515 var that = this ;
16- //const { ref } = Vue;
1716
1817 // CONST
1918 //that.block_id = options["block_id"];
@@ -23,7 +22,6 @@ var FormConstructor = ( function($) {
2322 that . storage_data = $ . form_storage . data ;
2423 that . media_prop = options [ "media_prop" ] ;
2524
26- //that.block_elements = options["form_config"].elements || null;
2725 that . states = {
2826 block_id : options [ "block_id" ] ,
2927 form_config : options [ "form_config" ] ,
@@ -48,10 +46,10 @@ var FormConstructor = ( function($) {
4846 that . vue_custom_components = that . components . custom_components ;
4947 // CONST
5048
49+ //append :root styles from blockpage.wrapper.html
50+ appendIframeWrapperStyles ( that . $iframe_wrapper ) ;
5151 // INIT
5252 that . vue_model = that . initVue ( ) ;
53-
54-
5553 }
5654
5755 FormConstructor . prototype . init = function ( vue_model ) {
@@ -94,8 +92,6 @@ var FormConstructor = ( function($) {
9492 FormConstructor . prototype . initVue = function ( ) {
9593 var that = this ;
9694
97- const { reactive } = Vue ;
98-
9995 const i18n = VueI18n . createI18n ( {
10096 locale : $ . site . lang ,
10197 legacy : false ,
@@ -107,12 +103,11 @@ var FormConstructor = ( function($) {
107103 fallbackLocale : 'en' ,
108104 messages : $ . form_storage . translate
109105 } ) ;
110- // i18n.global.locale.value = $.site.lang;
106+
111107 if ( typeof $ . vue_app === "object" && typeof $ . vue_app . unmount === "function" ) {
112108 $ . vue_app . unmount ( ) ;
113109 }
114110
115-
116111 $ . vue_app = Vue . createApp ( {
117112
118113 data ( ) {
@@ -249,7 +244,6 @@ var FormConstructor = ( function($) {
249244 let arr_options = that . storage_data [ this . group_config . type ] ;
250245
251246 let active_option = this . block_data ?. block_props ?. [ form_type ] ;
252- const form_type_custom = 'custom' ;
253247
254248 const header_name = this . group_config . name ;
255249
@@ -259,7 +253,7 @@ var FormConstructor = ( function($) {
259253 delimiters : [ '{ { ' , ' } }' ] ,
260254 components : {
261255 'ButtonStyleDropdown' : that . vue_custom_components [ 'component-button-color-dropdown' ] ,
262- } ,
256+ } ,
263257 methods : {
264258 change : function ( option ) { //put classes to remove in temp_active_option
265259 let self = this ;
@@ -1636,17 +1630,8 @@ var FormConstructor = ( function($) {
16361630 that . $iframe_wrapper [ 0 ] . execCommand ( 'foreColor' , false , '#' + option ) ;
16371631 $ ( self . getSelectionBoundaryElement ( false ) ) . removeAttr ( "class" ) ;
16381632 }
1639- //console.log(that.$iframe_wrapper[0].getSelection().focusNode, self.getSelectionBoundaryElement(true), self.getSelectionBoundaryElement(false))
1640- //if (that.$iframe_wrapper[0].getSelection().focusNode.parentNode.nodeName === "FONT") that.$iframe_wrapper[0].getSelection().focusNode.parentNode.classList = [];
1641- //that.$iframe_wrapper[0].execCommand('removeformat');
1642-
16431633 self . block_data . html = $editable . html ( ) ;
16441634
1645- //self.active_option = { type: 'self_color', value: '#' + option, name: 'Self color'};
1646- /*$.wa.editor._block_settings_drawer_promise.then(function(bs) {
1647- bs.saveBlockData(self.block_data);
1648- });
1649- console.log('saveBlockData', self.block_data)*/
16501635 } ,
16511636 changePalette : function ( option ) {
16521637 let self = this ;
@@ -1662,17 +1647,11 @@ var FormConstructor = ( function($) {
16621647 sel . addRange ( rng )
16631648 //that.$iframe_wrapper[0].execCommand("SelectAll");
16641649 }
1665- //that.$iframe_wrapper[0].execCommand('removeformat');
1666- //that.$iframe_wrapper[0].execCommand('formatblock', false, 'font');
1667- //console.log($(self.getSelectionBoundaryElement(true)).find('font'))
16681650 $ ( self . getSelectionBoundaryElement ( true ) ) . find ( 'font' ) . each ( function ( ) { $ ( this ) . removeAttr ( "class" ) } ) ;
1669- that . $iframe_wrapper [ 0 ] . execCommand ( 'foreColor' , false , '#000' ) ;
1670-
1671- //$(self.getSelectionBoundaryElement(true)).attr('class', option.value);
1651+ that . $iframe_wrapper [ 0 ] . execCommand ( 'foreColor' , false , '#010203' ) ;
16721652 that . $iframe_wrapper [ 0 ] . getSelection ( ) . focusNode . parentNode . color = '' ;
16731653 that . $iframe_wrapper [ 0 ] . getSelection ( ) . focusNode . parentNode . classList = [ option . value ] ;
16741654
1675-
16761655 self . block_data . html = $editable . html ( ) ;
16771656 $ . wa . editor . _block_settings_drawer_promise . then ( function ( bs ) {
16781657 bs . saveBlockData ( self . block_data ) ;
@@ -4125,8 +4104,43 @@ var FormConstructor = ( function($) {
41254104 }
41264105 return false ; // Возвращаем false, если все iframe имеют закрывающие теги
41274106 }
4107+
41284108 } ;
41294109
4110+ function appendIframeWrapperStyles ( iframe_document ) {
4111+ const root_style = Array . from ( iframe_document [ 0 ] . styleSheets )
4112+ . filter (
4113+ sheet =>
4114+ sheet . href === null
4115+ )
4116+ . reduce (
4117+ ( acc , sheet ) =>
4118+ ( acc = [
4119+ ...acc ,
4120+ ...Array . from ( sheet . cssRules ) . reduce (
4121+ ( def , rule ) =>
4122+ ( def =
4123+ rule . selectorText === ":root"
4124+ ? [
4125+ ...def ,
4126+ rule
4127+ ]
4128+ : def ) ,
4129+ [ ]
4130+ )
4131+ ] ) ,
4132+ [ ]
4133+ ) ;
4134+
4135+ if ( root_style . length ) {
4136+ const style = document . createElement ( 'style' ) ;
4137+ style . textContent = root_style [ 0 ] ?. cssText || '' ;
4138+ document . head . appendChild ( style ) ;
4139+ }
4140+
4141+ //console.log(iframe_document[0].styleSheets)
4142+ }
4143+
41304144 return FormConstructor ;
41314145
41324146} ) ( jQuery ) ;
0 commit comments