Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233
  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. *
  9. * @emails oncall+draft_js
  10. */
  11. 'use strict';
  12. var Immutable = require("immutable");
  13. var Map = Immutable.Map;
  14. function modifyBlockForContentState(contentState, selectionState, operation) {
  15. var startKey = selectionState.getStartKey();
  16. var endKey = selectionState.getEndKey();
  17. var blockMap = contentState.getBlockMap();
  18. var newBlocks = blockMap.toSeq().skipUntil(function (_, k) {
  19. return k === startKey;
  20. }).takeUntil(function (_, k) {
  21. return k === endKey;
  22. }).concat(Map([[endKey, blockMap.get(endKey)]])).map(operation);
  23. return contentState.merge({
  24. blockMap: blockMap.merge(newBlocks),
  25. selectionBefore: selectionState,
  26. selectionAfter: selectionState
  27. });
  28. }
  29. module.exports = modifyBlockForContentState;