From 466f377ffa6896e5aab24277855d301b4422c657 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Sun, 24 Jul 2016 17:59:26 -0700 Subject: [PATCH] fixes for style and consistency --- docs/reference/models/transform.md | 22 +++++++++++-------- lib/models/transforms.js | 2 +- .../single-block-string-shorthand/index.js | 0 .../single-block-string-shorthand/input.yaml | 0 .../single-block-string-shorthand/output.yaml | 0 .../single-block/index.js | 0 .../single-block/input.yaml | 0 .../single-block/output.yaml | 0 8 files changed, 14 insertions(+), 10 deletions(-) rename test/transforms/fixtures/{modify-node => set-node-by-key}/single-block-string-shorthand/index.js (100%) rename test/transforms/fixtures/{modify-node => set-node-by-key}/single-block-string-shorthand/input.yaml (100%) rename test/transforms/fixtures/{modify-node => set-node-by-key}/single-block-string-shorthand/output.yaml (100%) rename test/transforms/fixtures/{modify-node => set-node-by-key}/single-block/index.js (100%) rename test/transforms/fixtures/{modify-node => set-node-by-key}/single-block/input.yaml (100%) rename test/transforms/fixtures/{modify-node => set-node-by-key}/single-block/output.yaml (100%) diff --git a/docs/reference/models/transform.md b/docs/reference/models/transform.md index c7ab29a65..dcb4c94be 100644 --- a/docs/reference/models/transform.md +++ b/docs/reference/models/transform.md @@ -13,7 +13,7 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S - [Methods](#methods) - [`apply`](#apply) -- [Document & Selection Transforms](#document-selection-transforms) +- [Current State Transforms](#current-state-transforms) - [`deleteBackward`](#deletebackward) - [`deleteForward`](#deleteforward) - [`delete`](#delete) @@ -43,6 +43,8 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S - [`moveToRangeOf`](#movetorangeof) - [`moveTo`](#moveto) - [`move{Direction}`](#movedirection) +- [Node Transforms](#node-transforms) + - [`setNodeByKey`](#setNodeByKey) - [Document Transforms](#document-transforms) - [`deleteAtRange`](#deleteatrange) - [`deleteBackwardAtRange`](#deletebackwardatrange) @@ -60,7 +62,6 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S - [`unwrapInlineAtRange`](#unwrapinlineatrange) - [`wrapBlockAtRange`](#wrapblockatrange) - [`wrapInlineAtRange`](#wrapinlineatrange) - - [`setNodeByKey`](#setNodeByKey) - [History Transforms](#history-transforms) - [`redo`](#redo) - [`undo`](#undo) @@ -76,7 +77,7 @@ Applies all of the current transform steps, returning the newly transformed [`St - `snapshot: Boolean` — override the editor's built-in logic of whether to create a new snapshot in the history, that can be reverted to later. -## Document & Selection Transforms +## Current State Transforms ### `deleteBackward` `deleteBackward(n: Number) => Transform` @@ -230,6 +231,15 @@ Move the current selection's anchor point to the start of a `node` and its focus Move the current selection to a selection with merged `properties`. The `properties` can either be a [`Selection`](./selection.md) object or a plain Javascript object of selection properties. +## Node Transforms + +### `setNodeByKey` +`setNodeByKey(key: String, properties: Object) => Transform` +`setNodeByKey(key: String, type: String) => Transform` + +Set a dictionary of `properties` on the [`Node`](./node.md) with a `key`. For convenience, you can pass a `type` string or `properties` object. + + ## Document Transforms ### `deleteBackwardAtRange` @@ -320,12 +330,6 @@ Wrap the [`Block`](./block.md) nodes in a `range` with a new [`Block`](./block.m Wrap the [`Inline`](./inline.md) nodes in a `range` with a new [`Inline`](./inline.md) node of `type`, with optional `data`. -### `setNodeByKey` -`setNodeByKey(key: String, properties: Object) => Transform` -`setNodeByKey(key: String, type: String) => Transform` - -Set the properties of the [`Node`](./node.md) having the specified `key`. - ## History Transforms diff --git a/lib/models/transforms.js b/lib/models/transforms.js index 195c5cf1c..9003ccf91 100644 --- a/lib/models/transforms.js +++ b/lib/models/transforms.js @@ -902,7 +902,7 @@ const Transforms = { }, /** - * Modify a block. + * Set `properties` on a node by `key`. * * @param {String} key * @param {Object or String} properties diff --git a/test/transforms/fixtures/modify-node/single-block-string-shorthand/index.js b/test/transforms/fixtures/set-node-by-key/single-block-string-shorthand/index.js similarity index 100% rename from test/transforms/fixtures/modify-node/single-block-string-shorthand/index.js rename to test/transforms/fixtures/set-node-by-key/single-block-string-shorthand/index.js diff --git a/test/transforms/fixtures/modify-node/single-block-string-shorthand/input.yaml b/test/transforms/fixtures/set-node-by-key/single-block-string-shorthand/input.yaml similarity index 100% rename from test/transforms/fixtures/modify-node/single-block-string-shorthand/input.yaml rename to test/transforms/fixtures/set-node-by-key/single-block-string-shorthand/input.yaml diff --git a/test/transforms/fixtures/modify-node/single-block-string-shorthand/output.yaml b/test/transforms/fixtures/set-node-by-key/single-block-string-shorthand/output.yaml similarity index 100% rename from test/transforms/fixtures/modify-node/single-block-string-shorthand/output.yaml rename to test/transforms/fixtures/set-node-by-key/single-block-string-shorthand/output.yaml diff --git a/test/transforms/fixtures/modify-node/single-block/index.js b/test/transforms/fixtures/set-node-by-key/single-block/index.js similarity index 100% rename from test/transforms/fixtures/modify-node/single-block/index.js rename to test/transforms/fixtures/set-node-by-key/single-block/index.js diff --git a/test/transforms/fixtures/modify-node/single-block/input.yaml b/test/transforms/fixtures/set-node-by-key/single-block/input.yaml similarity index 100% rename from test/transforms/fixtures/modify-node/single-block/input.yaml rename to test/transforms/fixtures/set-node-by-key/single-block/input.yaml diff --git a/test/transforms/fixtures/modify-node/single-block/output.yaml b/test/transforms/fixtures/set-node-by-key/single-block/output.yaml similarity index 100% rename from test/transforms/fixtures/modify-node/single-block/output.yaml rename to test/transforms/fixtures/set-node-by-key/single-block/output.yaml