@@ -86,8 +86,13 @@ public function getEditor($subtype = NULL,
8686 : $ config ;
8787 // @todo Move to own JS file & Drupal Settings config var.
8888 $ markup = <<<HTML
89- <div id="editor_holder "></div>
89+ <div id="magic-pixie-dust "></div>
9090<script type="text/javascript">
91+ let target = document.getElementById("magic-pixie-dust");
92+ let shadow = target.attachShadow({mode: 'open'});
93+
94+ shadow.innerHTML = '<link rel="stylesheet" id="theme_stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"><link rel="stylesheet" id="icon_stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css"><div id="editor_holder"></div>';
95+
9196 var data = {};
9297 data.schema = $ schema_json;
9398 data.starting = $ starting_json;
@@ -102,10 +107,10 @@ public function getEditor($subtype = NULL,
102107
103108 // Initialize the editor with a JSON schema
104109 var editor = new JSONEditor(
105- document .getElementById('editor_holder'), {
110+ target.shadowRoot .getElementById('editor_holder'), {
106111 schema: data.schema,
107- theme: 'jqueryui ',
108- iconlib: 'jqueryui ',
112+ theme: 'bootstrap3 ',
113+ iconlib: 'fontawesome4 ',
109114 keep_oneof_values: false,
110115 ajax: true
111116 }
@@ -120,11 +125,18 @@ public function getEditor($subtype = NULL,
120125</script>
121126HTML ;
122127
123- // @todo Toggle based on developer settings.
124- drupal_add_js (drupal_get_path ('module ' , 'patternkit ' )
125- . '/js/jsoneditor.js ' );
126-
127- return $ markup ;
128+ return array (
129+ '#type ' => 'markup ' ,
130+ '#markup ' => $ markup ,
131+ '#attached ' => array (
132+ 'library ' => array (
133+ array ('system ' , 'ui ' ),
134+ ),
135+ 'js ' => array (
136+ drupal_get_path ('module ' , 'patternkit ' ) . '/js/jsoneditor.js ' ,
137+ ),
138+ ),
139+ );
128140 }
129141
130142 /**
0 commit comments