Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 

29 Zeilen
858 B

  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow strict-local
  9. * @emails oncall+draft_js
  10. */
  11. 'use strict';
  12. import type ContentState from "./ContentState";
  13. function updateEntityDataInContentState(contentState: ContentState, key: string, data: {
  14. [key: string]: mixed,
  15. ...
  16. }, merge: boolean): ContentState {
  17. const instance = contentState.getEntity(key);
  18. const entityData = instance.getData();
  19. const newData = merge ? { ...entityData,
  20. ...data
  21. } : data;
  22. const newInstance = instance.set('data', newData);
  23. const newEntityMap = contentState.getEntityMap().set(key, newInstance);
  24. return contentState.set('entityMap', newEntityMap);
  25. }
  26. module.exports = updateEntityDataInContentState;