diff --git a/ui-ngx/src/app/shared/components/json-form/json-form.component.html b/ui-ngx/src/app/shared/components/json-form/json-form.component.html
index 85bb0a71b8..e709307e90 100644
--- a/ui-ngx/src/app/shared/components/json-form/json-form.component.html
+++ b/ui-ngx/src/app/shared/components/json-form/json-form.component.html
@@ -15,8 +15,9 @@
limitations under the License.
-->
-
diff --git a/ui-ngx/src/app/shared/components/json-form/json-form.component.ts b/ui-ngx/src/app/shared/components/json-form/json-form.component.ts
index fa8b9b3427..5d28c12247 100644
--- a/ui-ngx/src/app/shared/components/json-form/json-form.component.ts
+++ b/ui-ngx/src/app/shared/components/json-form/json-form.component.ts
@@ -73,6 +73,9 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato
@ViewChild('reactRoot', {static: true})
reactRootElmRef: ElementRef;
+ @ViewChild('reactFullscreen', {static: true})
+ reactFullscreenElmRef: ElementRef;
+
private readonlyValue: boolean;
get readonly(): boolean {
return this.readonlyValue;
@@ -106,8 +109,7 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato
isModelValid = true;
isFullscreen = false;
- targetFullscreenElement: HTMLElement;
- fullscreenFinishFn: () => void;
+ fullscreenFinishFn: (el: Element) => void;
private propagateChange = null;
private propagateChangePending = false;
@@ -233,8 +235,7 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato
});
}
- private onToggleFullscreen(element: HTMLElement, fullscreenFinishFn?: () => void) {
- this.targetFullscreenElement = element;
+ private onToggleFullscreen(fullscreenFinishFn?: (el: Element) => void) {
this.isFullscreen = !this.isFullscreen;
this.fullscreenFinishFn = fullscreenFinishFn;
this.cd.markForCheck();
@@ -244,7 +245,7 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato
this.formProps.isFullscreen = fullscreen;
this.renderReactSchemaForm(false);
if (this.fullscreenFinishFn) {
- this.fullscreenFinishFn();
+ this.fullscreenFinishFn(this.reactFullscreenElmRef.nativeElement);
this.fullscreenFinishFn = null;
}
}
diff --git a/ui-ngx/src/app/shared/components/json-form/react/json-form-ace-editor.tsx b/ui-ngx/src/app/shared/components/json-form/react/json-form-ace-editor.tsx
index 12879d1fae..1ae375908f 100644
--- a/ui-ngx/src/app/shared/components/json-form/react/json-form-ace-editor.tsx
+++ b/ui-ngx/src/app/shared/components/json-form/react/json-form-ace-editor.tsx
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import * as React from 'react';
+import * as ReactDOM from 'react-dom';
import ThingsboardBaseComponent from './json-form-base-component';
import reactCSS from 'reactcss';
import Button from '@material-ui/core/Button';
@@ -42,6 +43,7 @@ interface ThingsboardAceEditorProps extends JsonFormFieldProps {
interface ThingsboardAceEditorState extends JsonFormFieldState {
isFull: boolean;
+ fullscreenContainerElement: Element;
helpVisible: boolean;
helpReady: boolean;
focused: boolean;
@@ -49,7 +51,6 @@ interface ThingsboardAceEditorState extends JsonFormFieldState {
class ThingsboardAceEditor extends React.Component {
- hostElement: HTMLElement;
private aceEditor: IEditorProps;
constructor(props) {
@@ -64,6 +65,7 @@ class ThingsboardAceEditor extends React.Component {
- if (this.aceEditor) {
- this.aceEditor.resize();
- this.aceEditor.renderer.updateFull();
- }
+ this.props.onToggleFullscreen((el) => {
+ this.setState({ isFull: !this.state.isFull, fullscreenContainerElement: el });
});
}
@@ -177,56 +175,61 @@ class ThingsboardAceEditor extends React.Component
- (this.hostElement = c)}>
-
-
-
-
-
- { this.props.onTidy ?
: null }
- { this.props.form.helpId ?
-
- {this.state.helpVisible ? : }
-
- { this.state.helpVisible && !this.state.helpReady ?
-
-
-
: null }
: null }
-
-
-
Loading...}>
-
-
-
-
{this.props.error}
+ const formDom = (
+
+
+
+
+
+ { this.props.onTidy ?
: null }
+ { this.props.form.helpId ?
+
+ {this.state.helpVisible ? : }
+
+ { this.state.helpVisible && !this.state.helpReady ?
+
+
+
: null }
: null }
+
+
Loading...}>
+
+
+
{this.props.error}
);
+ if (this.state.isFull) {
+ return ReactDOM.createPortal(formDom, this.state.fullscreenContainerElement);
+ } else {
+ return (
+
+ {formDom}
+
+ );
+ }
}
}
diff --git a/ui-ngx/src/app/shared/components/json-form/react/json-form-schema-form.tsx b/ui-ngx/src/app/shared/components/json-form/react/json-form-schema-form.tsx
index 782ac11ef8..e600e8b6fa 100644
--- a/ui-ngx/src/app/shared/components/json-form/react/json-form-schema-form.tsx
+++ b/ui-ngx/src/app/shared/components/json-form/react/json-form-schema-form.tsx
@@ -106,8 +106,8 @@ class ThingsboardSchemaForm extends React.Component {
this.props.onIconClick(key, val, iconSelectedFn);
}
- onToggleFullscreen(element: HTMLElement, fullscreenFinishFn?: () => void) {
- this.props.onToggleFullscreen(element, fullscreenFinishFn);
+ onToggleFullscreen(fullscreenFinishFn?: (el: Element) => void) {
+ this.props.onToggleFullscreen(fullscreenFinishFn);
}
onHelpClick(event: MouseEvent, helpId: string, helpVisibleFn: (visible: boolean) => void, helpReadyFn: (ready: boolean) => void) {
diff --git a/ui-ngx/src/app/shared/components/json-form/react/json-form.models.ts b/ui-ngx/src/app/shared/components/json-form/react/json-form.models.ts
index e36b36010b..b170bacb28 100644
--- a/ui-ngx/src/app/shared/components/json-form/react/json-form.models.ts
+++ b/ui-ngx/src/app/shared/components/json-form/react/json-form.models.ts
@@ -48,7 +48,7 @@ export type OnColorClickFn = (key: (string | number)[], val: tinycolor.ColorForm
colorSelectedFn: (color: tinycolor.ColorFormats.RGBA) => void) => void;
export type OnIconClickFn = (key: (string | number)[], val: string,
iconSelectedFn: (icon: string) => void) => void;
-export type onToggleFullscreenFn = (element: HTMLElement, fullscreenFinishFn?: () => void) => void;
+export type onToggleFullscreenFn = (fullscreenFinishFn?: (el: Element) => void) => void;
export type onHelpClickFn = (event: MouseEvent, helpId: string, helpVisibleFn: (visible: boolean) => void,
helpReadyFn: (ready: boolean) => void) => void;