feat: refactor tinymce editor to sharedComponents (#255)

This commit is contained in:
Kristin Aoki
2023-02-28 16:37:52 -05:00
committed by GitHub
parent e0c5573c8d
commit c65f60ec10
68 changed files with 1172 additions and 1014 deletions

View File

@@ -0,0 +1,27 @@
import { useRef } from 'react';
import * as module from './hooks';
export const getSaveBtnProps = ({ editorRef, ref, close }) => ({
onClick: () => {
if (editorRef && editorRef.current && ref && ref.current) {
const content = ref.current.state.doc.toString();
editorRef.current.setContent(content);
close();
}
},
});
export const prepareSourceCodeModal = ({ editorRef, close }) => {
const ref = useRef();
const saveBtnProps = module.getSaveBtnProps({ editorRef, ref, close });
if (editorRef && editorRef.current && typeof editorRef.current.getContent === 'function') {
const value = editorRef?.current?.getContent();
return { saveBtnProps, value, ref };
}
return { saveBtnProps, value: null, ref };
};
export default {
prepareSourceCodeModal,
};