mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 18:01:59 +00:00
Minor enhancements to the text color feature (#8551)
Some checks are pending
CI / test (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / test (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
parent
ab228b376b
commit
cabbd6f7e0
@ -135,7 +135,7 @@ export const TextColor = Extension.create<TextColorOptions>({
|
|||||||
unsetTextColor:
|
unsetTextColor:
|
||||||
() =>
|
() =>
|
||||||
({ chain }) => {
|
({ chain }) => {
|
||||||
return chain().setMark('textStyle', { color: null }).removeEmptyTextStyle().run()
|
return chain().unsetMark('textStyle').run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,12 +92,13 @@ export function showPopup (
|
|||||||
overlay: boolean
|
overlay: boolean
|
||||||
fixed?: boolean
|
fixed?: boolean
|
||||||
refId?: string
|
refId?: string
|
||||||
|
id?: string
|
||||||
} = {
|
} = {
|
||||||
category: 'popup',
|
category: 'popup',
|
||||||
overlay: true
|
overlay: true
|
||||||
}
|
}
|
||||||
): PopupResult {
|
): PopupResult {
|
||||||
const id = `${popupId++}`
|
const id = options?.id ?? `${popupId++}`
|
||||||
const closePopupOp = (): void => {
|
const closePopupOp = (): void => {
|
||||||
modalStore.update((popups) => {
|
modalStore.update((popups) => {
|
||||||
const pos = popups.findIndex((p) => (p as CompAndProps).id === id && p.type === 'popup')
|
const pos = popups.findIndex((p) => (p as CompAndProps).id === id && p.type === 'popup')
|
||||||
@ -107,6 +108,7 @@ export function showPopup (
|
|||||||
return popups
|
return popups
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
closePopupOp()
|
||||||
const _element = element instanceof HTMLElement ? getPopupPositionElement(element) : element
|
const _element = element instanceof HTMLElement ? getPopupPositionElement(element) : element
|
||||||
const data: Omit<CompAndProps, 'is'> = {
|
const data: Omit<CompAndProps, 'is'> = {
|
||||||
id,
|
id,
|
||||||
|
@ -50,7 +50,7 @@ const palette = {
|
|||||||
colorSpec('red', 'bg')
|
colorSpec('red', 'bg')
|
||||||
],
|
],
|
||||||
text: [
|
text: [
|
||||||
{ color: 'var(--theme-text-color-primary)' },
|
{ color: 'var(--theme-text-primary-color)' },
|
||||||
colorSpec('gray'),
|
colorSpec('gray'),
|
||||||
colorSpec('brown'),
|
colorSpec('brown'),
|
||||||
colorSpec('orange'),
|
colorSpec('orange'),
|
||||||
@ -65,33 +65,55 @@ const palette = {
|
|||||||
|
|
||||||
export async function openBackgroundColorOptions (editor: Editor, event: MouseEvent): Promise<void> {
|
export async function openBackgroundColorOptions (editor: Editor, event: MouseEvent): Promise<void> {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
showPopup(ColorPicker, { palette: palette.background }, getEventPositionElement(event), (val) => {
|
showPopup(
|
||||||
const color: string | undefined = val?.color
|
ColorPicker,
|
||||||
if (color === undefined) return
|
{ palette: palette.background, id: 'text-editor-background-color-picker' },
|
||||||
|
getEventPositionElement(event),
|
||||||
|
(val) => {
|
||||||
|
const color: string | undefined = val?.color
|
||||||
|
if (color === undefined) return
|
||||||
|
|
||||||
if (color === 'transparent') {
|
if (color === 'transparent') {
|
||||||
editor.commands.unsetBackgroundColor()
|
editor.commands.unsetBackgroundColor()
|
||||||
} else {
|
} else {
|
||||||
editor.commands.setBackgroundColor(color)
|
editor.commands.setBackgroundColor(color)
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
id: 'text-editor-background-color-picker',
|
||||||
|
category: 'popup',
|
||||||
|
overlay: true
|
||||||
}
|
}
|
||||||
resolve()
|
)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function openTextColorOptions (editor: Editor, event: MouseEvent): Promise<void> {
|
export async function openTextColorOptions (editor: Editor, event: MouseEvent): Promise<void> {
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
showPopup(ColorPicker, { palette: palette.text }, getEventPositionElement(event), (val) => {
|
showPopup(
|
||||||
const color: string | undefined = val?.color
|
ColorPicker,
|
||||||
if (color === undefined) return
|
{ palette: palette.text, letters: true },
|
||||||
|
getEventPositionElement(event),
|
||||||
|
(val) => {
|
||||||
|
const color: string | undefined = val?.color
|
||||||
|
if (color === undefined) return
|
||||||
|
|
||||||
if (color === 'var(--theme-text-color-primary)') {
|
if (color === 'var(--theme-text-primary-color)') {
|
||||||
editor.commands.unsetTextColor()
|
editor.commands.unsetTextColor()
|
||||||
} else {
|
} else {
|
||||||
editor.commands.setTextColor(color)
|
editor.commands.setTextColor(color)
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
id: 'text-editor-text-color-picker',
|
||||||
|
category: 'popup',
|
||||||
|
overlay: true
|
||||||
}
|
}
|
||||||
resolve()
|
)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import { Card } from '@hcengineering/presentation'
|
import { Card } from '@hcengineering/presentation'
|
||||||
|
|
||||||
export let palette: Array<{ color: string, preview?: string }> = [{ color: 'transparent' }]
|
export let palette: Array<{ color: string, preview?: string }> = [{ color: 'transparent' }]
|
||||||
|
export let letters: boolean = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
@ -32,11 +33,15 @@
|
|||||||
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
||||||
<div
|
<div
|
||||||
class="colorBox"
|
class="colorBox"
|
||||||
style:background-color={k.preview ?? k.color}
|
class:letters
|
||||||
|
class:solid={!letters}
|
||||||
|
style:--color={k.preview ?? k.color}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
handleSubmit(k)
|
handleSubmit(k)
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
|
{#if letters}A{/if}
|
||||||
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -61,6 +66,20 @@
|
|||||||
height: 1.5rem;
|
height: 1.5rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.solid {
|
||||||
|
background-color: var(--color);
|
||||||
box-shadow: var(--text-editor-color-picker-outline) 0px 0px 0px 1px inset;
|
box-shadow: var(--text-editor-color-picker-outline) 0px 0px 0px 1px inset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.letters {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: transparent;
|
||||||
|
border: 1px solid var(--color);
|
||||||
|
color: var(--color);
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user