Fix Codemirror undo history

This commit is contained in:
Gregory Schier
2024-10-09 12:00:52 -07:00
parent 2e2b3128c5
commit 2ca30bcb31
13 changed files with 1442 additions and 1457 deletions

2
src-web/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
vite.config.d.ts
vite.config.js

View File

@@ -1,4 +1,5 @@
import useResizeObserver from '@react-hook/resize-observer';
import type { GrpcMetadataEntry, GrpcRequest } from '@yaakapp-internal/models';
import classNames from 'classnames';
import type { CSSProperties } from 'react';
import React, { useCallback, useMemo, useRef, useState } from 'react';
@@ -6,7 +7,6 @@ import { createGlobalState } from 'react-use';
import type { ReflectResponseService } from '../hooks/useGrpc';
import { useRequestUpdateKey } from '../hooks/useRequestUpdateKey';
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
import type { GrpcMetadataEntry, GrpcRequest } from '@yaakapp-internal/models';
import { AUTH_TYPE_BASIC, AUTH_TYPE_BEARER, AUTH_TYPE_NONE } from '../lib/model_util';
import { BasicAuth } from './BasicAuth';
import { BearerAuth } from './BearerAuth';

View File

@@ -6,9 +6,7 @@ import {
handleRefresh,
jsonCompletion,
jsonSchemaLinter,
// eslint-disable-next-line import/named
stateExtensions,
// eslint-disable-next-line import/named
updateSchema,
} from 'codemirror-json-schema';
import { useEffect, useMemo, useRef } from 'react';

View File

@@ -63,7 +63,7 @@
.template-tag {
/* Colors */
@apply bg-surface text-text-subtle border-border-subtle;
@apply bg-surface text-text-subtle border-border-subtle whitespace-nowrap;
@apply hover:border-border-subtle hover:text-text hover:bg-surface-highlight;
@apply inline border px-1 mx-[0.5px] rounded cursor-default dark:shadow;

View File

@@ -174,7 +174,7 @@ export const Editor = forwardRef<EditorView | undefined, EditorProps>(function E
id: 'template-function',
size: 'sm',
title: 'Configure Function',
description: fn.description || null,
description: fn.description,
render: ({ hide }) => (
<TemplateFunctionDialog
templateFunction={fn}

View File

@@ -4,7 +4,7 @@ import {
closeBracketsKeymap,
completionKeymap,
} from '@codemirror/autocomplete';
import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';
import { history, historyKeymap, indentWithTab } from '@codemirror/commands';
import { javascript } from '@codemirror/lang-javascript';
import { json } from '@codemirror/lang-json';
import { xml } from '@codemirror/lang-xml';
@@ -134,7 +134,7 @@ export const baseExtensions = [
}),
syntaxHighlighting(syntaxHighlightStyle),
syntaxTheme,
EditorState.allowMultipleSelections.of(true),
keymap.of([...historyKeymap, ...completionKeymap]),
];
export const multiLineExtensions = [
@@ -156,14 +156,5 @@ export const multiLineExtensions = [
rectangularSelection(),
crosshairCursor(),
highlightActiveLineGutter(),
keymap.of([
indentWithTab,
...closeBracketsKeymap,
...defaultKeymap,
...searchKeymap,
...historyKeymap,
...foldKeymap,
...completionKeymap,
...lintKeymap,
]),
keymap.of([indentWithTab, ...closeBracketsKeymap, ...searchKeymap, ...foldKeymap, ...lintKeymap]),
];

View File

@@ -6,18 +6,17 @@
"scripts": {
"dev": "vite dev --force",
"build": "vite build",
"lint": "tsc && eslint . --ext .ts,.tsx"
"lint": "tsc --noEmit && eslint . --ext .ts,.tsx"
},
"dependencies": {
"@codemirror/commands": "^6",
"@codemirror/lang-javascript": "^6",
"@codemirror/lang-json": "^6",
"@codemirror/lang-xml": "^6",
"@codemirror/language": "^6",
"@codemirror/search": "^6",
"@lezer/generator": "^1.7.1",
"@lezer/highlight": "^1.2.1",
"@lezer/lr": "^1.4.2",
"@codemirror/commands": "6.7.0",
"@codemirror/lang-javascript": "^6.2.2",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-xml": "^6.0.2",
"@codemirror/language": "^6.6.0",
"@codemirror/search": "^6.2.3",
"@lezer/highlight": "^1.1.3",
"@lezer/lr": "^1.3.3",
"@react-hook/resize-observer": "^2.0.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tanstack/react-query": "^5.55.4",
@@ -57,6 +56,7 @@
"xml-formatter": "^3.6.3"
},
"devDependencies": {
"@lezer/generator": "^1.7.1",
"@tailwindcss/nesting": "^0.0.0-insiders.565cd3e",
"@tanstack/react-query-devtools": "^5.55.4",
"@types/node": "^22.5.4",