Socket
Socket
Sign inDemoInstall

@train860/tide

Package Overview
Dependencies
75
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @train860/tide

## 介绍


Version published
Maintainers
1
Created

Readme

Source

@train860/tide

Introduction

This package provides an easy-to-use editor component for React.

Installation

If you do not want to enable syntax highlighting for code blocks, you can choose not to install highlight.js.

npm install --save @train860/tide @train860/tide-starter-kit highlight.js
# or
yarn add @train860/tide @train860/tide-starter-kit highlight.js
# or
pnpm add @train860/tide @train860/tide-starter-kit highlight.js

Usage

import React, { useState } from 'react';
import { EditorRender, useEditor } from '@train860/tide';
import { StarterKit } from '@train860/tide-starter-kit';

import '@train860/tide/dist/style.css';
import 'highlight.js/styles/default.css';

function App() {
  const editor = useEditor({
    extensions: [StarterKit],
    content: '# Hello World!',
    onChange: (doc) => console.log('onChange', doc),
  });

  // Update editor content
  // editor.setContent('Changed content');

  return <EditorRender editor={editor} />;
}

To customize the styles, you can refer to the CSS variables in @train860/tide-theme/dist/variable.less.

Configuration

useEditor Options

OptionDescriptionTypeDefault
contentThe content of the editorHTMLContent | JSONContent | JSONContent[] | null-
autofocusWhether to focus automatically'start' | 'end' | 'all' | number | boolean | nullfalse
editableWhether to allow editingbooleantrue
fullscreenWhether to enable full-screen modebooleanfalse
readOnlyEmptyViewThe view when there is no content in read-only modeReactNodenull
readOnlyShowMenuWhether to show the menu bar in read-only modebooleanfalse
menuEnableUndoRedoWhether to enable undo/redo in the menu barbooleantrue
menuEnableFullscreenWhether to enable full-screen mode in the menu barbooleantrue
onFullscreenChangeCallback function when full-screen mode changes(fullscreen: boolean) => void-
onReadyCallback function after initialization is complete(editor: TideEditor) => void-
onChangeCallback function when content changes(doc: JSONContent, editor: TideEditor) => void-

More options can be found in the interface definition of TideEditorOptions.

EditorRenderProps

PropertyDescriptionTypeDefault
classNameCustom className for the containerstring-
styleCustom style for the containerCSSProperties-
menuClassNameCustom className for the menu barstring-
menuStyleCustom style for the menu barCSSProperties-
contentClassNameCustom className for the content areastring-
contentStyleCustom style for the content areaCSSProperties-

FAQs

Last updated on 05 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc