Skip to content

Commit

Permalink
Added data-cy and exported isEmojiSuggestionsMenuActive
Browse files Browse the repository at this point in the history
  • Loading branch information
gaagul committed Nov 22, 2023
1 parent 3de8ffa commit 0d42279
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/components/Editor/LinkPopOver.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const LinkPopOver = ({ editor }) => {
<>
<Input
required
data-cy="neeto-editor-edit-link-text-input"
label={t("neetoEditor.common.text")}
name="textContent"
placeholder={t("neetoEditor.placeholders.enterText")}
Expand All @@ -146,6 +147,7 @@ const LinkPopOver = ({ editor }) => {
autoFocus
required
className="ne-link-popover__url-input"
data-cy="neeto-editor-edit-link-url-input"
label={t("neetoEditor.common.url")}
name="urlString"
placeholder={t("neetoEditor.placeholders.url")}
Expand All @@ -154,13 +156,15 @@ const LinkPopOver = ({ editor }) => {
/>
<div className="ne-link-popover__edit-prompt-buttons">
<Button
data-cy="neeto-editor-edit-link"
disabled={!dirty}
label={t("neetoEditor.menu.link")}
loading={isSubmitting}
size="small"
type="submit"
/>
<Button
data-cy="neeto-editor-edit-link-cancel"
label={t("neetoEditor.common.cancel")}
size="small"
style="text"
Expand All @@ -180,6 +184,7 @@ const LinkPopOver = ({ editor }) => {
{" - "}
<Button
className="ne-link-popover__option-button"
data-cy="neeto-editor-link-popover-edit"
label={t("neetoEditor.common.edit")}
size="small"
style="link"
Expand All @@ -188,6 +193,7 @@ const LinkPopOver = ({ editor }) => {
<span>|</span>
<Button
className="ne-link-popover__option-button"
data-cy="neeto-editor-link-popover-unlink"
label={t("neetoEditor.common.unlink")}
size="small"
style="link"
Expand Down
4 changes: 4 additions & 0 deletions src/components/Editor/Menu/Fixed/LinkAddPopOver.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const LinkAddPopOver = ({ isAddLinkActive, setIsAddLinkActive, editor }) => {
<Input
required
autoFocus={!isLinkTextPresent}
data-cy="neeto-editor-add-link-text-input"
label={t("neetoEditor.common.text")}
placeholder={t("neetoEditor.placeholders.enterText")}
size="small"
Expand All @@ -144,6 +145,7 @@ const LinkAddPopOver = ({ isAddLinkActive, setIsAddLinkActive, editor }) => {
required
autoFocus={isLinkTextPresent}
className="ne-link-popover__url-input"
data-cy="neeto-editor-add-link-url-input"
label={t("neetoEditor.common.url")}
size="small"
{...{ error }}
Expand All @@ -156,12 +158,14 @@ const LinkAddPopOver = ({ isAddLinkActive, setIsAddLinkActive, editor }) => {
/>
<div className="ne-link-popover__edit-prompt-buttons">
<Button
data-cy="neeto-editor-add-link"
disabled={isSubmitDisabled}
label={t("neetoEditor.common.done")}
size="small"
onClick={handleAddLink}
/>
<Button
data-cy="neeto-editor-link-popover-cancel"
label={t("neetoEditor.common.cancel")}
size="small"
style="text"
Expand Down
3 changes: 3 additions & 0 deletions src/components/Editor/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ export const transformEditorContent = content =>
?.replaceAll(IMAGE_REGEX, IMAGE_REPLACEMENT_PATTERN)
?.replaceAll(EMPTY_DIV_REGEX, "")
?.replace(TRAILING_BR_REGEX, "");

export const isEmojiSuggestionsMenuActive = () =>
!!document.querySelector(".neeto-editor-emoji-suggestion");
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
import {
isEditorOverlaysActive,
transformEditorContent,
isEmojiSuggestionsMenuActive,
} from "components/Editor/utils";
import { substituteVariables } from "components/EditorContent/utils";
import { isEditorEmpty } from "utils/common";
Expand All @@ -21,5 +23,6 @@ export {
FormikEditor,
Attachments,
isEditorOverlaysActive,
isEmojiSuggestionsMenuActive,
transformEditorContent,
};
6 changes: 5 additions & 1 deletion stories/API-Reference/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ export const EDITOR_METHODS_TABLE_ROWS = [
"isEditorOverlaysActive",
"Returns a boolean value indicating whether the editor overlays are active or not.",
],
[
"isEmojiSuggestionsMenuActive",
"Returns a boolean value indicating whether the editor emoji suggestions menu is open or not.",
],
[
"transformEditorContent",
"Modifies the editor's content by performing specific operations, such as replacing <img> tags with <figure> tags, removing empty <div> tags containing line breaks, and eliminating trailing line breaks."
]
],
];

export const EDITOR_PROPS = [
Expand Down
2 changes: 2 additions & 0 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ export function isEditorEmpty(htmlContent: string | null | undefined): boolean;

export function isEditorOverlaysActive(): boolean;

export function isEmojiSuggestionsMenuActive(): boolean;

export function transformEditorContent(content: string): string;

export function substituteVariables(
Expand Down

0 comments on commit 0d42279

Please sign in to comment.