Skip to content

Json components height #1091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 8, 2024
Prev Previous commit
Next Next commit
duplicate editor data fixed
  • Loading branch information
MenamAfzal committed Aug 7, 2024
commit 46c6887ff71d16fff3c3f9367e1970e28d2634a9
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ let JsonEditorTmpComp = (function () {

const wrapperRef = useRef<HTMLDivElement>(null);
const view = useRef<EditorViewType | null>(null);
const initialized = useRef(false);
const state = useRef<EditorState | null>(null);
const editContent = useRef<string>();
const { extensions } = useExtensions({
codeType: "PureJSON",
Expand All @@ -102,21 +104,20 @@ let JsonEditorTmpComp = (function () {
});

useEffect(() => {
if (wrapperRef.current && !view.current) {
const state = EditorState.create({
if (!initialized.current && wrapperRef.current) {
state.current = EditorState.create({
doc: JSON.stringify(props.value.value, null, 2),
extensions,
});
view.current = new EditorView({state, parent: wrapperRef.current});
}
if (wrapperRef.current&&(props.showVerticalScrollbar||!props.showVerticalScrollbar)) {
const state = EditorState.create({
doc: JSON.stringify(props.value.value, null, 2),
extensions,
});
view.current = new EditorView({state, parent: wrapperRef.current});
}
}, [wrapperRef.current, props.showVerticalScrollbar]);

useEffect(() => {
if (state.current&&wrapperRef.current) {
view.current = new EditorView({ state: state.current, parent: wrapperRef.current });
initialized.current = true;
}
}, [props.showVerticalScrollbar])

if (wrapperRef.current && view.current && !editContent.current) {
const state = EditorState.create({
Expand Down
Loading