1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-20 22:21:20 +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: {
return state
.transform()
.mark('bold')
.addMark('bold')
.apply()
}
// When "`" is pressed, keep our existing code block logic.
@@ -160,7 +160,7 @@ class App extends React.Component {
case 66: {
return state
.transform()
.mark('bold')
.addMark('bold')
.apply()
}
case 192: {
@@ -222,7 +222,7 @@ class App extends React.Component {
const isBold = state.marks.some(mark => mark.type == 'bold')
return state
.transform()
[isBold ? 'unmark' : 'mark']('bold')
[isBold ? 'removeMark' : 'addMark']('bold')
.apply()
}
case 192: {

View File

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

View File

@@ -17,12 +17,12 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S
- [`delete`](#delete)
- [`insertFragment`](#insertfragment)
- [`insertText`](#inserttext)
- [`mark`](#mark)
- [`addMark`](#addmark)
- [`setBlock`](#setblock)
- [`setInline`](#setinline)
- [`splitBlock`](#splitblock)
- [`splitInline`](#splitinline)
- [`unmark`](#unmark)
- [`removeMark`](#removemark)
- [`unwrapBlock`](#unwrapblock)
- [`unwrapInline`](#unwrapinline)
- [`wrapBlock`](#wrapblock)
@@ -46,12 +46,12 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S
- [`deleteForwardAtRange`](#deleteforwardatrange)
- [`insertFragmentAtRange`](#insertfragmentatrange)
- [`insertTextAtRange`](#inserttextatrange)
- [`markAtRange`](#markatrange)
- [`addMarkAtRange`](#addmarkatrange)
- [`setBlockAtRange`](#setblockatrange)
- [`setInlineAtRange`](#setinlineatrange)
- [`splitBlockAtRange`](#splitblockatrange)
- [`splitInlineAtRange`](#splitinlineatrange)
- [`unmarkAtRange`](#unmarkatrange)
- [`removeMarkAtRange`](#removeMarkatrange)
- [`unwrapBlockAtRange`](#unwrapblockatrange)
- [`unwrapInlineAtRange`](#unwrapinlineatrange)
- [`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.
### `mark`
`mark(mark: Mark) => Transform`
`mark(type: String) => Transform`
### `addMark`
`addMark(mark: Mark) => 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.
@@ -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`.
### `unmark`
`unmark(mark: Mark) => Transform`
`unmark(type: String) => Transform`
### `removeMark`
`removeMark(mark: Mark) => 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.
@@ -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.
### `markAtRange`
`markAtRange(range: Selection, mark: Mark) => Transform`
`mark(range: Selection, type: String) => Transform`
### `addMarkAtRange`
`addMarkAtRange(range: Selection, mark: Mark) => 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.
@@ -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`.
### `unmarkAtRange`
`unmarkAtRange(range: Selection, mark: Mark) => Transform`
`unmark(range: Selection, type: String) => Transform`
### `removeMarkAtRange`
`removeMarkAtRange(range: Selection, mark: Mark) => 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.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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