refactor: move create state to editorHelper

This commit is contained in:
Shivam Mishra
2024-05-09 17:20:14 +05:30
parent eff24c0d71
commit 55b6e5fbf6
2 changed files with 25 additions and 23 deletions
@@ -2,7 +2,10 @@ import {
messageSchema,
MessageMarkdownTransformer,
MessageMarkdownSerializer,
buildEditor,
EditorState,
} from '@chatwoot/prosemirror-schema';
import * as Sentry from '@sentry/browser';
/**
@@ -281,3 +284,24 @@ export function setURLWithQueryAndSize(selectedImageNode, size, editorView) {
}
}
}
export const createState = (
content,
placeholder,
// eslint-disable-next-line default-param-last
plugins = [],
// eslint-disable-next-line default-param-last
methods = {},
enabledMenuOptions
) => {
return EditorState.create({
doc: new MessageMarkdownTransformer(messageSchema).parse(content),
plugins: buildEditor({
schema: messageSchema,
placeholder,
methods,
plugins,
enabledMenuOptions,
}),
});
};