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

3 лет назад
1234567891011121314151617181920212223242526272829303132333435363738
  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 invariant = require("fbjs/lib/invariant");
  13. /**
  14. * Obtain the start and end positions of the range that has the
  15. * specified entity applied to it.
  16. *
  17. * Entity keys are applied only to contiguous stretches of text, so this
  18. * method searches for the first instance of the entity key and returns
  19. * the subsequent range.
  20. */
  21. function getRangesForDraftEntity(block, key) {
  22. var ranges = [];
  23. block.findEntityRanges(function (c) {
  24. return c.getEntity() === key;
  25. }, function (start, end) {
  26. ranges.push({
  27. start: start,
  28. end: end
  29. });
  30. });
  31. !!!ranges.length ? process.env.NODE_ENV !== "production" ? invariant(false, 'Entity key not found in this range.') : invariant(false) : void 0;
  32. return ranges;
  33. }
  34. module.exports = getRangesForDraftEntity;