From 0e9fd2ea0954097d2b7094555e0ec0d29bbc4ed5 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Sun, 16 Apr 2017 03:32:55 +0300 Subject: [PATCH] find blockposition for comments in notes editor so they render correclty --- app/components/SimpleEditor/Editor.js | 1 + .../SimpleEditor/panes/Comments/CommentBoxList.js | 2 +- .../panes/Comments/CommentsProvider.js | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/components/SimpleEditor/Editor.js b/app/components/SimpleEditor/Editor.js index 25460f1..87d1d91 100644 --- a/app/components/SimpleEditor/Editor.js +++ b/app/components/SimpleEditor/Editor.js @@ -272,6 +272,7 @@ class Editor extends ProseEditor { containerId: this.props.containerId, controller: this, editorSession: this.editorSession, + notesProvider: notesProvider, fragment: this.props.fragment, surfaceManager: this.surfaceManager, toggleCommentsArea: this.toggleCommentsArea, diff --git a/app/components/SimpleEditor/panes/Comments/CommentBoxList.js b/app/components/SimpleEditor/panes/Comments/CommentBoxList.js index 90f1ca8..1cc7199 100644 --- a/app/components/SimpleEditor/panes/Comments/CommentBoxList.js +++ b/app/components/SimpleEditor/panes/Comments/CommentBoxList.js @@ -74,7 +74,7 @@ class CommentBoxList extends Component { const entries = provider.computeEntries() const activeEntry = provider.activeEntry - + console.log(entries) this.calculateTops(entries, activeEntry) } // TODO move to helper section?? diff --git a/app/components/SimpleEditor/panes/Comments/CommentsProvider.js b/app/components/SimpleEditor/panes/Comments/CommentsProvider.js index 9767f19..ba90522 100644 --- a/app/components/SimpleEditor/panes/Comments/CommentsProvider.js +++ b/app/components/SimpleEditor/panes/Comments/CommentsProvider.js @@ -282,6 +282,10 @@ class CommentsProvider extends TocProvider { return surfaceManager.getSurface(containerId) } + getMiniDocument () { + return this.config.controller.context.notesProvider.config.miniEditorSession.document + } + isSelectionLargerThanComments () { const commentBorders = this.getCommentBorders() if (!commentBorders) return false @@ -377,12 +381,21 @@ class CommentsProvider extends TocProvider { var doc = this.getDocument() var container = doc.get('body') + let docMini = '' + let containerMini = '' + + if (this.config.controller.context.notesProvider) { + docMini = this.getMiniDocument() + } + if (docMini) containerMini = docMini.get('mini') + // sort notes by // the index of the containing block // their position within that block comments = _.map(comments, function (comment) { const blockId = comment.path[0] - const blockPosition = container.getPosition(blockId) + let blockPosition = container.getPosition(blockId) + if (blockPosition === -1) blockPosition = containerMini.getPosition(blockId) const nodePosition = comment.start.offset return { -- GitLab