UNPKG

@elastic/eui

Version:

Elastic UI Component Library

68 lines (67 loc) 5.95 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports.getDefaultEuiMarkdownParsingPlugins = exports.defaultParsingPlugins = void 0; var _remarkParseNoTrim = _interopRequireDefault(require("remark-parse-no-trim")); var _remarkEmoji = _interopRequireDefault(require("remark-emoji")); var _remarkBreaks = _interopRequireDefault(require("remark-breaks")); var _remark_prismjs = _interopRequireDefault(require("../remark/remark_prismjs")); var MarkdownTooltip = _interopRequireWildcard(require("../markdown_tooltip")); var MarkdownCheckbox = _interopRequireWildcard(require("../markdown_checkbox")); var _markdown_link_validator = require("../markdown_link_validator"); var _excluded = ["exclude"]; /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ // Importing seemingly unused types from `unified` because the definitions // are exported for two versions of TypeScript (3.4, 4.0) and implicit // imports during eui.d.ts generation default to the incorrect version (3.4). // Explicit imports here resolve the version mismatch. function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; } var DEFAULT_PARSING_PLUGINS = { emoji: [_remarkEmoji.default, { emoticon: false }], lineBreaks: [_remarkBreaks.default, {}], linkValidator: [_markdown_link_validator.euiMarkdownLinkValidator, _markdown_link_validator.DEFAULT_OPTIONS], checkbox: [MarkdownCheckbox.parser, {}], tooltip: [MarkdownTooltip.parser, {}] }; var getDefaultEuiMarkdownParsingPlugins = exports.getDefaultEuiMarkdownParsingPlugins = function getDefaultEuiMarkdownParsingPlugins() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var exclude = _ref.exclude, parsingConfig = _objectWithoutProperties(_ref, _excluded); var parsingPlugins = [[_remarkParseNoTrim.default, {}], [_remark_prismjs.default, {}]]; Object.entries(DEFAULT_PARSING_PLUGINS).forEach(function (_ref2) { var _ref3 = _slicedToArray(_ref2, 2), pluginName = _ref3[0], plugin = _ref3[1]; // Check for plugin exclusions if (!(exclude !== null && exclude !== void 0 && exclude.includes(pluginName))) { // Check for plugin configuration overrides if (pluginName in parsingConfig) { parsingPlugins.push([plugin[0], parsingConfig[pluginName]]); } else { parsingPlugins.push(plugin); } } }); return parsingPlugins; }; var defaultParsingPlugins = exports.defaultParsingPlugins = getDefaultEuiMarkdownParsingPlugins();