mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-07-30 08:08:03 -05:00
Following changes done for the framework: - Framework for creating React based dynamic form view out of a pre-defined UI schema. Previously, it was based on Backform/Backbone. - The new framework and components will use MaterialUI as the base. Previously, Bootstrap/Backform/jQuery components were used. - The new code uses JSS instead of CSS since material UI and most modern React libraries also use JSS. In the future, this will allow us to change the theme in real-time without refresh. - 90% code covered by 80-85 new jasmine test cases. - Server group node UI Schema migration to new, with schema test cases. - Server node UI Schema migration to new, with schema test cases. - Database node UI Schema migration to new, with schema test cases. - Few other UI changes. Fixes #6130
41 lines
1.0 KiB
React
41 lines
1.0 KiB
React
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2021, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import React, { useEffect, useRef } from 'react';
|
|
import {default as OrigCodeMirror} from 'bundled_codemirror';
|
|
import PropTypes from 'prop-types';
|
|
|
|
/* React wrapper for CodeMirror */
|
|
export default function CodeMirror({name, value, options}) {
|
|
const taRef = useRef();
|
|
const cmObj = useRef();
|
|
|
|
useEffect(()=>{
|
|
/* Create the object only once on mount */
|
|
cmObj.current = new OrigCodeMirror.fromTextArea(
|
|
taRef.current, options);
|
|
}, []);
|
|
|
|
useEffect(()=>{
|
|
/* Refresh when value changes */
|
|
if(cmObj.current) {
|
|
cmObj.current.setValue(value);
|
|
cmObj.current.refresh();
|
|
}
|
|
}, [value]);
|
|
|
|
return <textarea ref={taRef} name={name} />;
|
|
}
|
|
|
|
CodeMirror.propTypes = {
|
|
name: PropTypes.string,
|
|
value: PropTypes.string,
|
|
options: PropTypes.object
|
|
};
|