首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何清除CodeMirror 6中的撤消历史记录?

如何清除CodeMirror 6中的撤消历史记录?
EN

Stack Overflow用户
提问于 2022-06-25 14:04:18
回答 1查看 48关注 0票数 0

我相信editor.clearHistory();CodeMirror 5工作,但是CodeMirror 6呢?

EN

回答 1

Stack Overflow用户

发布于 2022-06-25 16:40:45

代码语言:javascript
复制
interface HistoryConfig {
    /**
    The minimum depth (amount of events) to store. Defaults to 100.
    */
    minDepth?: number;
    /**
    The maximum time (in milliseconds) that adjacent events can be
    apart and still be grouped together. Defaults to 500.
    */
    newGroupDelay?: number;
}
/**
Create a history extension with the given configuration.
*/
declare function history(config?: HistoryConfig): Extension;
代码语言:javascript
复制
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { history } from '@codemirror/commands';

const state = EditorState.create({
  doc: 'my source code',
  extensions: [history({ minDepth: 10 })],
});

const view = new EditorView({
  parent: document.querySelector('#editor'),
  state,
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72754532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档