substance / surface

A building block for web-based text editors

Home Page:http://sandbox.substance.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Annotations visibility

vectorsize opened this issue · comments

Add a visibility parameter per annotations to for example display a certain type of annotation upon instantiation.

 this.surface = new Substance.Surface({
      el: this.$('.content')[0],
      content: this.model.content,
      annotations: annotations,
      types: {
         "em": {
            "inclusive": true,
            "visibility" : 'both' // active / inactive
         },
         "mark-1": {
           "inclusive": false,
            "visibility" : 'active' // both / inactive
         }
      }
    });

First quick implementation ready

Tested it with the composer and realized we need something slightly different.

Here's why: If i click on the surface to see the annotations, then enter a comment on the right side (the surface gets deactivated) the markers disappear... But what we actually want is markers to be displayed for the current node selection (even if the surface does not have the focus).

I just realized I could implement this without any logic, just by setting the css rules appropriately.

So our markers should only show up for selected nodes. As easy as that. :)

.content-node.selected .idea { background-color: rgba(171, 201, 36, 0.3); }
.content-node.selected .blur { background-color: rgba(16, 167, 222, 0.3); }
.content-node.selected .doubt { background-color: rgba(237, 96, 48, 0.3); }

Let me check how this works.

Haha. Works like a charm. So simple :P

Okay.. sorry for that.. I think we should remove that functionality completely.. and show all annotations all the time. Or in other words (just assign the classes) and leave the display part to the application (CSS). That's a hint that should go into the documentation.