diff --git a/package-lock.json b/package-lock.json
index 9722ede..6524eb8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,10 +20,12 @@
"font-awesome": "^4.7.0",
"hamburgers": "^1.2.1",
"marked": "^4.3.0",
+ "shortid": "^2.2.16",
"vue": "^3.2.47"
},
"devDependencies": {
"@types/dompurify": "^3.0.2",
+ "@types/shortid": "^0.0.29",
"@vitejs/plugin-vue": "^4.1.0",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
@@ -1140,6 +1142,12 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.1.tgz",
"integrity": "sha512-DZxSZWXxFfOlx7k7Rv4LAyiMroaxa3Ly/7OOzZO8cBNho0YzAi4qlbrx8W27JGqG57IgR/6J7r+nOJWw6kcvZA=="
},
+ "node_modules/@types/shortid": {
+ "version": "0.0.29",
+ "resolved": "https://registry.npmjs.org/@types/shortid/-/shortid-0.0.29.tgz",
+ "integrity": "sha512-9BCYD9btg2CY4kPcpMQ+vCR8U6V8f/KvixYD5ZbxoWlkhddNF5IeZMVL3p+QFUkg+Hb+kPAG9Jgk4bnnF1v/Fw==",
+ "dev": true
+ },
"node_modules/@types/trusted-types": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.3.tgz",
@@ -2767,6 +2775,19 @@
"node": ">=10"
}
},
+ "node_modules/shortid": {
+ "version": "2.2.16",
+ "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.16.tgz",
+ "integrity": "sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g==",
+ "dependencies": {
+ "nanoid": "^2.1.0"
+ }
+ },
+ "node_modules/shortid/node_modules/nanoid": {
+ "version": "2.1.11",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
+ "integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
+ },
"node_modules/simple-swizzle": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
@@ -3966,6 +3987,12 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.1.tgz",
"integrity": "sha512-DZxSZWXxFfOlx7k7Rv4LAyiMroaxa3Ly/7OOzZO8cBNho0YzAi4qlbrx8W27JGqG57IgR/6J7r+nOJWw6kcvZA=="
},
+ "@types/shortid": {
+ "version": "0.0.29",
+ "resolved": "https://registry.npmjs.org/@types/shortid/-/shortid-0.0.29.tgz",
+ "integrity": "sha512-9BCYD9btg2CY4kPcpMQ+vCR8U6V8f/KvixYD5ZbxoWlkhddNF5IeZMVL3p+QFUkg+Hb+kPAG9Jgk4bnnF1v/Fw==",
+ "dev": true
+ },
"@types/trusted-types": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.3.tgz",
@@ -5035,6 +5062,21 @@
"lru-cache": "^6.0.0"
}
},
+ "shortid": {
+ "version": "2.2.16",
+ "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.16.tgz",
+ "integrity": "sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g==",
+ "requires": {
+ "nanoid": "^2.1.0"
+ },
+ "dependencies": {
+ "nanoid": {
+ "version": "2.1.11",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz",
+ "integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA=="
+ }
+ }
+ },
"simple-swizzle": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
diff --git a/package.json b/package.json
index d10575f..830a9ba 100644
--- a/package.json
+++ b/package.json
@@ -21,10 +21,12 @@
"font-awesome": "^4.7.0",
"hamburgers": "^1.2.1",
"marked": "^4.3.0",
+ "shortid": "^2.2.16",
"vue": "^3.2.47"
},
"devDependencies": {
"@types/dompurify": "^3.0.2",
+ "@types/shortid": "^0.0.29",
"@vitejs/plugin-vue": "^4.1.0",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
diff --git a/src/App.vue b/src/App.vue
index 4928f3a..1d90175 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -28,10 +28,10 @@ const activeViewMode = ref(viewModes[0])
class="mt-[50px] px-3 py-6"
/>
-
+
diff --git a/src/components/Note.vue b/src/components/Note.vue
index 38dc89a..f1523c5 100644
--- a/src/components/Note.vue
+++ b/src/components/Note.vue
@@ -4,9 +4,14 @@ defineProps<{
}>()
-
- {{ note.title }}
-
- {{ note.content }}
+
+
+ {{ note.title }}
+
+
{{ note.content }}
+
diff --git a/src/components/SearchBar.vue b/src/components/SearchBar.vue
index 3d20b5d..594591e 100644
--- a/src/components/SearchBar.vue
+++ b/src/components/SearchBar.vue
@@ -1,6 +1,6 @@
@@ -29,20 +30,33 @@ const click = (note: Note) => {
/>
diff --git a/src/composables/useNotes.ts b/src/composables/useNotes.ts
index c34c441..dc410dd 100644
--- a/src/composables/useNotes.ts
+++ b/src/composables/useNotes.ts
@@ -25,13 +25,7 @@ watch(
)
export const setDefaultNotes = (defaultNotes: BaseNote[]) => {
- baseNotes.value = defaultNotes.map(
- (note): BaseNote => ({
- ...note,
- created: new Date().getTime(),
- modified: new Date().getTime(),
- })
- )
+ baseNotes.value = defaultNotes
}
export const getNoteById = (noteId: string) => {
@@ -41,7 +35,7 @@ export const getNoteById = (noteId: string) => {
export const findNotes = (query: string): Note[] => {
const removeMdFromText = (mdText: string): string => {
const div = document.createElement('div')
- div.innerHTML = mdToHtml(mdText, 'c@')
+ div.innerHTML = mdToHtml(mdText, 'c@', getNoteById)
const textWithoutMd = div.textContent || div.innerText || ''
return textWithoutMd
}
diff --git a/src/global.d.ts b/src/global.d.ts
index c02252d..7822dcd 100644
--- a/src/global.d.ts
+++ b/src/global.d.ts
@@ -1,6 +1,6 @@
declare global {
interface BaseNote {
- id?: string
+ id: string
title: string
content: string
created: number
diff --git a/src/utils/defaultNotes.ts b/src/utils/defaultNotes.ts
index 1383a83..732e4b6 100644
--- a/src/utils/defaultNotes.ts
+++ b/src/utils/defaultNotes.ts
@@ -1,3 +1,5 @@
+import shortid from 'shortid'
+
export const defaultNotes: BaseNote[] = [
{
isRoot: true,
@@ -8,13 +10,14 @@ export const defaultNotes: BaseNote[] = [
* Click on **Mindmap mode** in the menu left to visualize your notes
\n
Let's get started!`,
- created: 0,
- modified: 0,
},
{
title: 'brackets',
content: `If you type square brackets around text a link is created automatically. Like magic!`,
- created: 0,
- modified: 0,
},
-]
+].map((note) => ({
+ id: shortid.generate(),
+ created: new Date().getTime(),
+ modified: new Date().getTime(),
+ ...note,
+}))