Skip to content
Snippets Groups Projects
Commit 7ac684c9 authored by chris's avatar chris
Browse files

update title

parent dc23f59d
No related branches found
No related tags found
1 merge request!215set id
/* eslint react/prop-types: 0 */ /* eslint react/prop-types: 0 */
import React, { useContext, useMemo } from 'react'; import React, { useContext, useMemo, useEffect } from 'react';
import { WaxContext } from 'wax-prosemirror-core'; import { WaxContext } from 'wax-prosemirror-core';
import { DocumentHelpers } from 'wax-prosemirror-utilities'; import { DocumentHelpers } from 'wax-prosemirror-utilities';
import MenuButton from '../ui/buttons/MenuButton'; import MenuButton from '../ui/buttons/MenuButton';
...@@ -18,18 +18,26 @@ const TitleButton = ({ view = {}, item }) => { ...@@ -18,18 +18,26 @@ const TitleButton = ({ view = {}, item }) => {
const { dispatch, state } = view; const { dispatch, state } = view;
const handleMouseDown = (e, editorState, editorDispatch) => {
e.preventDefault();
run(editorState, dispatch);
};
const titleNode = DocumentHelpers.findChildrenByType( const titleNode = DocumentHelpers.findChildrenByType(
state.doc, state.doc,
state.config.schema.nodes.title, state.config.schema.nodes.title,
true, true,
); );
console.log(titleNode, app.config.get('config.TitleService')); const handleMouseDown = (e, editorState, editorDispatch) => {
e.preventDefault();
run(editorState, dispatch);
};
const serviceConfig = app.config.get('config.TitleService');
useEffect(() => {
if (titleNode[0]) {
serviceConfig.updateTitle(titleNode[0].node.textContent);
} else {
serviceConfig.updateTitle('');
}
}, [JSON.stringify(titleNode[0])]);
const isActive = !!active(state, activeViewId); const isActive = !!active(state, activeViewId);
const isDisabled = !select(state, activeViewId, activeView); const isDisabled = !select(state, activeViewId, activeView);
......
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