@@ -86,8 +86,13 @@ public function getEditor($subtype = NULL,
86
86
: $ config ;
87
87
// @todo Move to own JS file & Drupal Settings config var.
88
88
$ markup = <<<HTML
89
- <div id="editor_holder "></div>
89
+ <div id="magic-pixie-dust "></div>
90
90
<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
+
91
96
var data = {};
92
97
data.schema = $ schema_json;
93
98
data.starting = $ starting_json;
@@ -102,10 +107,10 @@ public function getEditor($subtype = NULL,
102
107
103
108
// Initialize the editor with a JSON schema
104
109
var editor = new JSONEditor(
105
- document .getElementById('editor_holder'), {
110
+ target.shadowRoot .getElementById('editor_holder'), {
106
111
schema: data.schema,
107
- theme: 'jqueryui ',
108
- iconlib: 'jqueryui ',
112
+ theme: 'bootstrap3 ',
113
+ iconlib: 'fontawesome4 ',
109
114
keep_oneof_values: false,
110
115
ajax: true
111
116
}
@@ -120,11 +125,18 @@ public function getEditor($subtype = NULL,
120
125
</script>
121
126
HTML ;
122
127
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
+ );
128
140
}
129
141
130
142
/**
0 commit comments