Skip to content
Snippets Groups Projects
Commit a848bd95 authored by victor mutai's avatar victor mutai
Browse files

chore: handle readonly mode

parent 276f9fcd
No related branches found
No related tags found
1 merge request!540Allow book owner to set AI use
import React, { useContext } from 'react'; import React, { useContext, useMemo } from 'react';
import { WaxContext, MenuButton } from 'wax-prosemirror-core'; import { WaxContext, MenuButton } from 'wax-prosemirror-core';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
const ToggleAiComponent = ({ item }) => { const ToggleAiComponent = ({ item }) => {
const { app } = useContext(WaxContext); const { app, pmViews } = useContext(WaxContext);
const enableService = app.config.get('config.AskAiContentService'); const enableService = app.config.get('config.AskAiContentService');
return enableService.AiOn ? ( let isDisabled = false;
<MenuButton const { main } = pmViews;
active={false} const isEditable = main.props.editable(editable => {
disabled={false} return editable;
iconName={item.icon} });
title={item.title}
/> if (!isEditable) isDisabled = true;
) : null;
return useMemo(
() =>
enableService.AiOn ? (
<MenuButton
active={false}
disabled={!isEditable}
iconName={item.icon}
title={item.title}
/>
) : null,
[enableService.AiOn, isDisabled],
);
}; };
ToggleAiComponent.propTypes = { ToggleAiComponent.propTypes = {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment