1.9.1 • Published 10 months ago

tk-note v1.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Rich Text Editor

Install

npm install tk-note

Usage

import React from "react";

import { SoftyNote } from "tk-note";

function YourComponent() {
  return (
    <div>
      <SoftyNote />
    </div>
  );
}

Props

<SoftyNote />

PropTypeDefault ValueDescription
onChange(e: any) => void-Callback function triggered when content changes.
initialValueany-The initial value/content of the editor.
readOnlybooleanfalseDetermines if the editor is in read-only mode.
editorClassNamestring-CSS class to apply to the editor component.
onUpload(file: File) => void-Handles the upload of files and returns the URL of the uploaded file.
MentionComponentItem({ item }) => any-Component for rendering items in the mention component list. Receives item containing text, link, key, and avatar.
MentionablesArrTComboboxItem[]-Array containing the objects of mentionables.
mentionComponentClassNamestring-CSS class to apply to the mention component.
slashComponentClassNamestring-CSS class to apply to the slash component.
slashItemClassNamestring-CSS class to apply to each item in the slash component list.
SlashArrTSlashArr[]-Array of objects to overwrite the title, description, or image of slash list items. Each object should contain the key of the element and the properties to overwrite.(keys are below)

Example Usage

import React, { useState } from "react";
import { SoftyNote, P_KEY } from "tk-note";

function App() {
  const [content, setContent] = useState("");

  const handleChange = (e) => {
    setContent(e.target.value);
  };

  const handleUpload = (file) => {
    // Handle file upload and return the URL
  };

  const mentionables = [
    {
      text: "John Doe",
      link: "https://example.com/johndoe",
      key: "1",
      avatar: "https://example.com/avatar1.png",
    },
    // more mentionables...
  ];

  const SlashArr = [
    {
      key: P_KEY,
      text: "فقرة",
      description: "ابدأ الكتابة بنص عادي.",
    },
  ];

  const MentionItem = ({ item }) => (
    <div className="flex items-center space-x-2">
      <img className="w-8 h-8 rounded-full" src={item.avatar} alt={item.text} />
      <a className="text-blue-500 hover:underline" href={item.link}>
        {item.text}
      </a>
    </div>
  );

  return (
    <div>
      <SoftyNote
        onChange={handleChange}
        initialValue={content}
        readOnly={false}
        editorClassName="px-[96px] border border-gray-300 "
        onUpload={handleUpload}
        MentionComponentItem={MentionItem}
        MentionablesArr={mentionables}
        mentionComponentClassName=" "
        slashComponentClassName=" "
        slashItemClassName=" "
        SlashArr={SlashArr}
      />
    </div>
  );
}

export default App;

Prop Descriptions

  • onChange: This prop takes a function that is triggered whenever the content of the editor changes. The function receives an event object as its argument.
  • initialValue: This is the initial content of the editor.
  • readOnly: A boolean prop that, when set to true, makes the editor read-only. By default, it is set to false, allowing content to be edited.
  • editorClassName: This prop allows you to pass a custom CSS class name to the editor component, making it easy to apply custom styles.
  • onUpload: This prop takes a function that handles the upload of files. The function receives a file object and should return the URL of the uploaded file.By default,files will be uploaded in cloudinary and everything works well.
  • MentionComponentItem: A component used to render items in the mention component list. It receives an item containing text, key,link(optional), and avatar(optional) (MentionComponent is called when typing @ ).
  • MentionablesArr: An array containing objects for mentionables .
  • mentionComponentClassName: A CSS class name to apply to the mention component.
  • SlashArr: An array of objects to customize the title, description, or image of slash list items in the <SoftyNote /> component. Each object in the array should contain the key of the slash list item to be customized, along with the properties to be overwritten, such as title, description, and img. This prop is useful for users who need to tailor the appearance of specific slash list items to better fit their application's requirements.
  • slashComponentClassName: A CSS class name to apply to the slash component.
  • slashItemClassName: A CSS class name to apply to each item in the slash component list.

KEYS

P_KEY H1_KEY H2_KEY H3_KEY BLOCKQUOTE_KEY TABLE_KEY DISC_KEY DECIMAL_KEY TODO_KEY HR_KEY TOGGLE_KEY LINK_KEY UPLOAD_IMAGE_KEY UPLOAD_VIDEO_KEY IMAGE_KEY MEDIA_EMBED_KEY CODE_BLOCK_KEY UPLOAD_FILE_KEY EXCALIDRAW_KEY INSERT_MATH_KEY

License

MIT © thabeut

@cloudinary/react@cloudinary/url-gen@hookform/resolvers@radix-ui/react-accordion@radix-ui/react-alert-dialog@radix-ui/react-avatar@radix-ui/react-checkbox@radix-ui/react-dialog@radix-ui/react-dropdown-menu@radix-ui/react-label@radix-ui/react-popover@radix-ui/react-scroll-area@radix-ui/react-separator@radix-ui/react-slot@radix-ui/react-toolbar@radix-ui/react-tooltip@tanstack/react-query@udecode/cn@udecode/plate-alignment@udecode/plate-autoformat@udecode/plate-basic-marks@udecode/plate-block-quote@udecode/plate-break@udecode/plate-caption@udecode/plate-cloud@udecode/plate-code-block@udecode/plate-combobox@udecode/plate-comments@udecode/plate-common@udecode/plate-cursor@udecode/plate-dnd@udecode/plate-emoji@udecode/plate-font@udecode/plate-heading@udecode/plate-highlight@udecode/plate-horizontal-rule@udecode/plate-indent@udecode/plate-indent-list@udecode/plate-juice@udecode/plate-kbd@udecode/plate-layout@udecode/plate-line-height@udecode/plate-link@udecode/plate-list@udecode/plate-media@udecode/plate-mention@udecode/plate-node-id@udecode/plate-paragraph@udecode/plate-reset-node@udecode/plate-select@udecode/plate-selection@udecode/plate-serializer-csv@udecode/plate-serializer-docx@udecode/plate-serializer-md@udecode/plate-slash-command@udecode/plate-tabbable@udecode/plate-table@udecode/plate-toggle@udecode/plate-trailing-block@udecode/plate-yjs@wiris/mathtype-genericaxiosbetter-react-mathjaxclass-variance-authoritycloudinaryclsxcmdkconcurrentlydate-fnsemoji-picker-reacteslint-plugin-prettierfile-saverhtml2canvasis-urllucide-reactreactreact-contenteditablereact-dndreact-dnd-html5-backendreact-domreact-dropzonereact-google-docs-viewerreact-hook-formreact-lite-youtube-embedreact-routerreact-router-domreact-scriptsreact-social-media-embedreact-textarea-autosizereact-to-pdfreact-toastifyreact-tweetrollup-plugin-visualizerslateslate-historyslate-hyperscriptslate-reactsonnerstyled-componentstailwind-mergetailwindcss-animateuse-debounceusehooks-tsvidifyvite-plugin-css-injected-by-jsvite-plugin-dtsvite-plugin-svgrvite-tsconfig-pathsyupzustand
1.8.2

1 year ago

1.6.4

1 year ago

1.8.1

1 year ago

1.6.3

1 year ago

1.8.0

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.7.9

1 year ago

1.7.8

1 year ago

1.7.7

1 year ago

1.5.9

1 year ago

1.7.6

1 year ago

1.5.8

1 year ago

1.7.5

1 year ago

1.5.7

1 year ago

1.7.4

1 year ago

1.5.6

1 year ago

1.9.1

10 months ago

1.7.3

1 year ago

1.5.5

1 year ago

1.9.0

10 months ago

1.5.4

1 year ago

1.7.1

1 year ago

1.5.3

1 year ago

1.8.9

11 months ago

1.8.8

11 months ago

1.8.7

12 months ago

1.6.9

1 year ago

1.8.6

12 months ago

1.6.8

1 year ago

1.8.5

12 months ago

1.6.7

1 year ago

1.8.4

12 months ago

1.6.6

1 year ago

1.8.3

12 months ago

1.6.5

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.7

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.9

1 year ago

1.3.8

1 year ago

1.2.0

1 year ago

1.2.8

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.3.5

1 year ago

1.2.6

1 year ago

1.1.7

1 year ago

1.3.4

1 year ago

1.2.5

1 year ago

1.1.6

1 year ago

1.3.3

1 year ago

1.2.4

1 year ago

1.1.5

1 year ago

1.2.3

1 year ago

1.1.4

1 year ago

1.3.1

1 year ago

1.2.2

1 year ago

1.1.3

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago