From 105427034b234b38ef255d61d4388cc51d609dbf Mon Sep 17 00:00:00 2001 From: leecason Date: Mon, 9 Mar 2020 18:05:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20SelectAll=20extension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MenuCommands/CommandButton.vue | 1 + src/extensions/index.ts | 1 + src/extensions/select_all.ts | 27 +++++++++++++++++++ src/i18n/en/index.ts | 3 +++ src/i18n/pl/index.ts | 3 +++ src/i18n/zh/index.ts | 3 +++ 6 files changed, 38 insertions(+) create mode 100644 src/extensions/select_all.ts diff --git a/src/components/MenuCommands/CommandButton.vue b/src/components/MenuCommands/CommandButton.vue index 1118ad45..8f586ffe 100644 --- a/src/components/MenuCommands/CommandButton.vue +++ b/src/components/MenuCommands/CommandButton.vue @@ -49,6 +49,7 @@ import 'vue-awesome/icons/expand'; import 'vue-awesome/icons/compress'; import 'vue-awesome/icons/print'; import 'vue-awesome/icons/eye'; +import 'vue-awesome/icons/regular/object-group'; import { Component, Prop, Vue } from 'vue-property-decorator'; import { Tooltip } from 'element-ui'; diff --git a/src/extensions/index.ts b/src/extensions/index.ts index 80bffa1a..69cc585b 100644 --- a/src/extensions/index.ts +++ b/src/extensions/index.ts @@ -42,3 +42,4 @@ export { default as FormatClear } from './format_clear'; export { default as Fullscreen } from './fullscreen'; export { default as Print } from './print'; export { default as Preview } from './preview'; +export { default as SelectAll } from './select_all'; diff --git a/src/extensions/select_all.ts b/src/extensions/select_all.ts new file mode 100644 index 00000000..0c85f8f6 --- /dev/null +++ b/src/extensions/select_all.ts @@ -0,0 +1,27 @@ +import { selectAll } from 'prosemirror-commands'; +import { Extension, MenuData } from 'tiptap'; +import { CommandFunction } from 'tiptap-commands'; +import { MenuBtnView } from '@/../types'; +import { t } from '@/i18n/index'; +import CommandButton from '@/components/MenuCommands/CommandButton.vue'; + +export default class SelectAll extends Extension implements MenuBtnView { + get name () { + return 'select_all'; + } + + commands () { + return (): CommandFunction => selectAll; + } + + menuBtnView ({ commands }: MenuData) { + return { + component: CommandButton, + componentProps: { + command: commands.select_all, + icon: 'regular/object-group', + tooltip: t('editor.extensions.SelectAll.tooltip'), + }, + }; + } +} diff --git a/src/i18n/en/index.ts b/src/i18n/en/index.ts index a188a514..0ebbed7a 100644 --- a/src/i18n/en/index.ts +++ b/src/i18n/en/index.ts @@ -152,6 +152,9 @@ export default { title: 'Preview', }, }, + SelectAll: { + tooltip: 'Select all', + }, }, characters: 'Characters', }, diff --git a/src/i18n/pl/index.ts b/src/i18n/pl/index.ts index eb7c074a..24a807f7 100644 --- a/src/i18n/pl/index.ts +++ b/src/i18n/pl/index.ts @@ -152,6 +152,9 @@ export default { title: 'Podgląd', }, }, + SelectAll: { + tooltip: 'Zaznacz wszystko', + }, }, characters: 'Postać', }, diff --git a/src/i18n/zh/index.ts b/src/i18n/zh/index.ts index 55bbe4bb..fe64ecde 100644 --- a/src/i18n/zh/index.ts +++ b/src/i18n/zh/index.ts @@ -152,6 +152,9 @@ export default { title: '预览', }, }, + SelectAll: { + tooltip: '全选', + }, }, characters: '字数', },