1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 06:31:28 +02:00

Rename mark/unmark transforms to addMark/removeMark (#113)

* Rename mark/unmark transforms to addMark/removeMark

* delete gitkeep
This commit is contained in:
Somasundaram Ayyappan
2016-07-19 00:30:30 +05:30
committed by Ian Storm Taylor
parent 3dbc29d4c8
commit 0289edfc29
35 changed files with 63 additions and 63 deletions

View File

@@ -84,7 +84,7 @@ class App extends React.Component {
case 66: { case 66: {
return state return state
.transform() .transform()
.mark('bold') .addMark('bold')
.apply() .apply()
} }
// When "`" is pressed, keep our existing code block logic. // When "`" is pressed, keep our existing code block logic.
@@ -160,7 +160,7 @@ class App extends React.Component {
case 66: { case 66: {
return state return state
.transform() .transform()
.mark('bold') .addMark('bold')
.apply() .apply()
} }
case 192: { case 192: {
@@ -222,7 +222,7 @@ class App extends React.Component {
const isBold = state.marks.some(mark => mark.type == 'bold') const isBold = state.marks.some(mark => mark.type == 'bold')
return state return state
.transform() .transform()
[isBold ? 'unmark' : 'mark']('bold') [isBold ? 'removeMark' : 'addMark']('bold')
.apply() .apply()
} }
case 192: { case 192: {

View File

@@ -52,7 +52,7 @@ class App extends React.Component {
const isBold = state.marks.some(mark => mark.type == 'bold') const isBold = state.marks.some(mark => mark.type == 'bold')
return state return state
.transform() .transform()
[isBold ? 'unmark' : 'mark']('bold') [isBold ? 'removeMark' : 'addMark']('bold')
.apply() .apply()
} }
@@ -90,7 +90,7 @@ function MarkHotkey(options) {
// Toggle the mark `type` based on whether it is active. // Toggle the mark `type` based on whether it is active.
return state return state
.transform() .transform()
[isActive ? 'unmark' : 'mark'](type) [isActive ? 'removeMark' : 'addMark'](type)
.apply() .apply()
} }
} }
@@ -248,7 +248,7 @@ function MarkHotkey(options) {
const isActive = state.marks.some(mark => mark.type == type) const isActive = state.marks.some(mark => mark.type == type)
return state return state
.transform() .transform()
[isActive ? 'unmark' : 'mark'](type) [isActive ? 'removeMark' : 'addMark'](type)
.apply() .apply()
} }
} }

View File

@@ -17,12 +17,12 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S
- [`delete`](#delete) - [`delete`](#delete)
- [`insertFragment`](#insertfragment) - [`insertFragment`](#insertfragment)
- [`insertText`](#inserttext) - [`insertText`](#inserttext)
- [`mark`](#mark) - [`addMark`](#addmark)
- [`setBlock`](#setblock) - [`setBlock`](#setblock)
- [`setInline`](#setinline) - [`setInline`](#setinline)
- [`splitBlock`](#splitblock) - [`splitBlock`](#splitblock)
- [`splitInline`](#splitinline) - [`splitInline`](#splitinline)
- [`unmark`](#unmark) - [`removeMark`](#removemark)
- [`unwrapBlock`](#unwrapblock) - [`unwrapBlock`](#unwrapblock)
- [`unwrapInline`](#unwrapinline) - [`unwrapInline`](#unwrapinline)
- [`wrapBlock`](#wrapblock) - [`wrapBlock`](#wrapblock)
@@ -46,12 +46,12 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S
- [`deleteForwardAtRange`](#deleteforwardatrange) - [`deleteForwardAtRange`](#deleteforwardatrange)
- [`insertFragmentAtRange`](#insertfragmentatrange) - [`insertFragmentAtRange`](#insertfragmentatrange)
- [`insertTextAtRange`](#inserttextatrange) - [`insertTextAtRange`](#inserttextatrange)
- [`markAtRange`](#markatrange) - [`addMarkAtRange`](#addmarkatrange)
- [`setBlockAtRange`](#setblockatrange) - [`setBlockAtRange`](#setblockatrange)
- [`setInlineAtRange`](#setinlineatrange) - [`setInlineAtRange`](#setinlineatrange)
- [`splitBlockAtRange`](#splitblockatrange) - [`splitBlockAtRange`](#splitblockatrange)
- [`splitInlineAtRange`](#splitinlineatrange) - [`splitInlineAtRange`](#splitinlineatrange)
- [`unmarkAtRange`](#unmarkatrange) - [`removeMarkAtRange`](#removeMarkatrange)
- [`unwrapBlockAtRange`](#unwrapblockatrange) - [`unwrapBlockAtRange`](#unwrapblockatrange)
- [`unwrapInlineAtRange`](#unwrapinlineatrange) - [`unwrapInlineAtRange`](#unwrapinlineatrange)
- [`wrapBlockAtRange`](#wrapblockatrange) - [`wrapBlockAtRange`](#wrapblockatrange)
@@ -90,9 +90,9 @@ Insert a `fragment` at the current selection. If the selection is expanded, it w
Insert a string of `text` at the current selection. If the selection is expanded, it will be deleted first. Insert a string of `text` at the current selection. If the selection is expanded, it will be deleted first.
### `mark` ### `addMark`
`mark(mark: Mark) => Transform` `addMark(mark: Mark) => Transform`
`mark(type: String) => Transform` `addMark(type: String) => Transform`
Add a [`mark`](./mark.md) to the characters in the current selection. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type. Add a [`mark`](./mark.md) to the characters in the current selection. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type.
@@ -118,9 +118,9 @@ Split the [`Block`](./block.md) in the current selection by `depth` levels. If t
Split the [`Inline`](./inline.md) node in the current selection by `depth` levels. If the selection is expanded, it will be deleted first. `depth` defaults to `Infinity`. Split the [`Inline`](./inline.md) node in the current selection by `depth` levels. If the selection is expanded, it will be deleted first. `depth` defaults to `Infinity`.
### `unmark` ### `removeMark`
`unmark(mark: Mark) => Transform` `removeMark(mark: Mark) => Transform`
`unmark(type: String) => Transform` `removeMark(type: String) => Transform`
Remove a [`mark`](./mark.md) from the characters in the current selection. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type. Remove a [`mark`](./mark.md) from the characters in the current selection. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type.
@@ -235,9 +235,9 @@ Insert a `fragment` at a `range`. If the selection is expanded, it will be delet
Insert a string of `text` at a `range`. If the selection is expanded, it will be deleted first. Insert a string of `text` at a `range`. If the selection is expanded, it will be deleted first.
### `markAtRange` ### `addMarkAtRange`
`markAtRange(range: Selection, mark: Mark) => Transform` `addMarkAtRange(range: Selection, mark: Mark) => Transform`
`mark(range: Selection, type: String) => Transform` `addMark(range: Selection, type: String) => Transform`
Add a [`mark`](./mark.md) to the characters in a `range`. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type. Add a [`mark`](./mark.md) to the characters in a `range`. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type.
@@ -263,9 +263,9 @@ Split the [`Block`](./block.md) in a `range` by `depth` levels. If the selection
Split the [`Inline`](./inline.md) node in a `range` by `depth` levels. If the selection is expanded, it will be deleted first. `depth` defaults to `Infinity`. Split the [`Inline`](./inline.md) node in a `range` by `depth` levels. If the selection is expanded, it will be deleted first. `depth` defaults to `Infinity`.
### `unmarkAtRange` ### `removeMarkAtRange`
`unmarkAtRange(range: Selection, mark: Mark) => Transform` `removeMarkAtRange(range: Selection, mark: Mark) => Transform`
`unmark(range: Selection, type: String) => Transform` `removeMark(range: Selection, type: String) => Transform`
Remove a [`mark`](./mark.md) from the characters in a `range`. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type. Remove a [`mark`](./mark.md) from the characters in a `range`. For convenience, you can pass a `type` string to implicitly create a [`Mark`](./mark.md) of that type.

View File

@@ -95,7 +95,7 @@ class HoveringMenu extends React.Component {
state = state state = state
.transform() .transform()
[isActive ? 'unmark' : 'mark'](type) [isActive ? 'removeMark' : 'addMark'](type)
.apply() .apply()
this.setState({ state }) this.setState({ state })

View File

@@ -133,7 +133,7 @@ class RichText extends React.Component {
state = state state = state
.transform() .transform()
[this.hasMark(mark) ? 'unmark' : 'mark'](mark) [this.hasMark(mark) ? 'removeMark' : 'addMark'](mark)
.apply() .apply()
e.preventDefault() e.preventDefault()
@@ -154,7 +154,7 @@ class RichText extends React.Component {
state = state state = state
.transform() .transform()
[isActive ? 'unmark' : 'mark'](type) [isActive ? 'removeMark' : 'addMark'](type)
.apply() .apply()
this.setState({ state }) this.setState({ state })

View File

@@ -700,7 +700,7 @@ class State extends new Record(DEFAULTS) {
* @return {State} state * @return {State} state
*/ */
mark(mark) { addMark(mark) {
let state = this let state = this
let { cursorMarks, document, selection } = state let { cursorMarks, document, selection } = state
@@ -712,7 +712,7 @@ class State extends new Record(DEFAULTS) {
return state return state
} }
document = document.markAtRange(selection, mark) document = document.addMarkAtRange(selection, mark)
state = state.merge({ document }) state = state.merge({ document })
return state return state
} }
@@ -826,7 +826,7 @@ class State extends new Record(DEFAULTS) {
* @return {State} state * @return {State} state
*/ */
unmark(mark) { removeMark(mark) {
let state = this let state = this
let { cursorMarks, document, selection } = state let { cursorMarks, document, selection } = state
@@ -838,7 +838,7 @@ class State extends new Record(DEFAULTS) {
return state return state
} }
document = document.unmarkAtRange(selection, mark) document = document.removeMarkAtRange(selection, mark)
state = state.merge({ document }) state = state.merge({ document })
return state return state
} }

View File

@@ -32,12 +32,12 @@ const DOCUMENT_TRANSFORMS = [
'deleteForwardAtRange', 'deleteForwardAtRange',
'insertFragmentAtRange', 'insertFragmentAtRange',
'insertTextAtRange', 'insertTextAtRange',
'markAtRange', 'addMarkAtRange',
'setBlockAtRange', 'setBlockAtRange',
'setInlineAtRange', 'setInlineAtRange',
'splitBlockAtRange', 'splitBlockAtRange',
'splitInlineAtRange', 'splitInlineAtRange',
'unmarkAtRange', 'removeMarkAtRange',
'unwrapBlockAtRange', 'unwrapBlockAtRange',
'unwrapInlineAtRange', 'unwrapInlineAtRange',
'wrapBlockAtRange', 'wrapBlockAtRange',
@@ -85,13 +85,13 @@ const STATE_TRANSFORMS = [
'deleteForward', 'deleteForward',
'insertFragment', 'insertFragment',
'insertText', 'insertText',
'mark', 'addMark',
'moveTo', 'moveTo',
'setBlock', 'setBlock',
'setInline', 'setInline',
'splitBlock', 'splitBlock',
'splitInline', 'splitInline',
'unmark', 'removeMark',
'unwrapBlock', 'unwrapBlock',
'unwrapInline', 'unwrapInline',
'wrapBlock', 'wrapBlock',

View File

@@ -310,7 +310,7 @@ const Transforms = {
* @return {Node} node * @return {Node} node
*/ */
markAtRange(range, mark) { addMarkAtRange(range, mark) {
let node = this let node = this
// Allow for just passing a type for convenience. // Allow for just passing a type for convenience.
@@ -565,7 +565,7 @@ const Transforms = {
* @return {Node} node * @return {Node} node
*/ */
unmarkAtRange(range, mark) { removeMarkAtRange(range, mark) {
let node = this let node = this
// Allow for just passing a type for convenience. // Allow for just passing a type for convenience.

View File

@@ -13,6 +13,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold') .addMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -13,6 +13,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold') .addMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold') .addMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold') .addMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold') .addMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold') .addMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold') .addMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold', { key: 'value' }) .addMarkAtRange(range, 'bold', { key: 'value' })
.apply() .apply()
} }

View File

@@ -14,6 +14,6 @@ export default function (state) {
return state return state
.transform() .transform()
.markAtRange(range, 'bold', Data.create({ key: 'value' })) .addMarkAtRange(range, 'bold', Data.create({ key: 'value' }))
.apply() .apply()
} }

View File

@@ -13,6 +13,6 @@ export default function (state) {
focusKey: second.key, focusKey: second.key,
focusOffset: 2 focusOffset: 2
}) })
.mark('bold') .addMark('bold')
.apply() .apply()
} }

View File

@@ -13,6 +13,6 @@ export default function (state) {
focusKey: second.key, focusKey: second.key,
focusOffset: 2 focusOffset: 2
}) })
.mark('bold') .addMark('bold')
.apply() .apply()
} }

View File

@@ -12,9 +12,9 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: 0 focusOffset: 0
}) })
.mark('bold') .addMark('bold')
.insertText('a') .insertText('a')
.unmark('bold') .removeMark('bold')
.insertText('b') .insertText('b')
.apply() .apply()
} }

View File

@@ -12,7 +12,7 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: 0 focusOffset: 0
}) })
.mark('bold') .addMark('bold')
.insertText('a') .insertText('a')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: 2 focusOffset: 2
}) })
.mark('bold') .addMark('bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: 1 focusOffset: 1
}) })
.mark('bold') .addMark('bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: first.length focusOffset: first.length
}) })
.mark('bold') .addMark('bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: 2 focusOffset: 2
}) })
.mark('bold') .addMark('bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: first.length focusOffset: first.length
}) })
.mark('bold') .addMark('bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: 1 focusOffset: 1
}) })
.mark('bold', { key: 'value' }) .addMark('bold', { key: 'value' })
.apply() .apply()
} }

View File

@@ -14,6 +14,6 @@ export default function (state) {
focusKey: first.key, focusKey: first.key,
focusOffset: 1 focusOffset: 1
}) })
.mark('bold', Data.create({ key: 'value' })) .addMark('bold', Data.create({ key: 'value' }))
.apply() .apply()
} }

View File

@@ -13,6 +13,6 @@ export default function (state) {
return state return state
.transform() .transform()
.unmarkAtRange(range, 'bold') .removeMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -13,6 +13,6 @@ export default function (state) {
return state return state
.transform() .transform()
.unmarkAtRange(range, 'bold') .removeMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.unmarkAtRange(range, 'bold') .removeMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.unmarkAtRange(range, 'bold') .removeMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.unmarkAtRange(range, 'bold') .removeMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.unmarkAtRange(range, 'bold') .removeMarkAtRange(range, 'bold')
.apply() .apply()
} }

View File

@@ -12,6 +12,6 @@ export default function (state) {
return state return state
.transform() .transform()
.unmarkAtRange(range, 'bold') .removeMarkAtRange(range, 'bold')
.apply() .apply()
} }