how to insert link #1379
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Demo: https://milkdown-storybook.vercel.app/?path=/story/components-link-tooltip--default |
Beta Was this translation helpful? Give feedback.
-
How to insert link without selecting text first? or is there any way to select some content? this.editor.action((ctx) => {
const view = ctx.get(editorViewCtx);
view.dispatch(view.state.tr.insertText(" "));
// select the inserted text and create selection
// don't know how to create selection
const selection =
view.state.tr.setSelection(selection);
ctx.get(linkTooltipAPI.key).addLink(selection.from, selection.to);
}); |
Beta Was this translation helpful? Give feedback.
Demo: https://milkdown-storybook.vercel.app/?path=/story/components-link-tooltip--default
Code: https://github.com/Milkdown/milkdown/blob/main/e2e/stories/components/link-tooltip.stories.ts#L58