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

54 строки
1.4 KiB

  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. * @legacyServerCallableInstance
  8. * @format
  9. * @flow
  10. * @emails oncall+draft_js
  11. */
  12. 'use strict';
  13. import type { DraftEntityMutability } from "./DraftEntityMutability";
  14. import type { DraftEntityType } from "./DraftEntityType";
  15. const Immutable = require("immutable");
  16. const {
  17. Record
  18. } = Immutable;
  19. const DraftEntityInstanceRecord = (Record({
  20. type: 'TOKEN',
  21. mutability: 'IMMUTABLE',
  22. data: Object
  23. }): any);
  24. /**
  25. * An instance of a document entity, consisting of a `type` and relevant
  26. * `data`, metadata about the entity.
  27. *
  28. * For instance, a "link" entity might provide a URI, and a "mention"
  29. * entity might provide the mentioned user's ID. These pieces of data
  30. * may be used when rendering the entity as part of a ContentBlock DOM
  31. * representation. For a link, the data would be used as an href for
  32. * the rendered anchor. For a mention, the ID could be used to retrieve
  33. * a hovercard.
  34. */
  35. class DraftEntityInstance extends DraftEntityInstanceRecord {
  36. getType(): DraftEntityType {
  37. return this.get('type');
  38. }
  39. getMutability(): DraftEntityMutability {
  40. return this.get('mutability');
  41. }
  42. getData(): Object {
  43. return this.get('data');
  44. }
  45. }
  46. module.exports = DraftEntityInstance;