Sha256: 74ea863dd5392b6db9a04a94a5dd60bb4f5719f21b81dfd1acf6c98df3150dfd

Contents?: true

Size: 1.85 KB

Versions: 4

Compression:

Stored size: 1.85 KB

Contents

Trix.registerElement "trix-inspector",
  defaultCSS: """
    %t {
      position: fixed;
      background: #fff;
      border: 1px solid #444;
      border-radius: 5px;
      padding: 10px;
      font-family: sans-serif;
      font-size: 12px;
      overflow: auto;
      word-wrap: break-word;
    }

    %t details {
      margin-bottom: 10px;
    }

    %t summary:focus {
      outline: none;
    }

    %t details .panel {
      padding: 10px;
    }

    %t .performance .metrics {
      margin: 0 0 5px 5px;
    }

    %t .selection .characters {
      margin-top: 10px;
    }

    %t .selection .character {
      display: inline-block;
      font-size: 8px;
      font-family: courier, monospace;
      line-height: 10px;
      vertical-align: middle;
      text-align: center;
      width: 10px;
      height: 10px;
      margin: 0 1px 1px 0;
      border: 1px solid #333;
      border-radius: 1px;
      background: #676666;
      color: #fff;
    }

    %t .selection .character.selected {
      background: yellow;
      color: #000;
    }
  """

  attachedCallback: ->
    @editorElement = document.querySelector("trix-editor[trix-id='#{@dataset.trixId}']")
    @views = @createViews()

    for view in @views
      view.render()
      @appendChild(view.element)

    @reposition()

    @resizeHandler = @reposition.bind(this)
    addEventListener("resize", @resizeHandler)

  detachedCallback: ->
    removeEventListener("resize", @resizeHandler)

  createViews: ->
    views = for View in Trix.Inspector.views
      new View @editorElement

    views.sort (a, b) ->
      a.title.toLowerCase() > b.title.toLowerCase()

  reposition: ->
    {top, right} = @editorElement.getBoundingClientRect()

    @style.top = "#{top}px"
    @style.left = "#{right + 10}px"
    @style.maxWidth = "#{window.innerWidth - right - 40}px"
    @style.maxHeight = "#{window.innerHeight - top - 30}px"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vapid-0.1.3 lib/vapid/vendor/trix/src/trix/inspector/element.coffee
vapid-0.1.2 lib/vapid/vendor/trix/src/trix/inspector/element.coffee
vapid-0.1.1 lib/vapid/vendor/trix/src/trix/inspector/element.coffee
vapid-0.1.0 lib/vapid/vendor/trix/src/trix/inspector/element.coffee