From 7bb133d88abee34ed0faed2bbe8363ab1ed03d60 Mon Sep 17 00:00:00 2001 From: makhnatkin Date: Thu, 19 Dec 2024 10:00:06 +0100 Subject: [PATCH] feat(toolbars): fixed types --- src/bundle/config/markup.tsx | 207 +++++++++++++++++++++++++++++++++++ src/bundle/config/wysiwyg.ts | 156 ++++++++++++++++++++++++++ 2 files changed, 363 insertions(+) diff --git a/src/bundle/config/markup.tsx b/src/bundle/config/markup.tsx index c8babf3d..b6835be9 100644 --- a/src/bundle/config/markup.tsx +++ b/src/bundle/config/markup.tsx @@ -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'; @@ -544,3 +545,209 @@ export const mToolbarConfig: MToolbarData = [ ], [mImagePopupData, mFilePopupData, mTableButton, mCheckboxButton], ]; + +export const mToolbarConfigByPreset: Record = { + 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 = { + 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, + ], +}; diff --git a/src/bundle/config/wysiwyg.ts b/src/bundle/config/wysiwyg.ts index e40b31fe..db9d1a38 100644 --- a/src/bundle/config/wysiwyg.ts +++ b/src/bundle/config/wysiwyg.ts @@ -590,6 +590,155 @@ export const wSelectionMenuConfig: SelectionContextConfig = [ wLinkItemData, ], ]; + +export const wToolbarConfigByPreset: Record = { + 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 = { zero: [], commonmark: [ @@ -676,6 +825,13 @@ export const wCommandMenuConfigByPreset: Record = { + zero: wCommandMenuConfigByPreset.zero.slice(), + commonmark: wCommandMenuConfigByPreset.commonmark.slice(), + default: wCommandMenuConfigByPreset.default.slice(), + yfm: wCommandMenuConfigByPreset.yfm.slice(), + full: wCommandMenuConfigByPreset.full.slice(), +}; export const wSelectionMenuConfigByPreset: Record = { zero: [], commonmark: [