diff --git a/frontend/apps/desktop/src/editor/autocomplete.tsx b/frontend/apps/desktop/src/editor/autocomplete.tsx index e66fadc4b..384cbfecf 100644 --- a/frontend/apps/desktop/src/editor/autocomplete.tsx +++ b/frontend/apps/desktop/src/editor/autocomplete.tsx @@ -183,12 +183,10 @@ export function createAutoCompletePlugin(args: { const onCreate = ( link: string, - name: string, range: {from: number; to: number}, ) => { const node = view.state.schema.nodes[nodeName].create({ link, - name, }) view.dispatch( view.state.tr.replaceWith( @@ -359,7 +357,7 @@ function AutocompletePopupInner( ) { let item = suggestions[group][idx] - onCreate(item.value, item.title, range) + onCreate(item.value, range) onClose() } return true @@ -469,7 +467,7 @@ function AutocompletePopupInner( // setIndex(i) }} onPress={() => { - onCreate(item.value, item.title, range) + onCreate(item.value, range) onClose() }} /> @@ -515,11 +513,7 @@ export type AutocompleteTokenPluginActiveState = { } export type AutocompleteTokenPluginActions = { - onCreate: ( - link: string, - name: string, - range: {from: number; to: number}, - ) => void + onCreate: (link: string, range: {from: number; to: number}) => void onClose: () => void } diff --git a/frontend/apps/desktop/src/editor/blocknote/core/api/nodeConversions/nodeConversions.ts b/frontend/apps/desktop/src/editor/blocknote/core/api/nodeConversions/nodeConversions.ts index 08140a04a..6114d708d 100644 --- a/frontend/apps/desktop/src/editor/blocknote/core/api/nodeConversions/nodeConversions.ts +++ b/frontend/apps/desktop/src/editor/blocknote/core/api/nodeConversions/nodeConversions.ts @@ -124,7 +124,6 @@ export function inlineContentToNodes( nodes.push( schema.nodes['inline-embed'].create({ link: content.link, - name: content.name, }), ) } else { @@ -234,7 +233,6 @@ function contentNodeToInlineContent(contentNode: Node) { content.push({ type: node.type.name, link: node.attrs.link, - name: node.attrs.name, }) currentContent = undefined @@ -412,10 +410,7 @@ export function nodeToBlock( })) { const blockSpec = blockSchema[blockInfo.contentType.name] if (!blockSpec) { - if ( - blockInfo.contentType.name === 'code-block' || - blockInfo.contentType.name === 'inline-embed' - ) { + if (blockInfo.contentType.name === 'code-block') { break } else throw Error( diff --git a/frontend/apps/desktop/src/editor/blocknote/core/extensions/Blocks/api/inlineContentTypes.ts b/frontend/apps/desktop/src/editor/blocknote/core/extensions/Blocks/api/inlineContentTypes.ts index 4d3bb8158..4c5c7874d 100644 --- a/frontend/apps/desktop/src/editor/blocknote/core/extensions/Blocks/api/inlineContentTypes.ts +++ b/frontend/apps/desktop/src/editor/blocknote/core/extensions/Blocks/api/inlineContentTypes.ts @@ -31,7 +31,6 @@ export type BNLink = { export type InlineEmbed = { type: 'inline-embed' link: string - name: string } export type PartialLink = Omit & { diff --git a/frontend/apps/desktop/src/editor/blocknote/core/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts b/frontend/apps/desktop/src/editor/blocknote/core/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts index 437757593..bf7f10c99 100644 --- a/frontend/apps/desktop/src/editor/blocknote/core/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +++ b/frontend/apps/desktop/src/editor/blocknote/core/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts @@ -200,7 +200,6 @@ class HyperlinkToolbarView { : this.pmView.state.selection.from tr = tr.setNodeMarkup(pos, null, { link: url, - name: text, }) // return } else { @@ -237,7 +236,6 @@ class HyperlinkToolbarView { : this.pmView.state.selection.from tr = tr.setNodeMarkup(pos, null, { link: url, - name: text, }) // return } else { @@ -422,9 +420,7 @@ class HyperlinkToolbarView { this.hyperlinkMarkRange!.to, ), url: this.hyperlinkMark!.attrs.link, - text: this.hyperlinkMark!.attrs.name - ? this.hyperlinkMark!.attrs.name - : ' ', + text: ' ', type: 'mention', id: container ? container.attrs.id : '', } diff --git a/frontend/apps/desktop/src/editor/hm-link-switch-toolbar.tsx b/frontend/apps/desktop/src/editor/hm-link-switch-toolbar.tsx index ce2362c96..f08b330a9 100644 --- a/frontend/apps/desktop/src/editor/hm-link-switch-toolbar.tsx +++ b/frontend/apps/desktop/src/editor/hm-link-switch-toolbar.tsx @@ -80,7 +80,7 @@ export function HypermediaLinkSwitchToolbar( editLink={props.editHyperlink} openUrl={props.openUrl} type={props.type} - hasName={props.type !== 'embed'} + hasName={props.type !== 'embed' && props.type !== 'mention'} hasSearch={props.type !== 'link'} isSeedDocument={unpackedRef ? true : false} /> @@ -132,7 +132,7 @@ export function HypermediaLinkSwitchToolbar( $pos.start() + offset + 1, state.schema.text( - mention.attrs.name, + mention.attrs.link, // @ts-ignore state.schema.marks['link'].create({href: props.url})!, ), @@ -175,7 +175,6 @@ export function HypermediaLinkSwitchToolbar( const node = state.schema.nodes['inline-embed'].create( { link: props.url, - name: props.text, }, state.schema.text(' '), ) @@ -186,7 +185,6 @@ export function HypermediaLinkSwitchToolbar( content: [], props: { link: props.url, - name: props.text ? props.text : props.url, }, } as PartialBlock // props.editor.insertBlocks([mentionBlock], props.id, 'after') diff --git a/frontend/apps/desktop/src/editor/hyperlink-toolbar.tsx b/frontend/apps/desktop/src/editor/hyperlink-toolbar.tsx index cbf62f3eb..fb29b7fa6 100644 --- a/frontend/apps/desktop/src/editor/hyperlink-toolbar.tsx +++ b/frontend/apps/desktop/src/editor/hyperlink-toolbar.tsx @@ -68,11 +68,9 @@ export function HypermediaLinkToolbar( editLink={props.editHyperlink} openUrl={props.openUrl} type={props.type} - hasName={true} + hasName={props.type !== 'mention'} hasSearch={props.type === 'mention'} isSeedDocument={props.isSeedDocument} - isFocused={props.isFocused} - setIsFocused={props.setIsFocused} /> ) diff --git a/frontend/apps/desktop/src/editor/mentions-plugin.tsx b/frontend/apps/desktop/src/editor/mentions-plugin.tsx index 721410962..6a1abe322 100644 --- a/frontend/apps/desktop/src/editor/mentions-plugin.tsx +++ b/frontend/apps/desktop/src/editor/mentions-plugin.tsx @@ -65,9 +65,6 @@ export function createInlineEmbedNode(bnEditor: any) { link: { default: '', }, - name: { - default: '', - }, } }, addProseMirrorPlugins() { @@ -83,24 +80,13 @@ function InlineEmbedNodeComponent(props: any) { - + ) } -export function MentionToken(props: { - value: string - name: string - selected?: boolean - updateAttributes: (attributes: {[key: string]: any}) => void -}) { +export function MentionToken(props: {value: string; selected?: boolean}) { const unpackedRef = unpackHmId(props.value) if (unpackedRef?.type == 'd') { @@ -113,28 +99,20 @@ export function MentionToken(props: { function DocumentMention({ unpackedRef, - name, selected, - updateAttributes, }: { unpackedRef: UnpackedHypermediaId - name: string selected?: boolean - updateAttributes: (attributes: {[key: string]: any}) => void }) { - let mentionName = name - if (!mentionName) { - const entity = useEntity(unpackedRef) - const docTitle = entity.data?.document - ? getDocumentTitle(entity.data?.document) - : unpackedRef.id + const entity = useEntity(unpackedRef) - if (!mentionName && docTitle) { - updateAttributes({name: docTitle}) - } - } - - return {mentionName} + return ( + + {entity.data?.document + ? getDocumentTitle(entity.data?.document) + : unpackedRef.id} + + ) } export function MentionText(props: any) { diff --git a/frontend/packages/shared/src/client/__tests__/editorblock-to-hmblock.test.ts b/frontend/packages/shared/src/client/__tests__/editorblock-to-hmblock.test.ts index 60c82fd72..6abbde486 100644 --- a/frontend/packages/shared/src/client/__tests__/editorblock-to-hmblock.test.ts +++ b/frontend/packages/shared/src/client/__tests__/editorblock-to-hmblock.test.ts @@ -282,7 +282,6 @@ describe('EditorBlock to HMBlock', () => { type: 'inline-embed', link: 'hm://asdf1234', styles: {}, - name: 'test embed', }, ], } @@ -294,9 +293,7 @@ describe('EditorBlock to HMBlock', () => { annotations: [ { type: 'Embed', - attributes: { - name: 'test embed', - }, + attributes: {}, starts: [6], ends: [7], link: 'hm://asdf1234', @@ -325,7 +322,6 @@ describe('EditorBlock to HMBlock', () => { type: 'inline-embed', link: 'hm://asdf1234', styles: {}, - name: 'test embed', }, { type: 'text', @@ -361,9 +357,7 @@ describe('EditorBlock to HMBlock', () => { annotations: [ { type: 'Embed', - attributes: { - name: 'test embed', - }, + attributes: {}, starts: [6], ends: [7], link: 'hm://asdf1234', diff --git a/frontend/packages/shared/src/client/__tests__/hmblock-to-editorblock.test.ts b/frontend/packages/shared/src/client/__tests__/hmblock-to-editorblock.test.ts index 22089fccf..245031f69 100644 --- a/frontend/packages/shared/src/client/__tests__/hmblock-to-editorblock.test.ts +++ b/frontend/packages/shared/src/client/__tests__/hmblock-to-editorblock.test.ts @@ -292,9 +292,7 @@ describe('HMBlock to EditorBlock', () => { { type: 'Embed', starts: [6], - attributes: { - name: 'test embed', - }, + attributes: {}, ends: [7], link: 'hm://asdf1234', }, @@ -319,7 +317,6 @@ describe('HMBlock to EditorBlock', () => { type: 'inline-embed', link: 'hm://asdf1234', styles: {}, - name: 'test embed', }, ], } @@ -336,9 +333,7 @@ describe('HMBlock to EditorBlock', () => { { type: 'Embed', starts: [6], - attributes: { - name: 'test embed', - }, + attributes: {}, ends: [7], link: 'hm://asdf1234', }, @@ -377,7 +372,6 @@ describe('HMBlock to EditorBlock', () => { type: 'inline-embed', link: 'hm://asdf1234', styles: {}, - name: 'test embed', }, { type: 'text', diff --git a/frontend/packages/shared/src/client/editorblock-to-hmblock.ts b/frontend/packages/shared/src/client/editorblock-to-hmblock.ts index a1dd7a579..1140c4554 100644 --- a/frontend/packages/shared/src/client/editorblock-to-hmblock.ts +++ b/frontend/packages/shared/src/client/editorblock-to-hmblock.ts @@ -86,12 +86,7 @@ export function editorBlockToHMBlock(editorBlock: EditorBlock): HMBlock { } if (leaf.type == 'inline-embed') { - annotations.addSpan( - 'Embed', - {link: leaf.link, name: leaf.name}, - start, - end, - ) + annotations.addSpan('Embed', {link: leaf.link}, start, end) } if (leaf.type == 'link') { @@ -214,7 +209,6 @@ function flattenLeaves( result.push({ ...leaf, text: '\uFFFC', - name: leaf.name, link: leaf.link, } as const) } diff --git a/frontend/packages/shared/src/client/hmblock-to-editorblock.ts b/frontend/packages/shared/src/client/hmblock-to-editorblock.ts index 99a69e917..4a579099b 100644 --- a/frontend/packages/shared/src/client/hmblock-to-editorblock.ts +++ b/frontend/packages/shared/src/client/hmblock-to-editorblock.ts @@ -278,7 +278,6 @@ export function hmBlockToEditorBlock(block: HMBlock): EditorBlock { if (l.type == 'Embed') { linkAnnotation = { type: 'inline-embed', - name: l.attributes.name, link: l.link, } } @@ -298,7 +297,6 @@ export function hmBlockToEditorBlock(block: HMBlock): EditorBlock { leaves.push({ type: 'inline-embed', styles: {}, - name: linkAnnotation.name, link: linkAnnotation.link, } as EditorInlineEmbed) textStart = i + 1 diff --git a/frontend/packages/shared/src/editor-types.ts b/frontend/packages/shared/src/editor-types.ts index a6fe52a26..68416f9a2 100644 --- a/frontend/packages/shared/src/editor-types.ts +++ b/frontend/packages/shared/src/editor-types.ts @@ -145,7 +145,6 @@ export interface EditorLink { export interface EditorInlineEmbed { type: 'inline-embed' link: string - name: string styles: EditorInlineStyles | {} } diff --git a/frontend/packages/shared/src/hm-types.ts b/frontend/packages/shared/src/hm-types.ts index e88cb1c96..36d7575ec 100644 --- a/frontend/packages/shared/src/hm-types.ts +++ b/frontend/packages/shared/src/hm-types.ts @@ -120,7 +120,6 @@ export const InlineEmbedAnnotationSchema = z .object({ type: z.literal('Embed'), ...baseAnnotationProperties, - attributes: z.object({name: z.string().optional()}), link: z.string(), }) .strict()