Skip to content

Releases: Resetand/textarea-markdown-editor

v1.0.4

01 Nov 16:27
Compare
Choose a tag to compare

What's Changed

🆕 Added ordered-list-auto-correct-extension by @Resetand in #15

Will handle enter keystroke, on which will autocorrect invalid ordered list patterns
1) some text -> 1. some text
1.1) some text -> 1.1. some text

Option is disabled by default, to enable add enableOrderedListAutoCorrectExtension: true option

<TextareaMarkdown
    options={{ enableOrderedListAutoCorrectExtension: true, ... }}
    ...
/>

Full Changelog: v1.0.3...v1.0.4

v1.0.3

01 Nov 10:18
Compare
Choose a tag to compare

What's Changed

🐞 Prevent URL paste markup handling if selected text is an URL by @Resetand in #14

Full Changelog: v1.0.2...v1.0.3

v1.0.2

01 Nov 09:56
Compare
Choose a tag to compare

What's Changed

🐞 Fixed paste link which contains dashes in domain causes page freeze #12
🐞 Fixed uncorrent pasting link inside a link markup

Full Changelog: v1.0.1...v1.0.2

v1.0.1

28 May 19:48
Compare
Choose a tag to compare

What's Changed

🆕 Added the ability to trigger custom commands with arguments (eg ref.trigger('[NAME]', ...args)) checkout the example here
🆕 Extend TextareaMarkdownRef by adding bultint Cursor prop (available by using ref.current.cursor)


PS 🤖 made internal internal refactoring: added eslint, prettier and pre-commit hooks

Full Changelog: v1.0.0...v1.0.1

v1.0.0

15 May 13:40
Compare
Choose a tag to compare

What's Changed

Breaking changes ❗

  • 🆕 Commands indent, unindent, enter, link-paste is no longer supported. you can access them by using options
    • enableIndentExtension - for indent / unindent commands
    • enableLinkPasteExtension - for link-paste
    • enablePrefixWrappingExtension - for enter
  • 🤖 Cursor util significantly rewritten, checkout the built-in commands implementations to see a real world examples of using
  • 🛠 WELL_KNOWN_COMMANDS renamed to BUILT_IN_COMMANDS
  • 🛠 CommandDefine type renamed to Command

Other

  • 🔥 You can specify custom wrapping prefixes using options.customPrefixWrapping, checkout the example
  • 🆕 Supporting react 18 as peer-dependence
  • 🆕 Added able to wrap selected inside order-list, unordered-list or quote markup
  • 🆕 Added able to use this library without react via bootstrapTextareaMarkdown.
  • 🐞 Fixed link pasting require user permission to read clipboard, now it's handling event directly instead of rely on Clipboard api
  • 🐞 Fixed undo(ctrl+z) behavior doesn’t work properly
  • 🛠 Got rid of react-trigger-change dependence

Cursor util migration guide

This utility is used internally by the library, and since version 1.0.0 it has been significantly redesigned to provide a simplified API

  • Cursor.raw is deprecated. You can use string directly as a parameter for all methods
  • Cursor.getLine(lineNumber?: number): stringCursor.lineAt(lineNumber: number): Line | null
  • Cursor.getIndentSize(lineNumber?: number): number is deprecated, you can define it by line.text.match(/^\s*/)?.[0].length
  • Cursor.getCurrentPosition(lineNumber?: number): TextAreaPositionCursor.position: Position
  • Cursor.getText(): stringCursor.value: string
  • Cursor.setText(text: string): voidCursor.setValue(value: string): void
  • Cursor.getSelected(): stringCursor.selection: Selection | null
  • Cursor.spliceContent is is deprecated:
    • Cursor.replaceLine([lineNumber], null) to remove line
    • Cursor.replaceLine([lineNumber], 'new content') to replace line content
    • Cursor.insert('inserted content') to insert content at cursor position
  • Cusor.insertPrefix is deprecated
    • Cursor.replaceLine([lineNumber], 'prefix' + cursor.lineAt([lineNumber]).text) add prefix for specific line
    • Cursor.replaceCurrentLines((line, index) => '${index + 1}. ${line.text}') add prefix for all selected lines via callback
  • Cursor.wrapSelected(markup: string): void and Cursor. wrapSingleLineSelected(markup: string): void is deprecated
    • Cursor.wrap("@") to wrap selected content with @
    • Cursor.wrap(['(', ')']) to wrap selected content with prefix( and suffix )

Typing reference:

type Line = {
    text: string;
    lineNumber: number;

    /** Index of the first character of the string */
    startsAt: number;

    /** Index of the end of the line (includes the characters up to) */
    endsAt: number;
};

type Selection = {
    /** List of lines that have been selected. Line is considered selected even if it is partially selected */
    lines: Line[];
    text: string;
    selectionStart: number;
    selectionEnd: number;
    selectionDirection: 'backward' | 'forward' | 'none';
};

type Position = {
    line: Line;
    cursorAt: number;
};

Checkout the built-in commands implementations to see a real world examples of using

Full Changelog: v0.1.13...v1.0.0