Replies: 9 comments 5 replies
-
I have try this https://codesandbox.io/s/gifted-meninsky-6kfc7t?file=/src/Editor.tsx:867-902
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
If all you need is just override the click behavior when clicking on link attributes, you should use a prosemirror plugin and configure the event hooks: https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn. Also, it's possible to pass in a custom dom element in toDOM in schema spec, you can extend the spec and override the behavior: linkSchema.extendSchema(prev => {
return (ctx) => {
const baseSchema = prev(ctx)
return {
...baseSchema,
toDOM: () => {
const a = document.createElement('a');
return a;
}
}
}
}) But in most cases, you should consider to use the first method. About the node view, as I mentioned before in your issue. It's not supposed to be used in marks so you shouldn't use that. |
Beta Was this translation helpful? Give feedback.
-
@Saul-Mirone thanks for the answer. I have try with handleClickOn but node here is not link (link is Mark object) onClick node is paragraph For method two its not clear how to set this new linkSchema to Mark object ? |
Beta Was this translation helpful? Give feedback.
-
@Saul-Mirone have you see the debugger on click on link => Node marks = [] (empty array) |
Beta Was this translation helpful? Give feedback.
-
Here is the sandbox with handleClickOn https://codesandbox.io/s/sharp-sammet-s562uw?file=/src/Editor.tsx |
Beta Was this translation helpful? Give feedback.
-
@Saul-Mirone it works now but how to https://codesandbox.io/s/sharp-sammet-s562uw?file=/src/Editor.tsx |
Beta Was this translation helpful? Give feedback.
-
@Saul-Mirone your workaround works for me thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi,
In milkdown v6 I have custom link and image nodes and use it like that: https://github.com/tagspaces/tagspaces-common/blob/develop/packages/tagspaces-md/src/MilkdownEditor.tsx#L155
In v7 it's have widgetViewFactory that can add content before and after position of link node (It's text node with Mark) : https://github.com/Milkdown/website/blob/main/src/components/playground-editor/editor-component/LinkWidget.tsx
But I want to completelly replace link with custom component like this: https://github.com/tagspaces/tagspaces-common/blob/develop/packages/tagspaces-md/src/MilkdownEditor.tsx#L94
How can be done this with milkdown v7?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions