diff --git a/src/cloud/components/DocPreview/DocPreviewRealtime.tsx b/src/cloud/components/DocPreview/DocPreviewRealtime.tsx index b941e6dbda..2ae08c719d 100644 --- a/src/cloud/components/DocPreview/DocPreviewRealtime.tsx +++ b/src/cloud/components/DocPreview/DocPreviewRealtime.tsx @@ -200,7 +200,7 @@ const DocPreviewRealtime = ({ Dismiss )} diff --git a/src/cloud/components/Editor/index.tsx b/src/cloud/components/Editor/index.tsx index 639530cb0a..8b13d4cb39 100644 --- a/src/cloud/components/Editor/index.tsx +++ b/src/cloud/components/Editor/index.tsx @@ -174,6 +174,7 @@ const Editor = ({ const [shortcodeConvertMenu, setShortcodeConvertMenu] = useState<{ pos: PositionRange cb: Callback + actionLabel?: string } | null>(null) const initialRenderDone = useRef(false) const { docsMap, workspacesMap, loadDoc } = useNav() @@ -392,8 +393,8 @@ const Editor = ({ }, }) pasteFormatPlugin(editor, { - openMenu: (pos, cb) => { - setShortcodeConvertMenu({ pos, cb }) + openMenu: (pos, cb, actionLabel) => { + setShortcodeConvertMenu({ pos, cb, actionLabel }) }, closeMenu: () => { setShortcodeConvertMenu(null) @@ -410,6 +411,8 @@ const Editor = ({ return { replacement: `[[ ${entityType} id="${org}/${repo}#${num}" ]]`, promptMenu: true, + actionLabel: + type === 'pull' ? 'Embed pull request' : 'Embed issue', } } } @@ -1035,7 +1038,7 @@ const Editor = ({ Dismiss )} diff --git a/src/cloud/lib/editor/plugins/pasteFormatPlugin.ts b/src/cloud/lib/editor/plugins/pasteFormatPlugin.ts index 2f11aa37b6..62536fac62 100644 --- a/src/cloud/lib/editor/plugins/pasteFormatPlugin.ts +++ b/src/cloud/lib/editor/plugins/pasteFormatPlugin.ts @@ -14,10 +14,15 @@ export type Callback = (convert: boolean) => void type FormatterResult = { replacement: string | null promptMenu: boolean + actionLabel?: string } interface Config { - openMenu: (position: PositionRange, callback: Callback) => void + openMenu: ( + position: PositionRange, + callback: Callback, + actionLabel?: string + ) => void closeMenu: () => void formatter: (pasted: string[]) => FormatterResult } @@ -53,7 +58,7 @@ export const pasteFormatPlugin = ( return } - const { replacement, promptMenu } = formatter(change.text) + const { replacement, promptMenu, actionLabel } = formatter(change.text) if (replacement === null) { return @@ -78,7 +83,7 @@ export const pasteFormatPlugin = ( close() } - openMenu(posRange, callback) + openMenu(posRange, callback, actionLabel) open = true }) } diff --git a/src/cloud/lib/hooks/editor/docEditor.ts b/src/cloud/lib/hooks/editor/docEditor.ts index afc4f3d860..8492465676 100644 --- a/src/cloud/lib/hooks/editor/docEditor.ts +++ b/src/cloud/lib/hooks/editor/docEditor.ts @@ -59,6 +59,7 @@ export function useDocEditor({ const [shortcodeConvertMenu, setShortcodeConvertMenu] = useState<{ pos: PositionRange cb: Callback + actionLabel?: string } | null>(null) const suggestionsRef = useRef([]) const { loadDoc } = useNav() @@ -220,8 +221,8 @@ export function useDocEditor({ }, }) pasteFormatPlugin(editor, { - openMenu: (pos, cb) => { - setShortcodeConvertMenu({ pos, cb }) + openMenu: (pos, cb, actionLabel) => { + setShortcodeConvertMenu({ pos, cb, actionLabel }) }, closeMenu: () => { setShortcodeConvertMenu(null) @@ -238,6 +239,8 @@ export function useDocEditor({ return { replacement: `[[ ${entityType} id="${org}/${repo}#${num}" ]]`, promptMenu: true, + actionLabel: + type === 'pull' ? 'Embed pull request' : 'Embed issue', } } } diff --git a/src/mobile/components/pages/DocEditPage.tsx b/src/mobile/components/pages/DocEditPage.tsx index 98d65fda4c..f11eda60e8 100644 --- a/src/mobile/components/pages/DocEditPage.tsx +++ b/src/mobile/components/pages/DocEditPage.tsx @@ -99,6 +99,7 @@ const Editor = ({ const [shortcodeConvertMenu, setShortcodeConvertMenu] = useState<{ pos: PositionRange cb: Callback + actionLabel?: string } | null>(null) const initialRenderDone = useRef(false) const titleRef = useRef(null) @@ -277,8 +278,8 @@ const Editor = ({ }, }) pasteFormatPlugin(editor, { - openMenu: (pos, cb) => { - setShortcodeConvertMenu({ pos, cb }) + openMenu: (pos, cb, actionLabel) => { + setShortcodeConvertMenu({ pos, cb, actionLabel }) }, closeMenu: () => { setShortcodeConvertMenu(null) @@ -295,6 +296,8 @@ const Editor = ({ return { replacement: `[[ ${entityType} id="${org}/${repo}#${num}" ]]`, promptMenu: true, + actionLabel: + type === 'pull' ? 'Embed pull request' : 'Embed issue', } } } @@ -590,7 +593,7 @@ const Editor = ({ Dismiss )}