-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement a standard document model toolbar with out of the box…
… functionalities in the document model editor (#430) * feat(design-system): added DocumentToolbar component * feat(document-model-libs): added documentToolbar option in EditorConfig type * feat(codegen): enabled support for ExtendedEditor + import actions in Editor
- Loading branch information
Showing
10 changed files
with
121 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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
25 changes: 25 additions & 0 deletions
25
packages/design-system/src/connect/components/document-toolbar/document-toolbar.stories.tsx
This file contains 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,25 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { DocumentToolbar } from "./document-toolbar"; | ||
|
||
const meta = { | ||
title: "Connect/Components/DocumentToolbar", | ||
component: DocumentToolbar, | ||
} satisfies Meta<typeof DocumentToolbar>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
title: "My Document Model V2", | ||
canUndo: true, | ||
canRedo: true, | ||
redo: () => console.log("redo"), | ||
undo: () => console.log("undo"), | ||
onClose: () => console.log("close"), | ||
onExport: () => console.log("export"), | ||
onShowRevisionHistory: () => console.log("show revision history"), | ||
onSwitchboardLinkClick: () => console.log("switchboard link click"), | ||
}, | ||
}; |
56 changes: 56 additions & 0 deletions
56
packages/design-system/src/connect/components/document-toolbar/document-toolbar.tsx
This file contains 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,56 @@ | ||
import { | ||
EditorUndoRedoButtons, | ||
EditorUndoRedoButtonsProps, | ||
} from "@/connect/components/editor-undo-redo-buttons"; | ||
import { | ||
EditorActionButtons, | ||
EditorActionButtonsProps, | ||
} from "@/connect/components/editor-action-buttons"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
export type DocumentToolbarProps = { | ||
title?: string; | ||
className?: string; | ||
} & Partial<EditorUndoRedoButtonsProps> & | ||
EditorActionButtonsProps; | ||
|
||
export const DocumentToolbar: React.FC<DocumentToolbarProps> = (props) => { | ||
const { | ||
undo, | ||
canUndo, | ||
redo, | ||
canRedo, | ||
title, | ||
onClose, | ||
onExport, | ||
className, | ||
onShowRevisionHistory, | ||
onSwitchboardLinkClick, | ||
} = props; | ||
|
||
return ( | ||
<div className={twMerge("flex items-center justify-between", className)}> | ||
<div> | ||
{undo && redo && canUndo && canRedo && ( | ||
<EditorUndoRedoButtons | ||
undo={undo} | ||
canUndo={canUndo} | ||
redo={redo} | ||
canRedo={canRedo} | ||
/> | ||
)} | ||
</div> | ||
<div> | ||
<h2 className="text-sm font-semibold">{title}</h2> | ||
</div> | ||
<div> | ||
<EditorActionButtons | ||
onClose={onClose} | ||
onExport={onExport} | ||
onShowRevisionHistory={onShowRevisionHistory} | ||
onSwitchboardLinkClick={onSwitchboardLinkClick} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/design-system/src/connect/components/document-toolbar/index.ts
This file contains 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 @@ | ||
export * from "./document-toolbar"; |
6 changes: 3 additions & 3 deletions
6
...ages/design-system/src/connect/components/editor-action-buttons/editor-action-buttons.tsx
This file contains 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
14 changes: 9 additions & 5 deletions
14
...esign-system/src/connect/components/editor-undo-redo-buttons/editor-undo-redo-buttons.tsx
This file contains 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 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 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 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