这里https://github.com/ProseMirror/prosemirror-state/blob/master/src/state.js#L122是prosemirror js代码行:

applyTransaction(rootTr) {
    //...
    outer: for (;;) {


在此javascript代码中无限循环之前的“外部”是什么意思?

更新。

该功能的完整代码:

  applyTransaction(rootTr) {
    if (!this.filterTransaction(rootTr)) return {state: this, transactions: []}

    let trs = [rootTr], newState = this.applyInner(rootTr), seen = null
    // This loop repeatedly gives plugins a chance to respond to
    // transactions as new transactions are added, making sure to only
    // pass the transactions the plugin did not see before.
    outer: for (;;) { // <--- this line !!!
      let haveNew = false
      for (let i = 0; i < this.config.plugins.length; i++) {
        let plugin = this.config.plugins[i]
        if (plugin.spec.appendTransaction) {
          let n = seen ? seen[i].n : 0, oldState = seen ? seen[i].state : this
          let tr = n < trs.length &&
              plugin.spec.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState)
          if (tr && newState.filterTransaction(tr, i)) {
            tr.setMeta("appendedTransaction", rootTr)
            if (!seen) {
              seen = []
              for (let j = 0; j < this.config.plugins.length; j++)
                seen.push(j < i ? {state: newState, n: trs.length} : {state: this, n: 0})
            }
            trs.push(tr)
            newState = newState.applyInner(tr)
            haveNew = true
          }
          if (seen) seen[i] = {state: newState, n: trs.length}
        }
      }
      if (!haveNew) return {state: newState, transactions: trs}
    }
  }

最佳答案

这是label


  带标签的语句可以与break或Continue语句一起使用。它为语句添加了可以引用的标识符。


看一下链接源,我的第一个猜测是它在那里,因此插件可以引用它。

关于javascript - “prosemirror”代码中的“外部”是什么意思?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60440676/

10-12 04:22