diff --git a/docs/guides/applying-custom-formatting.md b/docs/guides/applying-custom-formatting.md index 54e0bf368..5f84291a9 100644 --- a/docs/guides/applying-custom-formatting.md +++ b/docs/guides/applying-custom-formatting.md @@ -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: { diff --git a/docs/guides/using-plugins.md b/docs/guides/using-plugins.md index 0f4322c39..7a33b84b7 100644 --- a/docs/guides/using-plugins.md +++ b/docs/guides/using-plugins.md @@ -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() } } diff --git a/docs/reference/models/transform.md b/docs/reference/models/transform.md index c806731f2..ba3048c44 100644 --- a/docs/reference/models/transform.md +++ b/docs/reference/models/transform.md @@ -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. diff --git a/examples/hovering-menu/index.js b/examples/hovering-menu/index.js index a7df79657..b08773563 100644 --- a/examples/hovering-menu/index.js +++ b/examples/hovering-menu/index.js @@ -95,7 +95,7 @@ class HoveringMenu extends React.Component { state = state .transform() - [isActive ? 'unmark' : 'mark'](type) + [isActive ? 'removeMark' : 'addMark'](type) .apply() this.setState({ state }) diff --git a/examples/rich-text/index.js b/examples/rich-text/index.js index 1b8cfbc57..f3a48e327 100644 --- a/examples/rich-text/index.js +++ b/examples/rich-text/index.js @@ -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 }) diff --git a/lib/models/state.js b/lib/models/state.js index f4a073b59..9c0143bd6 100644 --- a/lib/models/state.js +++ b/lib/models/state.js @@ -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 } diff --git a/lib/models/transform.js b/lib/models/transform.js index 7e805ee52..bb63c1d03 100644 --- a/lib/models/transform.js +++ b/lib/models/transform.js @@ -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', diff --git a/lib/models/transforms.js b/lib/models/transforms.js index ec1e988fe..9e106f263 100644 --- a/lib/models/transforms.js +++ b/lib/models/transforms.js @@ -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. diff --git a/test/transforms/fixtures/mark-at-range/across-blocks/index.js b/test/transforms/fixtures/mark-at-range/across-blocks/index.js index f0a762f29..a7033464b 100644 --- a/test/transforms/fixtures/mark-at-range/across-blocks/index.js +++ b/test/transforms/fixtures/mark-at-range/across-blocks/index.js @@ -13,6 +13,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold') + .addMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/mark-at-range/across-inlines/index.js b/test/transforms/fixtures/mark-at-range/across-inlines/index.js index f0a762f29..a7033464b 100644 --- a/test/transforms/fixtures/mark-at-range/across-inlines/index.js +++ b/test/transforms/fixtures/mark-at-range/across-inlines/index.js @@ -13,6 +13,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold') + .addMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/mark-at-range/existing-marks/index.js b/test/transforms/fixtures/mark-at-range/existing-marks/index.js index 0bccf13fc..153f10068 100644 --- a/test/transforms/fixtures/mark-at-range/existing-marks/index.js +++ b/test/transforms/fixtures/mark-at-range/existing-marks/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold') + .addMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/mark-at-range/first-character/index.js b/test/transforms/fixtures/mark-at-range/first-character/index.js index ab40cb1a7..1947337df 100644 --- a/test/transforms/fixtures/mark-at-range/first-character/index.js +++ b/test/transforms/fixtures/mark-at-range/first-character/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold') + .addMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/mark-at-range/last-character/index.js b/test/transforms/fixtures/mark-at-range/last-character/index.js index 1f3ccccf3..2c59690e1 100644 --- a/test/transforms/fixtures/mark-at-range/last-character/index.js +++ b/test/transforms/fixtures/mark-at-range/last-character/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold') + .addMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/mark-at-range/middle-character/index.js b/test/transforms/fixtures/mark-at-range/middle-character/index.js index aa750c287..a5d0aacaf 100644 --- a/test/transforms/fixtures/mark-at-range/middle-character/index.js +++ b/test/transforms/fixtures/mark-at-range/middle-character/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold') + .addMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/mark-at-range/whole-word/index.js b/test/transforms/fixtures/mark-at-range/whole-word/index.js index 761dfcede..0073dbe5a 100644 --- a/test/transforms/fixtures/mark-at-range/whole-word/index.js +++ b/test/transforms/fixtures/mark-at-range/whole-word/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold') + .addMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/mark-at-range/with-data-object/index.js b/test/transforms/fixtures/mark-at-range/with-data-object/index.js index f3f3e405e..8ffe31c85 100644 --- a/test/transforms/fixtures/mark-at-range/with-data-object/index.js +++ b/test/transforms/fixtures/mark-at-range/with-data-object/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .markAtRange(range, 'bold', { key: 'value' }) + .addMarkAtRange(range, 'bold', { key: 'value' }) .apply() } diff --git a/test/transforms/fixtures/mark-at-range/with-data/index.js b/test/transforms/fixtures/mark-at-range/with-data/index.js index 61fc70281..97cf6bdb5 100644 --- a/test/transforms/fixtures/mark-at-range/with-data/index.js +++ b/test/transforms/fixtures/mark-at-range/with-data/index.js @@ -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() } diff --git a/test/transforms/fixtures/mark/across-blocks/index.js b/test/transforms/fixtures/mark/across-blocks/index.js index 4b18c0457..394b5c49e 100644 --- a/test/transforms/fixtures/mark/across-blocks/index.js +++ b/test/transforms/fixtures/mark/across-blocks/index.js @@ -13,6 +13,6 @@ export default function (state) { focusKey: second.key, focusOffset: 2 }) - .mark('bold') + .addMark('bold') .apply() } diff --git a/test/transforms/fixtures/mark/across-inlines/index.js b/test/transforms/fixtures/mark/across-inlines/index.js index 4b18c0457..394b5c49e 100644 --- a/test/transforms/fixtures/mark/across-inlines/index.js +++ b/test/transforms/fixtures/mark/across-inlines/index.js @@ -13,6 +13,6 @@ export default function (state) { focusKey: second.key, focusOffset: 2 }) - .mark('bold') + .addMark('bold') .apply() } diff --git a/test/transforms/fixtures/mark/collapsed-selection-off-again/index.js b/test/transforms/fixtures/mark/collapsed-selection-off-again/index.js index 962dc40e3..894edd0cb 100644 --- a/test/transforms/fixtures/mark/collapsed-selection-off-again/index.js +++ b/test/transforms/fixtures/mark/collapsed-selection-off-again/index.js @@ -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() } diff --git a/test/transforms/fixtures/mark/collapsed-selection/index.js b/test/transforms/fixtures/mark/collapsed-selection/index.js index ba6c09e19..ef5cf604b 100644 --- a/test/transforms/fixtures/mark/collapsed-selection/index.js +++ b/test/transforms/fixtures/mark/collapsed-selection/index.js @@ -12,7 +12,7 @@ export default function (state) { focusKey: first.key, focusOffset: 0 }) - .mark('bold') + .addMark('bold') .insertText('a') .apply() } diff --git a/test/transforms/fixtures/mark/existing-marks/index.js b/test/transforms/fixtures/mark/existing-marks/index.js index b28f088e8..a48f3652d 100644 --- a/test/transforms/fixtures/mark/existing-marks/index.js +++ b/test/transforms/fixtures/mark/existing-marks/index.js @@ -12,6 +12,6 @@ export default function (state) { focusKey: first.key, focusOffset: 2 }) - .mark('bold') + .addMark('bold') .apply() } diff --git a/test/transforms/fixtures/mark/first-character/index.js b/test/transforms/fixtures/mark/first-character/index.js index b7d99872b..27ef0a76a 100644 --- a/test/transforms/fixtures/mark/first-character/index.js +++ b/test/transforms/fixtures/mark/first-character/index.js @@ -12,6 +12,6 @@ export default function (state) { focusKey: first.key, focusOffset: 1 }) - .mark('bold') + .addMark('bold') .apply() } diff --git a/test/transforms/fixtures/mark/last-character/index.js b/test/transforms/fixtures/mark/last-character/index.js index 240a30cee..5a32590cd 100644 --- a/test/transforms/fixtures/mark/last-character/index.js +++ b/test/transforms/fixtures/mark/last-character/index.js @@ -12,6 +12,6 @@ export default function (state) { focusKey: first.key, focusOffset: first.length }) - .mark('bold') + .addMark('bold') .apply() } diff --git a/test/transforms/fixtures/mark/middle-character/index.js b/test/transforms/fixtures/mark/middle-character/index.js index b29f9620b..536b2a882 100644 --- a/test/transforms/fixtures/mark/middle-character/index.js +++ b/test/transforms/fixtures/mark/middle-character/index.js @@ -12,6 +12,6 @@ export default function (state) { focusKey: first.key, focusOffset: 2 }) - .mark('bold') + .addMark('bold') .apply() } diff --git a/test/transforms/fixtures/mark/whole-word/index.js b/test/transforms/fixtures/mark/whole-word/index.js index 592dc8443..8c09ae039 100644 --- a/test/transforms/fixtures/mark/whole-word/index.js +++ b/test/transforms/fixtures/mark/whole-word/index.js @@ -12,6 +12,6 @@ export default function (state) { focusKey: first.key, focusOffset: first.length }) - .mark('bold') + .addMark('bold') .apply() } diff --git a/test/transforms/fixtures/mark/with-data-object/index.js b/test/transforms/fixtures/mark/with-data-object/index.js index a5c893467..490c39bb5 100644 --- a/test/transforms/fixtures/mark/with-data-object/index.js +++ b/test/transforms/fixtures/mark/with-data-object/index.js @@ -12,6 +12,6 @@ export default function (state) { focusKey: first.key, focusOffset: 1 }) - .mark('bold', { key: 'value' }) + .addMark('bold', { key: 'value' }) .apply() } diff --git a/test/transforms/fixtures/mark/with-data/index.js b/test/transforms/fixtures/mark/with-data/index.js index 7c8263e1c..438cb3853 100644 --- a/test/transforms/fixtures/mark/with-data/index.js +++ b/test/transforms/fixtures/mark/with-data/index.js @@ -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() } diff --git a/test/transforms/fixtures/unmark-at-range/across-blocks/index.js b/test/transforms/fixtures/unmark-at-range/across-blocks/index.js index 2f4164301..fdc8a9640 100644 --- a/test/transforms/fixtures/unmark-at-range/across-blocks/index.js +++ b/test/transforms/fixtures/unmark-at-range/across-blocks/index.js @@ -13,6 +13,6 @@ export default function (state) { return state .transform() - .unmarkAtRange(range, 'bold') + .removeMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/unmark-at-range/across-inlines/index.js b/test/transforms/fixtures/unmark-at-range/across-inlines/index.js index 2f4164301..fdc8a9640 100644 --- a/test/transforms/fixtures/unmark-at-range/across-inlines/index.js +++ b/test/transforms/fixtures/unmark-at-range/across-inlines/index.js @@ -13,6 +13,6 @@ export default function (state) { return state .transform() - .unmarkAtRange(range, 'bold') + .removeMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/unmark-at-range/existing-marks/index.js b/test/transforms/fixtures/unmark-at-range/existing-marks/index.js index 67686382f..7883ecda7 100644 --- a/test/transforms/fixtures/unmark-at-range/existing-marks/index.js +++ b/test/transforms/fixtures/unmark-at-range/existing-marks/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .unmarkAtRange(range, 'bold') + .removeMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/unmark-at-range/first-character/index.js b/test/transforms/fixtures/unmark-at-range/first-character/index.js index f8b39860f..918eed955 100644 --- a/test/transforms/fixtures/unmark-at-range/first-character/index.js +++ b/test/transforms/fixtures/unmark-at-range/first-character/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .unmarkAtRange(range, 'bold') + .removeMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/unmark-at-range/last-character/index.js b/test/transforms/fixtures/unmark-at-range/last-character/index.js index 7c0949b67..bfc44defd 100644 --- a/test/transforms/fixtures/unmark-at-range/last-character/index.js +++ b/test/transforms/fixtures/unmark-at-range/last-character/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .unmarkAtRange(range, 'bold') + .removeMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/unmark-at-range/middle-character/index.js b/test/transforms/fixtures/unmark-at-range/middle-character/index.js index 0c6226f55..16ad6995f 100644 --- a/test/transforms/fixtures/unmark-at-range/middle-character/index.js +++ b/test/transforms/fixtures/unmark-at-range/middle-character/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .unmarkAtRange(range, 'bold') + .removeMarkAtRange(range, 'bold') .apply() } diff --git a/test/transforms/fixtures/unmark-at-range/whole-word/index.js b/test/transforms/fixtures/unmark-at-range/whole-word/index.js index e14846e4b..8358c358f 100644 --- a/test/transforms/fixtures/unmark-at-range/whole-word/index.js +++ b/test/transforms/fixtures/unmark-at-range/whole-word/index.js @@ -12,6 +12,6 @@ export default function (state) { return state .transform() - .unmarkAtRange(range, 'bold') + .removeMarkAtRange(range, 'bold') .apply() }