From 3b16a1c3f0fdfddd9bcb1edce7c1f86ef7edfd3d Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Sat, 7 Dec 2019 21:31:51 +0100 Subject: [PATCH] fix: ts (#3270) * fix: ts Fix: - Argument of type 'Point | undefined' is not assignable to parameter of type 'Location'. Type 'undefined' is not assignable to type 'Location'. - Types of property 'zIndex' are incompatible. * use && * use optional chaining * revert optional chaining (not supported) --- site/examples/mentions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/site/examples/mentions.js b/site/examples/mentions.js index 891707b80..d42a4027a 100644 --- a/site/examples/mentions.js +++ b/site/examples/mentions.js @@ -83,10 +83,10 @@ const MentionExample = () => { if (selection && Range.isCollapsed(selection)) { const [start] = Range.edges(selection) const wordBefore = Editor.before(editor, start, { unit: 'word' }) - const before = Editor.before(editor, wordBefore) - const beforeRange = Editor.range(editor, before, start) - const beforeText = Editor.text(editor, beforeRange) - const beforeMatch = beforeText.match(/^@(\w+)$/) + const before = wordBefore && Editor.before(editor, wordBefore) + const beforeRange = before && Editor.range(editor, before, start) + const beforeText = beforeRange && Editor.text(editor, beforeRange) + const beforeMatch = beforeText && beforeText.match(/^@(\w+)$/) const after = Editor.after(editor, start) const afterRange = Editor.range(editor, start, after) const afterText = Editor.text(editor, afterRange) @@ -116,7 +116,7 @@ const MentionExample = () => { top: '-9999px', left: '-9999px', position: 'absolute', - zIndex: '1', + zIndex: 1, padding: '3px', background: 'white', borderRadius: '4px',