diff --git a/src/components/Common/ErrorWrapper.jsx b/src/components/Common/ErrorWrapper.jsx index f52135b8..a894addd 100644 --- a/src/components/Common/ErrorWrapper.jsx +++ b/src/components/Common/ErrorWrapper.jsx @@ -1,12 +1,11 @@ import React from "react"; import classnames from "classnames"; +import { isNotPresent } from "neetocist"; import { is } from "ramda"; -import { isNilOrEmpty } from "utils/common"; - const ErrorWrapper = ({ error, children, className }) => { - const isError = !isNilOrEmpty(error); + const isError = !isNotPresent(error); const wrapperClasses = classnames({ "neeto-editor-error": isError, [className]: className, @@ -25,7 +24,7 @@ const ErrorWrapper = ({ error, children, className }) => { message = error.message; } - if (isNilOrEmpty(message)) return null; + if (isNotPresent(message)) return null; return message; }; diff --git a/src/components/Editor/CustomExtensions/SlashCommands/Menu.jsx b/src/components/Editor/CustomExtensions/SlashCommands/Menu.jsx index 873be60e..9c71f44b 100644 --- a/src/components/Editor/CustomExtensions/SlashCommands/Menu.jsx +++ b/src/components/Editor/CustomExtensions/SlashCommands/Menu.jsx @@ -2,8 +2,8 @@ import React, { forwardRef } from "react"; import Tippy from "@tippyjs/react"; import classnames from "classnames"; +import { isNotPresent } from "neetocist"; -import { isNilOrEmpty } from "utils/common"; import { scrollHandler } from "utils/scrollhandler"; class Menu extends React.Component { @@ -57,7 +57,7 @@ class Menu extends React.Component { const { items, editor, range } = this.props; const selectedItem = items[index]; const hasCommand = selectedItem && selectedItem.command; - const isLeafNode = isNilOrEmpty(selectedItem.items); + const isLeafNode = isNotPresent(selectedItem.items); if (hasCommand && isLeafNode) selectedItem.command({ editor, range }); }; @@ -89,7 +89,7 @@ class Menu extends React.Component { const { menuIndex, setActiveMenuIndex, items } = this.props; const { selectedIndex } = this.state; const selectedItem = items[selectedIndex]; - const hasSubItems = selectedItem && !isNilOrEmpty(selectedItem.items); + const hasSubItems = selectedItem && !isNotPresent(selectedItem.items); if (hasSubItems) setActiveMenuIndex(menuIndex + 1); }; @@ -101,7 +101,7 @@ class Menu extends React.Component { return (
{items.map((item, index) => { - const isLeafNode = isNilOrEmpty(item.items); + const isLeafNode = isNotPresent(item.items); const nodeElement = ( { const { t } = useTranslation(); @@ -85,7 +85,7 @@ const UnsplashImagePicker = ({ onSubmit, unsplashApiKey }) => { {t("neetoEditor.unsplash.errorMessage")}

)} - {!error && !loading && isNilOrEmpty(images) && ( + {!error && !loading && isNotPresent(images) && (

{ onClose={handleClose} >

- {!isNilOrEmpty(tabs) && ( + {!isNotPresent(tabs) && ( {tabs.map(({ key, title }) => ( { const { t } = useTranslation(); @@ -28,7 +28,7 @@ const LinkOption = ({ editor, handleClose, handleAnimateInvalidLink }) => { if (URL_REGEXP.test(link)) { editor.chain().focus().setLink({ href: link }).run(); handleClose(); - } else if (isNilOrEmpty(link)) { + } else if (isNotPresent(link)) { editor.chain().focus().unsetLink().run(); handleClose(); } else { diff --git a/src/components/Editor/Menu/Bubble/index.jsx b/src/components/Editor/Menu/Bubble/index.jsx index 4513717f..233014b9 100644 --- a/src/components/Editor/Menu/Bubble/index.jsx +++ b/src/components/Editor/Menu/Bubble/index.jsx @@ -2,11 +2,11 @@ import React, { useState } from "react"; import { BubbleMenu as BubbleMenuTipTap } from "@tiptap/react"; import classnames from "classnames"; +import { isNotPresent } from "neetocist"; import { roundArrow } from "tippy.js"; import "tippy.js/dist/svg-arrow.css"; import { EDITOR_OPTIONS } from "common/constants"; -import { isNilOrEmpty } from "utils/common"; import Options from "./Options"; @@ -37,7 +37,7 @@ const Bubble = ({ EDITOR_OPTIONS.LINK, ]; - const noTextOptions = isNilOrEmpty( + const noTextOptions = isNotPresent( textOptions.filter(option => bubbleMenuOptions.includes(option)) ); if (!editor || (!isImageNodeSelected && noTextOptions)) { diff --git a/src/components/Editor/Menu/Fixed/LinkAddPopOver.jsx b/src/components/Editor/Menu/Fixed/LinkAddPopOver.jsx index 4228b712..47c0c514 100644 --- a/src/components/Editor/Menu/Fixed/LinkAddPopOver.jsx +++ b/src/components/Editor/Menu/Fixed/LinkAddPopOver.jsx @@ -1,5 +1,6 @@ import React, { useState, useEffect, useRef } from "react"; +import { isNotPresent } from "neetocist"; import { useOnClickOutside } from "neetocommons/react-utils"; import { Button, Input } from "neetoui"; import { createPortal } from "react-dom"; @@ -7,7 +8,6 @@ import { useTranslation } from "react-i18next"; import { validateAndFormatUrl } from "components/Editor/utils"; import { URL_REGEXP } from "src/common/constants"; -import { isNilOrEmpty } from "utils/common"; const LinkAddPopOver = ({ isAddLinkActive, setIsAddLinkActive, editor }) => { const { from, to } = editor.state.selection; @@ -23,8 +23,8 @@ const LinkAddPopOver = ({ isAddLinkActive, setIsAddLinkActive, editor }) => { const { t } = useTranslation(); - const isLinkTextPresent = !isNilOrEmpty(linkText); - const isLinlUrlPresent = !isNilOrEmpty(linkUrl); + const isLinkTextPresent = !isNotPresent(linkText); + const isLinlUrlPresent = !isNotPresent(linkUrl); const isSubmitDisabled = !isLinkTextPresent || !isLinlUrlPresent; const popoverStyle = { diff --git a/src/hooks/useEditorWarnings.js b/src/hooks/useEditorWarnings.js index 327684ea..4dc0b792 100644 --- a/src/hooks/useEditorWarnings.js +++ b/src/hooks/useEditorWarnings.js @@ -1,13 +1,13 @@ import { useEffect } from "react"; -import { isNilOrEmpty } from "utils/common"; +import { isNotPresent } from "neetocist"; const useEditorWarnings = ({ initialValue }) => { useEffect(() => { const isProduction = [process.env.RAILS_ENV, process.env.NODE_ENV].includes( "production" ); - if (!isProduction && isNilOrEmpty(initialValue)) { + if (!isProduction && isNotPresent(initialValue)) { // eslint-disable-next-line no-console console.warn( `[neeto-editor]: Empty value of "initialValue" in needtoEditor is expected to be "

" instead of "${initialValue}".`