Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加layout例子 #69

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/.vuepress/public/img/code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions docs/example/layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
order: 3
---
# 布局

## 编辑器大小
在create编辑时,通过配置 [automaticLayout](../editor/interfaces/IStandaloneDiffEditorConstructionOptions.md#automaticlayout) 实现编辑器大小自适应:
``` javascript
monaco.editor.create(editorRef.value, {
value: '',
language: "javascript",
fixedOverflowWidgets: true,
fontFamily: "Arial",
fontSize: 14,
readOnly: true,
tabSize: 8,
insertSpaces: true,
wordWrap: 'on',
wordWrapColumn: 120,
// 默认值为false
automaticLayout: true,
});
```

::: danger

这个属性设置设置为 true ,则编辑器会在窗口大小发生变化时自动调整大小以适应新的窗口大小。 所以需要注意的是,如果有类似于侧边栏菜单关闭和展开的逻辑,一定要保证编辑器的容器盒子能够自使用宽度变化,否则无法触发编辑器的自适应

:::