@atlaskit/inline-edit
Version:
An inline edit displays a custom input component that switches between reading and editing on the same page.
33 lines (32 loc) • 966 B
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
/**
* Recursively extracts plain text content from a ReactNode.
*
* This is useful when a ReactNode needs to be represented as a string,
* e.g. for use in an `aria-label` attribute.
*/
var _getTextFromReactNode = function getTextFromReactNode(node) {
if (node == null || typeof node === 'boolean') {
return '';
}
if (typeof node === 'string') {
return node;
}
if (typeof node === 'number') {
return String(node);
}
if (Array.isArray(node)) {
return node.map(_getTextFromReactNode).join('');
}
if ( /*#__PURE__*/_react.default.isValidElement(node)) {
return _getTextFromReactNode(node.props.children);
}
return '';
};
var _default = exports.default = _getTextFromReactNode;