From f0b5d7722ad3afac9f168b678a00ed864c0faf69 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Thu, 29 Feb 2024 10:31:27 +0200 Subject: [PATCH] set comments into context --- wax-prosemirror-core/src/WaxContext.js | 2 +- .../src/AiService/components/ToggleAiComponent.js | 11 +++++++++-- .../src/CommentsService/CommentsService.js | 7 +++++-- .../src/CommentsService/components/RightArea.js | 3 ++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/wax-prosemirror-core/src/WaxContext.js b/wax-prosemirror-core/src/WaxContext.js index 4d3ee58f9..d97ec379c 100644 --- a/wax-prosemirror-core/src/WaxContext.js +++ b/wax-prosemirror-core/src/WaxContext.js @@ -18,7 +18,7 @@ export default props => { pmViews: props.view || {}, activeView: props.activeView || {}, activeViewId: props.activeViewId || {}, - options: { fullScreen: false, AiOn: false }, + options: { fullScreen: false }, transaction: {}, setTransaction: tr => { Object.assign(context.transaction, tr); diff --git a/wax-prosemirror-services/src/AiService/components/ToggleAiComponent.js b/wax-prosemirror-services/src/AiService/components/ToggleAiComponent.js index 6575a79f9..b730ea076 100644 --- a/wax-prosemirror-services/src/AiService/components/ToggleAiComponent.js +++ b/wax-prosemirror-services/src/AiService/components/ToggleAiComponent.js @@ -37,13 +37,20 @@ const ToggleAiComponent = ({ item }) => { enableService.AiOn ? ( <MenuButton active={checked} - disabled={!isEditable} + disabled={ + !isEditable || main.state.selection.from === main.state.selection.to + } iconName={item.icon} onMouseDown={onMouseDown} title={item.title} /> ) : null, - [checked, isDisabled, enableService.AiOn], + [ + checked, + isDisabled, + enableService.AiOn, + main.state.selection.from === main.state.selection.to, + ], ); }; diff --git a/wax-prosemirror-services/src/CommentsService/CommentsService.js b/wax-prosemirror-services/src/CommentsService/CommentsService.js index 5a6454014..5bf33affe 100644 --- a/wax-prosemirror-services/src/CommentsService/CommentsService.js +++ b/wax-prosemirror-services/src/CommentsService/CommentsService.js @@ -12,7 +12,7 @@ const PLUGIN_KEY = 'commentPlugin'; export default class CommentsService extends Service { boot() { const commentsConfig = this.app.config.get('config.CommentsService'); - console.log(commentsConfig); + this.app.PmPlugins.add(PLUGIN_KEY, CommentPlugin(PLUGIN_KEY)); this.app.PmPlugins.add( 'copyPasteCommentPlugin', @@ -21,7 +21,10 @@ export default class CommentsService extends Service { const options = { styles: {}, - onSelectionChange: items => commentsConfig.getComments(items), + onSelectionChange: items => { + commentsConfig.getComments(items); + this.app.context.setOption({ comments: items }); + }, onAnnotationListChange: () => true, document: '', field: 'annotations', diff --git a/wax-prosemirror-services/src/CommentsService/components/RightArea.js b/wax-prosemirror-services/src/CommentsService/components/RightArea.js index d3644d9b5..59e3b81f1 100644 --- a/wax-prosemirror-services/src/CommentsService/components/RightArea.js +++ b/wax-prosemirror-services/src/CommentsService/components/RightArea.js @@ -12,8 +12,9 @@ export default ({ area, users }) => { pmViews: { main }, app, activeView, + options, } = useContext(WaxContext); - + console.log(options); const commentPlugin = app.PmPlugins.get('commentPlugin'); const trakChangePlugin = app.PmPlugins.get('trackChangePlugin'); -- GitLab