fix: title and description on community post to support dark mode (#55)
* fix: implement dark mode for tinymce * bug on first render
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PUBLIC_TINYMCE_API_KEY } from '$env/static/public';
|
import { PUBLIC_TINYMCE_API_KEY } from '$env/static/public';
|
||||||
import Editor from '@tinymce/tinymce-svelte';
|
import Editor from '@tinymce/tinymce-svelte';
|
||||||
|
import { appStore } from '$lib/utils/store/app';
|
||||||
|
|
||||||
export let id = '';
|
export let id = '';
|
||||||
export let value: string;
|
export let value: string;
|
||||||
@@ -12,6 +13,9 @@
|
|||||||
|
|
||||||
const apiKey = PUBLIC_TINYMCE_API_KEY;
|
const apiKey = PUBLIC_TINYMCE_API_KEY;
|
||||||
|
|
||||||
|
let tinmycEditor: any;
|
||||||
|
let unmount = false
|
||||||
|
|
||||||
// editor configuration
|
// editor configuration
|
||||||
let conf = {
|
let conf = {
|
||||||
plugins: 'lists',
|
plugins: 'lists',
|
||||||
@@ -27,8 +31,12 @@
|
|||||||
min_height: height,
|
min_height: height,
|
||||||
max_height: maxHeight,
|
max_height: maxHeight,
|
||||||
placeholder: placeholder,
|
placeholder: placeholder,
|
||||||
|
skin: 'oxide-dark',
|
||||||
|
content_css: 'dark',
|
||||||
init_instance_callback: function (editor: any) {
|
init_instance_callback: function (editor: any) {
|
||||||
editorWindowRef = editor.iframeElement?.contentWindow;
|
editorWindowRef = editor.iframeElement?.contentWindow;
|
||||||
|
|
||||||
|
tinmycEditor = editor;
|
||||||
editor.on('Change', function () {
|
editor.on('Change', function () {
|
||||||
const html = editor.getContent();
|
const html = editor.getContent();
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
@@ -43,9 +51,28 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function handleModeChange(isDark: boolean) {
|
||||||
|
if (isDark) {
|
||||||
|
conf.content_css = 'dark';
|
||||||
|
conf.skin = 'oxide-dark';
|
||||||
|
} else {
|
||||||
|
conf.content_css = 'light';
|
||||||
|
conf.skin = 'oxide';
|
||||||
|
}
|
||||||
|
|
||||||
|
unmount = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
unmount = false;
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
|
||||||
$: value = !value ? '' : value;
|
$: value = !value ? '' : value;
|
||||||
|
|
||||||
|
$: handleModeChange($appStore.isDark);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Editor bind:value {apiKey} {conf} />
|
{#if !unmount}
|
||||||
|
<Editor bind:value {apiKey} bind:conf />
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
||||||
import { currentOrg } from '$lib/utils/store/org';
|
import { currentOrg } from '$lib/utils/store/org';
|
||||||
@@ -8,8 +8,11 @@
|
|||||||
import { snackbar } from '$lib/components/Snackbar/store';
|
import { snackbar } from '$lib/components/Snackbar/store';
|
||||||
import generateSlug from '$lib/utils/functions/generateSlug';
|
import generateSlug from '$lib/utils/functions/generateSlug';
|
||||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||||
|
import TextField from '$lib/components/Form/TextField.svelte';
|
||||||
|
|
||||||
let errors = {};
|
let errors: {
|
||||||
|
title?: string;
|
||||||
|
} = {};
|
||||||
let fields = {
|
let fields = {
|
||||||
title: '',
|
title: '',
|
||||||
body: ''
|
body: ''
|
||||||
@@ -62,23 +65,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3 p-2">
|
<div class="mb-3 p-2">
|
||||||
<input
|
<TextField
|
||||||
class="title rounded-lg border border-1 border-gray p-2 w-full focus:outline-none"
|
|
||||||
error="false"
|
|
||||||
autocomplete="off"
|
|
||||||
placeholder="Title"
|
|
||||||
aria-label="Title"
|
|
||||||
aria-describedby="title-input-validation"
|
|
||||||
type="text"
|
|
||||||
name="discussion_title"
|
|
||||||
id="discussion_title"
|
|
||||||
bind:value={fields.title}
|
bind:value={fields.title}
|
||||||
|
placeholder="Title"
|
||||||
|
errorMessage={errors.title}
|
||||||
/>
|
/>
|
||||||
{#if errors.title}
|
|
||||||
<p class="dark:text-white text-red-500 text-sm">
|
|
||||||
{errors.title}
|
|
||||||
</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TextEditor
|
<TextEditor
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
import ArrowLeftIcon from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
|
||||||
import { currentOrgPath, currentOrg } from '$lib/utils/store/org';
|
import { currentOrgPath, currentOrg } from '$lib/utils/store/org';
|
||||||
@@ -8,8 +8,11 @@
|
|||||||
import { snackbar } from '$lib/components/Snackbar/store';
|
import { snackbar } from '$lib/components/Snackbar/store';
|
||||||
import generateSlug from '$lib/utils/functions/generateSlug';
|
import generateSlug from '$lib/utils/functions/generateSlug';
|
||||||
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
import TextEditor from '$lib/components/TextEditor/index.svelte';
|
||||||
|
import TextField from '$lib/components/Form/TextField.svelte';
|
||||||
|
|
||||||
let errors = {};
|
let errors: {
|
||||||
|
title?: string;
|
||||||
|
} = {};
|
||||||
let fields = {
|
let fields = {
|
||||||
title: '',
|
title: '',
|
||||||
body: ''
|
body: ''
|
||||||
@@ -64,23 +67,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3 p-2">
|
<div class="mb-3 p-2">
|
||||||
<input
|
<TextField
|
||||||
class="title rounded-lg border border-1 border-gray p-2 w-full dark:text-black focus:outline-none"
|
|
||||||
error="false"
|
|
||||||
autocomplete="off"
|
|
||||||
placeholder="Title"
|
|
||||||
aria-label="Title"
|
|
||||||
aria-describedby="title-input-validation"
|
|
||||||
type="text"
|
|
||||||
name="discussion_title"
|
|
||||||
id="discussion_title"
|
|
||||||
bind:value={fields.title}
|
bind:value={fields.title}
|
||||||
|
placeholder="Title"
|
||||||
|
errorMessage={errors.title}
|
||||||
/>
|
/>
|
||||||
{#if errors.title}
|
|
||||||
<p class="dark:text-white text-red-500 text-sm">
|
|
||||||
{errors.title}
|
|
||||||
</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="px-2">
|
<div class="px-2">
|
||||||
<TextEditor
|
<TextEditor
|
||||||
|
|||||||
Reference in New Issue
Block a user