Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

DraftEditorPlaceholder.react.js 1.8 KiB

před 3 roky
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  13. var React = require("react");
  14. var cx = require("fbjs/lib/cx");
  15. /**
  16. * This component is responsible for rendering placeholder text for the
  17. * `DraftEditor` component.
  18. *
  19. * Override placeholder style via CSS.
  20. */
  21. var DraftEditorPlaceholder =
  22. /*#__PURE__*/
  23. function (_React$Component) {
  24. _inheritsLoose(DraftEditorPlaceholder, _React$Component);
  25. function DraftEditorPlaceholder() {
  26. return _React$Component.apply(this, arguments) || this;
  27. }
  28. var _proto = DraftEditorPlaceholder.prototype;
  29. _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
  30. return this.props.text !== nextProps.text || this.props.editorState.getSelection().getHasFocus() !== nextProps.editorState.getSelection().getHasFocus();
  31. };
  32. _proto.render = function render() {
  33. var hasFocus = this.props.editorState.getSelection().getHasFocus();
  34. var className = cx({
  35. 'public/DraftEditorPlaceholder/root': true,
  36. 'public/DraftEditorPlaceholder/hasFocus': hasFocus
  37. });
  38. var contentStyle = {
  39. whiteSpace: 'pre-wrap'
  40. };
  41. return React.createElement("div", {
  42. className: className
  43. }, React.createElement("div", {
  44. className: cx('public/DraftEditorPlaceholder/inner'),
  45. id: this.props.accessibilityID,
  46. style: contentStyle
  47. }, this.props.text));
  48. };
  49. return DraftEditorPlaceholder;
  50. }(React.Component);
  51. module.exports = DraftEditorPlaceholder;