Skip to content

Commit

Permalink
fix: add text after link
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Jan 9, 2024
1 parent 81611a8 commit bce053a
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/config/Slate/Link/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/*Customized LinkEditor to handle data-element*/
/*Customized LinkEditor to:
- handle data-element
- enhance link (enhanced_link_infos)
*/
import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { ReactEditor } from 'slate-react';
import { Transforms } from 'slate';
import {
_insertElement,
_unwrapElement,
Expand Down Expand Up @@ -57,17 +61,26 @@ const LinkEditor = (props) => {
editor.selection = selection;
insertElement(editor, { url, dataElement, enhanced_link_infos });
}
ReactEditor.focus(editor);
// ReactEditor.focus(editor);

dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
savedPosition.current = null;

ReactEditor.deselect(editor);
Transforms.collapse(editor, { edge: 'end' });
Transforms.insertText(editor, ' ');
}}
onClear={() => {
// clear button was pressed in the link edit popup
const newSelection = JSON.parse(
JSON.stringify(unwrapElement(editor)),
);
editor.selection = newSelection;
editor.savedSelection = newSelection;
try {
const newSelection = JSON.parse(
JSON.stringify(unwrapElement(editor)),
);
editor.selection = newSelection;
editor.savedSelection = newSelection;
} catch (e) {
//when no link was setted yet, and you clear the select item to link
}
}}
onOverrideContent={(c) => {
dispatch(setPluginOptions(pid, { show_sidebar_editor: false }));
Expand Down

0 comments on commit bce053a

Please sign in to comment.