refactor: isolate computed header calculation on effective requests (#2313)

Co-authored-by: liyasthomas <liyascthomas@gmail.com>
This commit is contained in:
Andrew Bastin
2022-05-11 14:53:06 +05:30
committed by GitHub
parent 450af983e2
commit d04520698d
4 changed files with 263 additions and 70 deletions

View File

@@ -47,6 +47,7 @@ const props = withDefaults(
styles: string
envs: { key: string; value: string; source: string }[] | null
focus: boolean
readonly: boolean
}>(),
{
value: "",
@@ -54,6 +55,7 @@ const props = withDefaults(
styles: "",
envs: null,
focus: false,
readonly: false,
}
)
@@ -123,7 +125,23 @@ const envTooltipPlugin = new HoppReactiveEnvPlugin(envVars, view)
const initView = (el: any) => {
const extensions: Extension = [
EditorView.contentAttributes.of({ "aria-label": props.placeholder }),
EditorView.updateListener.of((update) => {
if (props.readonly) {
update.view.contentDOM.inputMode = "none"
}
}),
EditorState.changeFilter.of(() => !props.readonly),
inputTheme,
props.readonly
? EditorView.theme({
".cm-content": {
caretColor: "var(--secondary-dark-color) !important",
color: "var(--secondary-dark-color) !important",
backgroundColor: "var(--divider-color) !important",
opacity: 0.25,
},
})
: EditorView.theme({}),
tooltips({
position: "absolute",
}),
@@ -141,6 +159,8 @@ const initView = (el: any) => {
ViewPlugin.fromClass(
class {
update(update: ViewUpdate) {
if (props.readonly) return
if (update.docChanged) {
const prevValue = clone(cachedValue.value)