Don't assume window.comments exists during Draftail init

This may break use of Draftail widgets in custom image models, where the usual editor js is not used.
pull/7288/head
Jacob Topp-Mugglestone 2021-06-22 10:37:43 +01:00
rodzic 688f022e48
commit 51c3c8cb40
1 zmienionych plików z 2 dodań i 3 usunięć
client/src/components/Draftail

Wyświetl plik

@ -114,8 +114,6 @@ const initEditor = (selector, options, currentScript) => {
enableHorizontalRule
};
const contentPath = window.comments.getContentPath(field);
const styles = getComputedStyle(document.documentElement);
const colors = {
standardHighlight: styles.getPropertyValue('--color-primary-light'),
@ -125,7 +123,8 @@ const initEditor = (selector, options, currentScript) => {
// If the field has a valid contentpath - ie is not an InlinePanel or under a ListBlock -
// and the comments system is initialized then use CommentableEditor, otherwise plain DraftailEditor
const editor = (window.comments.commentApp && contentPath !== '') ?
const contentPath = window.comments?.getContentPath(field) || '';
const editor = (window.comments?.commentApp && contentPath !== '') ?
<Provider store={window.comments.commentApp.store}>
<CommentableEditor
editorRef={editorRef}