diff --git a/packages/text-editor/src/components/CollaboratorEditor.svelte b/packages/text-editor/src/components/CollaboratorEditor.svelte index 06a8fb6b5b..78bd7c03ce 100644 --- a/packages/text-editor/src/components/CollaboratorEditor.svelte +++ b/packages/text-editor/src/components/CollaboratorEditor.svelte @@ -15,59 +15,30 @@ // --> @@ -485,99 +234,22 @@ {#if isFormatting && !readonly}
- { + needFocus = true + }} /> - - - - - -
- - -
- -
- - - - - {#if activeModes.has('table')} - - {/if}
{#if comparedVersion !== undefined} diff --git a/packages/text-editor/src/components/ReferenceInput.svelte b/packages/text-editor/src/components/ReferenceInput.svelte index d5b67968b8..988632b861 100644 --- a/packages/text-editor/src/components/ReferenceInput.svelte +++ b/packages/text-editor/src/components/ReferenceInput.svelte @@ -17,7 +17,6 @@ import { getClient } from '@hcengineering/presentation' import { AnySvelteComponent, - Button, EmojiPopup, Icon, IconEmoji, @@ -32,22 +31,11 @@ import { createEventDispatcher } from 'svelte' import { Completion } from '../Completion' import textEditorPlugin from '../plugin' - import { FORMAT_MODES, FormatMode, RefAction, RefInputActionItem, TextEditorHandler } from '../types' - import LinkPopup from './LinkPopup.svelte' + import { RefAction, RefInputActionItem, TextEditorHandler, TextFormatCategory } from '../types' import TextEditor from './TextEditor.svelte' import { completionConfig } from './extensions' import Attach from './icons/Attach.svelte' - import CodeBlock from './icons/CodeBlock.svelte' - import ListBullet from './icons/ListBullet.svelte' - import ListNumber from './icons/ListNumber.svelte' - import Quote from './icons/Quote.svelte' - import Bold from './icons/Bold.svelte' - import Code from './icons/Code.svelte' - import Italic from './icons/Italic.svelte' - import Link from './icons/Link.svelte' import RIMention from './icons/RIMention.svelte' - import RIStrikethrough from './icons/RIStrikethrough.svelte' - import Underline from './icons/Underline.svelte' import Send from './icons/Send.svelte' const dispatch = createEventDispatcher() @@ -64,10 +52,7 @@ const client = getClient() let textEditor: TextEditor - let textEditorToolbar: HTMLElement - let activeModes = new Set() - let isSelectionEmpty = true let isEmpty = true $: setContent(content) @@ -142,34 +127,6 @@ a.action(evt?.target as HTMLElement, editorHandler) } - function updateFormattingState () { - if (textEditor?.checkIsActive === undefined) { - return - } - activeModes = new Set(FORMAT_MODES.filter(textEditor.checkIsActive)) - isSelectionEmpty = textEditor.checkIsSelectionEmpty() - } - - function getToggler (toggle: () => void) { - return () => { - toggle() - textEditor.focus() - updateFormattingState() - } - } - - async function formatLink (): Promise { - const link = textEditor.getLink() - - showPopup(LinkPopup, { link }, undefined, undefined, (newLink) => { - if (newLink === '') { - textEditor.unsetLink() - } else { - textEditor.setLink(newLink) - } - }) - } - // Focusable control with index let focused = false export let focusIndex = -1 @@ -198,92 +155,6 @@
-
-
{#if showSend} @@ -371,10 +247,6 @@
diff --git a/packages/text-editor/src/components/StyledTextEditor.svelte b/packages/text-editor/src/components/StyledTextEditor.svelte index 5f6248740b..608319b82d 100644 --- a/packages/text-editor/src/components/StyledTextEditor.svelte +++ b/packages/text-editor/src/components/StyledTextEditor.svelte @@ -13,46 +13,14 @@ // limitations under the License. --> +
+ { + needFocus = true + }} + /> +
diff --git a/packages/text-editor/src/components/TextEditorStyleToolbar.svelte b/packages/text-editor/src/components/TextEditorStyleToolbar.svelte new file mode 100644 index 0000000000..a2297bf631 --- /dev/null +++ b/packages/text-editor/src/components/TextEditorStyleToolbar.svelte @@ -0,0 +1,321 @@ + + + +{#if textEditor} + {#each textFormatCategories as category, index} + {#if category === TextFormatCategory.Heading} + + + {/if} + {#if category === TextFormatCategory.TextDecoration} + + + + + {/if} + {#if category === TextFormatCategory.Link} + + {/if} + {#if category === TextFormatCategory.List} + + + {/if} + {#if category === TextFormatCategory.Quote} + + {/if} + {#if category === TextFormatCategory.Code} + + + {/if} + {#if category === TextFormatCategory.Table} + + {#if textEditor.isActive('table')} + + {/if} + {/if} + {#if index < textFormatCategories.length - 1} +
+ {/if} + {/each} +{/if} diff --git a/packages/text-editor/src/components/extensions.ts b/packages/text-editor/src/components/extensions.ts index f125f20fdc..bb69621035 100644 --- a/packages/text-editor/src/components/extensions.ts +++ b/packages/text-editor/src/components/extensions.ts @@ -42,7 +42,7 @@ export const taskListExtensions = [ }) ] -export const headingLevels: Level[] = [1, 2, 3, 4, 5, 6] +export const supportedHeadingLevels: Level[] = [1, 2] export const defaultExtensions: AnyExtension[] = [ StarterKit.configure({ @@ -60,7 +60,7 @@ export const defaultExtensions: AnyExtension[] = [ } }, heading: { - levels: headingLevels + levels: supportedHeadingLevels } }), Highlight.configure({ diff --git a/packages/text-editor/src/types.ts b/packages/text-editor/src/types.ts index 21eedd9a39..424e18536b 100644 --- a/packages/text-editor/src/types.ts +++ b/packages/text-editor/src/types.ts @@ -30,27 +30,15 @@ export interface RefInputActionItem extends Doc { /** * @public */ -export const FORMAT_MODES = [ - 'bold', - 'italic', - 'strike', - 'link', - 'orderedList', - 'bulletList', - 'blockquote', - 'code', - 'codeBlock', - 'heading', - 'heading1', - 'heading2', - 'table', - 'underline' -] as const - -/** - * @public - */ -export type FormatMode = (typeof FORMAT_MODES)[number] +export enum TextFormatCategory { + Heading = 'heading', + TextDecoration = 'text-decoration', // bold, italic, strike, underline + Link = 'link', + List = 'list', // orderedList, bulletList, + Quote = 'quote', // blockquote + Code = 'code', // code, codeBlock + Table = 'table' +} /** * @public diff --git a/packages/theme/styles/_text-editor.scss b/packages/theme/styles/_text-editor.scss index c7011ac284..cf018a6cff 100644 --- a/packages/theme/styles/_text-editor.scss +++ b/packages/theme/styles/_text-editor.scss @@ -2,9 +2,3 @@ cursor: pointer; object-fit: contain; } - -// need to override editor's bubble max-width -// due to https://github.com/atomiks/tippyjs/issues/451 -.tippy-box { - max-width: 450px !important; -} \ No newline at end of file