-
Notifications
You must be signed in to change notification settings - Fork 667
HtmlEditor: Update AI dialog controls && Add storybook story #29633
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
Merged
r-farkhutdinov
merged 14 commits into
DevExpress:25_1
from
r-farkhutdinov:25_1_ai_toolbar_story
Apr 25, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1676b6c
HTMLEditor: Add storybook story & update AI dialog controls
eb165fd
HTMLEditor: Disable AI menu if empty command provided & set up AI sto…
1460314
HTMLEditor: Fix dependencies list
9624a9e
HTMLEditor: Update Copy button location; make replace button split
30eac23
HTMLEditor: Update AI Dialog spacings for all themes
3a0475c
HTMLEditor: Fix DropDownButton min width
549d183
HTMLEditor: AI Dialog update toolbar buttons order
cad1381
HTMLEditor: Update Try Again button icon
32e2e7d
HTMLEditor: Update tests
b123657
HTMLEditor: Update formdialog overlay styles & format story data
6aee6e8
HTMLEditor: Remove treeview from dependencies
b6dee1e
HTMLEditor: Add menu disabled state test
7faa9a7
HTMLEditor: Add treeview dependency
56b5a45
HTMLEditor: Format story
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
apps/react-storybook/stories/htmleditor/HtmlEditor.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import React from 'react'; | ||
| import { HtmlEditor, Toolbar, Item, IHtmlEditorOptions, IItemProps } from 'devextreme-react/html-editor'; | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { defaultToolbarItems, fullToolbarItems } from './data'; | ||
| import { AIIntegration } from 'devextreme/artifacts/npm/devextreme/common/ai-integration'; | ||
|
|
||
| const meta: Meta<typeof HtmlEditor> = { | ||
| title: 'Editors/HtmlEditor', | ||
| component: HtmlEditor, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type HtmlEditorRenderArgs = IHtmlEditorOptions & { | ||
| items: IItemProps[], | ||
| }; | ||
|
|
||
| export const Overview: StoryObj<HtmlEditorRenderArgs> = { | ||
| argTypes: { | ||
| items: { | ||
| options: ['default', 'full'], | ||
| mapping: { | ||
| default: defaultToolbarItems, | ||
| full: fullToolbarItems, | ||
| }, | ||
| control: { | ||
| type: 'select', | ||
| labels: { | ||
| default: 'Default Toolbar', | ||
| full: 'Full Toolbar', | ||
| }, | ||
| }, | ||
| }, | ||
| rtlEnabled: { control: 'boolean' }, | ||
| readOnly: { control: 'boolean' }, | ||
| disabled: { control: 'boolean'}, | ||
| height: { control: 'number' }, | ||
| width: { control: 'text' }, | ||
| }, | ||
| args: { | ||
| items: defaultToolbarItems, | ||
| rtlEnabled: false, | ||
| readOnly: false, | ||
| disabled: false, | ||
| height: 500, | ||
| width: '100%', | ||
| }, | ||
| render: ({ items, ...editorProps }: HtmlEditorRenderArgs) => ( | ||
| <div style={{ width: '100%' }}> | ||
| <HtmlEditor {...editorProps} defaultValue="<p>Hello, world!</p>"> | ||
| <Toolbar> | ||
| {items.map((item, index) => ( | ||
| <Item key={index} {...item} /> | ||
| ))} | ||
| </Toolbar> | ||
| </HtmlEditor> | ||
| </div> | ||
| ), | ||
| } | ||
|
|
||
| export const WithAI: StoryObj<HtmlEditorRenderArgs> = { | ||
| args: { | ||
| items: [ | ||
| ...defaultToolbarItems, | ||
| { name: 'separator' }, | ||
| { name: 'ai' } | ||
| ], | ||
| height: 500, | ||
| width: '100%', | ||
| }, | ||
| render: ({ items, ...editorProps }: HtmlEditorRenderArgs) => ( | ||
| <div style={{ width: '100%' }}> | ||
| <HtmlEditor | ||
| {...editorProps} | ||
| defaultValue="<p>What is the capital of France?</p>" | ||
| aiIntegration={{} as AIIntegration} | ||
| > | ||
| <Toolbar> | ||
| {items.map((item, index) => ( | ||
| <Item key={index} {...item} /> | ||
| ))} | ||
| </Toolbar> | ||
| </HtmlEditor> | ||
| </div> | ||
| ), | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| export const defaultToolbarItems = [ | ||
| { name: 'bold' }, | ||
| { name: 'italic' }, | ||
| { name: 'underline' }, | ||
| { name: 'separator' }, | ||
| { name: 'undo' }, | ||
| { name: 'redo' }, | ||
| ]; | ||
|
|
||
| export const fullToolbarItems = [ | ||
| { name: 'undo' }, | ||
| { name: 'redo' }, | ||
| { name: 'separator' }, | ||
| { | ||
| name: 'size', | ||
| acceptedValues: ['8pt', '10pt', '12pt', '14pt', '18pt', '24pt', '36pt'], | ||
| options: { placeholder: 'Font size' }, | ||
| }, | ||
| { | ||
| name: 'font', | ||
| acceptedValues: ['Arial', 'Courier New', 'Georgia', 'Impact', 'Lucida Console', 'Tahoma', 'Times New Roman', 'Verdana'], | ||
| options: { placeholder: 'Font' }, | ||
| }, | ||
| { name: 'separator' }, | ||
| { name: 'bold' }, | ||
| { name: 'italic' }, | ||
| { name: 'strike' }, | ||
| { name: 'underline' }, | ||
| { name: 'separator' }, | ||
| { name: 'alignLeft' }, | ||
| { name: 'alignCenter' }, | ||
| { name: 'alignRight' }, | ||
| { name: 'alignJustify' }, | ||
| { name: 'separator' }, | ||
| { name: 'orderedList' }, | ||
| { name: 'bulletList' }, | ||
| { name: 'separator' }, | ||
| { | ||
| name: 'header', | ||
| acceptedValues: [false, 1, 2, 3, 4, 5], | ||
| options: { placeholder: 'Header' }, | ||
| }, | ||
| { name: 'separator' }, | ||
| { name: 'color' }, | ||
| { name: 'background' }, | ||
| { name: 'separator' }, | ||
| { name: 'link' }, | ||
| { name: 'image' }, | ||
| { name: 'separator' }, | ||
| { name: 'clear' }, | ||
| { name: 'codeBlock' }, | ||
| { name: 'blockquote' }, | ||
| { name: 'separator' }, | ||
| { name: 'insertTable' }, | ||
| { name: 'deleteTable' }, | ||
| { name: 'insertRowAbove' }, | ||
| { name: 'insertRowBelow' }, | ||
| { name: 'deleteRow' }, | ||
| { name: 'insertColumnLeft' }, | ||
| { name: 'insertColumnRight' }, | ||
| { name: 'deleteColumn' }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treeview?