@osmn-byhn/storybook-docs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ // ESM wrapper for the debug CommonJS package
2
+ import debugCJS from '../../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js';
3
+ export default debugCJS;
@@ -0,0 +1,3 @@
1
+ // ESM wrapper for the extend CommonJS package
2
+ import extendCJS from '../../../node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js';
3
+ export default extendCJS;
@@ -0,0 +1,49 @@
1
+ const path = require("path");
2
+
3
+ /** @type { import('@storybook/react-vite').StorybookConfig } */
4
+ module.exports = {
5
+ framework: "@storybook/react-vite",
6
+ stories: ["../stories/**/*.stories.@(ts|tsx)"],
7
+
8
+ viteFinal: async (config) => {
9
+ config.resolve = config.resolve || {};
10
+ const rootPath = path.resolve(__dirname, "../../..");
11
+
12
+ config.resolve.alias = {
13
+ ...(config.resolve.alias || {}),
14
+ "editor-react": path.resolve(rootPath, "packages/editor-react/src"),
15
+ "editor-core": path.resolve(rootPath, "packages/editor-core"),
16
+ "editor-parsers": path.resolve(rootPath, "packages/editor-parsers/src"),
17
+ // Use ESM wrappers for CommonJS packages to handle interop
18
+ "extend": path.resolve(__dirname, "extend-wrapper.js"),
19
+ "debug": path.resolve(__dirname, "debug-wrapper.js"),
20
+ "ms": path.resolve(__dirname, "ms-wrapper.js"),
21
+ };
22
+
23
+ // Ensure TypeScript files are resolved
24
+ config.resolve.extensions = [
25
+ ...(config.resolve.extensions || []),
26
+ ".ts",
27
+ ".tsx",
28
+ ".js",
29
+ ".cjs",
30
+ ];
31
+
32
+ // Configure dependency optimization for CommonJS packages
33
+ config.optimizeDeps = config.optimizeDeps || {};
34
+
35
+ // All problematic CommonJS packages are now handled via ESM wrappers
36
+ config.optimizeDeps.exclude = [
37
+ ...(config.optimizeDeps.exclude || []),
38
+ ];
39
+
40
+ // Configure esbuild to handle CommonJS dependencies properly
41
+ config.optimizeDeps.esbuildOptions = {
42
+ ...(config.optimizeDeps.esbuildOptions || {}),
43
+ mainFields: ["module", "main"],
44
+ platform: "browser",
45
+ };
46
+
47
+ return config;
48
+ },
49
+ };
@@ -0,0 +1,3 @@
1
+ // ESM wrapper for the ms CommonJS package
2
+ import msCJS from '../../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js';
3
+ export default msCJS;
@@ -0,0 +1,20 @@
1
+ /** @type { import('@storybook/react-vite').Preview } */
2
+ const preview = {
3
+ parameters: {
4
+ controls: {
5
+ matchers: {
6
+ color: /(background|color)$/i,
7
+ date: /Date$/i,
8
+ },
9
+ },
10
+
11
+ a11y: {
12
+ // 'todo' - show a11y violations in the test UI only
13
+ // 'error' - fail CI on a11y violations
14
+ // 'off' - skip a11y checks entirely
15
+ test: "todo"
16
+ }
17
+ },
18
+ };
19
+
20
+ export default preview;
@@ -0,0 +1,7 @@
1
+ import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
2
+ import { setProjectAnnotations } from '@storybook/react-vite';
3
+ import * as projectAnnotations from './preview';
4
+
5
+ // This is an important step to apply the right configuration when testing your stories.
6
+ // More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7
+ setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@osmn-byhn/storybook-docs",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "keywords": [],
7
+ "author": "",
8
+ "license": "ISC",
9
+ "devDependencies": {
10
+ "react": "^19.2.4",
11
+ "react-dom": "^19.2.4",
12
+ "storybook": "^1.0.0",
13
+ "@storybook/react-vite": "^10.2.3",
14
+ "@chromatic-com/storybook": "^5.0.0",
15
+ "@storybook/addon-vitest": "^10.2.3",
16
+ "@storybook/addon-a11y": "^10.2.3",
17
+ "@storybook/addon-docs": "^10.2.3",
18
+ "prop-types": "^15.8.1",
19
+ "vitest": "^4.0.18",
20
+ "playwright": "^1.58.1",
21
+ "@vitest/browser-playwright": "^4.0.18",
22
+ "@vitest/coverage-v8": "^4.0.18",
23
+ "@osmn-byhn/mdarea": "0.0.2"
24
+ },
25
+ "scripts": {
26
+ "test": "echo \"Error: no test specified\" && exit 1",
27
+ "storybook": "storybook dev -p 6006",
28
+ "build-storybook": "storybook build"
29
+ }
30
+ }
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { MarkdownEditorProvider, MarkdownEditor } from "editor-react";
4
+ import "./custom-theme.css";
5
+
6
+ const meta: Meta<typeof MarkdownEditor> = {
7
+ title: "Editor/CustomizedEditor",
8
+ component: MarkdownEditor,
9
+ argTypes: {
10
+ onChange: { action: 'changed' }
11
+ }
12
+ };
13
+
14
+ export default meta;
15
+
16
+ type Story = StoryObj<typeof MarkdownEditor>;
17
+
18
+ export const TurkishTheme: Story = {
19
+ args: {
20
+ labels: {
21
+ write: 'Editor',
22
+ preview: 'Page'
23
+ },
24
+ placeholder: "Customeized some markdown...",
25
+ previewStyle: {
26
+ fontFamily: 'Georgia, serif',
27
+ fontSize: '1.25rem',
28
+ lineHeight: '1.8',
29
+ color: '#333'
30
+ },
31
+ classNames: {
32
+ container: 'custom-dark-theme',
33
+ toolbar: 'custom-toolbar',
34
+ mobileTabs: 'custom-mobile-tabs',
35
+ tabBtn: 'custom-tab-btn',
36
+ contentArea: 'custom-content-area',
37
+ editorPane: 'custom-editor-pane',
38
+ previewPane: 'custom-preview-pane'
39
+ }
40
+ },
41
+ render: (args) => (
42
+ <div style={{ height: '600px', padding: '20px', backgroundColor: '#f3f4f6' }}>
43
+ <h3 style={{ marginBottom: '10px', fontFamily: 'sans-serif' }}>Customized Editor</h3>
44
+ <MarkdownEditor {...args} />
45
+ </div>
46
+ ),
47
+ };
48
+
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { MarkdownEditor } from "editor-react";
4
+
5
+ const meta: Meta<typeof MarkdownEditor> = {
6
+ title: "Editor/MarkdownEditor",
7
+ component: MarkdownEditor,
8
+ argTypes: {
9
+ onChange: { action: 'changed' }
10
+ }
11
+ };
12
+
13
+ export default meta;
14
+
15
+ type Story = StoryObj<typeof MarkdownEditor>;
16
+
17
+ export const Basic: Story = {
18
+ args: {
19
+ placeholder: "Type some markdown...",
20
+ },
21
+ render: (args) => (
22
+ <div style={{ height: '500px', padding: '20px' }}>
23
+ <MarkdownEditor {...args} />
24
+ </div>
25
+ ),
26
+ };
27
+
28
+
29
+
@@ -0,0 +1,133 @@
1
+ import React, { useState } from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { MarkdownEditorProvider } from "editor-react";
4
+ import { Preview } from "editor-react";
5
+ import { Editor } from "editor-react";
6
+ import { MarkdownEditor } from "editor-react";
7
+
8
+ const meta: Meta = {
9
+ title: "Editor/Independent Components",
10
+ };
11
+
12
+ export default meta;
13
+
14
+ type Story = StoryObj;
15
+
16
+ export const StandalonePreview: Story = {
17
+ args: {
18
+ markdown: "# Hello World\nThis content is passed directly via **markdown** prop.\n- List item 1\n- List item 2"
19
+ },
20
+ render: (args) => (
21
+ <div style={{ padding: '20px', border: '1px solid #ddd', borderRadius: '8px' }}>
22
+ <h3>Standalone Preview</h3>
23
+ <p>This preview is not connected to an editor context.</p>
24
+ <Preview {...args} />
25
+ </div>
26
+ ),
27
+ };
28
+
29
+
30
+ export const EditorWithStateExtraction: Story = {
31
+ render: () => {
32
+ const [value, setValue] = useState("# Initial Content\nType here...");
33
+
34
+ return (
35
+ <div style={{ padding: '20px', display: 'flex', gap: '20px' }}>
36
+ <div style={{ flex: 1 }}>
37
+ <h3>Editor (Controlled)</h3>
38
+ <MarkdownEditorProvider
39
+ initialValue={value}
40
+ onChange={(v) => setValue(v)}
41
+ >
42
+ <div style={{ border: '1px solid #ccc', height: '300px' }}>
43
+ <Editor />
44
+ </div>
45
+ </MarkdownEditorProvider>
46
+ </div>
47
+ <div style={{ flex: 1, padding: '10px', background: '#f5f5f5', borderRadius: '8px' }}>
48
+ <h3>State Output</h3>
49
+ <pre style={{ whiteSpace: 'pre-wrap' }}>{value}</pre>
50
+ </div>
51
+ </div>
52
+ );
53
+ },
54
+ };
55
+
56
+ export const MarkdownEditorControlled: Story = {
57
+ render: () => {
58
+ const [value, setValue] = useState("# Controlled Editor\n\nType here to see state update below.");
59
+
60
+ return (
61
+ <div style={{ padding: '20px' }}>
62
+ <div style={{ height: '400px', marginBottom: '20px' }}>
63
+ <MarkdownEditor
64
+ value={value}
65
+ onChange={setValue}
66
+ />
67
+ </div>
68
+
69
+ <div style={{ padding: '10px', background: '#f0f9ff', borderRadius: '8px', border: '1px solid #bae6fd' }}>
70
+ <strong>Current State:</strong>
71
+ <pre style={{ marginTop: '10px' }}>{value}</pre>
72
+ </div>
73
+ </div>
74
+ );
75
+ },
76
+
77
+ };
78
+
79
+ export const StyledPreview: Story = {
80
+ args: {
81
+ markdown: "# Stylish Preview\nThis has a custom font and background.",
82
+ style: {
83
+ "fontFamily": "Comic Sans MS, cursive, sans-serif",
84
+ "backgroundColor": "#fffbeb",
85
+ "padding": "20px",
86
+ "borderRadius": "12px",
87
+ "color": "red",
88
+ "border": "2px dashed #f59e0b"
89
+ }
90
+ },
91
+ render: (args) => (
92
+ <div style={{ padding: '20px', border: '1px solid #ddd', borderRadius: '8px' }}>
93
+ <h3>Styled Preview</h3>
94
+ <p>Demonstrates customizing the preview component directly.</p>
95
+ <Preview {...args} />
96
+ </div>
97
+ ),
98
+ };
99
+
100
+ export const CustomizedControlledEditor: Story = {
101
+ args: {
102
+ placeholder: "Start typing your masterpiece...",
103
+ previewStyle: {
104
+ fontFamily: 'Merriweather, serif',
105
+ fontSize: '1.1rem',
106
+ color: '#2c3e50',
107
+ lineHeight: '1.7'
108
+ },
109
+ classNames: {
110
+ container: 'custom-modern-theme',
111
+ toolbar: 'custom-modern-toolbar'
112
+ }
113
+ },
114
+ render: (args) => {
115
+ const [value, setValue] = useState("# Customized & Controlled\n\nThis editor has custom placeholder and preview styles, while being fully controlled.");
116
+
117
+ return (
118
+ <div style={{ padding: '20px' }}>
119
+ <div style={{ height: '500px', marginBottom: '20px' }}>
120
+ <MarkdownEditor
121
+ {...args}
122
+ value={value}
123
+ onChange={setValue}
124
+ />
125
+ </div>
126
+
127
+ <div style={{ padding: '10px', background: '#e0f2fe', borderRadius: '8px', color: '#0369a1' }}>
128
+ <strong>Live Value:</strong> {value.length} characters
129
+ </div>
130
+ </div>
131
+ );
132
+ },
133
+ };
@@ -0,0 +1,38 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { MarkdownEditor } from "editor-react";
4
+
5
+ const meta: Meta<typeof MarkdownEditor> = {
6
+ title: "Editor/Tailwind Example",
7
+ component: MarkdownEditor,
8
+ };
9
+
10
+ export default meta;
11
+
12
+ type Story = StoryObj<typeof MarkdownEditor>;
13
+
14
+ export const TailwindStyled: Story = {
15
+ args: {
16
+ placeholder: "Tailwind styled editor...",
17
+ classNames: {
18
+ container: "border-2 border-indigo-500 rounded-xl overflow-hidden shadow-lg",
19
+ toolbar: "bg-indigo-50 border-b border-indigo-100 p-2",
20
+ toolbarBtn: "hover:bg-indigo-200 text-indigo-700 rounded transition-colors duration-200",
21
+ textArea: "focus:ring-2 focus:ring-indigo-300 outline-none p-4",
22
+ previewPane: "prose prose-indigo max-w-none p-4 bg-white"
23
+ }
24
+ },
25
+ render: (args) => (
26
+ <div className="p-8 bg-gray-50 min-h-screen">
27
+ <div className="max-w-4xl mx-auto">
28
+ <h2 className="text-2xl font-bold text-gray-800 mb-6">Tailwind CSS Integration</h2>
29
+ <div style={{ height: '600px' }}>
30
+ <MarkdownEditor {...args} />
31
+ </div>
32
+ <p className="mt-4 text-gray-500 text-sm italic">
33
+ Note: This example uses utility classes. In a real project with Tailwind installed, these would apply automatically.
34
+ </p>
35
+ </div>
36
+ </div>
37
+ ),
38
+ };
@@ -0,0 +1,59 @@
1
+ /* Custom Theme for Markdown Editor */
2
+
3
+ .custom-dark-theme.md-editor-container {
4
+ border-color: #4b5563;
5
+ border-radius: 12px;
6
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
7
+ }
8
+
9
+ .custom-toolbar {
10
+ background-color: #1f2937 !important;
11
+ border-bottom-color: #374151 !important;
12
+ }
13
+
14
+ .custom-toolbar button {
15
+ color: #d1d5db !important;
16
+ }
17
+
18
+ .custom-toolbar button:hover {
19
+ background-color: #374151 !important;
20
+ color: #f3f4f6 !important;
21
+ }
22
+
23
+ .custom-toolbar button.active {
24
+ background-color: #4b5563 !important;
25
+ color: #fff !important;
26
+ }
27
+
28
+ .custom-content-area {
29
+ background-color: #f9fafb;
30
+ }
31
+
32
+ .custom-editor-pane textarea {
33
+ background-color: #fffaf0 !important;
34
+ /* Slight yellow tint for "paper" feel */
35
+ color: #333 !important;
36
+ }
37
+
38
+ .custom-preview-pane {
39
+ background-color: #ffffff !important;
40
+ font-family: 'Georgia', serif;
41
+ /* Serif font for preview */
42
+ }
43
+
44
+ /* Mobile Tabs Customization */
45
+ .custom-mobile-tabs {
46
+ background-color: #1f2937 !important;
47
+ border-bottom-color: #374151 !important;
48
+ }
49
+
50
+ .custom-tab-btn {
51
+ color: #9ca3af !important;
52
+ }
53
+
54
+ .custom-tab-btn.active {
55
+ background-color: #374151 !important;
56
+ color: #fbbf24 !important;
57
+ /* Amber color for active tab */
58
+ border-bottom-color: #fbbf24 !important;
59
+ }
@@ -0,0 +1,37 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ import { defineConfig } from 'vitest/config';
5
+
6
+ import { storybookTest } from '@storybook/addon-vitest/vitest-plugin';
7
+
8
+ import { playwright } from '@vitest/browser-playwright';
9
+
10
+ const dirname =
11
+ typeof __dirname !== 'undefined' ? __dirname : path.dirname(fileURLToPath(import.meta.url));
12
+
13
+ // More info at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon
14
+ export default defineConfig({
15
+ test: {
16
+ projects: [
17
+ {
18
+ extends: true,
19
+ plugins: [
20
+ // The plugin will run tests for the stories defined in your Storybook config
21
+ // See options at: https://storybook.js.org/docs/next/writing-tests/integrations/vitest-addon#storybooktest
22
+ storybookTest({ configDir: path.join(dirname, '.storybook') }),
23
+ ],
24
+ test: {
25
+ name: 'storybook',
26
+ browser: {
27
+ enabled: true,
28
+ headless: true,
29
+ provider: playwright({}),
30
+ instances: [{ browser: 'chromium' }],
31
+ },
32
+ setupFiles: ['.storybook/vitest.setup.js'],
33
+ },
34
+ },
35
+ ],
36
+ },
37
+ });