Skip to content
Snippets Groups Projects
Commit 14ef6ee2 authored by chris's avatar chris
Browse files

display on outline node

parent ae585622
No related branches found
No related tags found
1 merge request!407Hhmi fixes
......@@ -52,6 +52,7 @@ class OENContainersService extends Service {
{},
{
nodeType: 'oen_container',
findInParent: true,
markType: '',
followCursor: false,
selection: false,
......
......@@ -21,7 +21,7 @@ export default options => {
});
let mark = {};
let node = {};
let node = '';
/* Sets Default position at the end of the annotation. You
can overwrite the default position in your component.
Check: wax-prosemirror-components/src/components/comments/CommentBubbleComponent.js
......@@ -53,11 +53,11 @@ export default options => {
};
const displayOnNode = (focusedView, overlayOptions) => {
const { nodeType, followCursor } = overlayOptions;
const { nodeType, followCursor, findInParent } = overlayOptions;
const PMnode = focusedView.state.schema.nodes[nodeType];
node = DocumentHelpers.findNode(focusedView.state, PMnode);
console.log('here', node, PMnode);
node = DocumentHelpers.findNode(focusedView.state, PMnode, findInParent);
console.log(node);
if (!isObject(node)) return defaultOverlay;
const { from, to } = followCursor ? focusedView.state.selection : node;
......
......@@ -27,10 +27,25 @@ const findMark = (state, PMmark, toArr = false) => {
return markFound;
};
const findNode = (state, PMnode, parent = true) => {
const findNode = (state, PMnode, findInParent) => {
let nodeFound;
if (parent) {
if (findInParent) {
state.doc.nodesBetween(
state.selection.from,
state.selection.to,
(node, pos) => {
if (
node.type.name === 'oen_container' &&
node.attrs.class === 'outline'
) {
nodeFound = {
from: state.selection.from,
to: state.selection.to,
node,
};
}
},
);
} else if (
state.selection.node &&
state.selection.node.type.name === PMnode.name
......
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