Skip to content

Commit

Permalink
[#65723] Use if method
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejWas committed Sep 13, 2024
1 parent 7af505d commit 69650ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
13 changes: 4 additions & 9 deletions src/components/CodeMirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,10 @@ const CodeMirror = ({ text, id, root, mode, spellcheckOpts, highlights, collabor
.useHighlighter(highlights)
.useCompartment(suggestionCompartment, customHighlighter([]))
.useSpellcheck(spellcheckOpts)
.useCollaboration({
enabled: collaboration.opts.enabled || false,
ytext: collaboration.ytext,
undoManager: collaboration.undoManager,
provider: collaboration.provider,
editorRef,
})
.useComments({ enabled: collaboration.opts.commentsEnabled, ycomments: collaboration.ycomments })
.useSuggestionPopup({ enabled: collaboration.opts.commentsEnabled, ycomments: collaboration.ycomments, editorMountpoint })
.if(collaboration.opts.enabled, (b) => b.useCollaboration({ ...collaboration, editorRef }))
.if(collaboration.opts.commentsEnabled, (b) =>
b.useComments({ ycomments: collaboration.ycomments }).useSuggestionPopup({ ycomments: collaboration.ycomments, editorMountpoint }),
)
.addUpdateListener((update) => update.docChanged && text.set(view.state.doc.toString(), update))
.useFixFoldingScroll(focusScroll)
.useMoveCursorAfterFold()
Expand Down
13 changes: 4 additions & 9 deletions src/extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ export class ExtensionBuilder {
return this;
}

useComments({ enabled, ycomments }) {
if (!enabled) return this;
useComments({ ycomments }) {
this.important.push(commentExtension(ycomments));
return this;
}
Expand Down Expand Up @@ -127,9 +126,7 @@ export class ExtensionBuilder {
return this;
}

useCollaboration({ enabled = true, ytext, provider, undoManager, editorRef }) {
if (!enabled) return this;

useCollaboration({ ytext, provider, undoManager, editorRef }) {
this.extensions.push(yCollab(ytext, provider.awareness, { undoManager }));

if (undoManager) {
Expand All @@ -151,10 +148,8 @@ export class ExtensionBuilder {
return this;
}

useSuggestionPopup({ enabled, ycomments, editorMountpoint }) {
if (enabled) {
this.base.push(EditorView.updateListener.of((update) => suggestionPopup(update, ycomments, editorMountpoint)));
}
useSuggestionPopup({ ycomments, editorMountpoint }) {
this.base.push(EditorView.updateListener.of((update) => suggestionPopup(update, ycomments, editorMountpoint)));
return this;
}

Expand Down

0 comments on commit 69650ea

Please sign in to comment.