diff --git a/wax-prosemirror-components/src/components/link/LinkComponent.js b/wax-prosemirror-components/src/components/link/LinkComponent.js index 4ac075f6d86b843874fc8bc55e41b85e7e6f928a..7513a37d9a1cec2737c6f5659343d1e1f2e728a5 100644 --- a/wax-prosemirror-components/src/components/link/LinkComponent.js +++ b/wax-prosemirror-components/src/components/link/LinkComponent.js @@ -54,7 +54,7 @@ const StyledButtonCancel = styled.button` const LinkComponent = ({ mark, setPosition, position }) => { const href = mark ? mark.attrs.href : null; - const linkMark = mark ? mark : null; + const linkMark = mark || null; const { activeView } = useContext(WaxContext); const { state, dispatch } = activeView; const ref = useRef(null); @@ -69,26 +69,26 @@ const LinkComponent = ({ mark, setPosition, position }) => { }, [ref.current, href]); const addLinkHref = () => { - const href = linkHref; if (linkInput.current.value === '') { linkInput.current.focus(); return false; } - const linkMark = state.schema.marks.link; + const schemaLinkMark = state.schema.marks.link; const { tr } = state; dispatch( tr.addMark( mark.from, mark.to, - linkMark.create({ + schemaLinkMark.create({ ...((mark && mark.attrs) || {}), - href, + href: linkHref, }), ), ); setEditable(false); activeView.focus(); + return true; }; const removeLink = () => { @@ -194,9 +194,9 @@ const LinkComponent = ({ mark, setPosition, position }) => { <LinkWrapper ref={ref}> {editable && ( <Input - ref={linkInput} onChange={updateLinkHref} onKeyPress={handleKeyDown} + ref={linkInput} value={linkHref} /> )} diff --git a/wax-prosemirror-schema/src/marks/linkMark.js b/wax-prosemirror-schema/src/marks/linkMark.js index 26aea4a6d472b6a8e3a7c4726d14cc98a9ccd173..291fe66716ec95ac259d91ebf9a090d7e9dcf7ee 100644 --- a/wax-prosemirror-schema/src/marks/linkMark.js +++ b/wax-prosemirror-schema/src/marks/linkMark.js @@ -5,6 +5,7 @@ const link = { target: { default: 'blank' }, title: { default: null }, }, + excludes: 'link', inclusive: false, parseDOM: [ {