[英]How do I get the line count of an embedded Monaco editor in React? (including wrapping)
I want to extract the line count, including the wrapping, out of an embedded monaco editor in React.我想从 React 中的嵌入式 monaco 编辑器中提取行数,包括换行。 Here is a dummy setup:这是一个虚拟设置:
import React, { useEffect, useState, useRef } from 'react';
import Editor from '@monaco-editor/react';
function ExampleApp() {
const customHTMLRef = useRef(null);
const [lineCount, setLineCount = useState();
function handleHTMLEditorDidMount(editor, monaco) {
customHTMLRef.current = editor;
}
}
return (
<>
<Editor
theme='vs-dark'
height='100%'
width='100%'
defaultLanguage='html'
onMount={handleHTMLEditorDidMount}
/>
<div>Line Count is: {lineCount}</div>
</>
)
Some resources I was using, maybe you can see what I dont:我正在使用的一些资源,也许你可以看到我没有看到的:
https://github.com/Microsoft/monaco-editor/issues/947 https://github.com/Microsoft/monaco-editor/issues/947
https://codepen.io/monir/pen/72958128d822b228ba0245b16171c293?editors=0010 https://codepen.io/monir/pen/72958128d822b228ba0245b16171c293?editors=0010
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.