Skip to content
Snippets Groups Projects
Commit 52955f28 authored by chris's avatar chris
Browse files

fix nested comments boxes and active

parent 9db75678
No related branches found
No related tags found
2 merge requests!548Merge yjs with standard comments,!545Overlapping comments
...@@ -68,7 +68,50 @@ const getComments = debounce(comments => { ...@@ -68,7 +68,50 @@ const getComments = debounce(comments => {
console.log(comments); console.log(comments);
}, 2000); }, 2000);
const setComments = (comments = []) => { const setComments = (
comments = [
{
id: 'a1',
from: 70,
to: 82,
data: {
type: 'comment',
conversation: [
{
content: '1111',
displayName: 'admin',
userId: 'b3cfc28e-0f2e-45b5-b505-e66783d4f946',
timestamp: 1710501980537,
},
],
title: '111',
group: 'main',
viewId: 'main',
},
endHeight: 362.3579406738281,
},
{
id: 'a2',
from: 63,
to: 92,
data: {
type: 'comment',
conversation: [
{
content: '222',
displayName: 'admin',
userId: 'b3cfc28e-0f2e-45b5-b505-e66783d4f946',
timestamp: 1710501987197,
},
],
title: '222',
group: 'main',
viewId: 'main',
},
endHeight: 266.3579406738281,
},
],
) => {
return comments; return comments;
}; };
......
...@@ -23,7 +23,6 @@ export default class CommentsService extends Service { ...@@ -23,7 +23,6 @@ export default class CommentsService extends Service {
); );
const options = { const options = {
styles: {},
existingComments: () => { existingComments: () => {
const map = new Map(); const map = new Map();
if (commentsConfig.setComments().length > 0) { if (commentsConfig.setComments().length > 0) {
......
...@@ -99,7 +99,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { ...@@ -99,7 +99,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
pmViews[viewId].dispatch( pmViews[viewId].dispatch(
pmViews[viewId].state.tr.setSelection( pmViews[viewId].state.tr.setSelection(
new TextSelection(pmViews[viewId].state.tr.doc.resolve(comment.to - 1)), new TextSelection(pmViews[viewId].state.tr.doc.resolve(comment.from)),
), ),
); );
......
...@@ -67,11 +67,18 @@ export default ({ area, users }) => { ...@@ -67,11 +67,18 @@ export default ({ area, users }) => {
// annotation top // annotation top
if (area === 'main') { if (area === 'main') {
markNodeEl = document.querySelector(`[data-id="${id}"]`); markNodeEl = document.querySelector(`[data-id="${id}"]`);
if (markNodeEl) if (!markNodeEl && marksNodes[area][pos - 1]) {
markNodeEl = document.querySelector(
`[data-id="${marksNodes[area][pos - 1].id}"]`,
);
}
if (markNodeEl) {
annotationTop = annotationTop =
markNodeEl.getBoundingClientRect().top - markNodeEl.getBoundingClientRect().top -
WaxSurface.top + WaxSurface.top +
parseInt(WaxSurfaceMarginTop.slice(0, -2), 10); parseInt(WaxSurfaceMarginTop.slice(0, -2), 10);
}
} else { } else {
// Notes // Notes
panelWrapper = document.getElementsByClassName('panelWrapper'); panelWrapper = document.getElementsByClassName('panelWrapper');
......
...@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid'; ...@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
import { Decoration, DecorationSet } from 'prosemirror-view'; import { Decoration, DecorationSet } from 'prosemirror-view';
import AnnotationDecoration from './AnnotationDecoration'; import AnnotationDecoration from './AnnotationDecoration';
import { AnnotationPluginKey } from './AnnotationPlugin'; import { AnnotationPluginKey } from './AnnotationPlugin';
let toPos = 0;
export default class AnnotationState { export default class AnnotationState {
constructor(options) { constructor(options) {
this.decorations = DecorationSet.empty; this.decorations = DecorationSet.empty;
...@@ -59,10 +59,9 @@ export default class AnnotationState { ...@@ -59,10 +59,9 @@ export default class AnnotationState {
} }
createDecorations(state) { createDecorations(state) {
const { map, styles } = this.options; const { map } = this.options;
const decorations = []; const decorations = [];
// only terms, not connectives, are rendered
const termList = Array.from(map, ([key, value]) => { const termList = Array.from(map, ([key, value]) => {
// eslint-disable-next-line prefer-object-spread // eslint-disable-next-line prefer-object-spread
return Object.assign(Object.assign({}, value), { id: key }); return Object.assign(Object.assign({}, value), { id: key });
...@@ -70,16 +69,8 @@ export default class AnnotationState { ...@@ -70,16 +69,8 @@ export default class AnnotationState {
return 'from' in value && 'to' in value; return 'from' in value && 'to' in value;
}); });
// const annotationRendering = createAnnotationRendering(termList);
termList.forEach(annotation => { termList.forEach(annotation => {
const { from, to } = annotation; const { from, to } = annotation;
// eslint-disable-next-line
// console.log(`[${this.options.instance}] Decoration.inline()`, from, to, {
// id: annotation.id,
// data: annotation,
// });
if (from === to) { if (from === to) {
console.warn( console.warn(
`[${this.options.instance}] corrupt decoration `, `[${this.options.instance}] corrupt decoration `,
......
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