From c75f1e4c0c90b979c55fbdd79576e502716f8d0b Mon Sep 17 00:00:00 2001 From: generatedunixname89002005287564 Date: Thu, 14 May 2020 12:28:53 -0700 Subject: [PATCH] html/shared/draft-js/model/transaction Reviewed By: BobertForever Differential Revision: D21377973 fbshipit-source-id: 868723c6151bdd996dd2127bbc90114c6e95336b --- .../transaction/addEntityToContentState.js | 29 ---------------- src/model/transaction/addEntityToEntityMap.js | 28 --------------- .../transaction/createEntityInContentState.js | 34 ------------------- .../updateEntityDataInContentState.js | 31 ----------------- 4 files changed, 122 deletions(-) delete mode 100644 src/model/transaction/addEntityToContentState.js delete mode 100644 src/model/transaction/addEntityToEntityMap.js delete mode 100644 src/model/transaction/createEntityInContentState.js delete mode 100644 src/model/transaction/updateEntityDataInContentState.js diff --git a/src/model/transaction/addEntityToContentState.js b/src/model/transaction/addEntityToContentState.js deleted file mode 100644 index 230f02c061..0000000000 --- a/src/model/transaction/addEntityToContentState.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - * @emails oncall+draft_js - */ - -'use strict'; - -import type ContentState from 'ContentState'; -import type DraftEntityInstance from 'DraftEntityInstance'; - -const addEntityToEntityMap = require('addEntityToEntityMap'); - -function addEntityToContentState( - contentState: ContentState, - instance: DraftEntityInstance, -): ContentState { - return contentState.set( - 'entityMap', - addEntityToEntityMap(contentState.getEntityMap(), instance), - ); -} - -module.exports = addEntityToContentState; diff --git a/src/model/transaction/addEntityToEntityMap.js b/src/model/transaction/addEntityToEntityMap.js deleted file mode 100644 index a13431e657..0000000000 --- a/src/model/transaction/addEntityToEntityMap.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - * @emails oncall+draft_js - */ - -'use strict'; - -import type DraftEntityInstance from 'DraftEntityInstance'; -import type {OrderedMap} from 'immutable'; -// TODO: when removing the deprecated API update this to use the EntityMap type -// instead of OrderedMap - -let key = 0; - -function addEntityToEntityMap( - entityMap: OrderedMap<*, *>, - instance: DraftEntityInstance, -): OrderedMap<*, *> { - return entityMap.set(`${++key}`, instance); -} - -module.exports = addEntityToEntityMap; diff --git a/src/model/transaction/createEntityInContentState.js b/src/model/transaction/createEntityInContentState.js deleted file mode 100644 index 77a66f03ea..0000000000 --- a/src/model/transaction/createEntityInContentState.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - * @emails oncall+draft_js - */ - -'use strict'; - -import type ContentState from 'ContentState'; -import type {DraftEntityMutability} from 'DraftEntityMutability'; -import type {DraftEntityType} from 'DraftEntityType'; - -const DraftEntityInstance = require('DraftEntityInstance'); - -const addEntityToContentState = require('addEntityToContentState'); - -function createEntityInContentState( - contentState: ContentState, - type: DraftEntityType, - mutability: DraftEntityMutability, - data?: Object, -): ContentState { - return addEntityToContentState( - contentState, - new DraftEntityInstance({type, mutability, data: data || {}}), - ); -} - -module.exports = createEntityInContentState; diff --git a/src/model/transaction/updateEntityDataInContentState.js b/src/model/transaction/updateEntityDataInContentState.js deleted file mode 100644 index b95fe65ad7..0000000000 --- a/src/model/transaction/updateEntityDataInContentState.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow strict-local - * @emails oncall+draft_js - */ - -'use strict'; - -import type ContentState from 'ContentState'; - -function updateEntityDataInContentState( - contentState: ContentState, - key: string, - data: {[key: string]: mixed, ...}, - merge: boolean, -): ContentState { - const instance = contentState.getEntity(key); - const entityData = instance.getData(); - const newData = merge ? {...entityData, ...data} : data; - - const newInstance = instance.set('data', newData); - const newEntityMap = contentState.getEntityMap().set(key, newInstance); - return contentState.set('entityMap', newEntityMap); -} - -module.exports = updateEntityDataInContentState;