diff --git a/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.js b/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.js index 6bb40500..02f70b64 100644 --- a/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.js +++ b/assets/javascripts/discourse/connectors/after-d-editor/ai-helper-context-menu.js @@ -275,6 +275,11 @@ export default class AiHelperContextMenu extends Component { @afterRender positionContextMenu() { this._contextMenu = document.querySelector(".ai-helper-context-menu"); + + if (!this._dEditorInput || !this._contextMenu) { + return; + } + this.caretCoords = getCaretPosition(this._dEditorInput, { pos: caretPosition(this._dEditorInput), }); diff --git a/assets/javascripts/discourse/lib/show-ai-helper.js b/assets/javascripts/discourse/lib/show-ai-helper.js index 2b54d9fd..d0c7563b 100644 --- a/assets/javascripts/discourse/lib/show-ai-helper.js +++ b/assets/javascripts/discourse/lib/show-ai-helper.js @@ -15,7 +15,7 @@ export function showComposerAIHelper(outletArgs, helper, featureType) { export function showPostAIHelper(outletArgs, helper) { return ( _helperEnabled(helper.siteSettings) && - helper.currentUser.can_use_assistant_in_post + helper.currentUser?.can_use_assistant_in_post ); }