Releases: Resetand/textarea-markdown-editor
v1.0.4
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
v1.0.2
v1.0.1
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
What's Changed
Breaking changes ❗
- 🆕 Commands
indent
,unindent
,enter
,link-paste
is no longer supported. you can access them by usingoptions
enableIndentExtension
- forindent
/unindent
commandsenableLinkPasteExtension
- forlink-paste
enablePrefixWrappingExtension
- forenter
- 🤖
Cursor
util significantly rewritten, checkout the built-in commands implementations to see a real world examples of using - 🛠
WELL_KNOWN_COMMANDS
renamed toBUILT_IN_COMMANDS
- 🛠
CommandDefine
type renamed toCommand
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
orquote
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 methodsCursor.getLine(lineNumber?: number): string
→Cursor.lineAt(lineNumber: number): Line | null
Cursor.getIndentSize(lineNumber?: number): number
is deprecated, you can define it byline.text.match(/^\s*/)?.[0].length
Cursor.getCurrentPosition(lineNumber?: number): TextAreaPosition
→Cursor.position: Position
Cursor.getText(): string
→Cursor.value: string
Cursor.setText(text: string): void
→Cursor.setValue(value: string): void
Cursor.getSelected(): string
→Cursor.selection: Selection | null
Cursor.spliceContent
is is deprecated:Cursor.replaceLine([lineNumber], null)
to remove lineCursor.replaceLine([lineNumber], 'new content')
to replace line contentCursor.insert('inserted content')
to insert content at cursor position
Cusor.insertPrefix
is deprecatedCursor.replaceLine([lineNumber], 'prefix' + cursor.lineAt([lineNumber]).text)
add prefix for specific lineCursor.replaceCurrentLines((line, index) => '${index + 1}. ${line.text}')
add prefix for all selected lines via callback
Cursor.wrapSelected(markup: string): void
andCursor. wrapSingleLineSelected(markup: string): void
is deprecatedCursor.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