Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

fix color pallette when inserting color

belkhoujaons4cc9edaaeb75
diff --git a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
index 4317cef6..a2357f13 100644
--- a/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
+++ b/frontend/app/components/MarkdownEditor/LazyMarkdownEditor.vue
@@ -73,6 +73,9 @@ function exec(action: string, payload?: string) {
const selectedText = state.sliceDoc(from, to);
let changes;
+ let isColor = false;
+ let anchorPosition = 0;
+ let headPosition = 0;
switch (action) {
case 'bold':
@@ -103,17 +106,24 @@ function exec(action: string, payload?: string) {
changes = { from, to, insert: `1. ${selectedText}\n` };
break;
case 'color': {
+ isColor = true;
const color = String(payload || '').trim();
if (!color) return;
- const value = selectedText || 'text';
- const insert = `{color:${color}}(${value})`;
+ const insert = `{color:${color}}()`;
changes = { from, to, insert };
break;
}
}
+ if (isColor) {
+ headPosition = changes?.insert.length ? changes?.insert.length - 1 + from : 0;
+ anchorPosition = changes?.insert.length ? changes?.insert.length - 1 + to : 0;
+ } else {
+ headPosition = to + 2;
+ anchorPosition = from + 2;
+ }
view.dispatch({
changes,
- selection: { anchor: from + 2, head: to + 2 },
+ selection: { anchor: anchorPosition, head: headPosition },
});
view.focus();