fix: #390, safari rich text link bug

This commit is contained in:
James
2021-12-14 10:23:28 -05:00
parent 37f5fc3895
commit a16b99b0c8
3 changed files with 13 additions and 3 deletions

View File

@@ -58,6 +58,7 @@
.rich-text-link__url {
@include formInput;
padding-right: base(1.75);
min-width: base(12);
width: 100%;
background: rgba($color-background-gray, .1);

View File

@@ -69,6 +69,7 @@ const Link = ({ attributes, children, element }) => {
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.preventDefault();
close();
}
}}

View File

@@ -9,13 +9,21 @@ export const unwrapLink = (editor: Editor): void => {
Transforms.unwrapNodes(editor, { match: (n) => Element.isElement(n) && n.type === 'link' });
};
export const wrapLink = (editor: Editor, url?: string, newTab?: boolean): void => {
export const wrapLink = (editor, url?: string, newTab?: boolean): void => {
if (isLinkActive(editor)) {
unwrapLink(editor);
}
const { selection } = editor;
const isCollapsed = selection && Range.isCollapsed(selection);
const { selection, blurSelection } = editor;
if (blurSelection) {
Transforms.select(editor, blurSelection);
}
const selectionToUse = selection || blurSelection;
const isCollapsed = selectionToUse && Range.isCollapsed(selectionToUse);
const link = {
type: 'link',
url,