diff --git a/src/components/dashboard/toolbars/ResizeImage.tsx b/src/components/dashboard/toolbars/ResizeImage.tsx new file mode 100644 index 00000000..c041deeb --- /dev/null +++ b/src/components/dashboard/toolbars/ResizeImage.tsx @@ -0,0 +1,27 @@ +import { type EditorView } from "@codemirror/view" + +import { ICommand, wrapExecute } from "." + +const action = (view: EditorView) => { + wrapExecute({ + view, + prepend: ':::div{style="max=width: 300px"}\n', + append: "\n:::", + }) +} + +export const ResizeImage: ICommand = { + name: "image-size", + label: "Image Size", + icon: "i-mingcute-photo-album-2-fill", + execute: ({ view }) => { + action(view) + }, + shortcut: { + key: "Mod-Shift-s", + run(view) { + action(view) + return true + }, + }, +} diff --git a/src/components/dashboard/toolbars/index.tsx b/src/components/dashboard/toolbars/index.tsx index 6a43326e..9008a412 100644 --- a/src/components/dashboard/toolbars/index.tsx +++ b/src/components/dashboard/toolbars/index.tsx @@ -21,6 +21,7 @@ import { ListUnordered } from "./ListUnordered" import { Mention } from "./Mention" import { Multimedia } from "./Multimedia" import { Quote } from "./Quote" +import { ResizeImage } from "./ResizeImage" import { Strikethrough } from "./Strikethrough" import { Underline } from "./Underline" @@ -102,6 +103,7 @@ export const toolbars: ICommand[] = [ ListOrdered, Link, Multimedia, + ResizeImage, Mention, Formula, Emoji, diff --git a/src/messages/ja.json b/src/messages/ja.json index 8af32365..f5f5ee4c 100644 --- a/src/messages/ja.json +++ b/src/messages/ja.json @@ -110,6 +110,7 @@ "Link": "リンク", "Image": "画像", "Upload Image, Audio or Video": "画像、音声、動画をアップロード", + "ResizeImage": "画像のサイズを変更", "Tip: xLog Flavored Markdown": "ヒント:xLog 風のマークダウン", "Preview": "プレビュー", "Publish": "公開", diff --git a/src/messages/zh-TW.json b/src/messages/zh-TW.json index 82677a00..fec1e610 100644 --- a/src/messages/zh-TW.json +++ b/src/messages/zh-TW.json @@ -159,6 +159,7 @@ "Link": "連結", "Image": "圖片", "Upload Image, Audio or Video": "上傳圖片、音頻或視頻", + "ImageSize": "調整圖片大小", "Preview": "預覽", "Publish": "發布", "Update": "更新", diff --git a/src/messages/zh.json b/src/messages/zh.json index bfad9a1c..67380e61 100644 --- a/src/messages/zh.json +++ b/src/messages/zh.json @@ -174,6 +174,7 @@ "Link": "链接", "Image": "图片", "Upload Image, Audio or Video": "上传图片、音频或视频", + "ImageSize": "调整图像大小", "Mention": "提及", "Tip: xLog Flavored Markdown": "帮助:xLog 风格的 Markdown", "Preview": "预览",