Skip to content

Commit

Permalink
chore(demo): updated demo structure (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
makhnatkin authored Nov 20, 2024
1 parent aabd9d1 commit a4218bd
Show file tree
Hide file tree
Showing 56 changed files with 336 additions and 373 deletions.
12 changes: 6 additions & 6 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {Preview} from '@storybook/react';
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';

import {withThemeProvider, withLang} from '../demo/utils/preview';
import {withThemeProvider} from '../demo/hocs/withThemeProvider';
import {withLang} from '../demo/hocs/withLang';

const preview: Preview = {
decorators: [withThemeProvider, withLang],
Expand All @@ -12,12 +12,12 @@ const preview: Preview = {
},
options: {
storySort: {
order: ['Markdown Editor', ['Playground', '*'], '*'],
}
order: ['Markdown Editor', ['Playground', 'Presets', '*'], '*'],
},
},
controls: {
exclude: ['withDefaultInitialContent', 'initial']
}
exclude: ['withDefaultInitialContent', 'initial'],
},
},
globalTypes: {
theme: {
Expand Down
2 changes: 1 addition & 1 deletion demo/PMSelection.tsx → demo/components/PMSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
isNodeSelection,
isTextSelection,
isWholeSelection,
} from '../src';
} from '../../src';

export type WysiwygSelectionProps = ClassNameProps & {
editor: MarkdownEditorInstance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import '~@gravity-ui/uikit/styles/mixins.scss';
@import '../../node_modules/@gravity-ui/uikit/styles/mixins';

.playground {
max-width: 1296px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ import {getSanitizeYfmHtmlBlock} from '../../src/extensions/additional/YfmHtmlBl
import {cloneDeep} from '../../src/lodash';
import {CodeEditor} from '../../src/markup';
import {VERSION} from '../../src/version';
// ---
import {WysiwygSelection} from '../PMSelection';
import {WysiwygDevTools} from '../ProseMirrorDevTools';
import {SplitModePreview} from '../SplitModePreview';
import {block} from '../cn';
import {plugins} from '../constants/md-plugins';
import {randomDelay} from '../delay';
import {plugins} from '../defaults/md-plugins';
import useYfmHtmlBlockStyles from '../hooks/useYfmHtmlBlockStyles';
import {block} from '../utils/cn';
import {randomDelay} from '../utils/delay';
import {parseInsertedUrlAsImage} from '../utils/imageUrl';
import {debouncedUpdateLocation as updateLocation} from '../utils/location';

import {WysiwygSelection} from './PMSelection';
import {WysiwygDevTools} from './ProseMirrorDevTools';
import {SplitModePreview} from './SplitModePreview';

import './Playground.scss';

const b = block('playground');
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {applyDevTools, removeDevTools} from 'prosemirror-dev-toolkit';
import {EditorView} from 'prosemirror-view';
import {useEffectOnce, useUpdate} from 'react-use';

import type {MarkdownEditorInstance} from '../src';
import type {MarkdownEditorInstance} from '../../src';

export type WysiwygDevToolsProps = {
editor: MarkdownEditorInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import React, {useEffect, useMemo, useRef, useState} from 'react';
import transform from '@diplodoc/transform';
import {useThemeValue} from '@gravity-ui/uikit';

import {MarkupString, colorClassName} from '../src';
import {debounce} from '../src/lodash';
import {YfmStaticView} from '../src/view/components/YfmHtml';
import {withLatex} from '../src/view/hocs/withLatex';
import {MermaidConfig, withMermaid} from '../src/view/hocs/withMermaid';
import {withYfmHtmlBlock} from '../src/view/hocs/withYfmHtml';

import {LATEX_RUNTIME, MERMAID_RUNTIME, YFM_HTML_BLOCK_RUNTIME} from './constants/md-plugins';
import useYfmHtmlBlockStyles from './hooks/useYfmHtmlBlockStyles';
import {MarkupString, colorClassName} from '../../src';
import {debounce} from '../../src/lodash';
import {YfmStaticView} from '../../src/view/components/YfmHtml';
import {withLatex} from '../../src/view/hocs/withLatex';
import {MermaidConfig, withMermaid} from '../../src/view/hocs/withMermaid';
import {withYfmHtmlBlock} from '../../src/view/hocs/withYfmHtml';
import {LATEX_RUNTIME, MERMAID_RUNTIME, YFM_HTML_BLOCK_RUNTIME} from '../defaults/md-plugins';
import useYfmHtmlBlockStyles from '../hooks/useYfmHtmlBlockStyles';

const ML_ATTR = 'data-ml';
const mermaidConfig: MermaidConfig = {theme: 'forest'};
Expand Down
4 changes: 2 additions & 2 deletions demo/constants/default-args.ts → demo/defaults/args.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {Meta} from '@storybook/react';

import {PlaygroundMiniProps} from '../playground/PlaygroundMini';
import {PlaygroundMiniProps} from '../components/PlaygroundMini';

export const defaultArgs: Meta<PlaygroundMiniProps>['args'] = {
export const args: Meta<PlaygroundMiniProps>['args'] = {
initialEditor: 'wysiwyg',
settingsVisible: true,
allowHTML: true,
Expand Down
2 changes: 1 addition & 1 deletion demo/constants/md-content.ts → demo/defaults/content.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const initialMdContent = `
export const markup = `
&nbsp;
Welcome to the editor! Start typing the character \`/\`
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 0 additions & 14 deletions demo/editor-in-editor/EditorInEditor.stories.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions demo/escape-config/EscapeConfig.stories.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions demo/ghostExample/Ghost.stories.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions demo/gptPlugin/PlaygroundGPT.stories.tsx

This file was deleted.

10 changes: 1 addition & 9 deletions demo/utils/preview.tsx → demo/hocs/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import React from 'react';

import {ThemeProvider, configure} from '@gravity-ui/uikit';
import {configure} from '@gravity-ui/uikit';
import type {Decorator} from '@storybook/react';

import {configure as configureYfmEditor} from '../../src';

import '@gravity-ui/uikit/styles/styles.scss';

export const withThemeProvider: Decorator = (StoryItem, context) => {
return (
<ThemeProvider theme={context.globals.theme}>
<StoryItem {...context} />
</ThemeProvider>
);
};

export const withLang: Decorator = (StoryItem, context) => {
const lang = context.globals.lang;
configure({lang});
Expand Down
14 changes: 14 additions & 0 deletions demo/hocs/withThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

import {ThemeProvider} from '@gravity-ui/uikit';
import type {Decorator} from '@storybook/react';

import '@gravity-ui/uikit/styles/styles.scss';

export const withThemeProvider: Decorator = (StoryItem, context) => {
return (
<ThemeProvider theme={context.globals.theme}>
<StoryItem {...context} />
</ThemeProvider>
);
};
71 changes: 0 additions & 71 deletions demo/markdown/Markdown.stories.tsx

This file was deleted.

23 changes: 0 additions & 23 deletions demo/playground/Playground.stories.tsx

This file was deleted.

47 changes: 0 additions & 47 deletions demo/presets/Presets.stories.tsx

This file was deleted.

Loading

0 comments on commit a4218bd

Please sign in to comment.