UNPKG

@nextcloud/vue

Version:
1 lines 26.3 kB
{"version":3,"file":"NcRichText-1e8854a1.cjs","sources":["../../src/components/NcRichText/helpers.js","../../src/components/NcRichText/NcReferenceList.vue","../../src/components/NcRichText/autolink.js","../../src/components/NcRichText/placeholder.js","../../src/components/NcRichText/NcRichText.vue"],"sourcesContent":["/**\n * Regex pattern to match links to be resolved by the link-reference provider\n *\n * @type {RegExp}\n */\nexport const URL_PATTERN = /(\\s|^)(https?:\\/\\/)((?:[-A-Z0-9+_]+\\.)+[-A-Z]+(?:\\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\\s|$)/ig\n\n/**\n * Regex pattern to identify strings as links and then making them clickable\n * Opposed to the above regex this one also matches IP addresses, which we would like to be clickable,\n * but in general resolving references for them might mostly not work,\n * as the link provider checks for local addresses and does not resolve them.\n *\n * @type {RegExp}\n */\nexport const URL_PATTERN_AUTOLINK = /(\\s|\\(|^)((https?:\\/\\/)((?:[-A-Z0-9+_]+\\.)+[-A-Z0-9]+(?::[0-9]+)?(?:\\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*))(?=\\s|\\)|$)/ig\n","<template>\n\t<div v-if=\"isVisible\" class=\"widgets--list\" :class=\"{'icon-loading': loading }\">\n\t\t<div v-for=\"reference in displayedReferences\" :key=\"reference?.openGraphObject?.id\">\n\t\t\t<NcReferenceWidget :reference=\"reference\" />\n\t\t</div>\n\t</div>\n</template>\n<script>\nimport NcReferenceWidget from './NcReferenceWidget.vue'\nimport { URL_PATTERN } from './helpers.js'\n\nimport axios from '@nextcloud/axios'\nimport { generateOcsUrl } from '@nextcloud/router'\n\nexport default {\n\tname: 'NcReferenceList',\n\tcomponents: {\n\t\tNcReferenceWidget,\n\t},\n\tprops: {\n\t\ttext: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t\treferenceData: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t\tlimit: {\n\t\t\ttype: Number,\n\t\t\tdefault: 1,\n\t\t},\n\t},\n\tdata() {\n\t\treturn {\n\t\t\treferences: null,\n\t\t\tloading: true,\n\t\t}\n\t},\n\tcomputed: {\n\t\tisVisible() {\n\t\t\treturn this.loading || this.displayedReferences\n\t\t},\n\t\tvalues() {\n\t\t\treturn this.referenceData\n\t\t\t\t? this.referenceData\n\t\t\t\t: (this.references ? Object.values(this.references) : [])\n\t\t},\n\t\tfirstReference() {\n\t\t\treturn this.values[0] ?? null\n\t\t},\n\t\tdisplayedReferences() {\n\t\t\treturn this.values.slice(0, this.limit)\n\t\t},\n\t},\n\twatch: {\n\t\ttext: 'fetch',\n\t},\n\tmounted() {\n\t\tthis.fetch()\n\t},\n\tmethods: {\n\t\tfetch() {\n\t\t\tthis.loading = true\n\t\t\tif (this.referenceData) {\n\t\t\t\tthis.loading = false\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (!(new RegExp(URL_PATTERN).exec(this.text))) {\n\t\t\t\tthis.loading = false\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tthis.resolve().then((response) => {\n\t\t\t\tthis.references = response.data.ocs.data.references\n\t\t\t\tthis.loading = false\n\t\t\t}).catch((error) => {\n\t\t\t\tconsole.error('Failed to extract references', error)\n\t\t\t\tthis.loading = false\n\t\t\t})\n\t\t},\n\t\tresolve() {\n\t\t\tconst match = (new RegExp(URL_PATTERN).exec(this.text.trim()))\n\t\t\tif (this.limit === 1 && match) {\n\t\t\t\treturn axios.get(generateOcsUrl('references/resolve', 2) + `?reference=${encodeURIComponent(match[0])}`)\n\t\t\t}\n\n\t\t\treturn axios.post(generateOcsUrl('references/extract', 2), {\n\t\t\t\ttext: this.text,\n\t\t\t\tresolve: true,\n\t\t\t\tlimit: this.limit,\n\t\t\t})\n\t\t},\n\t},\n}\n</script>\n<style lang=\"scss\" scoped>\n.widgets--list.icon-loading {\n\tmin-height: 44px;\n}\n</style>\n","import { URL_PATTERN_AUTOLINK } from './helpers.js'\n\nimport { visit, SKIP } from 'unist-util-visit'\nimport { u } from 'unist-builder'\n\nconst NcLink = {\n\tname: 'NcLink',\n\tprops: {\n\t\thref: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t},\n\trender(h) {\n\t\treturn h('a', {\n\t\t\tattrs: {\n\t\t\t\thref: this.href,\n\t\t\t\trel: 'noopener noreferrer',\n\t\t\t\ttarget: '_blank',\n\t\t\t\tclass: 'rich-text--external-link',\n\t\t\t},\n\t\t}, [this.href.trim()])\n\t},\n}\n\nexport const remarkAutolink = function({ autolink, useMarkdown }) {\n\treturn function(tree) {\n\n\t\tif (!useMarkdown || !autolink) {\n\t\t\treturn\n\t\t}\n\n\t\tvisit(tree, (node) => node.type === 'text', (node, index, parent) => {\n\t\t\tlet parsed = parseUrl(node.value)\n\t\t\tparsed = parsed.map((n) => {\n\t\t\t\tif (typeof n === 'string') {\n\t\t\t\t\treturn u('text', n)\n\t\t\t\t}\n\n\t\t\t\treturn u('link', {\n\t\t\t\t\turl: n.props.href,\n\t\t\t\t}, [u('text', n.props.href)])\n\t\t\t}).filter((x) => x)\n\n\t\t\tparent.children.splice(index, 1, ...parsed.flat())\n\t\t\treturn [SKIP, index + parsed.flat().length]\n\t\t})\n\t}\n}\n\nexport const parseUrl = (text) => {\n\tlet match = URL_PATTERN_AUTOLINK.exec(text)\n\tconst list = []\n\tlet start = 0\n\twhile (match !== null) {\n\t\tlet href = match[2]\n\t\tlet textAfter\n\t\tlet textBefore = text.substring(start, match.index + match[1].length)\n\t\tif (href[0] === ' ') {\n\t\t\ttextBefore += href[0]\n\t\t\thref = href.substring(1).trim()\n\t\t}\n\t\tconst lastChar = href[(href.length - 1)]\n\t\tif (lastChar === '.' || lastChar === ',' || lastChar === ';' || (match[0][0] === '(' && lastChar === ')')) {\n\t\t\thref = href.substring(0, href.length - 1)\n\t\t\ttextAfter = lastChar\n\t\t}\n\t\tlist.push(textBefore)\n\t\tlist.push({ component: NcLink, props: { href } })\n\t\tif (textAfter) {\n\t\t\tlist.push(textAfter)\n\t\t}\n\t\tstart = match.index + match[0].length\n\t\tmatch = URL_PATTERN_AUTOLINK.exec(text)\n\t}\n\tlist.push(text.substring(start))\n\tconst joinedText = list.map((item) => typeof item === 'string' ? item : item.props.href).join('')\n\tif (text === joinedText) {\n\t\treturn list\n\t}\n\tconsole.error('Failed to reassemble the chunked text: ' + text)\n\treturn text\n}\n","import { parseUrl } from './autolink.js'\n\nimport { visit } from 'unist-util-visit'\nimport { u } from 'unist-builder'\n\nexport const remarkPlaceholder = function() {\n\treturn function(ast) {\n\t\tvisit(ast, (node) => node.type === 'text', visitor)\n\n\t\t/**\n\t\t *\n\t\t * @param {object} node The node\n\t\t * @param {number} index The index of the node\n\t\t * @param {object} parent The parent node\n\t\t */\n\t\tfunction visitor(node, index, parent) {\n\t\t\tconst placeholders = node.value.split(/(\\{[a-z\\-_.0-9]+\\})/ig)\n\t\t\t\t.map((entry, index, list) => {\n\t\t\t\t\tconst matches = entry.match(/^\\{([a-z\\-_.0-9]+)\\}$/i)\n\t\t\t\t\tif (!matches) {\n\t\t\t\t\t\treturn u('text', entry)\n\t\t\t\t\t}\n\t\t\t\t\tconst [, component] = matches\n\t\t\t\t\treturn u('element', {\n\t\t\t\t\t\ttagName: `#${component}`,\n\t\t\t\t\t})\n\t\t\t\t})\n\n\t\t\tparent.children.splice(index, 1, ...placeholders)\n\t\t}\n\t}\n}\n\nexport const prepareTextNode = ({ h, context }, text) => {\n\tif (context.autolink) {\n\t\ttext = parseUrl(text)\n\t}\n\tif (Array.isArray(text)) {\n\t\treturn text.map((entry) => {\n\t\t\tif (typeof entry === 'string') {\n\t\t\t\treturn entry\n\t\t\t}\n\t\t\tconst { component, props } = entry\n\t\t\t// do not override class of NcLink\n\t\t\tconst componentClass = component.name === 'NcLink' ? undefined : 'rich-text--component'\n\t\t\treturn h(component, {\n\t\t\t\tprops,\n\t\t\t\tclass: componentClass,\n\t\t\t})\n\t\t})\n\t}\n\treturn text\n}\n","<!--\n - @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>\n -\n - @author Julius Härtl <jus@bitgrid.net>\n - @author Guido Krömer <mail@cacodaemon.de>\n -\n - @license GNU AGPL version 3 or any later version\n -\n - This program is free software: you can redistribute it and/or modify\n - it under the terms of the GNU Affero General Public License as\n - published by the Free Software Foundation, either version 3 of the\n - License, or (at your option) any later version.\n -\n - This program is distributed in the hope that it will be useful,\n - but WITHOUT ANY WARRANTY; without even the implied warranty of\n - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n - GNU Affero General Public License for more details.\n -\n - You should have received a copy of the GNU Affero General Public License\n - along with this program. If not, see <http://www.gnu.org/licenses/>.\n -\n -->\n<docs>\n### General description\n\nThis component displays rich text with optional autolink or [Markdown support](https://www.markdownguide.org/basic-syntax/).\n\n```vue\n<template>\n\t<div>\n\t\t<textarea v-model=\"text\" />\n\t\t<NcCheckboxRadioSwitch :checked.sync=\"autolink\" type=\"checkbox\">Autolink</NcCheckboxRadioSwitch>\n\t\t<NcCheckboxRadioSwitch :checked.sync=\"useMarkdown\" type=\"checkbox\">Use Markdown</NcCheckboxRadioSwitch>\n\n\t\t<NcRichText\n\t\t\t:class=\"{'plain-text': !useMarkdown }\"\n\t\t\t:text=\"text\" :autolink=\"autolink\" :arguments=\"args\"\n\t\t\t:use-markdown=\"useMarkdown\" />\n\t</div>\n</template>\n<script>\nexport default {\n\tdata() {\n\t\treturn {\n\t\t\ttext: `## Hello everyone 🎉\nThe file {file} was added by {username}. Visit https://nextcloud.com to check it!\n\nSome examples for markdown syntax:\n1. **bold text**\n2. _italic text_\n3. example of \\`inline code\\`\n\n> blockquote example\n`,\n\t\t\tautolink: true,\n\t\t\tuseMarkdown: true,\n\t\t\targs: {\n\t\t\t\tfile: 'MyDocument.odt',\n\t\t\t\tusername: {\n\t\t\t\t\tcomponent: 'NcUserBubble',\n\t\t\t\t\tprops: {\n\t\t\t\t\t\tdisplayName: 'Jane Doe'\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t}\n\t},\n}\n</script>\n<style lang=\"scss\">\ntextarea {\n\twidth: 100%;\n\theight: 200px;\n}\n\n.plain-text {\n\twhite-space: pre-line;\n}\n</style>\n```\n\n### Usage with NcRichContenteditable\n\nSee [NcRichContenteditable](#/Components/NcRichContenteditable) documentation for more information\n\n```vue\n<template>\n\t<div>\n\t\t<NcRichContenteditable :value.sync=\"message\"\n\t\t\t:auto-complete=\"autoComplete\"\n\t\t\t:maxlength=\"100\"\n\t\t\t:user-data=\"userData\"\n\t\t\tplaceholder=\"Try mentioning user @Test01 or inserting emoji :smile\"\n\t\t\t@submit=\"onSubmit\" />\n\n\t\t<NcCheckboxRadioSwitch :checked.sync=\"autolink\" type=\"checkbox\">Autolink</NcCheckboxRadioSwitch>\n\t\t<NcCheckboxRadioSwitch :checked.sync=\"useMarkdown\" type=\"checkbox\">Use Markdown</NcCheckboxRadioSwitch>\n\n\t\t<NcRichText :text=\"text\"\n\t\t\t:autolink=\"autolink\"\n\t\t\t:arguments=\"userMentions\"\n\t\t\t:use-markdown=\"useMarkdown\" />\n\t</div>\n</template>\n<script>\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\tmessage: '',\n\t\t\t\tautolink: true,\n\t\t\t\tuseMarkdown: true,\n\t\t\t\tuserData: {\n\t\t\t\t\tTest01: {\n\t\t\t\t\t\ticon: 'icon-user',\n\t\t\t\t\t\tid: 'Test01',\n\t\t\t\t\t\ttitle: 'Test01',\n\t\t\t\t\t\tsource: 'users',\n\t\t\t\t\t\tprimary: true,\n\t\t\t\t\t},\n\t\t\t\t\tTest02: {\n\t\t\t\t\t\ticon: 'icon-user',\n\t\t\t\t\t\tid: 'Test02',\n\t\t\t\t\t\ttitle: 'Test02',\n\t\t\t\t\t\tsource: 'users',\n\t\t\t\t\t\tstatus: {\n\t\t\t\t\t\t\tclearAt: null,\n\t\t\t\t\t\t\ticon: '🎡',\n\t\t\t\t\t\t\tmessage: 'Visiting London',\n\t\t\t\t\t\t\tstatus: 'away',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsubline: 'Visiting London',\n\t\t\t\t\t},\n\t\t\t\t\t'Test@User': {\n\t\t\t\t\t\ticon: 'icon-user',\n\t\t\t\t\t\tid: 'Test@User',\n\t\t\t\t\t\ttitle: 'Test 03',\n\t\t\t\t\t\tsource: 'users',\n\t\t\t\t\t\tstatus: {\n\t\t\t\t\t\t\tclearAt: null,\n\t\t\t\t\t\t\ticon: '🎡',\n\t\t\t\t\t\t\tmessage: 'Having space in my name',\n\t\t\t\t\t\t\tstatus: 'online',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsubline: 'Visiting London',\n\t\t\t\t\t},\n\t\t\t\t\t'Test Offline': {\n\t\t\t\t\t\ticon: 'icon-user',\n\t\t\t\t\t\tid: 'Test Offline',\n\t\t\t\t\t\ttitle: 'Test Offline',\n\t\t\t\t\t\tsource: 'users',\n\t\t\t\t\t\tstatus: {\n\t\t\t\t\t\t\tclearAt: null,\n\t\t\t\t\t\t\ticon: null,\n\t\t\t\t\t\t\tmessage: null,\n\t\t\t\t\t\t\tstatus: 'offline',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsubline: null,\n\t\t\t\t\t},\n\t\t\t\t\t'Test DND': {\n\t\t\t\t\t\ticon: 'icon-user',\n\t\t\t\t\t\tid: 'Test DND',\n\t\t\t\t\t\ttitle: 'Test DND',\n\t\t\t\t\t\tsource: 'users',\n\t\t\t\t\t\tstatus: {\n\t\t\t\t\t\t\tclearAt: null,\n\t\t\t\t\t\t\ticon: null,\n\t\t\t\t\t\t\tmessage: 'Out sick',\n\t\t\t\t\t\t\tstatus: 'dnd',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsubline: 'Out sick',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tuserMentions: {\n\t\t\t\t\t'user-1': {\n\t\t\t\t\t\tcomponent: 'NcUserBubble',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tdisplayName: 'Test01',\n\t\t\t\t\t\t\tuser: 'Test01',\n\t\t\t\t\t\t\tprimary: true,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t'user-2': {\n\t\t\t\t\t\tcomponent: 'NcUserBubble',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tdisplayName: 'Test02',\n\t\t\t\t\t\t\tuser: 'Test02',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t'user-3': {\n\t\t\t\t\t\tcomponent: 'NcUserBubble',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tdisplayName: 'Test 03',\n\t\t\t\t\t\t\tuser: 'Test@User',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t'user-4': {\n\t\t\t\t\t\tcomponent: 'NcUserBubble',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tdisplayName: 'Test Offline',\n\t\t\t\t\t\t\tuser: 'Test Offline',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t'user-5': {\n\t\t\t\t\t\tcomponent: 'NcUserBubble',\n\t\t\t\t\t\tprops: {\n\t\t\t\t\t\t\tdisplayName: 'Test DND',\n\t\t\t\t\t\t\tuser: 'Test DND',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}\n\t\t},\n\t\tcomputed: {\n\t\t\ttext() {\n\t\t\t\treturn this.message\n\t\t\t\t\t\t.replace('@Test01', '{user-1}')\n\t\t\t\t\t\t.replace('@Test02', '{user-2}')\n\t\t\t\t\t\t.replace('@Test@User', '{user-3}')\n\t\t\t\t\t\t.replace('@\"Test Offline\"', '{user-4}')\n\t\t\t\t\t\t.replace('@\"Test DND\"', '{user-5}')\n\t\t\t},\n\t\t},\n\t\tmethods: {\n\t\t\tautoComplete(search, callback) {\n\t\t\t\tcallback(Object.values(this.userData))\n\t\t\t},\n\t\t\tonSubmit() {\n\t\t\t\talert(this.message)\n\t\t\t}\n\t\t}\n\t}\n</script>\n```\n</docs>\n\n<script>\nimport NcReferenceList from './NcReferenceList.vue'\nimport { remarkAutolink } from './autolink.js'\nimport { remarkPlaceholder, prepareTextNode } from './placeholder.js'\n\nimport { unified } from 'unified'\nimport markdown from 'remark-parse'\nimport breaks from 'remark-breaks'\nimport remark2rehype from 'remark-rehype'\nimport rehype2react from 'rehype-react'\nimport rehypeExternalLinks from 'rehype-external-links'\n\nexport default {\n\tname: 'NcRichText',\n\tcomponents: {\n\t\tNcReferenceList,\n\t},\n\tprops: {\n\t\ttext: {\n\t\t\ttype: String,\n\t\t\tdefault: '',\n\t\t},\n\t\targuments: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => {\n\t\t\t\treturn {}\n\t\t\t},\n\t\t},\n\t\treferenceLimit: {\n\t\t\ttype: Number,\n\t\t\tdefault: 0,\n\t\t},\n\t\t/** Provide data upfront to avoid extra http request */\n\t\treferences: {\n\t\t\ttype: Object,\n\t\t\tdefault: null,\n\t\t},\n\t\tmarkdownCssClasses: {\n\t\t\ttype: Object,\n\t\t\tdefault: () => {\n\t\t\t\treturn {\n\t\t\t\t\ta: 'rich-text--external-link',\n\t\t\t\t\tol: 'rich-text--ordered-list',\n\t\t\t\t\tul: 'rich-text--un-ordered-list',\n\t\t\t\t\tli: 'rich-text--list-item',\n\t\t\t\t\tstrong: 'rich-text--strong',\n\t\t\t\t\tem: 'rich-text--italic',\n\t\t\t\t\th1: 'rich-text--heading rich-text--heading-1',\n\t\t\t\t\th2: 'rich-text--heading rich-text--heading-2',\n\t\t\t\t\th3: 'rich-text--heading rich-text--heading-3',\n\t\t\t\t\th4: 'rich-text--heading rich-text--heading-4',\n\t\t\t\t\th5: 'rich-text--heading rich-text--heading-5',\n\t\t\t\t\th6: 'rich-text--heading rich-text--heading-6',\n\t\t\t\t\thr: 'rich-text--hr',\n\t\t\t\t\ttable: 'rich-text--table',\n\t\t\t\t\tpre: 'rich-text--pre',\n\t\t\t\t\tcode: 'rich-text--code',\n\t\t\t\t\tblockquote: 'rich-text--blockquote',\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tuseMarkdown: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: false,\n\t\t},\n\t\tautolink: {\n\t\t\ttype: Boolean,\n\t\t\tdefault: true,\n\t\t},\n\t},\n\tmethods: {\n\t\trenderPlaintext(h) {\n\t\t\tconst context = this\n\t\t\tconst placeholders = this.text.split(/(\\{[a-z\\-_.0-9]+\\})/ig).map(function(entry, index, list) {\n\t\t\t\tconst matches = entry.match(/^\\{([a-z\\-_.0-9]+)\\}$/i)\n\t\t\t\t// just return plain string nodes as text\n\t\t\t\tif (!matches) {\n\t\t\t\t\treturn prepareTextNode({ h, context }, entry)\n\t\t\t\t}\n\t\t\t\t// return component instance if argument is an object\n\t\t\t\tconst argumentId = matches[1]\n\t\t\t\tconst argument = context.arguments[argumentId]\n\t\t\t\tif (typeof argument === 'object') {\n\t\t\t\t\tconst { component, props } = argument\n\t\t\t\t\treturn h(component, {\n\t\t\t\t\t\tprops,\n\t\t\t\t\t\tclass: 'rich-text--component',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif (argument) {\n\t\t\t\t\treturn h('span', { class: 'rich-text--fallback' }, argument)\n\t\t\t\t}\n\t\t\t\treturn entry\n\t\t\t})\n\t\t\treturn h('div', { class: 'rich-text--wrapper' }, [\n\t\t\t\th('div', {}, placeholders.flat()),\n\t\t\t\tthis.referenceLimit > 0\n\t\t\t\t\t? h('div', { class: 'rich-text--reference-widget' }, [\n\t\t\t\t\t\th(NcReferenceList, { props: { text: this.text, referenceData: this.references } }),\n\t\t\t\t\t])\n\t\t\t\t\t: null,\n\t\t\t])\n\t\t},\n\t\trenderMarkdown(h) {\n\t\t\tconst renderedMarkdown = unified()\n\t\t\t\t.use(markdown)\n\t\t\t\t.use(remarkAutolink, {\n\t\t\t\t\tautolink: this.autolink,\n\t\t\t\t\tuseMarkdown: this.useMarkdown,\n\t\t\t\t})\n\t\t\t\t.use(breaks)\n\t\t\t\t.use(remark2rehype, {\n\t\t\t\t\thandlers: {\n\t\t\t\t\t\tcomponent(toHast, node) {\n\t\t\t\t\t\t\treturn toHast(node, node.component, { value: node.value })\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\t// .use(rehypeAddClasses, this.markdownCssClasses)\n\t\t\t\t.use(remarkPlaceholder)\n\t\t\t\t.use(rehypeExternalLinks, {\n\t\t\t\t\ttarget: '_blank',\n\t\t\t\t\trel: ['noopener noreferrer'],\n\t\t\t\t})\n\t\t\t\t.use(rehype2react, {\n\t\t\t\t\tcreateElement: (tag, attrs, children) => {\n\t\t\t\t\t\t// unescape special symbol \"<\" for simple text nodes\n\t\t\t\t\t\tchildren = children?.map(child => typeof child === 'string'\n\t\t\t\t\t\t\t? child.replace(/&lt;/gmi, '<')\n\t\t\t\t\t\t\t: child,\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tif (!tag.startsWith('#')) {\n\t\t\t\t\t\t\treturn h(tag, attrs, children)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst placeholder = this.arguments[tag.slice(1)]\n\t\t\t\t\t\tif (!placeholder) {\n\t\t\t\t\t\t\treturn h('span', { ...{ attrs }, ...{ class: 'rich-text--fallback' } }, [`{${tag.slice(1)}}`])\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!placeholder.component) {\n\t\t\t\t\t\t\treturn h('span', attrs, [placeholder])\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn h(\n\t\t\t\t\t\t\tplaceholder.component,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tattrs,\n\t\t\t\t\t\t\t\tprops: placeholder.props,\n\t\t\t\t\t\t\t\tclass: 'rich-text--component',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t\tprefix: false,\n\t\t\t\t})\n\t\t\t\t.processSync(this.text\n\t\t\t\t\t// escape special symbol \"<\" to not treat text as HTML\n\t\t\t\t\t.replace(/</gmi, '&lt;')\n\t\t\t\t\t// unescape special symbol \">\" to parse blockquotes\n\t\t\t\t\t.replace(/&gt;/gmi, '>')\n\t\t\t\t)\n\t\t\t\t.result\n\n\t\t\treturn h('div', { class: 'rich-text--wrapper rich-text--wrapper-markdown' }, [\n\t\t\t\trenderedMarkdown,\n\t\t\t\tthis.referenceLimit > 0\n\t\t\t\t\t? h('div', { class: 'rich-text--reference-widget' }, [\n\t\t\t\t\t\th(NcReferenceList, { props: { text: this.text, referenceData: this.references } }),\n\t\t\t\t\t])\n\t\t\t\t\t: null,\n\t\t\t])\n\t\t},\n\t},\n\trender(h) {\n\t\treturn this.useMarkdown\n\t\t\t? this.renderMarkdown(h)\n\t\t\t: this.renderPlaintext(h)\n\t},\n}\n</script>\n<style lang=\"scss\" scoped>\n/* stylelint-disable-next-line scss/at-import-partial-extension */\n@import './richtext.scss';\n\na:not(.rich-text--component) {\n\ttext-decoration: underline;\n}\n</style>\n"],"names":["URL_PATTERN","URL_PATTERN_AUTOLINK","_sfc_main","NcReferenceWidget","_a","response","error","match","axios","generateOcsUrl","NcLink","h","remarkAutolink","autolink","useMarkdown","tree","visit","node","index","parent","parsed","parseUrl","n","u","x","SKIP","text","list","start","href","textAfter","textBefore","lastChar","joinedText","item","remarkPlaceholder","ast","visitor","placeholders","entry","matches","component","prepareTextNode","context","props","componentClass","NcReferenceList","argumentId","argument","renderedMarkdown","unified","markdown","breaks","remark2rehype","toHast","rehypeExternalLinks","rehype2react","tag","attrs","children","child","placeholder"],"mappings":"gZAKaA,EAAc,4FAUdC,EAAuB,qHCDpCC,EAAA,CACA,KAAA,kBACA,WAAA,CACA,kBAAAC,EAAA,iBACA,EACA,MAAA,CACA,KAAA,CACA,KAAA,OACA,QAAA,EACA,EACA,cAAA,CACA,KAAA,OACA,QAAA,IACA,EACA,MAAA,CACA,KAAA,OACA,QAAA,CACA,CACA,EACA,MAAA,CACA,MAAA,CACA,W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