什么取代了 Monaco Editor 已弃用的 deltaDecorations 函数?

问题描述 投票:0回答:2

文档说它已被弃用:

(method) editor.ICodeEditor.deltaDecorations(oldDecorations: string[], newDecorations: monaco.editor.IModelDeltaDecoration[]): string[]
All decorations added through this call will get the ownerId of this editor.

@deprecated

The signature '(oldDecorations: string[], newDecorations: IModelDeltaDecoration[]): string[]' of 'editor.deltaDecorations' is deprecated.

但我发现的唯一例子仍然使用它

https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-line-and-inline-decorations

该文件没有说明是什么取代了它。

monaco-editor
2个回答
1
投票

根据https://github.com/microsoft/monaco-editor/blob/main/CHANGELOG.md

软弃用 ICodeEditor.deltaDecorations,无需采用。应改用 IEditor.createDecorationsCollection API。


0
投票

createDecorationsCollection
返回一个
monacoT.editor.IEditorDecorationsCollection
,它有一个
.clear()
方法来删除所有先前的装饰。

© www.soinside.com 2019 - 2024. All rights reserved.