Skip to content

Commit

Permalink
Fixed minor bugs and updated stories (#1030)
Browse files Browse the repository at this point in the history
* Fixed minor bugs and updated stories

* Updated text-formatting story
  • Loading branch information
gaagul authored Mar 12, 2024
1 parent f7b27fc commit 5c2e51a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";

import { NodeViewWrapper, NodeViewContent } from "@tiptap/react";
import classNames from "classnames";
import { Down } from "neetoicons";
import CopyToClipboardButton from "neetomolecules/CopyToClipboardButton";
import { Dropdown, Input } from "neetoui";
Expand All @@ -13,6 +14,7 @@ const { Menu, MenuItem } = Dropdown;

const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
const [keyword, setKeyword] = useState("");
const [isDropdownOpen, setIsDropdownOpen] = useState(false);

const { t } = useTranslation();

Expand All @@ -35,14 +37,21 @@ const CodeBlockComponent = ({ node, editor, updateAttributes }) => {
return (
<NodeViewWrapper data-cy="neeto-editor-code-block">
<pre>
<div className="neeto-editor-codeblock-options">
<div
className={classNames("neeto-editor-codeblock-options", {
"neeto-editor-codeblock-options--open": isDropdownOpen,
})}
>
<Dropdown
appendTo={() => document.body}
buttonSize="small"
buttonStyle="secondary"
icon={Down}
isOpen={isDropdownOpen}
label={node.attrs?.language || t("neetoEditor.common.auto")}
strategy="fixed"
onClick={() => setIsDropdownOpen(isOpen => !isOpen)}
onClose={() => setIsDropdownOpen(false)}
>
<Input
autoFocus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { lowlight } from "lowlight";

export const SORTED_LANGUAGE_LIST = lowlight.listLanguages().sort();
export const SORTED_LANGUAGE_LIST = [
...lowlight.listLanguages(),
"html",
].sort();
2 changes: 1 addition & 1 deletion src/components/EditorContent/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const CODE_BLOCK_REGEX =
export const VARIABLE_SPAN_REGEX =
/<span data-variable="" [^>]*data-label="([^"]+)">{{([^}]+)}}<\/span>/g;

export const LANGUAGE_LIST = lowlight.listLanguages();
export const LANGUAGE_LIST = [...lowlight.listLanguages(), "html"];
6 changes: 6 additions & 0 deletions src/styles/editor/_editor-content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@
&__input {
margin: 4px 4px;
}

&--open {
display: flex;
opacity: 1;
transform: scale(1);
}
}

&:hover {
Expand Down
2 changes: 1 addition & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
},
"localUploader": {
"dropFilesHere": "Drop your file(s) here or Browse.",
"maxFileSize": "Max. File Size: {{entity}}",
"maxFileSize": "Max. File Size: {{entity, anyCase}}",
"completed": "Completed"
}
}
Expand Down
25 changes: 25 additions & 0 deletions stories/Walkthroughs/Text-formatting.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Meta } from "@storybook/addon-docs";

<Meta
title="Walkthroughs/Text formatting"
parameters={{
layout: "padded",
viewMode: "docs",
previewTabs: {
canvas: {
hidden: true,
},
},
}}
/>

# Formatting text in rich text editor

<br />

neetoEditor offers a diverse range of features beyond basic text formatting. In addition to various formatting options
such as bold, italic, inline code, and strikethrough text, you can seamlessly integrate links and embedded content,
as well as include images, videos, and other attachments, providing a comprehensive set of tools for various types of
content and formatting.

[Learn more about formatting text](https://help.neetocal.com/articles/formatting-text-in-rich-text-editors).

0 comments on commit 5c2e51a

Please sign in to comment.