Blame view

public/assets/addons/fastflow/plugins/codemirror/src/measurement/widgets.js 1.02 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  import { contains, elt, removeChildrenAndAdd } from "../util/dom"
  import { e_target } from "../util/event"
  
  export function widgetHeight(widget) {
    if (widget.height != null) return widget.height
    let cm = widget.doc.cm
    if (!cm) return 0
    if (!contains(document.body, widget.node)) {
      let parentStyle = "position: relative;"
      if (widget.coverGutter)
        parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"
      if (widget.noHScroll)
        parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"
      removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle))
    }
    return widget.height = widget.node.parentNode.offsetHeight
  }
  
  // Return true when the given mouse event happened in a widget
  export function eventInWidget(display, e) {
    for (let n = e_target(e); n != display.wrapper; n = n.parentNode) {
      if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
          (n.parentNode == display.sizer && n != display.mover))
        return true
    }
  }