All Projects → wix → React Native Zss Rich Text Editor

wix / React Native Zss Rich Text Editor

Licence: other
React Native rich text editor based on ZSSRichTextEditor

Projects that are alternatives of or similar to React Native Zss Rich Text Editor

Jspaint
🎨 Classic MS Paint, REVIVED + ✨Extras
Stars: ✭ 5,972 (+690.99%)
Mutual labels:  editor
Mastering Pycharm Course
Course demos and handouts for Talk Python's Mastering PyCharm course
Stars: ✭ 700 (-7.28%)
Mutual labels:  editor
Vue Simplemde
📝 Vue SimpleMDE - use simplemde with vue.js
Stars: ✭ 730 (-3.31%)
Mutual labels:  editor
Etherealengine
C++ Game Engine and Editor
Stars: ✭ 653 (-13.51%)
Mutual labels:  editor
Sakura
SAKURA Editor (Japanese text editor for MS Windows)
Stars: ✭ 689 (-8.74%)
Mutual labels:  editor
Edizon
💡 A homebrew save management, editing tool and memory trainer for Horizon (Nintendo Switch)
Stars: ✭ 706 (-6.49%)
Mutual labels:  editor
Wp Editor.md
或许这是一个WordPress中最好,最完美的Markdown编辑器
Stars: ✭ 624 (-17.35%)
Mutual labels:  editor
Learn Vim
Learning Vim and Vimscript doesn't have to be hard. This is the guide that you're looking for.
Stars: ✭ 7,221 (+856.42%)
Mutual labels:  editor
Monaco Editor
A browser based code editor
Stars: ✭ 27,382 (+3526.75%)
Mutual labels:  editor
Stackedit.js
Add StackEdit to any website
Stars: ✭ 724 (-4.11%)
Mutual labels:  editor
Django Markdownx
Comprehensive Markdown plugin built for Django
Stars: ✭ 657 (-12.98%)
Mutual labels:  editor
Proton
Purely native and extensible rich text editor for iOS and macOS Catalyst apps
Stars: ✭ 685 (-9.27%)
Mutual labels:  editor
Nulis
Tree editor for writers
Stars: ✭ 712 (-5.7%)
Mutual labels:  editor
Oni2
Native, lightweight modal code editor
Stars: ✭ 6,704 (+787.95%)
Mutual labels:  editor
Uncolored
(Un)colored — Next generation desktop rich content editor that saves documents with themes. HTML & Markdown compatible. For Windows, OS X & Linux. — http://n457.github.io/Uncolored/
Stars: ✭ 733 (-2.91%)
Mutual labels:  editor
Wfd
flowable workflow designer base on @antv/g6
Stars: ✭ 639 (-15.36%)
Mutual labels:  editor
Electron Markdownify
📕 A minimal Markdown editor desktop app
Stars: ✭ 700 (-7.28%)
Mutual labels:  editor
React Simple Code Editor
Simple no-frills code editor with syntax highlighting
Stars: ✭ 740 (-1.99%)
Mutual labels:  editor
Suplemon
🍋 Console (CLI) text editor with multi cursor support. Suplemon replicates Sublime Text like functionality in the terminal. Try it out, give feedback, fork it!
Stars: ✭ 734 (-2.78%)
Mutual labels:  editor
Open C Book
开源书籍:《C语言编程透视》,配套视频课程《360° 剖析 Linux ELF》已上线,视频讲解更为系统和深入,欢迎订阅:https://www.cctalk.com/m/group/88089283
Stars: ✭ 715 (-5.3%)
Mutual labels:  editor

React Native Rich Text Editor

A fully functional Rich Text Editor for both Android and iOS, based off the ZSSRichTextEditor project.

Installation

npm i --save react-native-zss-rich-text-editor

On Android, add the following to the end of your android/app/build.gradle

project.afterEvaluate {
    apply from: '../../node_modules/react-native-zss-rich-text-editor/htmlCopy.gradle';
    copyEditorHtmlToAppAssets(file('../../node_modules/react-native-zss-rich-text-editor'))
}

Also, follow instructions here to add the native react-native-webview-bridge-updated dependency.

Usage

react-native-zss-rich-text-editor exports two Components and one const dictionary:

RichTextEditor

The editor component. Simply place this component in your view hierarchy to receive a fully functional Rich text Editor.

RichTextEditor takes the following optional props:

  • initialTitleHTML

    HTML that will be rendered in the title section as soon as the component loads.

  • initialContentHTML

    HTML that will be rendered in the content section on load.

  • titlePlaceholder

    Text that will be used as a placeholder when no text is present in the title section.

  • contentPlaceholder

    Text that will be used as a placeholder when no text is present in the content section.

  • customCSS

    Any custom CSS styles that you want to inject to the editor.

  • editorInitializedCallback

    A function that will be called when the editor has been initialized.

RichTextEditor also has methods that can be used on its ref to set styling at the current selection or cursor position:

  • setBold()
  • setItalic()
  • setUnderline()
  • heading1()
  • heading2()
  • heading3()
  • heading4()
  • heading5()
  • heading6()
  • setParagraph()
  • removeFormat()
  • alignLeft()
  • alignCenter()
  • alignRight()
  • alignFull()
  • insertBulletsList()
  • insertOrderedList()
  • insertLink(url, title)
  • updateLink(url, title)
  • insertImage(attributes)
  • setSubscript()
  • setSuperscript()
  • setStrikethrough()
  • setHR()
  • setIndent()
  • setOutdent()
  • setBackgroundColor(color)
  • setTextColor(color)

This method shows a dialog for setting a link title and url, that will be inserted at the current cursor location.

  • showLinkDialog(optionalTitle = '', optionalUrl = '')

To adjust content, placeholders or css, use these methods

  • setTitlePlaceholder(placeholder)
  • setContentPlaceholder(placeholder)
  • setCustomCSS(css)
  • setTitleHTML(html)
  • setContentHTML(html)

These methods are used when adding content such as images or links that will intefere with the cursor position. prepareInsert saves the current selection, and restoreSelection will replace it after the insertion is done. It is called implicitly by insertImage and insertLink so they should probably never be called directly.

  • prepareInsert()
  • restoreSelection()

To get the content or title HTML, use these asynchronous methods.

  • async getTitleHtml()
  • async getTitleText()
  • async getContentHtml()
  • async getSelectedText()

To focus or blur sections, use these methods

  • focusTitle()
  • focusContent()
  • blurTitleEditor()
  • blurContentEditor()

To know when the title or content are in focus, use the following methods.

  • setTitleFocusHandler(callbackHandler)
  • setContentFocusHandler(callbackHandler)

This method registers a function that will get called whenver the cursor position changes or a change is made to the styling of the editor at the cursor's position., The callback will be called with an array of actions that are active at the cusor position, allowing a toolbar to respond to changes.

  • registerToolbar(listener)

Example Usage:

<RichTextEditor
  ref={(r) => this.richtext = r}
  initialTitleHTML={'Title!!'}
  initialContentHTML={'Hello <b>World</b> <p>this is a new paragraph</p> <p>this is another new paragraph</p>'}
  editorInitializedCallback={() => this.onEditorInitialized()}
/>

RichTextEditor

RichTextToolbar

This is a Component that provides a toolbar for easily controlling an editor. It is designed to be used together with a RichTextEditor component.

The RichTextToolbar has one required property:

  • getEditor()

Which must provide a function that returns a ref to a RichTextEditor component.

This is because the ref is not created until after the first render, before which the toolbar is rendered. This means that any ref passed directly will inevitably be passed as undefined.

Other props supported by the RichTextToolbar component are:

  • actions

    An array of actions to be provided by this toolbar. The default actions are:

    • actions.insertImage
    • actions.setBold
    • actions.setItalic
    • actions.insertBulletsList
    • actions.insertOrderedList
    • actions.insertLink
  • onPressAddLink

  • onPressAddImage

    Functions called when the addLink or addImageactions are tapped.

  • selectedButtonStyle

  • iconTint

  • selectedIconTint

  • unselectedButtonStyle

    These provide options for styling action buttons.

  • renderAction

    Altenatively, you can provide a render function that will be used instead of the default, so you can fully control the tollbar design.

  • iconMap

    RichTextToolbar comes with default icons for the default actions it renders. To override those, or to add icons for non-default actions, provide them in a dictionary to this prop.

Example Usage:

<RichTextToolbar
	getEditor={() => this.richtext}
/>

RichTextEditor

RichTextEditor

actions

This is a set of consts of all supported actions. These will be passed in arrays to all callbacks registered with the editor using the registerToolbar() method.

{
	setTitleHtml: 'SET_TITLE_HTML',
  	setContentHtml: 'SET_CONTENT_HTML',
  	getTitleHtml: 'GET_TITLE_HTML',
  	getTitleText: 'GET_TITLE_TEXT',
 	getContentHtml: 'GET_CONTENT_HTML',
  	getSelectedText: 'GET_SELECTED_TEXT',
  	blurTitleEditor: 'BLUR_TITLE_EDITOR',
  	blurContentEditor: 'BLUR_CONTENT_EDITOR',
  	focusTitle: 'FOCUS_TITLE',
  	focusContent: 'FOCUS_CONTENT',
	
  	setBold: 'bold',
  	setItalic: 'italic',
  	setUnderline: 'underline',
  	heading1: 'h1',
  	heading2: 'h2',
  	heading3: 'h3',
  	heading4: 'h4',
  	heading5: 'h5',
  	heading6: 'h6',
  	setParagraph: 'SET_PARAGRAPH',
  	removeFormat: 'REMOVE_FORMAT',
  	alignLeft: 'justifyLeft',
  	alignCenter: 'justifyCenter',
  	alignRight: 'justifyRight',
  	alignFull: 'justifyFull',
  	insertBulletsList: 'unorderedList',
  	insertOrderedList: 'orderedList',
  	insertLink: 'INST_LINK',
  	updateLink: 'UPDATE_LINK',
  	insertImage: 'INST_IMAGE',
  	setSubscript: 'subscript',
  	setSuperscript: 'superscript',
  	setStrikethrough: 'strikeThrough',
  	setHR: 'horizontalRule',
  	setIndent: 'indent',
  	setOutdent: 'outdent',
  	setTitlePlaceholder: 'SET_TITLE_PLACEHOLDER',
  	setContentPlaceholder: 'SET_CONTENT_PLACEHOLDER',
  	setTitleFocusHandler: 'SET_TITLE_FOCUS_HANDLER',
  	setContentFocusHandler: 'SET_CONTENT_FOCUS_HANDLER',
  	prepareInsert: 'PREPARE_INSERT',
  	restoreSelection: 'RESTORE_SELECTION',
  	setCustomCSS: 'SET_CUSTOM_CSS',
  	setTextColor: 'SET_TEXT_COLOR',
  	setBackgroundColor: 'SET_BACKGROUND_COLOR',
}

Attribution

react-native-zss-rich-text-editor is a wrapper around the amazing ZSSRichTextEditor project. It also communicates with the editor using (a tiny fork) of the awesome react-native-webview-bridge project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].