Newer
Older
import { isEmpty } from 'lodash';
import { useTranslation } from 'react-i18next';
import { WaxContext, DocumentHelpers, MenuButton } from 'wax-prosemirror-core';
activeViewId,
activeView,
} = useContext(WaxContext);
const { dispatch, state } = view;
const titleNode = DocumentHelpers.findChildrenByType(
state.doc,
state.config.schema.nodes.title,
true,
);
e.preventDefault();
run(editorState, dispatch);
};
const serviceConfig = app.config.get('config.TitleService');
let chapterTitle = '';
if (titleNode[0]) chapterTitle = titleNode[0].node.textContent;
let isDisabled = !select(state, activeViewId, activeView);
const isEditable = main.props.editable(editable => {
return editable;
});
if (!isEditable) isDisabled = true;
const TitleButtonComponent = useMemo(
() => (
<MenuButton
active={isActive || false}
disabled={isDisabled}
iconName={icon}
label={
!isEmpty(i18n) && i18n.exists(`Wax.BlockLevel.${label}`)
? t(`Wax.BlockLevel.${label}`)
: label
}
onMouseDown={e => handleMouseDown(e, view.state, view.dispatch)}
title={
!isEmpty(i18n) && i18n.exists(`Wax.BlockLevel.${title}`)
? t(`Wax.BlockLevel.${title}`)
: title
}