Previously there was too much work proofreading text, new implementation provides a single shortcut and easy way of proofreading text. Co-authored-by: Martin Brennan <[email protected]>
38 lines
938 B
JavaScript
38 lines
938 B
JavaScript
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
import ModalDiffModal from "../discourse/components/modal/diff-modal";
|
|
|
|
function initializeProofread(api) {
|
|
api.addComposerToolbarPopupMenuOption({
|
|
action: (toolbarEvent) => {
|
|
const modal = api.container.lookup("service:modal");
|
|
|
|
modal.show(ModalDiffModal, {
|
|
model: {
|
|
toolbarEvent,
|
|
},
|
|
});
|
|
},
|
|
icon: "spell-check",
|
|
label: "discourse_ai.ai_helper.context_menu.proofread_prompt",
|
|
shortcut: "ALT+P",
|
|
condition: () => {
|
|
const siteSettings = api.container.lookup("service:site-settings");
|
|
const currentUser = api.getCurrentUser();
|
|
|
|
return (
|
|
siteSettings.ai_helper_enabled && currentUser?.can_use_assistant_in_post
|
|
);
|
|
},
|
|
});
|
|
}
|
|
|
|
export default {
|
|
name: "discourse-ai-helper",
|
|
|
|
initialize() {
|
|
withPluginApi("1.1.0", (api) => {
|
|
initializeProofread(api);
|
|
});
|
|
},
|
|
};
|