Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve custom inline color management https://github.com/siyuan-note/siyuan/issues/13749

Daniel97c3c3c2284f
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 32bfc4b352..eee1e2f672 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "إدارة الألوان المخصصة",
+ "deleteCustomColorTip": "بعد الحذف والحفظ، سيعود المحتوى الذي يستخدم اللون المخصص «${name}» إلى اللون المحفوظ عند تطبيقه، ولن يتغير بعد ذلك مع التبديل بين الوضعين الفاتح والداكن. هل أنت متأكد من حذفه؟",
"mobileMenuNavigation": "التنقل",
"mobileBottomBar": "الشريط السفلي",
"insertSuperBlockLeft": "إدراج عمود إلى اليسار",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 87ae8a705c..99c33610fc 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Benutzerdefinierte Farben verwalten",
+ "deleteCustomColorTip": "Nach dem Löschen und Speichern verwendet Inhalt mit der benutzerdefinierten Farbe „${name}“ wieder die beim Anwenden gespeicherte Farbe und folgt nicht mehr dem Wechsel zwischen hellem und dunklem Modus. Möchten Sie sie wirklich löschen?",
"mobileMenuNavigation": "Navigation",
"mobileBottomBar": "Untere Leiste",
"insertSuperBlockLeft": "Spalte links einfügen",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 9994928b05..3f874027e0 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Manage custom colors",
+ "deleteCustomColorTip": "After deleting and saving, content using the custom color “${name}” will fall back to the color saved when it was applied and will no longer follow light/dark mode changes. Are you sure you want to delete it?",
"mobileMenuNavigation": "Navigation",
"mobileBottomBar": "Bottom bar",
"insertSuperBlockLeft": "Insert column to the left",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 6c90198f0b..1a43b4bc71 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Administrar colores personalizados",
+ "deleteCustomColorTip": "Después de eliminar y guardar, el contenido que use el color personalizado «${name}» volverá al color guardado cuando se aplicó y dejará de adaptarse al cambio entre los modos claro y oscuro. ¿Seguro que quieres eliminarlo?",
"mobileMenuNavigation": "Navegación",
"mobileBottomBar": "Barra inferior",
"insertSuperBlockLeft": "Insertar columna a la izquierda",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 79e75844dc..61f9546360 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Gérer les couleurs personnalisées",
+ "deleteCustomColorTip": "Après la suppression et l’enregistrement, le contenu utilisant la couleur personnalisée « ${name} » reprendra la couleur enregistrée lors de son application et ne suivra plus les changements de mode clair/sombre. Voulez-vous vraiment la supprimer ?",
"mobileMenuNavigation": "Navigation",
"mobileBottomBar": "Barre inférieure",
"insertSuperBlockLeft": "Insérer une colonne à gauche",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 196842067e..37db0e632d 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "ניהול צבעים מותאמים אישית",
+ "deleteCustomColorTip": "לאחר המחיקה והשמירה, תוכן המשתמש בצבע המותאם אישית „${name}” יחזור לצבע שנשמר בעת החלתו ולא ישתנה עוד במעבר בין מצב בהיר לכהה. האם למחוק אותו?",
"mobileMenuNavigation": "ניווט",
"mobileBottomBar": "סרגל תחתון",
"insertSuperBlockLeft": "הוספת עמודה משמאל",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 50a799cf40..c8dc7ae332 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "कस्टम रंग प्रबंधित करें",
+ "deleteCustomColorTip": "हटाने और सहेजने के बाद, कस्टम रंग “${name}” का उपयोग करने वाली सामग्री लागू करते समय सहेजे गए रंग पर वापस आ जाएगी और फिर हल्के/गहरे मोड के बदलाव का अनुसरण नहीं करेगी। क्या आप वाकई इसे हटाना चाहते हैं?",
"mobileMenuNavigation": "नेविगेशन",
"mobileBottomBar": "निचली पट्टी",
"insertSuperBlockLeft": "बाईं ओर कॉलम डालें",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 577ff14604..17198b5185 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Kelola warna kustom",
+ "deleteCustomColorTip": "Setelah dihapus dan disimpan, konten yang menggunakan warna kustom “${name}” akan kembali ke warna yang disimpan saat diterapkan dan tidak lagi mengikuti perubahan mode terang/gelap. Yakin ingin menghapusnya?",
"mobileMenuNavigation": "Navigasi",
"mobileBottomBar": "Bilah bawah",
"insertSuperBlockLeft": "Sisipkan kolom di sebelah kiri",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index f1bbb5a258..c8112fe853 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Gestisci colori personalizzati",
+ "deleteCustomColorTip": "Dopo l’eliminazione e il salvataggio, il contenuto che usa il colore personalizzato “${name}” tornerà al colore salvato al momento dell’applicazione e non seguirà più il cambio tra modalità chiara e scura. Vuoi davvero eliminarlo?",
"mobileMenuNavigation": "Navigazione",
"mobileBottomBar": "Barra inferiore",
"insertSuperBlockLeft": "Inserisci colonna a sinistra",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index 6f5033c060..d02ca70a0e 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "カスタム色を管理",
+ "deleteCustomColorTip": "削除して保存すると、カスタム色「${name}」を使用している内容は適用時に保存された色へ戻り、ライトモードとダークモードの切り替えに追従しなくなります。削除してもよろしいですか?",
"mobileMenuNavigation": "ナビゲーション",
"mobileBottomBar": "下部バー",
"insertSuperBlockLeft": "左側に列を挿入",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index 5f6ea16c60..b4c10ac568 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "사용자 지정 색상 관리",
+ "deleteCustomColorTip": "삭제 후 저장하면 사용자 지정 색상 “${name}”을 사용하는 콘텐츠는 적용할 때 저장된 색상으로 대체되며 더 이상 밝은/어두운 모드 전환을 따르지 않습니다. 삭제하시겠습니까?",
"mobileMenuNavigation": "내비게이션",
"mobileBottomBar": "하단 바",
"insertSuperBlockLeft": "왼쪽에 열 삽입",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 04bafb307d..4c1df53e03 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Aangepaste kleuren beheren",
+ "deleteCustomColorTip": "Na verwijderen en opslaan valt inhoud die de aangepaste kleur ‘${name}’ gebruikt terug op de kleur die bij het toepassen is opgeslagen en volgt deze niet langer wisselingen tussen de lichte en donkere modus. Weet je zeker dat je deze wilt verwijderen?",
"mobileMenuNavigation": "Navigatie",
"mobileBottomBar": "Onderste balk",
"insertSuperBlockLeft": "Kolom links invoegen",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 2e164b5903..052cc1762b 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Zarządzaj kolorami niestandardowymi",
+ "deleteCustomColorTip": "Po usunięciu i zapisaniu zawartość używająca niestandardowego koloru „${name}” powróci do koloru zapisanego podczas zastosowania i przestanie reagować na przełączanie trybu jasnego i ciemnego. Czy na pewno chcesz go usunąć?",
"mobileMenuNavigation": "Nawigacja",
"mobileBottomBar": "Dolny pasek",
"insertSuperBlockLeft": "Wstaw kolumnę po lewej",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index eb5de5a847..65bad72b27 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Gerenciar cores personalizadas",
+ "deleteCustomColorTip": "Após excluir e salvar, o conteúdo que usa a cor personalizada “${name}” voltará à cor salva quando ela foi aplicada e não acompanhará mais a alternância entre os modos claro e escuro. Tem certeza de que deseja excluí-la?",
"mobileMenuNavigation": "Navegação",
"mobileBottomBar": "Barra inferior",
"insertSuperBlockLeft": "Inserir coluna à esquerda",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index d3f66e0925..f668f2a6a9 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Управление пользовательскими цветами",
+ "deleteCustomColorTip": "После удаления и сохранения содержимое с пользовательским цветом «${name}» вернётся к цвету, сохранённому при применении, и больше не будет меняться при переключении светлого и тёмного режимов. Удалить этот цвет?",
"mobileMenuNavigation": "Навигация",
"mobileBottomBar": "Нижняя панель",
"insertSuperBlockLeft": "Вставить столбец слева",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index 6c85c007ad..998e313227 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Spravovať vlastné farby",
+ "deleteCustomColorTip": "Po odstránení a uložení sa obsah používajúci vlastnú farbu „${name}“ vráti k farbe uloženej pri jej použití a prestane sa prispôsobovať prepínaniu svetlého a tmavého režimu. Naozaj ju chcete odstrániť?",
"mobileMenuNavigation": "Navigácia",
"mobileBottomBar": "Spodná lišta",
"insertSuperBlockLeft": "Vložiť stĺpec vľavo",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index bc2ca1356b..d2f397cdb7 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "จัดการสีที่กำหนดเอง",
+ "deleteCustomColorTip": "หลังจากลบและบันทึก เนื้อหาที่ใช้สีที่กำหนดเอง “${name}” จะกลับไปใช้สีที่บันทึกไว้ตอนนำไปใช้ และจะไม่เปลี่ยนตามการสลับโหมดสว่าง/มืดอีกต่อไป คุณแน่ใจหรือไม่ว่าต้องการลบ?",
"mobileMenuNavigation": "การนำทาง",
"mobileBottomBar": "แถบด้านล่าง",
"insertSuperBlockLeft": "แทรกคอลัมน์ทางซ้าย",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index ebd73cbf83..ba133ac483 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Özel renkleri yönet",
+ "deleteCustomColorTip": "Silip kaydettikten sonra “${name}” özel rengini kullanan içerik, uygulandığı sırada kaydedilen renge döner ve artık açık/koyu mod değişikliklerini izlemez. Silmek istediğinizden emin misiniz?",
"mobileMenuNavigation": "Gezinme",
"mobileBottomBar": "Alt çubuk",
"insertSuperBlockLeft": "Sola sütun ekle",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 6066bd1e5c..f257a9813e 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "Керування власними кольорами",
+ "deleteCustomColorTip": "Після видалення та збереження вміст із власним кольором «${name}» повернеться до кольору, збереженого під час застосування, і більше не змінюватиметься при перемиканні світлого й темного режимів. Видалити цей колір?",
"mobileMenuNavigation": "Навігація",
"mobileBottomBar": "Нижня панель",
"insertSuperBlockLeft": "Вставити стовпець ліворуч",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index 3adcf8b528..8f71b4a452 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "管理自定义颜色",
+ "deleteCustomColorTip": "删除并保存后,文档中使用自定义颜色“${name}”的内容将回退到应用时保存的颜色,且不再随明亮模式和暗黑模式切换。确定要删除吗?",
"mobileMenuNavigation": "导航",
"mobileBottomBar": "底栏",
"insertSuperBlockLeft": "左侧插入分栏",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 54017325ec..a697be5f8a 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,6 @@
{
+ "manageCustomColors": "管理自定義顏色",
+ "deleteCustomColorTip": "刪除並儲存後,文件中使用自定義顏色「${name}」的內容將回退到套用時儲存的顏色,且不再隨明亮模式和暗黑模式切換。確定要刪除嗎?",
"mobileMenuNavigation": "導航",
"mobileBottomBar": "底欄",
"insertSuperBlockLeft": "左側插入分欄",
diff --git a/app/src/assets/scss/business/_color.scss b/app/src/assets/scss/business/_color.scss
index 1bc02524ed..3bfe3abf5a 100644
--- a/app/src/assets/scss/business/_color.scss
+++ b/app/src/assets/scss/business/_color.scss
@@ -16,6 +16,7 @@
font-size: 16px;
font-weight: 500;
color: var(--b3-theme-on-background);
+ user-select: none;
&--list {
margin: 0 8px 0 0;
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index c144d053a5..3e172bacc2 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -398,8 +398,8 @@ export const renderTextMenu = (protyle: IProtyle, toolbarElement: Element) => {
});
const getManageHTML = (type: TInlineStyleType) => window.siyuan.config.readonly || window.siyuan.isPublish ? "" :
`<button class="keyboard__slash-item" data-action="manageInlineStyle" data-inline-style-type="${type}">
- <svg class="keyboard__slash-icon"><use xlink:href="#iconAdd"></use></svg>
- <span class="keyboard__slash-text">${window.siyuan.languages.manage}</span>
+ <svg class="keyboard__slash-icon"><use xlink:href="#iconSettings"></use></svg>
+ <span class="keyboard__slash-text">${window.siyuan.languages.manageCustomColors}</span>
</button>`;
const nodeElements = getFontNodeElements(protyle);
diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.ts
index 3a6514d158..335cd44181 100644
--- a/app/src/protyle/toolbar/Font.ts
+++ b/app/src/protyle/toolbar/Font.ts
@@ -145,7 +145,7 @@ export const appearanceMenu = (protyle: IProtyle, nodeElements?: Element[],
}
});
const getManageHTML = (type: TInlineStyleType) => window.siyuan.config.readonly || window.siyuan.isPublish ? "" :
- `<button class="color__square ariaLabel" data-position="3south" aria-label="${window.siyuan.languages.manage}" data-action="manageInlineStyle" data-inline-style-type="${type}"><svg class="svg--mid"><use xlink:href="#iconAdd"></use></svg></button>`;
+ `<button class="color__square ariaLabel" data-position="3south" aria-label="${window.siyuan.languages.manageCustomColors}" data-action="manageInlineStyle" data-inline-style-type="${type}"><svg class="svg--mid"><use xlink:href="#iconSettings"></use></svg></button>`;
const element = document.createElement("div");
element.classList.add("protyle-font");
diff --git a/app/src/protyle/toolbar/inlineStyleDialog.ts b/app/src/protyle/toolbar/inlineStyleDialog.ts
index 27b1f1864d..daa4aefb3e 100644
--- a/app/src/protyle/toolbar/inlineStyleDialog.ts
+++ b/app/src/protyle/toolbar/inlineStyleDialog.ts
@@ -1,4 +1,5 @@
import {Dialog} from "../../dialog";
+import {confirmDialog} from "../../dialog/confirmDialog";
import {showMessage} from "../../dialog/message";
import {escapeAttr, escapeHtml} from "../../util/escape";
import {isMobile} from "../../util/functions";
@@ -41,24 +42,25 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
return;
}
const draft = cloneInlineStyles();
+ const persistedStyleIDs = new Set(draft.styles.map(style => style.id));
let editingIndex: number | undefined;
let saving = false;
const dialog = new Dialog({
title: window.siyuan.languages.color,
width: isMobile() ? "92vw" : "600px",
- content: `<div class="b3-dialog__content" style="display:flex;flex-direction:column;gap:12px;max-height:70vh;overflow:auto">
+ content: `<div class="b3-dialog__content" style="max-height:70vh;overflow:auto">
<div data-panel="list">
<div data-type="inlineStyleList" class="b3-list b3-list--background fn__selectnone" style="--file-toggle-width:0px"></div>
- <button class="b3-button b3-button--outline" data-action="new" type="button" style="margin-top:8px">
+ <button class="b3-button b3-button--outline" data-action="new" type="button">
<svg><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.new}
</button>
</div>
<div data-panel="editor" class="fn__none">
- <label class="b3-label fn__flex">
+ <label class="b3-label b3-label--inner fn__flex" style="align-items:center">
<span style="min-width:96px">${window.siyuan.languages.name}</span>
<input class="b3-text-field fn__flex-1" data-field="name">
</label>
- <label class="b3-label fn__flex">
+ <label class="b3-label b3-label--inner fn__flex" style="align-items:center">
<span style="min-width:96px">${window.siyuan.languages.color}</span>
<select class="b3-select fn__flex-1" data-field="type">
<option value="color">${window.siyuan.languages.colorFont}</option>
@@ -66,35 +68,30 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
<option value="style1">${window.siyuan.languages.color}</option>
</select>
</label>
- <div class="fn__flex" style="align-items:stretch;gap:12px;flex-wrap:wrap">
- <div class="b3-label fn__flex-1" style="min-width:200px">
+ <div class="b3-label b3-label--inner fn__flex" style="align-items:flex-start;gap:24px;flex-wrap:wrap">
+ <div class="fn__flex-1" style="min-width:200px">
<div>${window.siyuan.languages.themeLight}</div>
- <label class="fn__flex" data-property="color" style="margin-top:8px">
+ <label class="fn__flex" data-property="color" style="align-items:center;margin-top:8px">
<span class="fn__flex-1">${window.siyuan.languages.colorFont}</span>
<input class="b3-text-field" data-field="lightColor" type="color">
</label>
- <label class="fn__flex" data-property="backgroundColor" style="margin-top:8px">
+ <label class="fn__flex" data-property="backgroundColor" style="align-items:center;margin-top:8px">
<span class="fn__flex-1">${window.siyuan.languages.colorPrimary}</span>
<input class="b3-text-field" data-field="lightBackgroundColor" type="color">
</label>
</div>
- <div class="b3-label fn__flex-1" style="min-width:200px">
+ <div class="fn__flex-1" style="min-width:200px">
<div>${window.siyuan.languages.themeDark}</div>
- <label class="fn__flex" data-property="color" style="margin-top:8px">
+ <label class="fn__flex" data-property="color" style="align-items:center;margin-top:8px">
<span class="fn__flex-1">${window.siyuan.languages.colorFont}</span>
<input class="b3-text-field" data-field="darkColor" type="color">
</label>
- <label class="fn__flex" data-property="backgroundColor" style="margin-top:8px">
+ <label class="fn__flex" data-property="backgroundColor" style="align-items:center;margin-top:8px">
<span class="fn__flex-1">${window.siyuan.languages.colorPrimary}</span>
<input class="b3-text-field" data-field="darkBackgroundColor" type="color">
</label>
</div>
</div>
- <div class="fn__flex" style="justify-content:flex-end;margin-top:12px">
- <button class="b3-button b3-button--cancel" data-action="cancelEdit" type="button">${window.siyuan.languages.cancel}</button>
- <span class="fn__space"></span>
- <button class="b3-button b3-button--text" data-action="confirmEdit" type="button">${window.siyuan.languages.confirm}</button>
- </div>
</div>
</div>
<div class="b3-dialog__action" data-panel="actions">
@@ -105,9 +102,10 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
});
const listPanel = dialog.element.querySelector('[data-panel="list"]') as HTMLElement;
const editorPanel = dialog.element.querySelector('[data-panel="editor"]') as HTMLElement;
- const actionsPanel = dialog.element.querySelector('[data-panel="actions"]') as HTMLElement;
const listElement = dialog.element.querySelector('[data-type="inlineStyleList"]') as HTMLElement;
const newElement = dialog.element.querySelector('[data-action="new"]') as HTMLButtonElement;
+ const cancelElement = dialog.element.querySelector('[data-action="cancel"]') as HTMLButtonElement;
+ const saveElement = dialog.element.querySelector('[data-action="save"]') as HTMLButtonElement;
const nameElement = dialog.element.querySelector('[data-field="name"]') as HTMLInputElement;
const typeElement = dialog.element.querySelector('[data-field="type"]') as HTMLSelectElement;
const lightColorElement = dialog.element.querySelector('[data-field="lightColor"]') as HTMLInputElement;
@@ -117,7 +115,7 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
const renderList = () => {
listElement.innerHTML = draft.styles.length === 0 ?
- `<div class="b3-list-item"><span class="b3-list-item__text">${window.siyuan.languages.empty}</span></div>` :
+ "" :
draft.styles.map((style, index) => `<div class="b3-list-item b3-list-item--narrow" data-id="${escapeAttribute(style.id)}" data-index="${index}">
<span class="b3-list-item__graphic ariaLabel fn__grab" data-drag="true" draggable="true" data-position="north" aria-label="${escapeAttribute(window.siyuan.languages.sort)}"><svg><use xlink:href="#iconDrag"></use></svg></span>
<span class="color__square color__square--list" style="${renderPreviewStyle(style)}">A</span>
@@ -127,6 +125,7 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
<span class="b3-list-item__action b3-list-item__action--warning ariaLabel" data-action="delete" data-index="${index}" data-position="north" aria-label="${escapeAttribute(window.siyuan.languages.delete)}"><svg><use xlink:href="#iconTrashcan"></use></svg></span>
</div>`).join("");
newElement.disabled = draft.styles.length >= MAX_INLINE_STYLES;
+ newElement.style.marginTop = draft.styles.length === 0 ? "0" : "8px";
};
const updateColorVisibility = () => {
@@ -139,11 +138,17 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
});
};
+ const setEditorActionMode = (editing: boolean) => {
+ cancelElement.dataset.action = editing ? "cancelEdit" : "cancel";
+ saveElement.dataset.action = editing ? "confirmEdit" : "save";
+ saveElement.textContent = editing ? window.siyuan.languages.confirm : window.siyuan.languages.save;
+ };
+
const showList = () => {
editingIndex = undefined;
editorPanel.classList.add("fn__none");
listPanel.classList.remove("fn__none");
- actionsPanel.classList.remove("fn__none");
+ setEditorActionMode(false);
renderList();
};
@@ -159,8 +164,8 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
darkBackgroundElement.value = style?.dark.backgroundColor || "#554b00";
updateColorVisibility();
listPanel.classList.add("fn__none");
- actionsPanel.classList.add("fn__none");
editorPanel.classList.remove("fn__none");
+ setEditorActionMode(true);
nameElement.focus();
};
@@ -278,8 +283,21 @@ export const openInlineStyleDialog = (initialType: TInlineStyleType = "backgroun
} else if (action === "edit") {
showEditor(index);
} else if (action === "delete") {
- draft.styles.splice(index, 1);
- renderList();
+ const style = draft.styles[index];
+ if (!style) {
+ return;
+ }
+ const removeStyle = () => {
+ draft.styles.splice(index, 1);
+ renderList();
+ };
+ if (persistedStyleIDs.has(style.id)) {
+ confirmDialog(window.siyuan.languages.deleteOpConfirm,
+ window.siyuan.languages.deleteCustomColorTip.replace("${name}", `<b>${escapeHtml(style.name)}</b>`),
+ removeStyle, undefined, true);
+ } else {
+ removeStyle();
+ }
} else if (action === "cancelEdit") {
showList();
} else if (action === "confirmEdit") {