From 5e3226563e5702fb67fdb6e5c4ffd33c83fd4367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Thu, 6 Jul 2023 20:38:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(custom-block):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=85=A8=E5=AE=BD=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD=20|=20Ad?= =?UTF-8?q?d=20full-width=20display=20function.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/i18n/en_US.json | 3 +++ public/i18n/zh_CHT.json | 3 +++ public/i18n/zh_CN.json | 3 +++ src/configs/default.ts | 33 ++++++++++++++++++++++- src/styles/custom-block-width-full.less | 36 +++++++++++++++++++++++++ src/styles/index.less | 1 + 6 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/styles/custom-block-width-full.less diff --git a/public/i18n/en_US.json b/public/i18n/en_US.json index c8354a8..b5ea989 100644 --- a/public/i18n/en_US.json +++ b/public/i18n/en_US.json @@ -21,6 +21,9 @@ }, "custom-block-style": { "label": "Block Style" + }, + "custom-block-width-full": { + "label": "Full-width Display" } } } diff --git a/public/i18n/zh_CHT.json b/public/i18n/zh_CHT.json index 3a5c05c..cf03fb4 100644 --- a/public/i18n/zh_CHT.json +++ b/public/i18n/zh_CHT.json @@ -21,6 +21,9 @@ }, "custom-block-style": { "label": "塊樣式" + }, + "custom-block-width-full": { + "label": "全寬顯示" } } } diff --git a/public/i18n/zh_CN.json b/public/i18n/zh_CN.json index 01922ff..11c9667 100644 --- a/public/i18n/zh_CN.json +++ b/public/i18n/zh_CN.json @@ -21,6 +21,9 @@ }, "custom-block-style": { "label": "块样式" + }, + "custom-block-width-full": { + "label": "全宽显示" } } } diff --git a/src/configs/default.ts b/src/configs/default.ts index 6668e37..e4e4387 100644 --- a/src/configs/default.ts +++ b/src/configs/default.ts @@ -46,7 +46,7 @@ export const DEFAULT_CONFIG: IConfig = { ], }, { // 分割线 - id: "custom-block-separator-1", + id: "custom-block-separator-0", enable: true, mode: MenuItemMode.separator, multi: false, @@ -55,6 +55,37 @@ export const DEFAULT_CONFIG: IConfig = { [sdk.siyuan.NodeType.NodeDocument]: { enable: false }, }, }, + { // 全宽显示 + id: "custom-block-width-full", + enable: true, + mode: MenuItemMode.button, + multi: true, + icon: "iconHideDock", + accelerator: "width: full", + token: "width-full", + type: { + default: { enable: false }, + [sdk.siyuan.NodeType.NodeAudio]: { enable: true }, + [sdk.siyuan.NodeType.NodeIFrame]: { enable: true }, + [sdk.siyuan.NodeType.NodeVideo]: { enable: true }, + [sdk.siyuan.NodeType.NodeWidget]: { enable: true }, + }, + tasks: [ + { + type: TaskType.toggle, + params: { + name: "custom-block-width", + token: "full", + }, + }, + ], + }, + { // 分割线 + id: "custom-block-separator-1", + enable: true, + mode: MenuItemMode.separator, + multi: false, + }, { // 弹幕 id: "custom-block-render-danmaku", enable: true, diff --git a/src/styles/custom-block-width-full.less b/src/styles/custom-block-width-full.less new file mode 100644 index 0000000..bfaeb81 --- /dev/null +++ b/src/styles/custom-block-width-full.less @@ -0,0 +1,36 @@ +// Copyright (C) 2023 Zuoqiu Yingyi +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +/* 全宽显示 */ + +:root { + &[plugin-custom-block~=width-full] { + .protyle-wysiwyg { + [custom-block-width~=full] { + &[data-node-id] { + .iframe-content { + + &, + >iframe, + >video, + >audio { + width: 100% !important; + } + } + } + } + } + } +} diff --git a/src/styles/index.less b/src/styles/index.less index 6251d4d..3c9477f 100644 --- a/src/styles/index.less +++ b/src/styles/index.less @@ -21,3 +21,4 @@ @import (once) url(./custom-block-render-index.less); @import (once) url(./custom-block-render-outline.less); @import (once) url(./custom-block-render-scroll.less); +@import (once) url(./custom-block-width-full.less);