diff --git a/src/layer.ts b/src/layer.ts index 8dea591..503c0f7 100644 --- a/src/layer.ts +++ b/src/layer.ts @@ -198,6 +198,9 @@ interface LayerConfig { /// Called on every view update. Returning true triggers a marker /// update (a call to `markers` and drawing of those markers). update(update: ViewUpdate, layer: HTMLElement): boolean + /// Whether to update this layer every time the document view + /// changes. Defaults to true. + updateOnDocViewUpdate: boolean /// Build a set of markers for this layer, and measure their /// dimensions. markers(view: EditorView): readonly LayerMarker[] @@ -241,6 +244,10 @@ class LayerView { } } + docViewUpdate(view: EditorView) { + if (this.layer.updateOnDocViewUpdate !== false) view.requestMeasure(this.measureReq) + } + setOrder(state: EditorState) { let pos = 0, order = state.facet(layerOrder) while (pos < order.length && order[pos] != this.layer) pos++