Skip to content

Commit

Permalink
feat(bundle)!: rename yfm ––> markdown in variable and file names (#259)
Browse files Browse the repository at this point in the history
Renamed:
- `useYfmEditor` and `UseYfmEditorProps` ––> `useMarkdownEditor` and `UseMarkdownEditorProps`
- `YfmEditorView` and `YfmEditorViewProps` ––> `MarkdownEditorView` and `MarkdownEditorViewProps`
- `YfmEditorProvider` and `useYfmEditorContext` ––> `MarkdownEditorProvider` and `useMarkdownEditorContext`
- `YfmEditorType` ––> `MarkdownEditorType`
  • Loading branch information
d3m1d0v authored Jun 3, 2024
1 parent db3749a commit c63381f
Show file tree
Hide file tree
Showing 12 changed files with 313 additions and 308 deletions.
18 changes: 10 additions & 8 deletions demo/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {toaster} from '@gravity-ui/uikit/toaster-singleton-react-18';

import {MarkupString, logger} from '../src';
import {
YfmEditorType,
YfmEditorView,
MarkdownEditorType,
MarkdownEditorView,
markupToolbarConfigs,
useYfmEditor,
useMarkdownEditor,
wysiwygToolbarConfigs,
} from '../src/bundle';
import {RenderPreview, ToolbarActionData} from '../src/bundle/Editor';
Expand Down Expand Up @@ -54,7 +54,7 @@ export type PlaygroundProps = {
initial?: MarkupString;
allowHTML?: boolean;
settingsVisible?: boolean;
initialEditor?: YfmEditorType;
initialEditor?: MarkdownEditorType;
breaks?: boolean;
linkify?: boolean;
linkifyTlds?: string | string[];
Expand Down Expand Up @@ -90,7 +90,9 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
renderPreviewDefined,
height,
} = props;
const [editorType, setEditorType] = React.useState<YfmEditorType>(initialEditor ?? 'wysiwyg');
const [editorType, setEditorType] = React.useState<MarkdownEditorType>(
initialEditor ?? 'wysiwyg',
);
const [mdRaw, setMdRaw] = React.useState<MarkupString>(initial || '');

React.useEffect(() => {
Expand All @@ -112,7 +114,7 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
[allowHTML, breaks, linkify, linkifyTlds, sanitizeHtml],
);

const mdEditor = useYfmEditor({
const mdEditor = useMarkdownEditor({
allowHTML,
linkify,
linkifyTlds,
Expand Down Expand Up @@ -164,7 +166,7 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
function onChange() {
setMdRaw(mdEditor.getValue());
}
function onChangeEditorType({type}: {type: YfmEditorType}) {
function onChangeEditorType({type}: {type: MarkdownEditorType}) {
setEditorType(type);
}
const onToolbarAction = ({id, editorType: type}: ToolbarActionData) => {
Expand Down Expand Up @@ -263,7 +265,7 @@ export const Playground = React.memo<PlaygroundProps>((props) => {
<hr />
<React.StrictMode>
<div className={b('editor')} style={{height: height ?? 'initial'}}>
<YfmEditorView
<MarkdownEditorView
autofocus
toaster={toaster}
className={b('editor-view')}
Expand Down
8 changes: 4 additions & 4 deletions demo/editor-in-editor/EditorInEditorExtension/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {EditorView, NodeView} from 'prosemirror-view';
import {createPortal} from 'react-dom';

import {ExtensionAuto, getReactRendererFromState} from '../../../src';
import {YfmEditorView, YfmEditorViewProps, useYfmEditor} from '../../../src/bundle';
import {MarkdownEditorView, MarkdownEditorViewProps, useMarkdownEditor} from '../../../src/bundle';

import './index.scss';

Expand Down Expand Up @@ -102,11 +102,11 @@ class EditorInEditorNodeView implements NodeView {

type YfmEditorProps = {
initialContent: string;
toaster: YfmEditorViewProps['toaster'];
toaster: MarkdownEditorViewProps['toaster'];
};

function InnerEditor({initialContent, toaster}: YfmEditorProps) {
const mdEditor = useYfmEditor({
const mdEditor = useMarkdownEditor({
initialMarkup: initialContent,
initialEditorType: 'wysiwyg',
initialToolbarVisible: true,
Expand All @@ -115,7 +115,7 @@ function InnerEditor({initialContent, toaster}: YfmEditorProps) {
allowHTML: false,
});
return (
<YfmEditorView
<MarkdownEditorView
editor={mdEditor}
toaster={toaster}
settingsVisible={false}
Expand Down
6 changes: 3 additions & 3 deletions demo/editor-in-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {useEffect} from 'react';
import {toaster} from '@gravity-ui/uikit/toaster-singleton-react-18';

import {BaseNode} from '../../src';
import {YfmEditorView, useYfmEditor} from '../../src/bundle';
import {MarkdownEditorView, useMarkdownEditor} from '../../src/bundle';
import {VERSION} from '../../src/version';
import {block} from '../cn';

Expand All @@ -16,7 +16,7 @@ import {
const b = block('playground');

export const PlaygroundEditorInEditor: React.FC = () => {
const mdEditor = useYfmEditor({
const mdEditor = useMarkdownEditor({
initialEditorType: 'wysiwyg',
initialToolbarVisible: true,
allowHTML: false,
Expand Down Expand Up @@ -52,7 +52,7 @@ export const PlaygroundEditorInEditor: React.FC = () => {
</div>
<hr />
<div className={b('editor')}>
<YfmEditorView
<MarkdownEditorView
stickyToolbar
settingsVisible
editor={mdEditor}
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/HorizontalDrag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {EventHandler, useCallback, useEffect, useRef, useState} from 'rea
import {clamp} from '../lodash';

import {EditorInt} from './Editor';
import {cnEditorComponent} from './YfmEditorView';
import {cnEditorComponent} from './MarkdownEditorView';

export const IN_RESIZE_CLASSNAME = 'in-resize';

Expand Down
File renamed without changes.
Loading

0 comments on commit c63381f

Please sign in to comment.