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

Отмена последнего действия при клике на текстовое поле #445

Open
rLukoyanov opened this issue Oct 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@rLukoyanov
Copy link

Description

Исходная компонента

import React from 'react';

import {
  MarkdownEditorView,
  useMarkdownEditor,
} from '@gravity-ui/markdown-editor';
import { toaster } from '@gravity-ui/uikit/toaster-singleton-react-18';

import { configure } from '@gravity-ui/markdown-editor';

configure({
  lang: 'ru',
});

type Props = {
  onChange: (value: string) => void;
};

export function Editor({ onChange }: Props) {
  const editor = useMarkdownEditor({
    initial: {
      toolbarVisible: true,
    },
  });

  React.useEffect(() => {
    function changeHandler() {
      const value = editor.getValue();
      onChange(value);
    }

    editor.on('change', changeHandler);
    return () => {
      editor.off('change', changeHandler);
    };
  }, [editor, onChange]);

  return (
    <MarkdownEditorView
      stickyToolbar
      toaster={toaster}
      editor={editor}
      settingsVisible={false}
      className="markdown-editor-wrapper"
    />
  );
}

Проблема - если наш эдитор поставить в тег тогда при клике будет срабатывать кнопка "Отменить"

<label>
   <Editor onChange={setDescription} />
</label>
Screen.Recording.2024-10-25.at.18.18.20.mov
@rLukoyanov rLukoyanov added the enhancement New feature or request label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant