Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(channels): migrate all consumers to new markdown builder (#2755)
teo3cb242078a00
diff --git a/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsx b/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsxindex c130b6e9b6..4e64b90606 100644--- a/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/NewCallButton.tsx@@ -1,6 +1,6 @@import { useSplitLayout } from '@app/component/split-layout/layout';import { RecipientSelector } from '@core/component/RecipientSelector';-import { getDestinationFromOptions } from '@core/component/NewMessage';+import { getDestinationFromOptions } from '@core/util/destination';import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';import type { WithCustomUserInput } from '@core/user';import { isErr } from '@core/util/maybeResult';diff --git a/js/app/packages/block-channel/component/Compose.tsx b/js/app/packages/block-channel/component/Compose.tsxindex b4c2cf5d98..81d0308c40 100644--- a/js/app/packages/block-channel/component/Compose.tsx+++ b/js/app/packages/block-channel/component/Compose.tsx@@ -18,7 +18,7 @@ import {type InputSnapshot,} from '@channel/Input';import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';-import { getDestinationFromOptions } from '@core/component/NewMessage';+import { getDestinationFromOptions } from '@core/util/destination';import { RecipientSelector } from '@core/component/RecipientSelector';import { isMobile } from '@core/mobile/isMobile';import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';diff --git a/js/app/packages/block-channel/component/DeprecatedChannelInput/MarkdownArea.tsx b/js/app/packages/block-channel/component/DeprecatedChannelInput/MarkdownArea.tsxdeleted file mode 100644index e23332d1a4..0000000000--- a/js/app/packages/block-channel/component/DeprecatedChannelInput/MarkdownArea.tsx+++ /dev/null@@ -1,384 +0,0 @@-import { DecoratorRenderer } from '@core/component/LexicalMarkdown/component/core/DecoratorRenderer';-import { NodeAccessoryRenderer } from '@core/component/LexicalMarkdown/component/core/NodeAccessoryRenderer';-import { EmojiMenu } from '@core/component/LexicalMarkdown/component/menu/EmojiMenu';-import { FloatingLinkMenu } from '@core/component/LexicalMarkdown/component/menu/FloatingLinkMenu';-import { MentionsMenu } from '@core/component/LexicalMarkdown/component/menu/MentionsMenu';-import {- createLexicalWrapper,- type LexicalWrapper,- LexicalWrapperContext,-} from '@core/component/LexicalMarkdown/context/LexicalWrapperContext';-import {- autoRegister,- customSelectionDataPlugin,- DefaultShortcuts,- defaultSelectionData,- type ItemMention,- keyboardFocusPlugin,- keyboardShortcutsPlugin,- markdownPastePlugin,- mentionsPlugin,- NODE_TRANSFORM,- type NodeTransformType,- registerRootEventListener,- type SelectionData,- tabIndentationPlugin,- tableCellResizerPlugin,- tablePlugin,-} from '@core/component/LexicalMarkdown/plugins';-import { codePlugin } from '@core/component/LexicalMarkdown/plugins/code/codePlugin';-import { emojisPlugin } from '@core/component/LexicalMarkdown/plugins/emojis/emojisPlugin';-import { restoreFocusPlugin } from '@core/component/LexicalMarkdown/plugins/restore-focus';-import { createMenuOperations } from '@core/component/LexicalMarkdown/shared/inlineMenu';-import {- editorIsEmpty,- initializeEditorEmpty,- insertText,- setEditorStateFromMarkdown,-} from '@core/component/LexicalMarkdown/utils';-import type { PortalScope } from '@core/component/ScopedPortal';-import type { IUser } from '@core/user';-import type { HistoryItem } from '@queries/history/types';-import { onElementConnect } from '@solid-primitives/lifecycle';-import { isMobile } from '@solid-primitives/platform';-import { filePastePlugin } from 'core/component/LexicalMarkdown/plugins/file-paste/filePastePlugin';-import { createAccessoryStore } from 'core/component/LexicalMarkdown/plugins/node-accessory/nodeAccessoryPlugin';-import { normalizeEnterPlugin } from 'core/component/LexicalMarkdown/plugins/normalize-enter/';-import { textPastePlugin } from 'core/component/LexicalMarkdown/plugins/text-paste/textPastePlugin';-import {- COMMAND_PRIORITY_CRITICAL,- COMMAND_PRIORITY_HIGH,- FORMAT_TEXT_COMMAND,- KEY_ENTER_COMMAND,- KEY_ESCAPE_COMMAND,- KEY_TAB_COMMAND,- type LexicalEditor,- type TextFormatType,-} from 'lexical';--import {- type Accessor,- createEffect,- createSignal,- type JSXElement,- onCleanup,- type Setter,- Show,-} from 'solid-js';-import { createStore, type SetStoreFunction } from 'solid-js/store';--export type UseChannelMarkdown = {- focus: () => void;- blur: () => void;- mentions: Accessor<ItemMention[]>;- state: Accessor<string>;- formatState: SelectionData;- clear: () => void;- ref: Accessor<HTMLDivElement | undefined>;- insert: (value: string) => void;- MarkdownArea: (props: ConsumableMarkdownAreaProps) => JSXElement;- setInlineFormat: (format: TextFormatType) => void;- setNodeFormat: (transform: NodeTransformType) => void;- editor: LexicalEditor;-};--export function useChannelMarkdownArea(): UseChannelMarkdown {- const [mentions, setMentions] = createSignal<ItemMention[]>([]);- const [state, setState] = createSignal<string>('');- const [mountRef, setMountRef] = createSignal<HTMLDivElement>();- const [formatState, setFormatState] = createStore<SelectionData>(- structuredClone(defaultSelectionData)- );-- const lexicalWrapper = createLexicalWrapper({- type: 'chat',- namespace: 'channel-markdown-area',- isInteractable: () => true,- });-- function focus() {- setTimeout(() => {- lexicalWrapper.editor.focus();- }, 0);- }-- function blur() {- lexicalWrapper.editor.blur();- }-- function insert(text: string) {- insertText(lexicalWrapper.editor, text);- }-- function inlineFormat(format: TextFormatType): void {- lexicalWrapper.editor.focus();- lexicalWrapper.editor.dispatchCommand(FORMAT_TEXT_COMMAND, format);- }-- function nodeFormat(transform: NodeTransformType): void {- lexicalWrapper.editor.focus();- lexicalWrapper.editor.dispatchCommand(NODE_TRANSFORM, transform);- }-- function ChannelMarkdownArea(props: ConsumableMarkdownAreaProps) {- return (- <MarkdownArea- setMountRef={setMountRef}- setMentions={setMentions}- markdownState={state}- setMarkdownState={setState}- lexicalWrapper={lexicalWrapper}- formatState={formatState}- setFormatState={setFormatState}- {...props}- />- );- }-- function clear() {- initializeEditorEmpty(lexicalWrapper.editor);- lexicalWrapper.editor.read(() => {});- setMentions([]);- }-- return {- insert,- MarkdownArea: ChannelMarkdownArea,- focus,- blur,- mentions,- state,- ref: mountRef,- clear,- formatState,- setInlineFormat: inlineFormat,- setNodeFormat: nodeFormat,- editor: lexicalWrapper.editor,- };-}--type MarkdownAreaProps = {- setMountRef: Setter<HTMLDivElement | undefined>;- setMentions: Setter<ItemMention[]>;- markdownState: Accessor<string>;- setMarkdownState: Setter<string>;- lexicalWrapper: LexicalWrapper;- setFormatState: SetStoreFunction<SelectionData>;- formatState: SelectionData;-};--export type ConsumableMarkdownAreaProps = {- onChange?: (value: string) => void;- onEnter?: (e: KeyboardEvent) => boolean;- onBlur?: () => void;- onEscape?: (e: KeyboardEvent) => boolean;- onTab?: (e: KeyboardEvent) => boolean;- onFocusLeaveStart?: (e: KeyboardEvent) => void;- onFocusLeaveEnd?: (e: KeyboardEvent) => void;- initialValue?: string;- placeholder?: string;- users?: Accessor<IUser[]>;- history?: Accessor<HistoryItem[]>;- onPasteFilesAndDirs?: (- files: FileSystemFileEntry[],- directories: FileSystemDirectoryEntry[]- ) => void;- dontFocusOnMount?: boolean;- disableMentions?: boolean;- useBlockBoundary?: boolean;- portalScope?: PortalScope;-};--function MarkdownArea(props: MarkdownAreaProps & ConsumableMarkdownAreaProps) {- const { editor, plugins, cleanup } = props.lexicalWrapper;-- const onConnect = () => {- editor.setEditable(true);- if (props.initialValue) {- setEditorStateFromMarkdown(editor, props.initialValue);- } else {- initializeEditorEmpty(editor);- }- if (!isMobile && !props.dontFocusOnMount) editor.focus();- };-- createEffect(() => {- props.onChange?.(props.markdownState());- });-- const [showPlaceholder, setShowPlaceholder] = createSignal(true);-- const mentionsMenuOperations = createMenuOperations();- const emojisMenuOperations = createMenuOperations();-- const menuIsOpen = () => {- return mentionsMenuOperations.isOpen() || emojisMenuOperations.isOpen();- };-- const [accessories, setAccessories] = createAccessoryStore();-- plugins- .richText()- .list()- .markdownShortcuts()- .delete()- .state<string>(props.setMarkdownState, 'markdown')- .history(400)- .use(- customSelectionDataPlugin(- props.lexicalWrapper,- props.formatState,- props.setFormatState- )- )- .use(emojisPlugin({ menu: emojisMenuOperations }))- .use(codePlugin({ accessories, setAccessories }))- .use(tabIndentationPlugin())- .use(textPastePlugin())- .use(markdownPastePlugin())- .use(normalizeEnterPlugin())- .use(restoreFocusPlugin())- .use(- tablePlugin({- hasCellMerge: true,- hasCellBackgroundColor: false,- hasTabHandler: true,- hasHorizontalScroll: true,- })- )- .use(- keyboardShortcutsPlugin({- shortcuts: DefaultShortcuts,- })- )- .use(tableCellResizerPlugin());-- if (props.onFocusLeaveEnd || props.onFocusLeaveStart) {- plugins.use(- keyboardFocusPlugin({- onFocusLeaveStart: props.onFocusLeaveStart,- onFocusLeaveEnd: props.onFocusLeaveEnd,- ignoreKeys: menuIsOpen,- })- );- }-- if (!props.disableMentions) {- plugins.use(- mentionsPlugin({- menu: mentionsMenuOperations,- setMentions: props.setMentions,- })- );- }-- if (props.onPasteFilesAndDirs) {- plugins.use(- filePastePlugin({- onPasteFilesAndDirs: props.onPasteFilesAndDirs,- })- );- }-- if (props.onEnter !== undefined) {- autoRegister(- editor.registerCommand(- KEY_ENTER_COMMAND,- (e) => {- if (!e) return false;- // TODO (seamus) : This is hacky. If we got a props.onEnter,then shift+enter becomes- // the new "regular enter", so we delete the shiftKey and pass along to lexical.- if (e.shiftKey) {- Object.defineProperty(e, 'shiftKey', { value: false });- return false;- }-- const captured = props.onEnter!(e);- if (captured) {- e.preventDefault();- e.stopPropagation();- }- return captured;- },- // Run at HIGH here to that the mentions menu can run at CRITICAL- COMMAND_PRIORITY_HIGH- )- );- }-- onCleanup(() => {- cleanup();- });-- createEffect(() => {- props.markdownState();- setShowPlaceholder(editorIsEmpty(editor));- });-- autoRegister(- editor.registerCommand(- KEY_ESCAPE_COMMAND,- (e) => {- return props.onEscape ? props.onEscape(e) : false;- },- COMMAND_PRIORITY_CRITICAL- ),- editor.registerCommand(- KEY_TAB_COMMAND,- (e) => {- return props.onTab ? props.onTab(e) : false;- },- COMMAND_PRIORITY_CRITICAL- )- );-- let disposeBlurFn: () => void = () => {};- createEffect(() => {- disposeBlurFn();- const blurFn = props.onBlur;- if (!blurFn) return;- disposeBlurFn = registerRootEventListener(editor, 'blur', blurFn);- onCleanup(() => disposeBlurFn());- });-- return (- <LexicalWrapperContext.Provider value={props.lexicalWrapper}>- <div class="relative w-full min-h-8">- <div- ref={(el) => {- onElementConnect(el, () => {- editor.setRootElement(el);- onConnect();- props.setMountRef(el);- });- }}- contentEditable={true}- ></div>- <DecoratorRenderer editor={editor} />- <NodeAccessoryRenderer editor={editor} store={accessories} />- <Show when={showPlaceholder()}>- <div class="pointer-events-none text-ink-placeholder absolute top-0">- <p class="p-0 m-0">{props.placeholder ?? '...'}</p>- </div>- </Show>- <EmojiMenu- editor={editor}- menu={emojisMenuOperations}- useBlockBoundary={props.useBlockBoundary}- portalScope={props.portalScope}- />- <Show when={!props.disableMentions}>- <MentionsMenu- editor={editor}- menu={mentionsMenuOperations}- users={props.users}- block={'channel'}- useBlockBoundary={props.useBlockBoundary}- portalScope={props.portalScope}- />- </Show>- <FloatingLinkMenu />- </div>- </LexicalWrapperContext.Provider>- );-}diff --git a/js/app/packages/channel/Participants/ParticipantsAddPanel.tsx b/js/app/packages/channel/Participants/ParticipantsAddPanel.tsxindex 9742ecb7dc..9889e3e799 100644--- a/js/app/packages/channel/Participants/ParticipantsAddPanel.tsx+++ b/js/app/packages/channel/Participants/ParticipantsAddPanel.tsx@@ -1,4 +1,4 @@-import { getDestinationFromOptions } from '@core/component/NewMessage';+import { getDestinationFromOptions } from '@core/util/destination';import { RecipientSelector } from '@core/component/RecipientSelector';import {recipientEntityMapper,diff --git a/js/app/packages/core/component/ForwardToChannel.tsx b/js/app/packages/core/component/ForwardToChannel.tsxindex 59b9bbf4c3..e51647585a 100644--- a/js/app/packages/core/component/ForwardToChannel.tsx+++ b/js/app/packages/core/component/ForwardToChannel.tsx@@ -1,4 +1,5 @@-import { useChannelMarkdownArea } from '@block-channel/component/DeprecatedChannelInput/MarkdownArea';+import { createConfiguredChannelMarkdownEditor } from '@channel/Input';+import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';import { useAnalytics } from '@app/component/analytics-context';import { useIsAuthenticated } from '@core/auth';import {@@ -27,7 +28,7 @@ import {} from 'solid-js';import { Button } from '@ui/components/Button';import { CustomScrollbar } from '@core/component/CustomScrollbar';-import { getDestinationFromOptions } from './NewMessage';+import { getDestinationFromOptions } from '@core/util/destination';import { Permissions } from './SharePermissions';import { toast } from './Toast/Toast';import { ScrollIndicators } from './VerticalScrollIndicators';@@ -70,11 +71,18 @@ export function ForwardToChannel(props: ForwardToChannelProps) {const [mdScrollRef, setMdScrollRef] = createSignal<HTMLElement>();- const {- focus: focusMarkdownArea,- state: markdownState,- MarkdownArea,- } = useChannelMarkdownArea();+ const [markdown, setMarkdown] = createSignal('');+ const markdownEditor = createConfiguredChannelMarkdownEditor({+ namespace: 'forward-to-channel-markdown',+ enableMentions: true,+ onChange: setMarkdown,+ onEnter: (e) => {+ handleSubmit();+ e.preventDefault();+ return true;+ },+ });+ markdownEditor.buildHandle();const [triedToSubmit, setTriedToSubmit] = createSignal(false);const { all: destinationOptions } = useCombinedRecipients();@@ -170,7 +178,7 @@ export function ForwardToChannel(props: ForwardToChannelProps) {sendToUsers({attachments: [asAttachment()],users: destination_.users,- content: markdownState(),+ content: markdown(),mentions: [],}).then((res) => {if (!res) {@@ -200,7 +208,7 @@ export function ForwardToChannel(props: ForwardToChannelProps) {submitChannelPermissions(option.id),sendToChannel({attachments: [asAttachment()],- content: markdownState(),+ content: markdown(),channelId: option.id,mentions: [],}).then((res) => {@@ -227,7 +235,7 @@ export function ForwardToChannel(props: ForwardToChannelProps) {// handles option.kind of user, custom, and contact (gmail)sendToUsers({attachments: [asAttachment()],- content: markdownState(),+ content: markdown(),users: [option.id],mentions: [],}).then((res) => {@@ -327,21 +335,14 @@ export function ForwardToChannel(props: ForwardToChannelProps) {<CustomScrollbar scrollContainer={mdScrollRef} /><divclass="grow-1 shrink-1 min-h-20 max-h-40 overflow-y-auto scrollbar-hidden px-[12px] py-[6px] w-full text-sm"- onClick={() => focusMarkdownArea()}+ onClick={() => markdownEditor.controls.focus()}ref={setMdScrollRef}>- <MarkdownArea+ <MarkdownShell+ config={markdownEditor}placeholder="Optional message"- onEnter={(e: KeyboardEvent) => {- handleSubmit();- e.preventDefault();- return true;- }}- initialValue={markdownState()}- onTab={() => false}- useBlockBoundary={false}portalScope="local"- dontFocusOnMount+ class="text-sm"/></div></div>diff --git a/js/app/packages/core/component/NewMessage.tsx b/js/app/packages/core/component/NewMessage.tsxdeleted file mode 100644index ceb215db23..0000000000--- a/js/app/packages/core/component/NewMessage.tsx+++ /dev/null@@ -1,302 +0,0 @@-import { FormatRibbon } from '@block-channel/component/DeprecatedChannelInput/FormatRibbon';-import { useChannelMarkdownArea } from '@block-channel/component/DeprecatedChannelInput/MarkdownArea';-import { useBlockId, useBlockName } from '@core/block';-import { RecipientSelector } from '@core/component/RecipientSelector';-import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';-import type { CombinedRecipientItem, WithCustomUserInput } from '@core/user';-import { useSendMessageToPeople } from '@core/util/channels';-import { buildSimpleEntityUrl } from '@core/util/url';-import XIcon from '@icon/regular/x.svg';-import { Dialog } from '@kobalte/core/dialog';-import type { PointerDownOutsideEvent } from '@kobalte/core/primitives/create-interact-outside';-import PaperPlaneIcon from '@phosphor-icons/core/regular/paper-plane-tilt.svg?component-solid';-import type { SimpleMention } from '@service-comms/generated/models/simpleMention';-import { createSignal, type JSXElement, Show, type Signal } from 'solid-js';-import { DeprecatedTextButton } from './DeprecatedTextButton';-import type { ItemMention } from './LexicalMarkdown/plugins';-import { toast } from './Toast/Toast';--type NewMessageProps = {- // source of where we are making the new message- source: 'block' | 'menu';- title: string;- trigger?: JSXElement;- isOpenSignal?: Signal<boolean>;-};--type UserDestination = {- type: 'users';- users: string[];-};--type ChannelDestination = {- type: 'channel';- id: string;-};--type Destination = UserDestination | ChannelDestination;--type DestinationType<T extends CombinedRecipientItem> =- T extends CombinedRecipientItem<'channel'>- ? Extract<T, CombinedRecipientItem<'channel'>> extends T- ? ChannelDestination // T is ONLY channel- : Destination // T includes channel and others- : // T excludes channel- UserDestination;--function CopyLinkButton() {- const blockName = useBlockName();- const blockId = useBlockId();-- function handleCopyLink() {- navigator.clipboard.writeText(- buildSimpleEntityUrl({- type: blockName,- id: blockId,- })- );- toast.success('Link copied to clipboard');- }-- return (- <DeprecatedTextButton- text="Copy Link"- theme="base"- onClick={handleCopyLink}- />- );-}--export function getDestinationFromOptions<T extends CombinedRecipientItem>(- options: T[]-): DestinationType<T> {- let maybeChannel = options.find((o) => o.kind === 'channel');- if (maybeChannel) {- return {- type: 'channel',- id: maybeChannel.id,- } as any;- }-- const userIds = options- .filter((o) => {- if (o.kind === 'custom') {- return !o.data.invalid;- }- return true;- })- .map((o) => {- if (o.kind === 'channel') return;- return o.id;- })- .filter((id) => id != null);-- return {- type: 'users',- users: userIds,- } as any;-}--function mentionToSimpleMention(mention: ItemMention): SimpleMention {- return {- entity_type: mention.itemType,- entity_id: mention.itemId,- };-}--export function NewMessage(props: NewMessageProps) {- const { all: destinationOptions } = useCombinedRecipients();- const [selectedOptions, setSelectedOptions] = createSignal<- WithCustomUserInput<'user' | 'contact' | 'channel'>[]- >([]);- const [triedToSubmit, setTriedToSubmit] = createSignal(false);-- const {- focus: focusMarkdownArea,- state: markdownState,- mentions,- formatState: markdownFormatState,- setInlineFormat,- setNodeFormat,- MarkdownArea,- } = useChannelMarkdownArea();-- const { sendToUsers, sendToChannel } = useSendMessageToPeople();- const asAttachment =- props.source === 'block'- ? { entity_type: useBlockName(), entity_id: useBlockId() }- : undefined;-- function handleSubmit() {- let options_ = selectedOptions();- if (!options_ || options_.length === 0) {- setTriedToSubmit(true);- return;- }- const destination_ = getDestinationFromOptions(options_);- if (!destination_) return;- if (destination_.type === 'users') {- sendToUsers({- users: destination_.users,- content: markdownState(),- attachments: asAttachment ? [asAttachment] : [],- mentions: mentions().map(mentionToSimpleMention),- navigate: { navigate: true },- });- } else if (destination_.type === 'channel') {- sendToChannel({- channelId: destination_.id,- content: markdownState(),- attachments: asAttachment ? [asAttachment] : [],- mentions: mentions().map(mentionToSimpleMention),- navigate: { navigate: true },- });- }-- if (props.isOpenSignal) {- props.isOpenSignal[1](false);- }- }-- const [warningGiven, setWarningGiven] = createSignal(false);-- const handleInteractOutside = (e: PointerDownOutsideEvent) => {- e.preventDefault();- const trimmed = markdownState().trim();- if (trimmed.length > 0 && warningGiven() === false) {- toast.alert(- 'Are you sure you want to leave? Your message will be deleted.'- );- setWarningGiven(true);- } else {- if (props.isOpenSignal) {- props.isOpenSignal[1](false);- }- }- };-- return (- <Dialog- modal- open={props.isOpenSignal ? props.isOpenSignal[0]() : undefined}- onOpenChange={props.isOpenSignal ? props.isOpenSignal[1] : undefined}- >- <Show when={props.trigger}>- {(triggerComponent) => {- return <Dialog.Trigger>{triggerComponent()}</Dialog.Trigger>;- }}- </Show>- <Dialog.Portal>- <Dialog.Overlay- class="fixed flex inset-0 z-modal bg-modal-overlay items-center justify-center text-ink transition-[max-height] duration-350 ease-out sm:transition-none portal-scope"- style={{- 'max-height': 'calc(100% - var(--keyboard-height))',- }}- >- <Dialog.Content- class="w-[512px] bg-dialog rounded-lg border-edge border-1 shadow-lg"- onPointerDownOutside={(e) => {- handleInteractOutside(e);- }}- >- <div class="flex flex-row justify-between items-center p-4">- <Dialog.Title class="font-medium text-2xl text-ink-muted">- {props.title}- </Dialog.Title>- <Dialog.CloseButton class="text-ink-muted hover:bg-hover hover-transition-bg rounded-md p-1">- <XIcon class="w-5 h-5" />- </Dialog.CloseButton>- </div>- <div class="flex flex-col p-2 gap-2">- <RecipientSelector<'user' | 'contact' | 'channel'>- options={destinationOptions}- selectedOptions={selectedOptions()}- setSelectedOptions={setSelectedOptions}- placeholder="Add by email or channel"- triedToSubmit={triedToSubmit}- triggerMode="input"- />- <div class="flex flex-col w-full h-[200px] rounded-md border border-edge">- <FormatRibbon- state={markdownFormatState}- inlineFormat={setInlineFormat}- nodeFormat={setNodeFormat}- />- <div- class="w-full h-full p-2 overflow-auto portal-scope"- onClick={() => focusMarkdownArea()}- >- <MarkdownArea- placeholder="Write a message..."- initialValue={markdownState()}- onEnter={(e: KeyboardEvent) => {- e.preventDefault();- return true;- }}- onEscape={(e: KeyboardEvent) => {- e.preventDefault();- e.stopPropagation();- return true;- }}- portalScope="local"- />- </div>- </div>- </div>- <div class="w-full flex flex-row justify-between items-center p-2">- <Show when={props.source === 'block'} fallback={<div />}>- <CopyLinkButton />- </Show>- <div class="flex flex-row gap-2 items-center">- <DeprecatedTextButton- disabled={markdownState().trim().length === 0}- text="Send"- theme="accent"- onClick={handleSubmit}- />- </div>- </div>- </Dialog.Content>- </Dialog.Overlay>- </Dialog.Portal>- </Dialog>- );-}--export function useNewMessageModal(- props: Pick<NewMessageProps, 'title' | 'source'>-) {- const isOpenSignal = createSignal(false);- return {- Modal: () => {- return (- <Show when={isOpenSignal[0]()}>- <NewMessage- source={props.source}- title={props.title}- isOpenSignal={isOpenSignal}- />- </Show>- );- },- open: () => isOpenSignal[1](true),- close: () => isOpenSignal[1](false),- };-}--export function ForwardButton() {- return (- <NewMessage- source="block"- trigger={- <DeprecatedTextButton- icon={PaperPlaneIcon}- theme={'base'}- text={undefined}- children={undefined}- />- }- title="Forward Message"- />- );-}diff --git a/js/app/packages/core/util/destination.ts b/js/app/packages/core/util/destination.tsnew file mode 100644index 0000000000..2ecc5c2c4b--- /dev/null+++ b/js/app/packages/core/util/destination.ts@@ -0,0 +1,50 @@+import type { CombinedRecipientItem } from '@core/user';++type UserDestination = {+ type: 'users';+ users: string[];+};++type ChannelDestination = {+ type: 'channel';+ id: string;+};++type Destination = UserDestination | ChannelDestination;++type DestinationType<T extends CombinedRecipientItem> =+ T extends CombinedRecipientItem<'channel'>+ ? Extract<T, CombinedRecipientItem<'channel'>> extends T+ ? ChannelDestination+ : Destination+ : UserDestination;++export function getDestinationFromOptions<T extends CombinedRecipientItem>(+ options: T[]+): DestinationType<T> {+ let maybeChannel = options.find((o) => o.kind === 'channel');+ if (maybeChannel) {+ return {+ type: 'channel',+ id: maybeChannel.id,+ } as any;+ }++ const userIds = options+ .filter((o) => {+ if (o.kind === 'custom') {+ return !o.data.invalid;+ }+ return true;+ })+ .map((o) => {+ if (o.kind === 'channel') return;+ return o.id;+ })+ .filter((id) => id != null);++ return {+ type: 'users',+ users: userIds,+ } as any;+}diff --git a/js/app/packages/notifications/components/Playground.tsx b/js/app/packages/notifications/components/Playground.tsxindex d4a7db1194..03a47ff8a0 100644--- a/js/app/packages/notifications/components/Playground.tsx+++ b/js/app/packages/notifications/components/Playground.tsx@@ -1,5 +1,6 @@import { globalSplitManager } from '@app/signal/splitLayout';-import { useChannelMarkdownArea } from '@block-channel/component/DeprecatedChannelInput/MarkdownArea';+import { createConfiguredChannelMarkdownEditor } from '@channel/Input';+import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';import { DeprecatedTextButton } from '@core/component/DeprecatedTextButton';import { NotificationRenderer } from '@core/component/NotificationRenderer';import { formatDate } from '@core/util/date';@@ -30,6 +31,9 @@ import {usePlatformNotificationState,} from './PlatformNotificationProvider';+const PLAYGROUND_INITIAL_VALUE =+ "Hey! Check out this **cool feature** we just shipped.\n\nHere's a code example:\n```typescript\nconst notify = () => {\n console.log('Hello!');\n};\n```\n\nLet me know what you think!";+type NotificationsByType = Map<string, UnifiedNotification[]>;function groupNotificationsByType(@@ -247,7 +251,7 @@ function PermissionButton(props: { platformNotif: any }) {}function CustomBuilder(props: {- markdownArea: ReturnType<typeof useChannelMarkdownArea>;+ markdownEditor: ReturnType<typeof createConfiguredChannelMarkdownEditor>;customNotification: UnifiedNotification;onTest: (notification: UnifiedNotification) => void;}) {@@ -266,11 +270,10 @@ function CustomBuilder(props: {Message Content</label><div class="border border-edge-muted rounded-lg p-3 bg-menu min-h-64 max-h-96 overflow-auto">- <props.markdownArea.MarkdownArea+ <MarkdownShell+ config={props.markdownEditor}placeholder="Type your markdown message here... (use @ for mentions)"- initialValue="Hey! Check out this **cool feature** we just shipped.\n\nHere's a code example:\n```typescript\nconst notify = () => {\n console.log('Hello!');\n};\n```\n\nLet me know what you think!"- users={() => []}- history={() => []}+ initialValue={PLAYGROUND_INITIAL_VALUE}/></div><p class="text-xs text-ink-muted mt-2">@@ -454,7 +457,14 @@ function EmptyState(props: { title: string; description: string }) {function PlaygroundContent() {const { ws } = createMockWebsocket();const platformNotif = usePlatformNotificationState();- const markdownArea = useChannelMarkdownArea();+ const [markdown, setMarkdown] = createSignal(PLAYGROUND_INITIAL_VALUE);+ const markdownEditor = createConfiguredChannelMarkdownEditor({+ namespace: 'notifications-playground-markdown',+ enableMentions: true,+ users: () => [],+ onChange: setMarkdown,+ });+ markdownEditor.buildHandle();const notificationSource = createNotificationSource(ws);@@ -488,7 +498,7 @@ function PlaygroundContent() {notification_event_type: 'channel_message_send',notification_metadata: {sender: 'user-custom',- messageContent: markdownArea.state(),+ messageContent: markdown(),messageId: 'msg-custom',channelType: 'direct_message',channelName: 'test-channel',@@ -641,7 +651,7 @@ function PlaygroundContent() {}><CustomBuilder- markdownArea={markdownArea}+ markdownEditor={markdownEditor}customNotification={customNotification()}onTest={handleTestNotification}/>