Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

DraftEntityInstance.js 1.7 KiB

3 lat temu
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. *
  10. * @emails oncall+draft_js
  11. */
  12. 'use strict';
  13. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  14. var Immutable = require("immutable");
  15. var Record = Immutable.Record;
  16. var DraftEntityInstanceRecord = Record({
  17. type: 'TOKEN',
  18. mutability: 'IMMUTABLE',
  19. data: Object
  20. });
  21. /**
  22. * An instance of a document entity, consisting of a `type` and relevant
  23. * `data`, metadata about the entity.
  24. *
  25. * For instance, a "link" entity might provide a URI, and a "mention"
  26. * entity might provide the mentioned user's ID. These pieces of data
  27. * may be used when rendering the entity as part of a ContentBlock DOM
  28. * representation. For a link, the data would be used as an href for
  29. * the rendered anchor. For a mention, the ID could be used to retrieve
  30. * a hovercard.
  31. */
  32. var DraftEntityInstance =
  33. /*#__PURE__*/
  34. function (_DraftEntityInstanceR) {
  35. _inheritsLoose(DraftEntityInstance, _DraftEntityInstanceR);
  36. function DraftEntityInstance() {
  37. return _DraftEntityInstanceR.apply(this, arguments) || this;
  38. }
  39. var _proto = DraftEntityInstance.prototype;
  40. _proto.getType = function getType() {
  41. return this.get('type');
  42. };
  43. _proto.getMutability = function getMutability() {
  44. return this.get('mutability');
  45. };
  46. _proto.getData = function getData() {
  47. return this.get('data');
  48. };
  49. return DraftEntityInstance;
  50. }(DraftEntityInstanceRecord);
  51. module.exports = DraftEntityInstance;