Skip to content

Commit

Permalink
feat(toolbars): fixed types
Browse files Browse the repository at this point in the history
  • Loading branch information
makhnatkin committed Dec 19, 2024
1 parent 1b9c538 commit 7bb133d
Show file tree
Hide file tree
Showing 2 changed files with 363 additions and 0 deletions.
207 changes: 207 additions & 0 deletions src/bundle/config/markup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
import {MToolbarColors} from '../toolbar/markup/MToolbarColors';
import {MToolbarFilePopup} from '../toolbar/markup/MToolbarFilePopup';
import {MToolbarImagePopup} from '../toolbar/markup/MToolbarImagePopup';
import type {MarkdownEditorPreset} from '../types';

import {ActionName} from './action-names';
import {icons} from './icons';
Expand Down Expand Up @@ -544,3 +545,209 @@ export const mToolbarConfig: MToolbarData = [
],
[mImagePopupData, mFilePopupData, mTableButton, mCheckboxButton],
];

export const mToolbarConfigByPreset: Record<MarkdownEditorPreset, MToolbarData> = {
zero: [mHistoryGroupConfig],
commonmark: [
[mUndoItemData, mRedoItemData],
[mBoldItemData, mItalicItemData],
[
{
id: 'heading',
type: ToolbarDataType.ListButton,
icon: icons.headline,
withArrow: true,
title: i18n.bind(null, 'heading'),
data: [
mHeading1ItemData,
mHeading2ItemData,
mHeading3ItemData,
mHeading4ItemData,
mHeading5ItemData,
mHeading6ItemData,
],
},
{
id: 'list',
type: ToolbarDataType.ListButton,
icon: icons.bulletList,
withArrow: true,
title: i18n.bind(null, 'list'),
data: [mBulletListItemData, mOrderedListItemData],
},
mLinkButton,
mQuoteButton,
{
id: 'code',
type: ToolbarDataType.ListButton,
icon: icons.code,
withArrow: true,
title: i18n.bind(null, 'code'),
data: [mCodeItemData, mCodeblockItemData],
},
],
],
default: [
[mUndoItemData, mRedoItemData],
[mBoldItemData, mItalicItemData, mStrikethroughItemData],
[
{
id: 'heading',
type: ToolbarDataType.ListButton,
icon: icons.headline,
withArrow: true,
title: i18n.bind(null, 'heading'),
data: [
mHeading1ItemData,
mHeading2ItemData,
mHeading3ItemData,
mHeading4ItemData,
mHeading5ItemData,
mHeading6ItemData,
],
},
{
id: 'list',
type: ToolbarDataType.ListButton,
icon: icons.bulletList,
withArrow: true,
title: i18n.bind(null, 'list'),
data: [mBulletListItemData, mOrderedListItemData],
},
mLinkButton,
mQuoteButton,
{
id: 'code',
type: ToolbarDataType.ListButton,
icon: icons.code,
withArrow: true,
title: i18n.bind(null, 'code'),
data: [mCodeItemData, mCodeblockItemData],
},
],
],
yfm: [
[mUndoItemData, mRedoItemData],
[
mBoldItemData,
mItalicItemData,
mUnderlineItemData,
mStrikethroughItemData,
mMonospaceItemData,
],
[
{
id: 'heading',
type: ToolbarDataType.ListButton,
icon: icons.headline,
withArrow: true,
title: i18n.bind(null, 'heading'),
data: [
mHeading1ItemData,
mHeading2ItemData,
mHeading3ItemData,
mHeading4ItemData,
mHeading5ItemData,
mHeading6ItemData,
],
},
{
id: 'list',
type: ToolbarDataType.ListButton,
icon: icons.bulletList,
withArrow: true,
title: i18n.bind(null, 'list'),
data: [mBulletListItemData, mOrderedListItemData],
},
mLinkButton,
mNoteButton,
mCutButton,
mQuoteButton,
{
id: 'code',
type: ToolbarDataType.ListButton,
icon: icons.code,
withArrow: true,
title: i18n.bind(null, 'code'),
data: [mCodeItemData, mCodeblockItemData],
},
],
[mImagePopupData, mFilePopupData, mTableButton, mCheckboxButton],
],
full: mToolbarConfig.slice(),
};

export const mHiddenDataByPreset: Record<MarkdownEditorPreset, MToolbarItemData[]> = {
zero: [],
commonmark: [
mHeading1ItemData,
mHeading2ItemData,
mHeading3ItemData,
mHeading4ItemData,
mHeading5ItemData,
mHeading6ItemData,
mBulletListItemData,
mOrderedListItemData,
mLinkButton,
mQuoteButton,
mCodeblockItemData,
mHruleItemData,
],
default: [
mHeading1ItemData,
mHeading2ItemData,
mHeading3ItemData,
mHeading4ItemData,
mHeading5ItemData,
mHeading6ItemData,
mBulletListItemData,
mOrderedListItemData,
mLinkButton,
mQuoteButton,
mCodeblockItemData,
mHruleItemData,
],
yfm: [
mHeading1ItemData,
mHeading2ItemData,
mHeading3ItemData,
mHeading4ItemData,
mHeading5ItemData,
mHeading6ItemData,
mBulletListItemData,
mOrderedListItemData,
mLinkButton,
mQuoteButton,
mNoteButton,
mCutButton,
mCodeblockItemData,
mCheckboxButton,
mTableButton,
mImagePopupData,
mHruleItemData,
mFilePopupData,
mTabsItemData,
],
full: [
mHeading1ItemData,
mHeading2ItemData,
mHeading3ItemData,
mHeading4ItemData,
mHeading5ItemData,
mHeading6ItemData,
mBulletListItemData,
mOrderedListItemData,
mLinkButton,
mQuoteButton,
mNoteButton,
mCutButton,
mCodeblockItemData,
mCheckboxButton,
mTableButton,
mImagePopupData,
mHruleItemData,
mEmojiItemData,
mFilePopupData,
mTabsItemData,
],
};
156 changes: 156 additions & 0 deletions src/bundle/config/wysiwyg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,155 @@ export const wSelectionMenuConfig: SelectionContextConfig = [
wLinkItemData,
],
];

export const wToolbarConfigByPreset: Record<MarkdownEditorPreset, WToolbarData> = {
zero: [[wUndoItemData, wRedoItemData]],
commonmark: [
[wUndoItemData, wRedoItemData],
[wBoldItemData, wItalicItemData],
[
{
id: 'heading',
type: ToolbarDataType.ListButton,
icon: icons.headline,
withArrow: true,
title: i18n.bind(null, 'heading'),
data: [
wTextItemData,
wHeading1ItemData,
wHeading2ItemData,
wHeading3ItemData,
wHeading4ItemData,
wHeading5ItemData,
wHeading6ItemData,
],
},
{
id: 'list',
type: ToolbarDataType.ListButton,
icon: icons.bulletList,
withArrow: true,
title: i18n.bind(null, 'list'),
data: [
wBulletListItemData,
wOrderedListItemData,
wSinkListItemData,
wLiftListItemData,
],
},
wLinkItemData,
wQuoteItemData,
{
id: 'code',
type: ToolbarDataType.ListButton,
icon: icons.code,
withArrow: true,
title: i18n.bind(null, 'code'),
data: [wCodeItemData, wCodeBlockItemData],
},
],
],
default: [
[wUndoItemData, wRedoItemData],
[wBoldItemData, wItalicItemData, wStrikethroughItemData],
[
{
id: 'heading',
type: ToolbarDataType.ListButton,
icon: icons.headline,
withArrow: true,
title: i18n.bind(null, 'heading'),
data: [
wTextItemData,
wHeading1ItemData,
wHeading2ItemData,
wHeading3ItemData,
wHeading4ItemData,
wHeading5ItemData,
wHeading6ItemData,
],
},
{
id: 'list',
type: ToolbarDataType.ListButton,
icon: icons.bulletList,
withArrow: true,
title: i18n.bind(null, 'list'),
data: [
wBulletListItemData,
wOrderedListItemData,
wSinkListItemData,
wLiftListItemData,
],
},
wLinkItemData,
wQuoteItemData,
{
id: 'code',
type: ToolbarDataType.ListButton,
icon: icons.code,
withArrow: true,
title: i18n.bind(null, 'code'),
data: [wCodeItemData, wCodeBlockItemData],
},
],
],
yfm: [
[wUndoItemData, wRedoItemData],
[
wBoldItemData,
wItalicItemData,
wUnderlineItemData,
wStrikethroughItemData,
wMonospaceItemData,
],
[
{
id: 'heading',
type: ToolbarDataType.ListButton,
icon: icons.headline,
withArrow: true,
title: i18n.bind(null, 'heading'),
data: [
wTextItemData,
wHeading1ItemData,
wHeading2ItemData,
wHeading3ItemData,
wHeading4ItemData,
wHeading5ItemData,
wHeading6ItemData,
],
},
{
id: 'list',
type: ToolbarDataType.ListButton,
icon: icons.bulletList,
withArrow: true,
title: i18n.bind(null, 'list'),
data: [
wBulletListItemData,
wOrderedListItemData,
wSinkListItemData,
wLiftListItemData,
],
},
wLinkItemData,
wNoteItemData,
wCutItemData,
wQuoteItemData,
{
id: 'code',
type: ToolbarDataType.ListButton,
icon: icons.code,
withArrow: true,
title: i18n.bind(null, 'code'),
data: [wCodeItemData, wCodeBlockItemData],
},
],
[wImageItemData, wFileItemData, wTableItemData, wCheckboxItemData],
],
full: wToolbarConfig.slice(),
};
export const wCommandMenuConfigByPreset: Record<MarkdownEditorPreset, WToolbarItemData[]> = {
zero: [],
commonmark: [
Expand Down Expand Up @@ -676,6 +825,13 @@ export const wCommandMenuConfigByPreset: Record<MarkdownEditorPreset, WToolbarIt
wTabsItemData,
],
};
export const wHiddenDataByPreset: Record<MarkdownEditorPreset, WToolbarItemData[]> = {
zero: wCommandMenuConfigByPreset.zero.slice(),
commonmark: wCommandMenuConfigByPreset.commonmark.slice(),
default: wCommandMenuConfigByPreset.default.slice(),
yfm: wCommandMenuConfigByPreset.yfm.slice(),
full: wCommandMenuConfigByPreset.full.slice(),
};
export const wSelectionMenuConfigByPreset: Record<MarkdownEditorPreset, SelectionContextConfig> = {
zero: [],
commonmark: [
Expand Down

0 comments on commit 7bb133d

Please sign in to comment.