Skip to content
Snippets Groups Projects
Commit 96547eb1 authored by chris's avatar chris
Browse files

find sections

parent aa74e364
No related branches found
No related tags found
1 merge request!407Hhmi fixes
......@@ -102,7 +102,12 @@ const WaxView = forwardRef((props, ref) => {
'main',
);
if (debug) applyDevTools(view);
if (autoFocus && view) view.focus();
if (autoFocus && view)
setTimeout(() => {
view.focus();
view.state.tr.insertText('', 0);
view.dispatch(view.state.tr);
}, 500);
return () => view.destroy();
}
......
......@@ -4,7 +4,6 @@ import { WaxContext } from 'wax-prosemirror-core';
import { DOMParser } from 'prosemirror-model';
import { ReplaceStep, ReplaceAroundStep } from 'prosemirror-transform';
import { Selection } from 'prosemirror-state';
import { v4 as uuidv4 } from 'uuid';
import styled from 'styled-components';
import { Icon } from 'wax-prosemirror-components';
......@@ -70,15 +69,22 @@ export default ({ setPosition, position }) => {
setPosition({ ...position, left, top });
}, [position.left]);
useEffect(() => {}, []);
const generateHeadings = () => {
const {
tr,
selection: { from, to },
doc,
} = main.state;
const parser = DOMParser.fromSchema(main.state.config.schema);
const allSections = [];
doc.descendants((editorNode, index) => {
if (Node.type.name === 'oen_section') {
allSections.push(editorNode);
}
});
const content =
'<h1>heading when i click note</h1><p>some text when i click note</p>';
const parsedContent = parser.parse(elementFromString(content));
......@@ -88,6 +94,10 @@ export default ({ setPosition, position }) => {
};
if (!readOnly) {
return <button onClick={generateHeadings}>generate</button>;
return (
<button onClick={generateHeadings} type="button">
generate
</button>
);
}
};
......@@ -57,7 +57,6 @@ export default options => {
const PMnode = focusedView.state.schema.nodes[nodeType];
node = DocumentHelpers.findNode(focusedView.state, PMnode, findInParent);
console.log(node);
if (!isObject(node)) return defaultOverlay;
const { from, to } = followCursor ? focusedView.state.selection : node;
......
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