diff --git a/docs/APIReference-APIMigration.md b/docs/APIReference-APIMigration.md index 1f92e2253f..462d020516 100644 --- a/docs/APIReference-APIMigration.md +++ b/docs/APIReference-APIMigration.md @@ -11,9 +11,9 @@ to the `ContentState` record. This API improvement unlocks the path for many benefits that will be available in v0.11: -* DraftEntity instances and storage will be immutable. -* DraftEntity will no longer be globally accessible. -* Any changes to entity data will trigger a re-render. +- DraftEntity instances and storage will be immutable. +- DraftEntity will no longer be globally accessible. +- Any changes to entity data will trigger a re-render. ## Quick Overview @@ -24,21 +24,15 @@ Here is a quick list of what has been changed and how to update your application **Old Syntax** ```js -const entityKey = Entity.create( - urlType, - 'IMMUTABLE', - {src: urlValue}, -); +const entityKey = Entity.create(urlType, 'IMMUTABLE', {src: urlValue}); ``` **New Syntax** ```js -const contentStateWithEntity = contentState.createEntity( - urlType, - 'IMMUTABLE', - {src: urlValue}, -); +const contentStateWithEntity = contentState.createEntity(urlType, 'IMMUTABLE', { + src: urlValue, +}); const entityKey = contentStateWithEntity.getLastCreatedEntityKey(); ``` @@ -65,7 +59,8 @@ const entityInstance = contentState.getEntity(entityKey); ```js const compositeDecorator = new CompositeDecorator([ { - strategy: (contentBlock, callback) => exampleFindTextRange(contentBlock, callback), + strategy: (contentBlock, callback) => + exampleFindTextRange(contentBlock, callback), component: ExampleTokenComponent, }, ]); @@ -76,11 +71,9 @@ const compositeDecorator = new CompositeDecorator([ ```js const compositeDecorator = new CompositeDecorator([ { - strategy: ( - contentBlock, - callback, - contentState - ) => exampleFindTextRange(contentBlock, callback, contentState), + strategy: (contentBlock, callback, contentState) => ( + contentBlock, callback, contentState + ), component: ExampleTokenComponent, }, ]); @@ -88,24 +81,21 @@ const compositeDecorator = new CompositeDecorator([ Note that ExampleTokenComponent will receive contentState as a prop. -Why does the 'contentState' get passed into the decorator strategy now? Because we may need it if our strategy is to find certain entities in the contentBlock: +Why does the 'contentState' get passed into the decorator strategy now? Because we may need it if our strategy is to find certain entities in the contentBlock: ```js const mutableEntityStrategy = function(contentBlock, callback, contentState) { - contentBlock.findEntityRanges( - (character) => { - const entityKey = character.getEntity(); - if (entityKey === null) { - return false; - } - // To look for certain types of entities, - // or entities with a certain mutability, - // you may need to get the entity from contentState. - // In this example we get only mutable entities. - return contentState.getEntity(entityKey).getMutability() === 'MUTABLE'; - }, - callback, - ); + contentBlock.findEntityRanges(character => { + const entityKey = character.getEntity(); + if (entityKey === null) { + return false; + } + // To look for certain types of entities, + // or entities with a certain mutability, + // you may need to get the entity from contentState. + // In this example we get only mutable entities. + return contentState.getEntity(entityKey).getMutability() === 'MUTABLE'; + }, callback); }; ``` @@ -115,34 +105,25 @@ const mutableEntityStrategy = function(contentBlock, callback, contentState) { ```js function findLinkEntities(contentBlock, callback) { - contentBlock.findEntityRanges( - (character) => { - const entityKey = character.getEntity(); - return ( - entityKey !== null && - Entity.get(entityKey).getType() === 'LINK' - ); - }, - callback, - ); -}; + contentBlock.findEntityRanges(character => { + const entityKey = character.getEntity(); + return entityKey !== null && Entity.get(entityKey).getType() === 'LINK'; + }, callback); +} ``` **New Syntax** ```js function findLinkEntities(contentBlock, callback, contentState) { - contentBlock.findEntityRanges( - (character) => { - const entityKey = character.getEntity(); - return ( - entityKey !== null && - contentState.getEntity(entityKey).getType() === 'LINK' - ); - }, - callback, - ); -}; + contentBlock.findEntityRanges(character => { + const entityKey = character.getEntity(); + return ( + entityKey !== null && + contentState.getEntity(entityKey).getType() === 'LINK' + ); + }, callback); +} ``` ## More Information diff --git a/docs/APIReference-CharacterMetadata.md b/docs/APIReference-CharacterMetadata.md index aa34f9ef25..42c40a1e61 100644 --- a/docs/APIReference-CharacterMetadata.md +++ b/docs/APIReference-CharacterMetadata.md @@ -26,7 +26,7 @@ for information on how `CharacterMetadata` is used within `ContentBlock`. ## Overview -*Static Methods* +_Static Methods_ -*Methods* +_Methods_