General.Web/wwwroot/lib/codemirror-5.31.0/src/model/mark_text.js

(开头部分) 10KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

import { eltP } from "../util/dom"
import { eventMixin, hasHandler, on } from "../util/event"
import { endOperation, operation, runInOp, startOperation } from "../display/operations"
import { clipPos, cmp, Pos } from "../line/pos"
import { lineNo, updateLineHeight } from "../line/utils_line"
import { clearLineMeasurementCacheFor, findViewForLine, textHeight } from "../measurement/position_measurement"
import { seeReadOnlySpans, seeCollapsedSpans } from "../line/saw_special_spans"
import { addMarkedSpan, conflictingCollapsedRange, getMarkedSpanFor, lineIsHidden, lineLength, MarkedSpan, removeMarkedSpan, visualLine } from "../line/spans"
import { copyObj, indexOf, lst } from "../util/misc"
import { signalLater } from "../util/operation_group"
import { widgetHeight } from "../measurement/widgets"
import { regChange, regLineChange } from "../display/view_tracking"

import { linkedDocs } from "./document_data"
import { addChangeToHistory } from "./history"
import { reCheckSelection } from "./selection_updates"

// TEXTMARKERS

// Created with markText and setBookmark methods. A TextMarker is a
// handle that can be used to clear or find a marked position in the
// document. Line objects hold arrays (markedSpans) containing
// {from, to, marker} object pointing to such marker objects, and
// indicating that such a marker is present on that line. Multiple
// lines may point to the same marker when it spans across lines.
// The spans will have null for their from/to properties when the
// marker continues beyond the start/end of the line. Markers have
// links back to the lines they currently touch.

// Collapsed markers have unique ids, in order to be able to order
// them, which is needed for uniquely determining an outer marker
// when they overlap (they may nest, but not partially overlap).
let nextMarkerId = 0

export class TextMarker {
  constructor(doc, type) {
    this.lines = []
    this.type = type
    this.doc = doc
    this.id = ++nextMarkerId
  }

  // Clear the marker.
  clear() {
    if (this.explicitlyCleared) return
    let cm = this.doc.cm, withOp = cm && !cm.curOp
    if (withOp) startOperation(cm)
    if (hasHandler(this, "clear")) {
      let found = this.find()
      if (found) signalLater(this, "clear", found.from, found.to)
    }
    let min = null, max = null
    for (let i = 0; i < this.lines.length; ++i) {
      let line = this.lines[i]
      let span = getMarkedSpanFor(line.markedSpans, this)
      if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text")
      else if (cm) {
        if (span.to != null) max = lineNo(line)
        if (span.from != null) min = lineNo(line)
      }
后面还有 232 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。