欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 幼教 > vue-codemirror定位光标位置并在光标处插入信息

vue-codemirror定位光标位置并在光标处插入信息

2025/9/20 16:09:32 来源:https://blog.csdn.net/m0_61343119/article/details/144988978  浏览:    关键词:vue-codemirror定位光标位置并在光标处插入信息
业务场景:在代码编辑器外点击按钮,向代码编辑器内的光标处新增一条拼接好的信息。

getCursor方法:

官方文档:
doc.getCursor(?start: string) → {line, ch}
Retrieve one end of the primary selection. start is an optional string indicating which end of the selection to return. It may be “from”, “to”, “head” (the side of the selection that moves when you press shift+arrow), or “anchor” (the fixed side of the selection). Omitting the argument is the same as passing “head”. A {line, ch} object will be returned.

粗暴翻译:
能获取到光标所在的位置,返回一个{line, ch}对象

replaceRange方法:

官方文档:
doc.replaceRange(replacement: string, from: {line, ch}, to: {line, ch}, ?origin: string)
Replace the part of the document between from and to with the given string. from and to must be {line, ch} objects. to can be left off to simply insert the string at

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词