Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: simplify tag alias system

thecodrrdcf4aeb3fce1
diff --git a/apps/web/src/common/dialogcontroller.js b/apps/web/src/common/dialogcontroller.js
index 1109b670e..43914e0e3 100644
--- a/apps/web/src/common/dialogcontroller.js
+++ b/apps/web/src/common/dialogcontroller.js
@@ -14,7 +14,6 @@ import download from "../utils/download";
import { zip } from "../utils/zip";
import Config from "../utils/config";
import Dialogs from "../components/dialogs";
-import { toTitleCase } from "../utils/string";
function showDialog(dialog) {
const root = document.getElementById("dialogContainer");
@@ -521,7 +520,8 @@ export function showEditTagDialog(tagId) {
return showDialog((Dialogs, perform) => (
<Dialogs.ItemDialog
title={"Edit tag"}
- subtitle={`You are editing #${tag.alias || tag.title}.`}
+ subtitle={`You are editing #${db.tags.alias(tag.id)}.`}
+ defaultValue={db.tags.alias(tag.id)}
item={tag}
onClose={() => perform(false)}
onAction={async (title) => {
@@ -541,8 +541,9 @@ export function showRenameColorDialog(colorId) {
return showDialog((Dialogs, perform) => (
<Dialogs.ItemDialog
title={"Rename color"}
- subtitle={`You are renaming color ${toTitleCase(color.title)}.`}
+ subtitle={`You are renaming color ${db.colors.alias(color.id)}.`}
item={color}
+ defaultValue={db.colors.alias(color.id)}
onClose={() => perform(false)}
onAction={async (title) => {
if (!title) return;
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index f7c28b66a..2b4aa0a96 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -14,15 +14,15 @@ import { db } from "./db";
import { sanitizeFilename } from "../utils/filename";
import { isTesting } from "../utils/platform";
-export const COLORS = {
- red: "#f44336",
- orange: "#FF9800",
- yellow: "#FFD600",
- green: "#4CAF50",
- blue: "#2196F3",
- purple: "#673AB7",
- gray: "#9E9E9E",
-};
+export const COLORS = [
+ "Red",
+ "Orange",
+ "Yellow",
+ "Green",
+ "Blue",
+ "Purple",
+ "Gray",
+];
export const SUBSCRIPTION_STATUS = {
BASIC: 0,
diff --git a/apps/web/src/components/dialogs/item-dialog.js b/apps/web/src/components/dialogs/item-dialog.js
index b95294d3d..d6c7663ac 100644
--- a/apps/web/src/components/dialogs/item-dialog.js
+++ b/apps/web/src/components/dialogs/item-dialog.js
@@ -35,7 +35,7 @@ function ItemDialog(props) {
name="title"
autoFocus
data-test-id="item-dialog-title"
- defaultValue={props.item?.alias || props.item?.title}
+ defaultValue={props.defaultValue}
/>
</Box>
</Dialog>
diff --git a/apps/web/src/components/editor/header.js b/apps/web/src/components/editor/header.js
index 602fc710e..c84c3e991 100644
--- a/apps/web/src/components/editor/header.js
+++ b/apps/web/src/components/editor/header.js
@@ -42,7 +42,7 @@ function Header() {
<Autosuggest
sx={{ ml: 1 }}
getData={() => db.tags.all}
- getFields={(item) => [item.title, item.alias]}
+ getFields={(item) => [db.tags.alias(item.id)]}
limit={5}
onAdd={(value) => setTag(value)}
onSelect={(item) => setTag(item.title)}
@@ -63,7 +63,7 @@ function Header() {
>
<Icon.Tag size={14} />
<Text variant="title" fontWeight="body">
- {item.alias || item.title}
+ {db.tags.alias(item.id)}
</Text>
</Flex>
)}
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index 4af847c5c..27634a199 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useRef } from "react";
-import { Flex, Text } from "rebass";
+import { Flex } from "rebass";
import Button from "../button";
import * as Icon from "../icons";
import { Virtuoso } from "react-virtuoso";
diff --git a/apps/web/src/components/menu/colors.js b/apps/web/src/components/menu/colors.js
index 860b23182..227de5376 100644
--- a/apps/web/src/components/menu/colors.js
+++ b/apps/web/src/components/menu/colors.js
@@ -1,7 +1,6 @@
import React from "react";
import { COLORS } from "../../common";
import * as Icon from "../icons/index";
-import { objectMap } from "../../utils/object";
import { useStore } from "../../stores/note-store";
import { Flex } from "rebass";
import useMobile from "../../utils/use-mobile";
@@ -12,7 +11,7 @@ function Colors(props) {
const isMobile = useMobile();
return (
<Flex flexWrap="wrap">
- {objectMap(COLORS, (label, code) => (
+ {COLORS.map((label) => (
<Flex
sx={{ position: "relative" }}
onClick={() => setColor(id, label)}
@@ -23,7 +22,7 @@ function Colors(props) {
<Icon.Circle
size={isMobile ? 45 : 25}
style={{ cursor: "pointer" }}
- color={label}
+ color={label.toLowerCase()}
strokeWidth={0}
data-test-id={`menuitem-colors-${label}`}
/>
diff --git a/apps/web/src/components/navigation-menu/index.js b/apps/web/src/components/navigation-menu/index.js
index 0af12cf40..14dea3776 100644
--- a/apps/web/src/components/navigation-menu/index.js
+++ b/apps/web/src/components/navigation-menu/index.js
@@ -7,7 +7,6 @@ import { useStore as useThemeStore } from "../../stores/theme-store";
import Animated from "../animated";
import NavigationItem from "./navigation-item";
import { navigate } from "../../navigation";
-import { toTitleCase } from "../../utils/string";
import { db } from "../../common/db";
import useMobile from "../../utils/use-mobile";
import { useLocation } from "wouter";
@@ -135,10 +134,10 @@ function NavigationMenu(props) {
{colors.map((color) => (
<NavigationItem
key={color.id}
- title={toTitleCase(color.alias || color.title)}
+ title={db.colors.alias(color.id)}
icon={Icon.Circle}
selected={location === `/colors/${color.id}`}
- color={color.title}
+ color={color.title.toLowerCase()}
onClick={() => {
navigate(`/colors/${color.id}`);
}}
@@ -160,7 +159,7 @@ function NavigationMenu(props) {
{pins.map((pin) => (
<NavigationItem
key={pin.id}
- title={pin.alias || pin.title}
+ title={pin.type === "tag" ? db.tags.alias(pin.id) : pin.title}
menu={{
items: [
{
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 81244620c..403f93ad3 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -25,7 +25,7 @@ function Note(props) {
const primary = useMemo(() => {
if (!note.color) return "primary";
- return note.color;
+ return note.color.toLowerCase();
}, [note.color]);
const notebook = useMemo(() => {
@@ -81,7 +81,7 @@ function Note(props) {
return (
<IconTag
key={tagItem.id}
- text={tagItem.alias || tagItem.title}
+ text={db.tags.alias(tagItem.id)}
icon={Icon.Tag}
onClick={() => {
if (!tagItem.id) return showToast("Tag not found.");
diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.js
index 35754adbd..cc84661c8 100644
--- a/apps/web/src/components/properties/index.js
+++ b/apps/web/src/components/properties/index.js
@@ -4,11 +4,9 @@ import { Flex, Text, Button } from "rebass";
import { useStore } from "../../stores/editor-store";
import { COLORS } from "../../common";
import { db } from "../../common/db";
-import { objectMap } from "../../utils/object";
import { useStore as useAppStore } from "../../stores/app-store";
import Animated from "../animated";
import Toggle from "./toggle";
-import { toTitleCase } from "../../utils/string";
import { showMoveNoteDialog } from "../../common/dialog-controller";
import { navigate } from "../../navigation";
@@ -117,7 +115,7 @@ function Properties() {
))}
</Flex>
<Flex flexDirection="column">
- {objectMap(COLORS, (label, code) => (
+ {COLORS.map((label) => (
<Flex
key={label}
justifyContent="space-between"
@@ -128,12 +126,12 @@ function Properties() {
data-test-id={`properties-${label}`}
>
<Flex key={label} alignItems="center">
- <Icon.Circle size={14} color={label} />
+ <Icon.Circle size={14} color={label.toLowerCase()} />
<Text ml={1} color="text" variant="body">
- {toTitleCase(label)}
+ {label}
</Text>
</Flex>
- {color === label && (
+ {label.toLowerCase() === color?.toLowerCase() && (
<Icon.Checkmark
color="primary"
size={20}
diff --git a/apps/web/src/navigation/routes.js b/apps/web/src/navigation/routes.js
index 4121a849b..dc9308cee 100644
--- a/apps/web/src/navigation/routes.js
+++ b/apps/web/src/navigation/routes.js
@@ -1,6 +1,5 @@
import React from "react";
import { db } from "../common/db";
-import { toTitleCase } from "../utils/string";
import Home from "../views/home";
import Notebooks from "../views/notebooks";
import Notes from "../views/notes.js";
@@ -147,7 +146,7 @@ const routes = {
return {
key: "notes",
type: "notes",
- title: toTitleCase(title),
+ title: title,
component: <Notes />,
buttons: {
search: {
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index b4d9a2a81..53d0b4316 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -8729,9 +8729,22 @@ normalize-url@^3.0.0:
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-3.3.0.tgz"
integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg==
+notes-core@../notesnook-core/:
+ version "6.8.4"
+ dependencies:
+ "@stablelib/blake2s" "^1.0.1"
+ dayjs "^1.10.6"
+ fast-sort "^2.0.1"
+ lean-he "^2.1.2"
+ no-internet "^1.5.2"
+ qclone "^1.0.4"
+ quill-delta-to-html "^0.12.0"
+ showdown "https://github.com/thecodrr/showdown"
+ spark-md5 "^3.0.1"
+
"notes-core@git+https://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:[email protected]/streetwriters/notesnook-core.git":
version "6.8.4"
- resolved "git+https://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:[email protected]/streetwriters/notesnook-core.git#18b05fecdcab12278eb4e2e83e20e1f2d2cc97d0"
+ resolved "git+https://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:[email protected]/streetwriters/notesnook-core.git#217831febd77c3eeeda2e02f4bd5f86a5ddfe716"
dependencies:
"@stablelib/blake2s" "^1.0.1"
dayjs "^1.10.6"