From 49e50f0c5229308fbe03931379cf58d8ae15926d Mon Sep 17 00:00:00 2001 From: Maxime Cannoodt Date: Fri, 9 Sep 2022 15:23:16 +0200 Subject: [PATCH] feat: :sparkles: Add notification popup to warn about 1.0.0 --- webapp/src/lib/components/Callout.svelte | 19 +++++--- webapp/src/lib/components/Dismissable.svelte | 51 ++++++++++++++++++++ webapp/src/routes/note/[id].svelte | 3 ++ 3 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 webapp/src/lib/components/Dismissable.svelte diff --git a/webapp/src/lib/components/Callout.svelte b/webapp/src/lib/components/Callout.svelte index 62d5c53..35f495c 100644 --- a/webapp/src/lib/components/Callout.svelte +++ b/webapp/src/lib/components/Callout.svelte @@ -2,8 +2,8 @@ import { getCalloutColor, getCalloutIcon } from '$lib/util/callout'; import CalloutIcon from '$lib/components/CalloutIcon.svelte'; - let title = ''; - let type = 'note'; + export let title = ''; + export let type = 'note'; let color = '--callout-warning'; let icon = 'note'; let init = false; @@ -12,8 +12,9 @@ $: if (content) { const titleElement = content.getElementsByTagName('p')[0]; + const preFilled = title != ''; const match = titleElement.innerText.split('\n')[0].match(/\[!(.+)\]([+-]?)(?:\s(.+))?/); - if (match) { + if (match && !preFilled) { type = match[1]?.trim(); title = match[3]?.trim() ?? type[0].toUpperCase() + type.substring(1).toLowerCase(); } @@ -22,11 +23,13 @@ icon = getCalloutIcon(type); // Remove title from content - const pos = titleElement.innerHTML.indexOf('
'); - if (pos >= 0) { - titleElement.innerHTML = titleElement.innerHTML.substring(pos + 4); - } else { - titleElement.innerHTML = ''; + if (!preFilled) { + const pos = titleElement.innerHTML.indexOf('
'); + if (pos >= 0) { + titleElement.innerHTML = titleElement.innerHTML.substring(pos + 4); + } else { + titleElement.innerHTML = ''; + } } init = true; } diff --git a/webapp/src/lib/components/Dismissable.svelte b/webapp/src/lib/components/Dismissable.svelte new file mode 100644 index 0000000..5340802 --- /dev/null +++ b/webapp/src/lib/components/Dismissable.svelte @@ -0,0 +1,51 @@ + + +{#if show} + +
+ +

+ Obsidian QuickShare and Noteshare.space are now out of beta 🚀 You can now find the plugin + in the Obsidian community plugin marketplace (see instructions). + Check out the roadmap for upcoming features here. +

+
+ +
+
+
+{/if} diff --git a/webapp/src/routes/note/[id].svelte b/webapp/src/routes/note/[id].svelte index 7f86569..40debbb 100644 --- a/webapp/src/routes/note/[id].svelte +++ b/webapp/src/routes/note/[id].svelte @@ -25,6 +25,7 @@ import { browser } from '$app/env'; import RawRenderer from '$lib/components/RawRenderer.svelte'; import LogoDocument from 'svelte-icons/md/MdUndo.svelte'; + import Dismissable from '$lib/components/Dismissable.svelte'; // Auto-loaded from [id].ts endpoint export let note: EncryptedNote; @@ -78,6 +79,8 @@ {#if plaintext}
+ +