@plexui/vue 0.40.1 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/Markdown/Markdown.js +10 -1
- package/dist/es/components/Markdown/Markdown.js.map +1 -1
- package/dist/es/components/Markdown/directives.js +52 -11
- package/dist/es/components/Markdown/directives.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +64 -30
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/types/components/Markdown/directives.d.ts +11 -2
- package/package.json +2 -2
|
@@ -135,7 +135,16 @@ export const Markdown = defineComponent({
|
|
|
135
135
|
const mergedRemarkPlugins = computed(() => {
|
|
136
136
|
const baseRemarkPlugins = [
|
|
137
137
|
remarkDirective,
|
|
138
|
-
|
|
138
|
+
// The directives this Markdown renders as elements: its own and the components' tags
|
|
139
|
+
[
|
|
140
|
+
markdownRemarkDirective,
|
|
141
|
+
{
|
|
142
|
+
names: [
|
|
143
|
+
...(props.directives?.map((directive) => directive.directiveName) ?? []),
|
|
144
|
+
...Object.keys(props.components ?? {}),
|
|
145
|
+
],
|
|
146
|
+
},
|
|
147
|
+
],
|
|
139
148
|
...mathPlugins.value.remarkPlugins,
|
|
140
149
|
];
|
|
141
150
|
if (props.breakNewLines) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../../../src/components/Markdown/Markdown.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAiC,MAAM,KAAK,CAAA;AAChH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,2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,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,kCAAkC,CAAC;gBACzE,GAAG,KAAK,CAAC,UAAU;aACpB,CAAA;YACD,MAAM,UAAU,GACd,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;gBAC1C,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,MAAM,CAAA;gBAC/C,OAAO,GAAG,CAAA;YACZ,CAAC,EAAE,cAAc,CAAC,IAAI,cAAc,CAAA;YAEtC,OAAO,cAAc,CAAC;gBACpB,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC3D,aAAa,EAAE,mBAAmB,CAAC,KAAK;gBACxC,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;gBACnF,UAAU;gBACV,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;gBAC5C,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,YAAY,EAAE,KAAK,CAAC,YAAY;aACjC,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import type { PluggableList } from \"unified\"\nimport remarkBreaks from \"remark-breaks\"\nimport remarkDirective from \"remark-directive\"\nimport remarkGfm from \"remark-gfm\"\nimport { Text, computed, defineComponent, h, isVNode, normalizeClass, type Component, type PropType } from \"vue\"\nimport { CodeBlock, CodeBlockBase, CodeBlockBaseCode, getSlotText } from \"../CodeBlock/CodeBlock.js\"\nimport { CollapsibleCodeBlock } from \"../CodeBlock/CollapsibleCodeBlock.js\"\nimport { TextLink } from \"../TextLink/index.js\"\nimport { markdownRemarkDirective, type MarkdownDirective } from \"./directives.js\"\nimport { renderMarkdown, sanitizeUrl, type MarkdownComponents } from \"./pipeline.js\"\nimport { defaultUrlTransform, type UrlTransform } from \"./urlTransform.js\"\nimport { useMathPlugins } from \"./useMathPlugins.js\"\nimport { useParseMarkdownPre } from \"./useParseMarkdownPre.js\"\nimport s from \"@plexui/styles/components/Markdown/Markdown.module.css\"\n\n// Vue port of packages/ui/src/components/Markdown/Markdown.tsx. React's\n// react-markdown is replaced by the same unified pipeline rendered through\n// Vue's JSX runtime (./pipeline.ts), so the elements, attributes and keys\n// match. The markdown is the text of the default slot (interpolate a string,\n// `{{ md }}`, so its newlines are kept) or, when the slot is empty, the\n// `source` prop.\n\nconst supportsLookbehind = (() => {\n try {\n new RegExp(\"(?<=a)b\")\n return true\n } catch {\n return false\n }\n})()\n\n/**\n * A component that renders one markdown element: it gets the hast `node`\n * prop, the element's attributes (`class`, `href`, ...) and its content as\n * the default slot. A tag name (`\"span\"`) works too.\n */\nexport type MarkdownComponent = Component | string\n\n// Every markdown component gets the hast element as `node`; declaring it\n// keeps it off the DOM\nconst nodeProps = { node: Object as PropType<Record<string, unknown>> }\n\nconst Pre = defineComponent({\n name: \"MarkdownPre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst InlineCode = defineComponent({\n name: \"MarkdownInlineCode\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => h(\"code\", { class: [s.InlineCode, attrs.class] }, slots.default?.())\n },\n})\n\nconst Anchor = defineComponent({\n name: \"MarkdownAnchor\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n // React DOM sanitizes the href TextLink renders; Vue does not, so it happens here\n return () =>\n h(\n TextLink,\n { as: \"a\", ...attrs, ...(typeof attrs.href === \"string\" ? { href: sanitizeUrl(attrs.href) } : null) },\n { default: () => slots.default?.() },\n )\n },\n})\n\n// Sourced from common markdown implementations\nconst TableCell = defineComponent({\n name: \"MarkdownTableCell\",\n props: nodeProps,\n setup(_props, { slots }) {\n return () =>\n h(\n \"td\",\n null,\n (slots.default?.() ?? []).map((child) =>\n // Markdown does not support <br> tags in tables without parsing raw\n // HTML (which may not be safe), so we need to manually handle them\n isVNode(child) && child.type === Text && child.children === \"<br>\" ? h(\"br\") : child,\n ),\n )\n },\n})\n\nconst COMMON_COMPONENTS: MarkdownComponents = {\n code: InlineCode,\n pre: Pre,\n a: Anchor,\n td: TableCell,\n}\n\nconst NonCopyableCodeBlock = defineComponent({\n name: \"MarkdownNonCopyableCodeBlock\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlockBase, { class: attrs.class }, { default: () => [h(CodeBlockBaseCode, { language, code })] })\n }\n },\n})\n\nconst NON_COPYABLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: NonCopyableCodeBlock,\n}\n\nconst CollapsiblePre = defineComponent({\n name: \"MarkdownCollapsiblePre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CollapsibleCodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst COLLAPSIBLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: CollapsiblePre,\n}\n\n/** Renders markdown: GFM, directives, optional LaTeX, Plex code blocks and links. */\nexport const Markdown = defineComponent({\n name: \"Markdown\",\n // Like React, only `class` reaches the DOM (on the wrapping div)\n inheritAttrs: false,\n props: {\n /** Markdown source, used when the default slot is empty */\n source: String,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n directives: Array as PropType<MarkdownDirective<any>[]>,\n /** Determines if remark-math plugins should be loaded for rendering LaTeX. @default false */\n includeMath: { type: Boolean, default: false },\n /** Determines whether single newlines should insert <br> tags. @default false */\n breakNewLines: { type: Boolean, default: false },\n /** Tag name → component overrides, applied over the built-in ones */\n components: Object as PropType<Record<string, MarkdownComponent>>,\n remarkPlugins: Array as PropType<PluggableList>,\n rehypePlugins: Array as PropType<PluggableList>,\n allowedElements: Array as PropType<ReadonlyArray<string>>,\n disallowedElements: Array as PropType<ReadonlyArray<string>>,\n /** Rewrites URLs; the default drops unsafe protocols (`javascript:`), keeps `tel:` and `sms:` */\n urlTransform: { type: Function as PropType<UrlTransform | null>, default: defaultUrlTransform },\n skipHtml: { type: Boolean, default: false },\n /** @default true */\n copyableCodeBlocks: { type: Boolean, default: true },\n /** Determines if code blocks should use the collapsible view with \"View Code\" button. @default true */\n collapsibleCodeBlocks: { type: Boolean, default: true },\n },\n setup(props, { slots, attrs }) {\n const mathPlugins = useMathPlugins(() => props.includeMath)\n\n const mergedRemarkPlugins = computed(() => {\n const baseRemarkPlugins: PluggableList = [\n remarkDirective,\n markdownRemarkDirective,\n ...mathPlugins.value.remarkPlugins,\n ]\n\n if (props.breakNewLines) {\n baseRemarkPlugins.push(remarkBreaks)\n }\n\n // remark-gfm requires lookbehind support, which will throw in <= Safari 16.4\n // with no easily available polyfill.\n if (supportsLookbehind) {\n // Do not treat single tilde as strikethrough to allow for more\n // conversational use cases such as \"~$20-$30\"\n baseRemarkPlugins.push([remarkGfm, { singleTilde: false }])\n }\n\n return [...baseRemarkPlugins, ...(props.remarkPlugins ?? [])]\n })\n\n return () => {\n const slotText = getSlotText(slots.default?.())\n const source = slotText !== \"\" ? slotText : (props.source ?? \"\")\n\n const baseComponents: MarkdownComponents = {\n ...COMMON_COMPONENTS,\n ...(props.collapsibleCodeBlocks ? COLLAPSIBLE_CODE_BLOCK_COMPONENTS : null),\n ...(props.copyableCodeBlocks ? null : NON_COPYABLE_CODE_BLOCK_COMPONENTS),\n ...props.components,\n }\n const components =\n props.directives?.reduce((acc, directive) => {\n acc[directive.directiveName] = directive.render\n return acc\n }, baseComponents) ?? baseComponents\n\n return renderMarkdown({\n children: source,\n className: normalizeClass([s.MarkdownContent, attrs.class]),\n remarkPlugins: mergedRemarkPlugins.value,\n rehypePlugins: [...(props.rehypePlugins ?? []), ...mathPlugins.value.rehypePlugins],\n components,\n allowedElements: props.allowedElements,\n disallowedElements: props.disallowedElements,\n skipHtml: props.skipHtml,\n urlTransform: props.urlTransform,\n })\n }\n },\n})\n\nexport type MarkdownProps = InstanceType<typeof Markdown>[\"$props\"]\n"]}
|
|
1
|
+
{"version":3,"file":"Markdown.js","sourceRoot":"","sources":["../../../../src/components/Markdown/Markdown.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAC9C,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,cAAc,EAAiC,MAAM,KAAK,CAAA;AAChH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACpG,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAA0B,MAAM,iBAAiB,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,WAAW,EAA2B,MAAM,eAAe,CAAA;AACpF,OAAO,EAAE,mBAAmB,EAAqB,MAAM,mBAAmB,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAEtE,wEAAwE;AACxE,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,iBAAiB;AAEjB,MAAM,kBAAkB,GAA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AG,CAAA;YACZ,CAAC,EAAE,cAAc,CAAC,IAAI,cAAc,CAAA;YAEtC,OAAO,cAAc,CAAC;gBACpB,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC3D,aAAa,EAAE,mBAAmB,CAAC,KAAK;gBACxC,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC;gBACnF,UAAU;gBACV,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;gBAC5C,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,YAAY,EAAE,KAAK,CAAC,YAAY;aACjC,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import type { PluggableList } from \"unified\"\nimport remarkBreaks from \"remark-breaks\"\nimport remarkDirective from \"remark-directive\"\nimport remarkGfm from \"remark-gfm\"\nimport { Text, computed, defineComponent, h, isVNode, normalizeClass, type Component, type PropType } from \"vue\"\nimport { CodeBlock, CodeBlockBase, CodeBlockBaseCode, getSlotText } from \"../CodeBlock/CodeBlock.js\"\nimport { CollapsibleCodeBlock } from \"../CodeBlock/CollapsibleCodeBlock.js\"\nimport { TextLink } from \"../TextLink/index.js\"\nimport { markdownRemarkDirective, type MarkdownDirective } from \"./directives.js\"\nimport { renderMarkdown, sanitizeUrl, type MarkdownComponents } from \"./pipeline.js\"\nimport { defaultUrlTransform, type UrlTransform } from \"./urlTransform.js\"\nimport { useMathPlugins } from \"./useMathPlugins.js\"\nimport { useParseMarkdownPre } from \"./useParseMarkdownPre.js\"\nimport s from \"@plexui/styles/components/Markdown/Markdown.module.css\"\n\n// Vue port of packages/ui/src/components/Markdown/Markdown.tsx. React's\n// react-markdown is replaced by the same unified pipeline rendered through\n// Vue's JSX runtime (./pipeline.ts), so the elements, attributes and keys\n// match. The markdown is the text of the default slot (interpolate a string,\n// `{{ md }}`, so its newlines are kept) or, when the slot is empty, the\n// `source` prop.\n\nconst supportsLookbehind = (() => {\n try {\n new RegExp(\"(?<=a)b\")\n return true\n } catch {\n return false\n }\n})()\n\n/**\n * A component that renders one markdown element: it gets the hast `node`\n * prop, the element's attributes (`class`, `href`, ...) and its content as\n * the default slot. A tag name (`\"span\"`) works too.\n */\nexport type MarkdownComponent = Component | string\n\n// Every markdown component gets the hast element as `node`; declaring it\n// keeps it off the DOM\nconst nodeProps = { node: Object as PropType<Record<string, unknown>> }\n\nconst Pre = defineComponent({\n name: \"MarkdownPre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst InlineCode = defineComponent({\n name: \"MarkdownInlineCode\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => h(\"code\", { class: [s.InlineCode, attrs.class] }, slots.default?.())\n },\n})\n\nconst Anchor = defineComponent({\n name: \"MarkdownAnchor\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n // React DOM sanitizes the href TextLink renders; Vue does not, so it happens here\n return () =>\n h(\n TextLink,\n { as: \"a\", ...attrs, ...(typeof attrs.href === \"string\" ? { href: sanitizeUrl(attrs.href) } : null) },\n { default: () => slots.default?.() },\n )\n },\n})\n\n// Sourced from common markdown implementations\nconst TableCell = defineComponent({\n name: \"MarkdownTableCell\",\n props: nodeProps,\n setup(_props, { slots }) {\n return () =>\n h(\n \"td\",\n null,\n (slots.default?.() ?? []).map((child) =>\n // Markdown does not support <br> tags in tables without parsing raw\n // HTML (which may not be safe), so we need to manually handle them\n isVNode(child) && child.type === Text && child.children === \"<br>\" ? h(\"br\") : child,\n ),\n )\n },\n})\n\nconst COMMON_COMPONENTS: MarkdownComponents = {\n code: InlineCode,\n pre: Pre,\n a: Anchor,\n td: TableCell,\n}\n\nconst NonCopyableCodeBlock = defineComponent({\n name: \"MarkdownNonCopyableCodeBlock\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CodeBlockBase, { class: attrs.class }, { default: () => [h(CodeBlockBaseCode, { language, code })] })\n }\n },\n})\n\nconst NON_COPYABLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: NonCopyableCodeBlock,\n}\n\nconst CollapsiblePre = defineComponent({\n name: \"MarkdownCollapsiblePre\",\n inheritAttrs: false,\n props: nodeProps,\n setup(_props, { slots, attrs }) {\n return () => {\n const { code, language } = useParseMarkdownPre(slots.default?.())\n return h(CollapsibleCodeBlock, { language, class: attrs.class, code })\n }\n },\n})\n\nconst COLLAPSIBLE_CODE_BLOCK_COMPONENTS: MarkdownComponents = {\n pre: CollapsiblePre,\n}\n\n/** Renders markdown: GFM, directives, optional LaTeX, Plex code blocks and links. */\nexport const Markdown = defineComponent({\n name: \"Markdown\",\n // Like React, only `class` reaches the DOM (on the wrapping div)\n inheritAttrs: false,\n props: {\n /** Markdown source, used when the default slot is empty */\n source: String,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n directives: Array as PropType<MarkdownDirective<any>[]>,\n /** Determines if remark-math plugins should be loaded for rendering LaTeX. @default false */\n includeMath: { type: Boolean, default: false },\n /** Determines whether single newlines should insert <br> tags. @default false */\n breakNewLines: { type: Boolean, default: false },\n /** Tag name → component overrides, applied over the built-in ones */\n components: Object as PropType<Record<string, MarkdownComponent>>,\n remarkPlugins: Array as PropType<PluggableList>,\n rehypePlugins: Array as PropType<PluggableList>,\n allowedElements: Array as PropType<ReadonlyArray<string>>,\n disallowedElements: Array as PropType<ReadonlyArray<string>>,\n /** Rewrites URLs; the default drops unsafe protocols (`javascript:`), keeps `tel:` and `sms:` */\n urlTransform: { type: Function as PropType<UrlTransform | null>, default: defaultUrlTransform },\n skipHtml: { type: Boolean, default: false },\n /** @default true */\n copyableCodeBlocks: { type: Boolean, default: true },\n /** Determines if code blocks should use the collapsible view with \"View Code\" button. @default true */\n collapsibleCodeBlocks: { type: Boolean, default: true },\n },\n setup(props, { slots, attrs }) {\n const mathPlugins = useMathPlugins(() => props.includeMath)\n\n const mergedRemarkPlugins = computed(() => {\n const baseRemarkPlugins: PluggableList = [\n remarkDirective,\n // The directives this Markdown renders as elements: its own and the components' tags\n [\n markdownRemarkDirective,\n {\n names: [\n ...(props.directives?.map((directive) => directive.directiveName) ?? []),\n ...Object.keys(props.components ?? {}),\n ],\n },\n ],\n ...mathPlugins.value.remarkPlugins,\n ]\n\n if (props.breakNewLines) {\n baseRemarkPlugins.push(remarkBreaks)\n }\n\n // remark-gfm requires lookbehind support, which will throw in <= Safari 16.4\n // with no easily available polyfill.\n if (supportsLookbehind) {\n // Do not treat single tilde as strikethrough to allow for more\n // conversational use cases such as \"~$20-$30\"\n baseRemarkPlugins.push([remarkGfm, { singleTilde: false }])\n }\n\n return [...baseRemarkPlugins, ...(props.remarkPlugins ?? [])]\n })\n\n return () => {\n const slotText = getSlotText(slots.default?.())\n const source = slotText !== \"\" ? slotText : (props.source ?? \"\")\n\n const baseComponents: MarkdownComponents = {\n ...COMMON_COMPONENTS,\n ...(props.collapsibleCodeBlocks ? COLLAPSIBLE_CODE_BLOCK_COMPONENTS : null),\n ...(props.copyableCodeBlocks ? null : NON_COPYABLE_CODE_BLOCK_COMPONENTS),\n ...props.components,\n }\n const components =\n props.directives?.reduce((acc, directive) => {\n acc[directive.directiveName] = directive.render\n return acc\n }, baseComponents) ?? baseComponents\n\n return renderMarkdown({\n children: source,\n className: normalizeClass([s.MarkdownContent, attrs.class]),\n remarkPlugins: mergedRemarkPlugins.value,\n rehypePlugins: [...(props.rehypePlugins ?? []), ...mathPlugins.value.rehypePlugins],\n components,\n allowedElements: props.allowedElements,\n disallowedElements: props.disallowedElements,\n skipHtml: props.skipHtml,\n urlTransform: props.urlTransform,\n })\n }\n },\n})\n\nexport type MarkdownProps = InstanceType<typeof Markdown>[\"$props\"]\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Comment, Text, isVNode } from "vue";
|
|
2
|
-
import { visit } from "unist-util-visit";
|
|
2
|
+
import { SKIP, visit } from "unist-util-visit";
|
|
3
3
|
import { createId } from "../../lib/ids.js";
|
|
4
4
|
import { decodeBase64, encodeBase64 } from "../../lib/safeBase64.js";
|
|
5
5
|
/**
|
|
@@ -43,17 +43,58 @@ export function createMarkdownDirective({ render, name, mode, }) {
|
|
|
43
43
|
directive.render = renderDirective;
|
|
44
44
|
return directive;
|
|
45
45
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* A directive's attribute reaches its element only as a plain HTML attribute: a lowercase name (`title`, `data-*`,
|
|
48
|
+
* `aria-*`), so never a DOM property such as `innerHTML` or React's `dangerouslySetInnerHTML`; never an event handler,
|
|
49
|
+
* an inline style, a frame's document or `is`.
|
|
50
|
+
*/
|
|
51
|
+
const ATTRIBUTE_NAME = /^[a-z][a-z0-9-]*$/;
|
|
52
|
+
const UNSAFE_ATTRIBUTE = /^(?:on|style$|srcdoc$|formaction$|is$)/;
|
|
53
|
+
/** The attributes that load or open a URL: one with a protocol other than Markdown's safe ones is dropped. */
|
|
54
|
+
const URL_ATTRIBUTES = new Set(["href", "src", "action", "cite", "poster", "background", "ping", "data", "codebase"]);
|
|
55
|
+
const SAFE_PROTOCOL = /^(?:https?|ircs?|mailto|xmpp|tel|sms)$/i;
|
|
56
|
+
/** react-markdown's `defaultUrlTransform` test, with `tel:` and `sms:` as the Markdown's own transform. */
|
|
57
|
+
const isSafeUrl = (value) => {
|
|
58
|
+
const colon = value.indexOf(":");
|
|
59
|
+
const firstOf = (char) => value.indexOf(char);
|
|
60
|
+
return (colon === -1 ||
|
|
61
|
+
[firstOf("/"), firstOf("?"), firstOf("#")].some((index) => index !== -1 && colon > index) ||
|
|
62
|
+
SAFE_PROTOCOL.test(value.slice(0, colon).trim()));
|
|
63
|
+
};
|
|
64
|
+
const safeAttributes = (attributes) => Object.fromEntries(Object.entries(attributes ?? {}).filter(([key, value]) => ATTRIBUTE_NAME.test(key) &&
|
|
65
|
+
!UNSAFE_ATTRIBUTE.test(key) &&
|
|
66
|
+
!(URL_ATTRIBUTES.has(key) && !isSafeUrl(String(value ?? "")))));
|
|
67
|
+
/**
|
|
68
|
+
* Directives become elements only when the Markdown knows them: a `directives` entry or a `components` key, with
|
|
69
|
+
* their attributes minus event handlers, `style` and `srcdoc`. Any other directive stays what was written: an inline
|
|
70
|
+
* or leaf one its source text, a container one its content in a plain `div`. Text from elsewhere (a server, a user)
|
|
71
|
+
* can't make an element of its choosing with attributes of its choosing.
|
|
72
|
+
*/
|
|
73
|
+
export function markdownRemarkDirective(options = {}) {
|
|
74
|
+
const names = new Set(options.names ?? []);
|
|
48
75
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
return (tree) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
...node.data
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
return (tree, file) => {
|
|
77
|
+
const source = file?.value == null ? "" : String(file.value);
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
visit(tree, ["textDirective", "leafDirective", "containerDirective"], (node, index, parent) => {
|
|
80
|
+
if (names.has(node.name)) {
|
|
81
|
+
node.data = { hName: node.name, hProperties: safeAttributes(node.attributes), ...node.data };
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (node.type === "containerDirective") {
|
|
85
|
+
node.data = { hName: "div", hProperties: {}, ...node.data };
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!parent || typeof index !== "number")
|
|
89
|
+
return;
|
|
90
|
+
const start = node.position?.start?.offset;
|
|
91
|
+
const end = node.position?.end?.offset;
|
|
92
|
+
const value = typeof start === "number" && typeof end === "number" && end <= source.length
|
|
93
|
+
? source.slice(start, end)
|
|
94
|
+
: `${node.type === "leafDirective" ? "::" : ":"}${node.name}`;
|
|
95
|
+
const text = { type: "text", value };
|
|
96
|
+
parent.children[index] = node.type === "leafDirective" ? { type: "paragraph", children: [text] } : text;
|
|
97
|
+
return SKIP;
|
|
57
98
|
});
|
|
58
99
|
};
|
|
59
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../../../src/components/Markdown/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAkF,MAAM,KAAK,CAAA;AAC5H,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAWpE;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,KAAqC,EAAmD,EAAE;IAC5G,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAClD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAA;IAClC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IACpB,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAA;IAC3E,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,SAAS,CAAA;IAC5D,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK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CAAC,MAAM,GAAG,eAAe,CAAA;IAElC,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,uBAAuB;IACrC,8DAA8D;IAC9D,OAAO,CAAC,IAAS,EAAE,EAAE;QACnB,KAAK,CAAC,IAAI,EAAE,CAAC,eAAe,EAAE,eAAe,EAAE,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE;YAC7E,IAAI,CAAC,IAAI,GAAG;gBACV,KAAK,EAAE,IAAI,CAAC,IAAI;gBAChB,WAAW,EAAE,IAAI,CAAC,UAAU;gBAC5B,GAAG,IAAI,CAAC,IAAI;aACb,CAAA;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { Comment, Text, isVNode, type FunctionalComponent, type VNode, type VNodeArrayChildren, type VNodeChild } from \"vue\"\nimport { visit } from \"unist-util-visit\"\nimport { createId } from \"../../lib/ids.js\"\nimport { decodeBase64, encodeBase64 } from \"../../lib/safeBase64.js\"\n\ntype ValidDirectiveProps = { children?: string } & Partial<Record<string, unknown>>\n\nexport interface MarkdownDirective<T extends ValidDirectiveProps = ValidDirectiveProps> {\n directiveName: string\n /** Functional component Markdown renders the directive with */\n render: FunctionalComponent<{ attrs?: string }>\n (props: T): string\n}\n\n/**\n * React's rendered `children`: nothing, the text of a single text child, the\n * single vnode, or the list.\n */\nconst toChildren = (nodes: VNodeArrayChildren | undefined): string | VNode | VNodeArrayChildren | undefined => {\n if (!nodes || nodes.length === 0) return undefined\n if (nodes.length > 1) return nodes\n const [node] = nodes\n if (isVNode(node) && node.type === Text) return String(node.children ?? \"\")\n if (isVNode(node) && node.type === Comment) return undefined\n return isVNode(node) ? node : nodes\n}\n\n/**\n * Vue port of packages/ui/src/components/Markdown/directives.ts. `render`\n * gets the decoded attributes plus `children`: the directive's label as a\n * string when it is plain text, otherwise its vnodes.\n */\nexport function createMarkdownDirective<T extends ValidDirectiveProps>({\n render,\n name,\n mode,\n}: {\n render: (props: T) => VNodeChild\n name: string\n mode: \"inline\" | \"block\"\n}): MarkdownDirective<T> {\n const prefix = `OaiMdDirective_${name}`\n const uniqueName = createId(prefix, prefix.length + 6)\n\n function directive(props: T) {\n const { children, ...attributes } = props\n // Always true, as in React: the attributes are encoded even when empty\n const attrs = Object.keys(attributes).length >= 0 ? `attrs=\"${encodeBase64(attributes)}\"` : \"\"\n const leader = mode === \"inline\" ? \" :\" : \"\\n\\n:::\"\n\n return `${leader}${uniqueName}${children ? `[${children}]` : \"\"}{${attrs}}`\n }\n\n const renderDirective: FunctionalComponent<{ attrs?: string }> = ({ attrs }, { slots }) => {\n const parsedAttrs = attrs ? decodeBase64<T>(attrs) : ({} as T)\n return render({ ...parsedAttrs, children: toChildren(slots.default?.()) })\n }\n // React's render reads only `attrs` and `children`: nothing falls through\n renderDirective.inheritAttrs = false\n\n directive.directiveName = uniqueName\n directive.render = renderDirective\n\n return directive\n}\n\n/** React's `reactMarkdownRemarkDirective`: directives become elements named after them. */\nexport function markdownRemarkDirective() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (tree: any) => {\n visit(tree, [\"textDirective\", \"leafDirective\", \"containerDirective\"], (node) => {\n node.data = {\n hName: node.name,\n hProperties: node.attributes,\n ...node.data,\n }\n return node\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"directives.js","sourceRoot":"","sources":["../../../../src/components/Markdown/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAkF,MAAM,KAAK,CAAA;AAC5H,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAWpE;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,KAAqC,EAAmD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CAAC,IAAI,CAAA;YACvG,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { Comment, Text, isVNode, type FunctionalComponent, type VNode, type VNodeArrayChildren, type VNodeChild } from \"vue\"\nimport { SKIP, visit } from \"unist-util-visit\"\nimport { createId } from \"../../lib/ids.js\"\nimport { decodeBase64, encodeBase64 } from \"../../lib/safeBase64.js\"\n\ntype ValidDirectiveProps = { children?: string } & Partial<Record<string, unknown>>\n\nexport interface MarkdownDirective<T extends ValidDirectiveProps = ValidDirectiveProps> {\n directiveName: string\n /** Functional component Markdown renders the directive with */\n render: FunctionalComponent<{ attrs?: string }>\n (props: T): string\n}\n\n/**\n * React's rendered `children`: nothing, the text of a single text child, the\n * single vnode, or the list.\n */\nconst toChildren = (nodes: VNodeArrayChildren | undefined): string | VNode | VNodeArrayChildren | undefined => {\n if (!nodes || nodes.length === 0) return undefined\n if (nodes.length > 1) return nodes\n const [node] = nodes\n if (isVNode(node) && node.type === Text) return String(node.children ?? \"\")\n if (isVNode(node) && node.type === Comment) return undefined\n return isVNode(node) ? node : nodes\n}\n\n/**\n * Vue port of packages/ui/src/components/Markdown/directives.ts. `render`\n * gets the decoded attributes plus `children`: the directive's label as a\n * string when it is plain text, otherwise its vnodes.\n */\nexport function createMarkdownDirective<T extends ValidDirectiveProps>({\n render,\n name,\n mode,\n}: {\n render: (props: T) => VNodeChild\n name: string\n mode: \"inline\" | \"block\"\n}): MarkdownDirective<T> {\n const prefix = `OaiMdDirective_${name}`\n const uniqueName = createId(prefix, prefix.length + 6)\n\n function directive(props: T) {\n const { children, ...attributes } = props\n // Always true, as in React: the attributes are encoded even when empty\n const attrs = Object.keys(attributes).length >= 0 ? `attrs=\"${encodeBase64(attributes)}\"` : \"\"\n const leader = mode === \"inline\" ? \" :\" : \"\\n\\n:::\"\n\n return `${leader}${uniqueName}${children ? `[${children}]` : \"\"}{${attrs}}`\n }\n\n const renderDirective: FunctionalComponent<{ attrs?: string }> = ({ attrs }, { slots }) => {\n const parsedAttrs = attrs ? decodeBase64<T>(attrs) : ({} as T)\n return render({ ...parsedAttrs, children: toChildren(slots.default?.()) })\n }\n // React's render reads only `attrs` and `children`: nothing falls through\n renderDirective.inheritAttrs = false\n\n directive.directiveName = uniqueName\n directive.render = renderDirective\n\n return directive\n}\n\n/**\n * A directive's attribute reaches its element only as a plain HTML attribute: a lowercase name (`title`, `data-*`,\n * `aria-*`), so never a DOM property such as `innerHTML` or React's `dangerouslySetInnerHTML`; never an event handler,\n * an inline style, a frame's document or `is`.\n */\nconst ATTRIBUTE_NAME = /^[a-z][a-z0-9-]*$/\nconst UNSAFE_ATTRIBUTE = /^(?:on|style$|srcdoc$|formaction$|is$)/\n\n/** The attributes that load or open a URL: one with a protocol other than Markdown's safe ones is dropped. */\nconst URL_ATTRIBUTES = new Set([\"href\", \"src\", \"action\", \"cite\", \"poster\", \"background\", \"ping\", \"data\", \"codebase\"])\nconst SAFE_PROTOCOL = /^(?:https?|ircs?|mailto|xmpp|tel|sms)$/i\n\n/** react-markdown's `defaultUrlTransform` test, with `tel:` and `sms:` as the Markdown's own transform. */\nconst isSafeUrl = (value: string) => {\n const colon = value.indexOf(\":\")\n const firstOf = (char: string) => value.indexOf(char)\n return (\n colon === -1 ||\n [firstOf(\"/\"), firstOf(\"?\"), firstOf(\"#\")].some((index) => index !== -1 && colon > index) ||\n SAFE_PROTOCOL.test(value.slice(0, colon).trim())\n )\n}\n\nconst safeAttributes = (attributes: Record<string, unknown> | null | undefined) =>\n Object.fromEntries(\n Object.entries(attributes ?? {}).filter(\n ([key, value]) =>\n ATTRIBUTE_NAME.test(key) &&\n !UNSAFE_ATTRIBUTE.test(key) &&\n !(URL_ATTRIBUTES.has(key) && !isSafeUrl(String(value ?? \"\"))),\n ),\n )\n\n/**\n * Directives become elements only when the Markdown knows them: a `directives` entry or a `components` key, with\n * their attributes minus event handlers, `style` and `srcdoc`. Any other directive stays what was written: an inline\n * or leaf one its source text, a container one its content in a plain `div`. Text from elsewhere (a server, a user)\n * can't make an element of its choosing with attributes of its choosing.\n */\nexport function markdownRemarkDirective(options: { names?: Iterable<string> } = {}) {\n const names = new Set(options.names ?? [])\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (tree: any, file?: { value?: unknown }) => {\n const source = file?.value == null ? \"\" : String(file.value)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n visit(tree, [\"textDirective\", \"leafDirective\", \"containerDirective\"], (node: any, index, parent: any) => {\n if (names.has(node.name)) {\n node.data = { hName: node.name, hProperties: safeAttributes(node.attributes), ...node.data }\n return\n }\n if (node.type === \"containerDirective\") {\n node.data = { hName: \"div\", hProperties: {}, ...node.data }\n return\n }\n if (!parent || typeof index !== \"number\") return\n const start = node.position?.start?.offset\n const end = node.position?.end?.offset\n const value =\n typeof start === \"number\" && typeof end === \"number\" && end <= source.length\n ? source.slice(start, end)\n : `${node.type === \"leafDirective\" ? \"::\" : \":\"}${node.name}`\n const text = { type: \"text\", value }\n parent.children[index] = node.type === \"leafDirective\" ? { type: \"paragraph\", children: [text] } : text\n return SKIP\n })\n }\n}\n"]}
|
|
@@ -5,10 +5,12 @@ import { keepMovedFocus } from "../../lib/helpers.js";
|
|
|
5
5
|
import { markdownEditorExtensions, markdownEditorSchema, rehypeEditorSchema, remarkLineBreaks, remarkWithoutHtml, } from "../../lib/markdownEditorSchema.js";
|
|
6
6
|
import { Bold as BoldIcon, Italic as ItalicIcon, Link as LinkIcon, List as ListIcon, ListNumbers as ListNumbersIcon, } from "../Icon/index.js";
|
|
7
7
|
import { Tooltip } from "../Tooltip/index.js";
|
|
8
|
-
import { Button } from "../Button/index.js";
|
|
9
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogBody, DialogFooter } from "../Dialog/index.js";
|
|
8
|
+
import { Button, NavigationButton } from "../Button/index.js";
|
|
9
|
+
import { Dialog, DialogContent, DialogHeader, DialogHeaderAction, DialogTitle, DialogBody, DialogFooter } from "../Dialog/index.js";
|
|
10
10
|
import { Field } from "../Field/index.js";
|
|
11
|
+
import { FieldGroup } from "../FieldGroup/index.js";
|
|
11
12
|
import { Input } from "../Input/index.js";
|
|
13
|
+
import { usePhoneLayout } from "../PhoneLayout/index.js";
|
|
12
14
|
import { flattenSlot } from "../Tooltip/slot.js";
|
|
13
15
|
import { renderMarkdown } from "../Markdown/pipeline.js";
|
|
14
16
|
import s from "@plexui/styles/components/MarkdownEditor/MarkdownEditor.module.css";
|
|
@@ -45,41 +47,72 @@ const LinkDialog = defineComponent({
|
|
|
45
47
|
title.value = initialTitle;
|
|
46
48
|
}
|
|
47
49
|
});
|
|
50
|
+
// On a phone the dialog is a sheet of the kit's grouped form: Cancel is the sheet's close button, Save its confirm
|
|
51
|
+
// button in the bar, the fields rows of a card and Remove a destructive row of its own (owner 21.11)
|
|
52
|
+
const phone = usePhoneLayout();
|
|
53
|
+
const fields = ref(null);
|
|
54
|
+
const save = () => { if (!props.disabled)
|
|
55
|
+
props.onSave(url.value, title.value); };
|
|
56
|
+
const onKeydown = (event) => {
|
|
57
|
+
if (event.key === "Enter" && !event.isComposing && event.target instanceof HTMLInputElement) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
save();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const urlInput = () => h(Input, {
|
|
63
|
+
type: "url", inputmode: "url", autocapitalize: "none", autocorrect: "off", spellcheck: false,
|
|
64
|
+
placeholder: phone.value ? "Required" : "Enter URL", value: url.value, disabled: props.disabled,
|
|
65
|
+
"onUpdate:value": (value) => { url.value = value; },
|
|
66
|
+
});
|
|
67
|
+
const titleInput = () => h(Input, {
|
|
68
|
+
placeholder: phone.value ? "Optional" : "Enter link title", value: title.value, disabled: props.disabled,
|
|
69
|
+
"onUpdate:value": (value) => { title.value = value; },
|
|
70
|
+
});
|
|
48
71
|
return () => h(Dialog, {
|
|
49
72
|
"open": props.open,
|
|
50
73
|
"onUpdate:open": (next) => { if (!next)
|
|
51
74
|
props.onCancel(); },
|
|
52
75
|
}, { default: () => h(DialogContent, {
|
|
53
|
-
width: 450, mobileVariant: "sheet", showClose:
|
|
76
|
+
width: 450, mobileVariant: "sheet", surface: "grouped", showClose: phone.value,
|
|
77
|
+
// On a phone the address is what the sheet asks for: it takes the focus, not the close button before it
|
|
78
|
+
onOpenAutoFocus: (event) => {
|
|
79
|
+
if (!phone.value)
|
|
80
|
+
return;
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
fields.value?.querySelector('input[type="url"]')?.focus();
|
|
83
|
+
},
|
|
54
84
|
onCloseAutoFocus: props.onRestoreFocus,
|
|
55
85
|
}, { default: () => [
|
|
56
|
-
h(DialogHeader, null, { default: () =>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
h(DialogHeader, null, { default: () => [
|
|
87
|
+
h(DialogTitle, null, { default: () => "Link" }),
|
|
88
|
+
phone.value
|
|
89
|
+
? h(DialogHeaderAction, null, { default: () => h(NavigationButton, { action: "confirm", "aria-label": "Save", disabled: props.disabled, onClick: save }) })
|
|
90
|
+
: null,
|
|
91
|
+
] }),
|
|
92
|
+
h(DialogBody, null, { default: () => phone.value
|
|
93
|
+
// The groups keep the spacing of a grouped form between them
|
|
94
|
+
? h("div", { ref: fields, onKeydown }, [
|
|
95
|
+
// A long address needs the cell's width: the label stands over the value, as a Textarea's row
|
|
96
|
+
h(FieldGroup, null, { default: () => [
|
|
97
|
+
h(Field, { row: true, orientation: "vertical", label: "URL" }, { default: urlInput }),
|
|
98
|
+
h(Field, { row: true, orientation: "vertical", label: "Title" }, { default: titleInput }),
|
|
99
|
+
] }),
|
|
100
|
+
props.isEditing
|
|
101
|
+
? h(FieldGroup, null, { default: () => h("div", { "data-row": "" }, [
|
|
102
|
+
h(Button, { block: true, color: "danger", variant: "ghost", disabled: props.disabled, onClick: () => { if (!props.disabled)
|
|
103
|
+
props.onRemove(); } }, { default: () => "Remove Link" }),
|
|
104
|
+
]) })
|
|
105
|
+
: null,
|
|
106
|
+
])
|
|
107
|
+
: h("div", { ref: fields, class: s.LinkDialogFields, onKeydown }, [
|
|
108
|
+
h(Field, { label: "URL" }, { default: urlInput }),
|
|
109
|
+
h(Field, { label: "Link title" }, { default: titleInput }),
|
|
110
|
+
]) }),
|
|
111
|
+
phone.value ? null : h(DialogFooter, null, { default: () => [
|
|
78
112
|
props.isEditing ? h(Button, { color: "danger", variant: "soft", disabled: props.disabled, onClick: () => { if (!props.disabled)
|
|
79
113
|
props.onRemove(); } }, { default: () => "Remove" }) : null,
|
|
80
114
|
h(Button, { color: "secondary", variant: "soft", onClick: () => props.onCancel() }, { default: () => "Cancel" }),
|
|
81
|
-
h(Button, { color: "primary", disabled: props.disabled, onClick:
|
|
82
|
-
props.onSave(url.value, title.value); } }, { default: () => "Save" }),
|
|
115
|
+
h(Button, { color: "primary", disabled: props.disabled, onClick: save }, { default: () => "Save" }),
|
|
83
116
|
] }),
|
|
84
117
|
] }) });
|
|
85
118
|
},
|
|
@@ -174,7 +207,6 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
174
207
|
orderedList: false,
|
|
175
208
|
bulletList: false,
|
|
176
209
|
});
|
|
177
|
-
const linkCanEnable = ref(false);
|
|
178
210
|
const isControlled = () => props.value !== undefined;
|
|
179
211
|
let suppressChange = false;
|
|
180
212
|
let linkSelection = null;
|
|
@@ -187,7 +219,6 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
187
219
|
orderedList: e.isActive("orderedList"),
|
|
188
220
|
bulletList: e.isActive("bulletList"),
|
|
189
221
|
});
|
|
190
|
-
linkCanEnable.value = !e.state.selection.empty || e.isActive("link");
|
|
191
222
|
};
|
|
192
223
|
const editorAttributes = () => ({
|
|
193
224
|
"class": s.EditorContent,
|
|
@@ -300,6 +331,9 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
300
331
|
const chain = instance.chain().setTextSelection({ from: range.from, to: range.to });
|
|
301
332
|
if (!url)
|
|
302
333
|
chain.unsetLink().run();
|
|
334
|
+
// With no text selected the link is new text at the caret: its title, or the address itself
|
|
335
|
+
else if (range.from === range.to)
|
|
336
|
+
chain.insertContent(linkText(title || url, url)).run();
|
|
303
337
|
else if (title && title !== selectedText)
|
|
304
338
|
chain.insertContent(linkText(title, url)).run();
|
|
305
339
|
else
|
|
@@ -388,7 +422,7 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
388
422
|
offered.has("link") && h(ToolbarButton, {
|
|
389
423
|
tooltip: "Link",
|
|
390
424
|
active: activeMarks.link,
|
|
391
|
-
disabled
|
|
425
|
+
disabled,
|
|
392
426
|
icon: LinkIcon,
|
|
393
427
|
onClick: openLinkDialog,
|
|
394
428
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditor.js","sourceRoot":"","sources":["../../../../src/components/MarkdownEditor/MarkdownEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,QAAQ,EACR,GAAG,EACH,KAAK,GAGN,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,YAAY,EAA6B,MAAM,cAAc,CAAA;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAGlB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EACL,IAAI,IAAI,QAAQ,EAChB,MAAM,IAAI,UAAU,EACpB,IAAI,IAAI,QAAQ,EAChB,IAAI,IAAI,QAAQ,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AC,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3H,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAA","sourcesContent":["import {\n defineComponent,\n h,\n reactive,\n ref,\n watch,\n type Component,\n type PropType,\n} from \"vue\"\nimport { EditorContent, useEditor } from \"@tiptap/vue-3\"\nimport { getMarkRange, type Editor as CoreEditor } from \"@tiptap/core\"\nimport type { Variants } from \"@plexui/styles/types\"\nimport { keepMovedFocus } from \"../../lib/helpers.js\"\nimport {\n markdownEditorExtensions,\n markdownEditorSchema,\n rehypeEditorSchema,\n remarkLineBreaks,\n remarkWithoutHtml,\n type MarkdownEditorFormat,\n type MarkdownEditorSchema,\n} from \"../../lib/markdownEditorSchema.js\"\nimport {\n Bold as BoldIcon,\n Italic as ItalicIcon,\n Link as LinkIcon,\n List as ListIcon,\n ListNumbers as ListNumbersIcon,\n} from \"../Icon/index.js\"\nimport { Tooltip } from \"../Tooltip/index.js\"\nimport { Button } from \"../Button/index.js\"\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogBody, DialogFooter } from \"../Dialog/index.js\"\nimport { Field } from \"../Field/index.js\"\nimport { Input } from \"../Input/index.js\"\nimport { flattenSlot } from \"../Tooltip/slot.js\"\nimport { renderMarkdown } from \"../Markdown/pipeline.js\"\nimport s from \"@plexui/styles/components/MarkdownEditor/MarkdownEditor.module.css\"\n\n// Vue port of packages/ui/src/components/MarkdownEditor/MarkdownEditor.tsx on\n// @tiptap/vue-3 with the same extensions, configured the same way, so\n// ProseMirror renders the same DOM and tiptap-markdown emits the same markdown.\n//\n// - The editor is created on mount (@tiptap/vue-3's `useEditor`, like React's\n// `immediatelyRender: false`) and destroyed on unmount.\n// - Value: `value` + `update:value` (`v-model:value`) and `change` mirror\n// React's `value` + `onChange`; `default-value` is the uncontrolled start.\n// As in React, a controlled value is only pushed into the editor when it\n// changes and differs from the editor's markdown.\n// - As in React, `update:value` / `change` also fire once when the editor is\n// created and whenever `disabled` changes (`setEditable` emits an update).\n// - Options React reads only when it creates the editor (`placeholder`,\n// `formats`, `breaks`, the initial content) are read once here too; `id`, `aria-label`,\n// `aria-labelledby`, `aria-describedby` and `aria-invalid` follow the\n// props, as React re-applies them on render.\n// - `toolbarEnd` is the `#toolbarEnd` slot. Like React, only `class` is\n// applied (to the container); other attributes are not forwarded.\n// - The shared Dialog owns focus trapping and closing. Its portal is not part\n// of the editor's click area, so editing a link preserves its selection.\n\ntype EditorLike = Pick<CoreEditor, \"isActive\" | \"state\">\n\nconst getMarkdown = (editor: CoreEditor) =>\n (editor.storage as unknown as Record<string, { getMarkdown?: () => string }>).markdown?.getMarkdown?.() ?? \"\"\n\n// A link inserted as a text node, not as `<a>` HTML: the markdown parser runs\n// with `html: false`, so HTML would land in the text as written\nconst linkText = (text: string, href: string) => ({\n type: \"text\",\n text,\n marks: [{ type: \"link\", attrs: { href } }],\n})\n\nexport const markdownEditorStyles = {\n toolbarButton: s.ToolbarButton,\n}\n\nexport type { MarkdownEditorFormat }\n\ntype LinkSelection = { from: number; to: number; doc: CoreEditor[\"state\"][\"doc\"] }\n\nconst LinkDialog = defineComponent({\n name: \"MarkdownEditorLinkDialog\",\n props: {\n open: { type: Boolean, required: true },\n initialUrl: { type: String, required: true },\n initialTitle: { type: String, required: true },\n isEditing: { type: Boolean, required: true },\n disabled: { type: Boolean, required: true },\n onSave: { type: Function as PropType<(url: string, title: string) => void>, required: true },\n onRemove: { type: Function as PropType<() => void>, required: true },\n onCancel: { type: Function as PropType<() => void>, required: true },\n onRestoreFocus: { type: Function as PropType<(event: Event) => void>, required: true },\n },\n setup(props) {\n const url = ref(props.initialUrl)\n const title = ref(props.initialTitle)\n watch(() => [props.open, props.initialUrl, props.initialTitle] as const, ([open, initialUrl, initialTitle]) => {\n if (open) { url.value = initialUrl; title.value = initialTitle }\n })\n return () => h(Dialog, {\n \"open\": props.open,\n \"onUpdate:open\": (next: boolean) => { if (!next) props.onCancel() },\n }, { default: () => h(DialogContent, {\n width: 450, mobileVariant: \"sheet\", showClose: false,\n onCloseAutoFocus: props.onRestoreFocus,\n }, { default: () => [\n h(DialogHeader, null, { default: () => h(DialogTitle, null, { default: () => \"Link\" }) }),\n h(DialogBody, null, { default: () => h(\"div\", {\n class: s.LinkDialogFields,\n onKeydown: (event: KeyboardEvent) => {\n if (event.key === \"Enter\" && !event.isComposing && event.target instanceof HTMLInputElement) {\n event.preventDefault()\n if (!props.disabled) props.onSave(url.value, title.value)\n }\n },\n }, [\n h(Field, { label: \"URL\" }, { default: () => h(Input, {\n type: \"url\", inputmode: \"url\", autocapitalize: \"none\", autocorrect: \"off\", spellcheck: false,\n placeholder: \"Enter URL\", value: url.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { url.value = value },\n }) }),\n h(Field, { label: \"Link title\" }, { default: () => h(Input, {\n placeholder: \"Enter link title\", value: title.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { title.value = value },\n }) }),\n ]) }),\n h(DialogFooter, null, { default: () => [\n props.isEditing ? h(Button, { color: \"danger\", variant: \"soft\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onRemove() } }, { default: () => \"Remove\" }) : null,\n h(Button, { color: \"secondary\", variant: \"soft\", onClick: () => props.onCancel() }, { default: () => \"Cancel\" }),\n h(Button, { color: \"primary\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onSave(url.value, title.value) } }, { default: () => \"Save\" }),\n ] }),\n ] }) })\n },\n})\n\nconst ToolbarButton = defineComponent({\n name: \"MarkdownEditorToolbarButton\",\n props: {\n tooltip: { type: String, required: true },\n active: { type: Boolean, default: false },\n disabled: { type: Boolean, default: false },\n icon: { type: [Object, Function] as PropType<Component>, required: true },\n onClick: { type: Function as PropType<() => void>, required: true },\n },\n setup(props) {\n return () =>\n h(\n Tooltip,\n { content: props.tooltip, compact: true },\n {\n default: () =>\n h(\n Button,\n {\n \"color\": \"secondary\", \"variant\": \"ghost\", \"size\": \"2xs\", \"iconSize\": \"sm\", \"uniform\": true, \"mobileMaterial\": \"flat\",\n \"class\": s.ToolbarButton,\n \"data-active\": props.active || undefined,\n \"selected\": props.active,\n // Formatting buttons are toggles: announce their on/off state\n \"aria-pressed\": props.active,\n // React DOM never calls onClick on a disabled button, even\n // for a dispatched event; Vue's listener would run\n \"onClick\": () => {\n if (!props.disabled) props.onClick()\n },\n \"disabled\": props.disabled,\n \"aria-label\": props.tooltip,\n },\n { default: () => h(props.icon) },\n ),\n },\n )\n },\n})\n\nconst MarkdownEditorComponent = defineComponent({\n name: \"MarkdownEditor\",\n inheritAttrs: false,\n props: {\n /** Visual style of the editor. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\">>, default: \"outline\" },\n /** Disables editing and the toolbar. @default false */\n disabled: { type: Boolean, default: false },\n /** Marks the editor as invalid. @default false */\n invalid: { type: Boolean, default: false },\n /** Placeholder text when empty (read when the editor is created) */\n placeholder: String,\n /** Controlled value as a markdown string (`v-model:value`) */\n value: { type: String, default: undefined },\n /** Default value as a markdown string for uncontrolled mode */\n defaultValue: { type: String, default: undefined },\n /**\n * The formats the editor offers, read when the editor is created. A format left out has no toolbar button,\n * shortcut or input rule; in pasted text its markers stay text, as typed, pasted HTML and incoming markdown keep\n * its text without it, and the markdown does not write it.\n * @default [\"bold\", \"italic\", \"orderedList\", \"bulletList\", \"link\"]\n */\n formats: { type: Array as PropType<MarkdownEditorFormat[]>, default: undefined },\n /**\n * A single newline is a line break, read and written as one \"\\n\", read when the editor is created. Without it a\n * line break is written as a backslash and a newline, and a single newline joins the lines. @default false\n */\n breaks: { type: Boolean, default: false },\n /** Minimum visible rows. @default 1 */\n rows: { type: Number, default: 1 },\n /** `id` of the editable element */\n id: String,\n /** Accessible name of the editable element; a `<label for>` cannot name a contenteditable region */\n ariaLabel: String,\n /** Id of the element that names the editor, such as a Field label */\n ariaLabelledby: String,\n /** `aria-describedby` of the editable element */\n ariaDescribedby: String,\n /** Sets `aria-invalid=\"true\"` on the editable element and the invalid style */\n ariaInvalid: { type: Boolean, default: undefined },\n },\n emits: {\n /** The editor's markdown after a change (`v-model:value`) */\n \"update:value\": (markdown: string) => typeof markdown === \"string\",\n /** Same as `update:value` (React's `onChange`) */\n \"change\": (markdown: string) => typeof markdown === \"string\",\n },\n setup(props, { slots, attrs, emit }) {\n // The schema is the editor's, made once with it, as the toolbar offers what the schema has\n const schema = markdownEditorSchema(props.formats, props.breaks)\n const focused = ref(false)\n const linkDialogOpen = ref(false)\n const linkDialogInitial = ref({ url: \"\", title: \"\" })\n const activeMarks = reactive({\n bold: false,\n italic: false,\n link: false,\n orderedList: false,\n bulletList: false,\n })\n const linkCanEnable = ref(false)\n const isControlled = () => props.value !== undefined\n let suppressChange = false\n let linkSelection: LinkSelection | null = null\n let restoreEditorFocus = false\n\n const syncToolbar = (e: EditorLike) => {\n Object.assign(activeMarks, {\n bold: e.isActive(\"bold\"),\n italic: e.isActive(\"italic\"),\n link: e.isActive(\"link\"),\n orderedList: e.isActive(\"orderedList\"),\n bulletList: e.isActive(\"bulletList\"),\n })\n linkCanEnable.value = !e.state.selection.empty || e.isActive(\"link\")\n }\n\n const editorAttributes = () => ({\n \"class\": s.EditorContent,\n \"role\": \"textbox\",\n \"aria-multiline\": \"true\",\n ...(props.id && { id: props.id }),\n ...(props.ariaLabel && { \"aria-label\": props.ariaLabel }),\n ...(props.ariaLabelledby && { \"aria-labelledby\": props.ariaLabelledby }),\n ...(props.ariaDescribedby && { \"aria-describedby\": props.ariaDescribedby }),\n ...(props.ariaInvalid && { \"aria-invalid\": \"true\" }),\n })\n\n const editor = useEditor({\n extensions: markdownEditorExtensions(schema, props.placeholder),\n content: props.value ?? props.defaultValue ?? \"\",\n editable: !props.disabled,\n editorProps: {\n attributes: editorAttributes(),\n },\n onFocus: () => {\n focused.value = true\n },\n onBlur: () => {\n focused.value = false\n },\n onUpdate: ({ editor: e }) => {\n if (suppressChange) return\n const md = getMarkdown(e)\n emit(\"update:value\", md)\n emit(\"change\", md)\n },\n onSelectionUpdate: ({ editor: e }) => syncToolbar(e),\n onTransaction: ({ editor: e }) => {\n syncToolbar(e)\n if (linkSelection && linkSelection.doc !== e.state.doc) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n })\n\n // React re-applies the editor props on every render\n watch(editorAttributes, (attributes) => {\n editor.value?.setOptions({ editorProps: { attributes } })\n })\n\n watch(\n () => [editor.value, props.value, isControlled()] as const,\n ([instance, value, controlled]) => {\n if (!instance || !controlled) return\n const currentMd = getMarkdown(instance)\n if (value !== currentMd) {\n suppressChange = true\n instance.commands.setContent(value || \"\", { emitUpdate: false })\n suppressChange = false\n }\n },\n )\n\n watch(\n () => [editor.value, props.disabled] as const,\n ([instance, disabled]) => {\n if (instance) instance.setEditable(!disabled)\n if (disabled) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n )\n\n const handleContainerMouseDown = (evt: MouseEvent) => {\n const instance = editor.value\n if (props.disabled || !instance) return\n const target = evt.target\n if (!(target instanceof Element) || !(evt.currentTarget instanceof Element) || !evt.currentTarget.contains(target)) return\n if (target.closest(\"button, [type='button'], [role='button'], a, input, label\")) return\n // A press in the text places the caret there itself\n if (instance.view.dom.contains(target)) return\n if (instance.isFocused) return\n evt.preventDefault()\n instance.commands.focus(\"end\")\n }\n\n const openLinkDialog = () => {\n const instance = editor.value\n if (!instance || props.disabled) return\n const url = instance.getAttributes(\"link\").href ?? \"\"\n const selection = instance.state.selection\n const range = selection.empty && instance.isActive(\"link\")\n ? getMarkRange(selection.$from, instance.schema.marks.link, { href: url })\n : selection\n if (!range) return\n linkSelection = { from: range.from, to: range.to, doc: instance.state.doc }\n restoreEditorFocus = true\n linkDialogInitial.value = { url, title: instance.state.doc.textBetween(range.from, range.to, \"\") }\n linkDialogOpen.value = true\n }\n const handleLinkSave = (url: string, title: string) => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n const selectedText = instance.state.doc.textBetween(range.from, range.to, \"\")\n const chain = instance.chain().setTextSelection({ from: range.from, to: range.to })\n if (!url) chain.unsetLink().run()\n else if (title && title !== selectedText) chain.insertContent(linkText(title, url)).run()\n else chain.setLink({ href: url }).run()\n }\n const handleLinkRemove = () => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n instance.chain().setTextSelection({ from: range.from, to: range.to }).unsetLink().run()\n }\n const handleLinkCancel = () => { linkDialogOpen.value = false }\n const handleRestoreFocus = (event: Event) => {\n keepMovedFocus(event)\n const shouldRestore = restoreEditorFocus && !event.defaultPrevented\n event.preventDefault()\n restoreEditorFocus = false\n linkSelection = null\n const instance = editor.value\n if (shouldRestore && instance && !instance.isDestroyed && !props.disabled) {\n const closingScope = event.target\n requestAnimationFrame(() => {\n if (instance.isDestroyed || !instance.isEditable) return\n const doc = instance.view.dom.ownerDocument\n const active = doc.activeElement\n if (active && active !== doc.body && !instance.view.dom.contains(active)\n && !(closingScope instanceof Node && closingScope.contains(active))) return\n // Check at the actual restore, then focus synchronously: Tiptap's\n // focus command queues another frame that could steal moved focus.\n instance.view.focus()\n })\n }\n }\n\n return () => {\n const { variant, disabled, invalid, ariaInvalid, rows } = props\n const isInvalid = invalid || ariaInvalid\n const minHeight = 20 * rows + 16\n // React renders the slot only for a truthy `toolbarEnd`\n const toolbarEnd = slots.toolbarEnd?.()\n const hasToolbarEnd = flattenSlot(toolbarEnd).length > 0\n const offered = schema.formats\n // Groups of the offered formats, a separator between two of them\n const groups = [\n [\n offered.has(\"bold\") && h(ToolbarButton, {\n tooltip: \"Bold\",\n active: activeMarks.bold,\n disabled,\n icon: BoldIcon,\n onClick: () => editor.value?.chain().focus().toggleBold().run(),\n }),\n offered.has(\"italic\") && h(ToolbarButton, {\n tooltip: \"Italic\",\n active: activeMarks.italic,\n disabled,\n icon: ItalicIcon,\n onClick: () => editor.value?.chain().focus().toggleItalic().run(),\n }),\n ],\n [\n offered.has(\"orderedList\") && h(ToolbarButton, {\n tooltip: \"Numbered list\",\n active: activeMarks.orderedList,\n disabled,\n icon: ListNumbersIcon,\n onClick: () => editor.value?.chain().focus().toggleOrderedList().run(),\n }),\n offered.has(\"bulletList\") && h(ToolbarButton, {\n tooltip: \"Bullet list\",\n active: activeMarks.bulletList,\n disabled,\n icon: ListIcon,\n onClick: () => editor.value?.chain().focus().toggleBulletList().run(),\n }),\n ],\n [\n offered.has(\"link\") && h(ToolbarButton, {\n tooltip: \"Link\",\n active: activeMarks.link,\n disabled: disabled || !linkCanEnable.value,\n icon: LinkIcon,\n onClick: openLinkDialog,\n }),\n ],\n ].map((group) => group.filter((button) => button !== false)).filter((group) => group.length > 0)\n\n return h(\n \"div\",\n {\n \"class\": [s.Container, attrs.class],\n \"data-variant\": variant,\n \"data-focused\": String(focused.value),\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-invalid\": isInvalid ? \"\" : undefined,\n \"onMousedown\": handleContainerMouseDown,\n },\n [\n groups.length || hasToolbarEnd\n ? h(\"div\", { class: s.Toolbar, onMousedown: (e: MouseEvent) => e.preventDefault() }, [\n h(\"div\", { class: s.ToolbarGroup }, [\n ...groups.flatMap((group, index) => [\n ...(index ? [h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" })] : []),\n ...group,\n ]),\n ...(hasToolbarEnd\n ? [\n ...(groups.length ? [h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" })] : []),\n h(\"div\", { class: s.ToolbarEnd }, toolbarEnd),\n ]\n : []),\n ]),\n ])\n : null,\n\n h(\"div\", { class: s.Editor, style: { minHeight: `${minHeight}px` } }, [\n editor.value\n ? h(EditorContent, { editor: editor.value })\n : editorFirstFrame(props.value ?? props.defaultValue ?? \"\", props.placeholder, props.disabled, schema),\n ]),\n\n h(LinkDialog, {\n open: linkDialogOpen.value,\n initialUrl: linkDialogInitial.value.url,\n initialTitle: linkDialogInitial.value.title,\n isEditing: !!linkDialogInitial.value.url,\n disabled,\n onRestoreFocus: handleRestoreFocus,\n onSave: handleLinkSave,\n onRemove: handleLinkRemove,\n onCancel: handleLinkCancel,\n }),\n ],\n )\n }\n },\n})\n\n/**\n * The content before the editor exists, on the server and until it mounts: the markdown as the editor will show it,\n * in its schema and its own boxes (EditorContent's, then ProseMirror's), so the page does not move when ProseMirror\n * takes over, as in React. An empty editor shows its placeholder while it can be edited (`showOnlyWhenEditable`).\n */\nconst editorFirstFrame = (markdown: string, placeholder: string | undefined, disabled: boolean, schema: MarkdownEditorSchema) => {\n const hint = placeholder && !disabled ? placeholder : undefined\n return h(\"div\", null, [\n h(\"div\", { class: [\"tiptap\", s.EditorContent] }, [\n markdown.trim()\n ? renderMarkdown({\n children: markdown,\n remarkPlugins: schema.breaks ? [remarkWithoutHtml, remarkLineBreaks] : [remarkWithoutHtml],\n rehypePlugins: [rehypeEditorSchema(schema, hint)],\n })\n : h(\"p\", { class: hint ? \"is-editor-empty\" : undefined, \"data-placeholder\": hint ? placeholder : undefined }, [h(\"br\")]),\n ]),\n ])\n}\n\n/**\n * Compact rich text editor for markdown, with a formatting toolbar (bold,\n * italic, lists, links). Bind the markdown with `v-model:value`.\n */\nexport const MarkdownEditor = MarkdownEditorComponent\n\nexport type MarkdownEditorProps = InstanceType<typeof MarkdownEditorComponent>[\"$props\"]\n"]}
|
|
1
|
+
{"version":3,"file":"MarkdownEditor.js","sourceRoot":"","sources":["../../../../src/components/MarkdownEditor/MarkdownEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,QAAQ,EACR,GAAG,EACH,KAAK,GAGN,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE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CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3H,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAA","sourcesContent":["import {\n defineComponent,\n h,\n reactive,\n ref,\n watch,\n type Component,\n type PropType,\n} from \"vue\"\nimport { EditorContent, useEditor } from \"@tiptap/vue-3\"\nimport { getMarkRange, type Editor as CoreEditor } from \"@tiptap/core\"\nimport type { Variants } from \"@plexui/styles/types\"\nimport { keepMovedFocus } from \"../../lib/helpers.js\"\nimport {\n markdownEditorExtensions,\n markdownEditorSchema,\n rehypeEditorSchema,\n remarkLineBreaks,\n remarkWithoutHtml,\n type MarkdownEditorFormat,\n type MarkdownEditorSchema,\n} from \"../../lib/markdownEditorSchema.js\"\nimport {\n Bold as BoldIcon,\n Italic as ItalicIcon,\n Link as LinkIcon,\n List as ListIcon,\n ListNumbers as ListNumbersIcon,\n} from \"../Icon/index.js\"\nimport { Tooltip } from \"../Tooltip/index.js\"\nimport { Button, NavigationButton } from \"../Button/index.js\"\nimport { Dialog, DialogContent, DialogHeader, DialogHeaderAction, DialogTitle, DialogBody, DialogFooter } from \"../Dialog/index.js\"\nimport { Field } from \"../Field/index.js\"\nimport { FieldGroup } from \"../FieldGroup/index.js\"\nimport { Input } from \"../Input/index.js\"\nimport { usePhoneLayout } from \"../PhoneLayout/index.js\"\nimport { flattenSlot } from \"../Tooltip/slot.js\"\nimport { renderMarkdown } from \"../Markdown/pipeline.js\"\nimport s from \"@plexui/styles/components/MarkdownEditor/MarkdownEditor.module.css\"\n\n// Vue port of packages/ui/src/components/MarkdownEditor/MarkdownEditor.tsx on\n// @tiptap/vue-3 with the same extensions, configured the same way, so\n// ProseMirror renders the same DOM and tiptap-markdown emits the same markdown.\n//\n// - The editor is created on mount (@tiptap/vue-3's `useEditor`, like React's\n// `immediatelyRender: false`) and destroyed on unmount.\n// - Value: `value` + `update:value` (`v-model:value`) and `change` mirror\n// React's `value` + `onChange`; `default-value` is the uncontrolled start.\n// As in React, a controlled value is only pushed into the editor when it\n// changes and differs from the editor's markdown.\n// - As in React, `update:value` / `change` also fire once when the editor is\n// created and whenever `disabled` changes (`setEditable` emits an update).\n// - Options React reads only when it creates the editor (`placeholder`,\n// `formats`, `breaks`, the initial content) are read once here too; `id`, `aria-label`,\n// `aria-labelledby`, `aria-describedby` and `aria-invalid` follow the\n// props, as React re-applies them on render.\n// - `toolbarEnd` is the `#toolbarEnd` slot. Like React, only `class` is\n// applied (to the container); other attributes are not forwarded.\n// - The shared Dialog owns focus trapping and closing. Its portal is not part\n// of the editor's click area, so editing a link preserves its selection.\n\ntype EditorLike = Pick<CoreEditor, \"isActive\" | \"state\">\n\nconst getMarkdown = (editor: CoreEditor) =>\n (editor.storage as unknown as Record<string, { getMarkdown?: () => string }>).markdown?.getMarkdown?.() ?? \"\"\n\n// A link inserted as a text node, not as `<a>` HTML: the markdown parser runs\n// with `html: false`, so HTML would land in the text as written\nconst linkText = (text: string, href: string) => ({\n type: \"text\",\n text,\n marks: [{ type: \"link\", attrs: { href } }],\n})\n\nexport const markdownEditorStyles = {\n toolbarButton: s.ToolbarButton,\n}\n\nexport type { MarkdownEditorFormat }\n\ntype LinkSelection = { from: number; to: number; doc: CoreEditor[\"state\"][\"doc\"] }\n\nconst LinkDialog = defineComponent({\n name: \"MarkdownEditorLinkDialog\",\n props: {\n open: { type: Boolean, required: true },\n initialUrl: { type: String, required: true },\n initialTitle: { type: String, required: true },\n isEditing: { type: Boolean, required: true },\n disabled: { type: Boolean, required: true },\n onSave: { type: Function as PropType<(url: string, title: string) => void>, required: true },\n onRemove: { type: Function as PropType<() => void>, required: true },\n onCancel: { type: Function as PropType<() => void>, required: true },\n onRestoreFocus: { type: Function as PropType<(event: Event) => void>, required: true },\n },\n setup(props) {\n const url = ref(props.initialUrl)\n const title = ref(props.initialTitle)\n watch(() => [props.open, props.initialUrl, props.initialTitle] as const, ([open, initialUrl, initialTitle]) => {\n if (open) { url.value = initialUrl; title.value = initialTitle }\n })\n // On a phone the dialog is a sheet of the kit's grouped form: Cancel is the sheet's close button, Save its confirm\n // button in the bar, the fields rows of a card and Remove a destructive row of its own (owner 21.11)\n const phone = usePhoneLayout()\n const fields = ref<HTMLElement | null>(null)\n const save = () => { if (!props.disabled) props.onSave(url.value, title.value) }\n const onKeydown = (event: KeyboardEvent) => {\n if (event.key === \"Enter\" && !event.isComposing && event.target instanceof HTMLInputElement) {\n event.preventDefault()\n save()\n }\n }\n const urlInput = () => h(Input, {\n type: \"url\", inputmode: \"url\", autocapitalize: \"none\", autocorrect: \"off\", spellcheck: false,\n placeholder: phone.value ? \"Required\" : \"Enter URL\", value: url.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { url.value = value },\n })\n const titleInput = () => h(Input, {\n placeholder: phone.value ? \"Optional\" : \"Enter link title\", value: title.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { title.value = value },\n })\n return () => h(Dialog, {\n \"open\": props.open,\n \"onUpdate:open\": (next: boolean) => { if (!next) props.onCancel() },\n }, { default: () => h(DialogContent, {\n width: 450, mobileVariant: \"sheet\", surface: \"grouped\", showClose: phone.value,\n // On a phone the address is what the sheet asks for: it takes the focus, not the close button before it\n onOpenAutoFocus: (event: Event) => {\n if (!phone.value) return\n event.preventDefault()\n fields.value?.querySelector<HTMLInputElement>('input[type=\"url\"]')?.focus()\n },\n onCloseAutoFocus: props.onRestoreFocus,\n }, { default: () => [\n h(DialogHeader, null, { default: () => [\n h(DialogTitle, null, { default: () => \"Link\" }),\n phone.value\n ? h(DialogHeaderAction, null, { default: () => h(NavigationButton, { action: \"confirm\", \"aria-label\": \"Save\", disabled: props.disabled, onClick: save }) })\n : null,\n ] }),\n h(DialogBody, null, { default: () => phone.value\n // The groups keep the spacing of a grouped form between them\n ? h(\"div\", { ref: fields, onKeydown }, [\n // A long address needs the cell's width: the label stands over the value, as a Textarea's row\n h(FieldGroup, null, { default: () => [\n h(Field, { row: true, orientation: \"vertical\", label: \"URL\" }, { default: urlInput }),\n h(Field, { row: true, orientation: \"vertical\", label: \"Title\" }, { default: titleInput }),\n ] }),\n props.isEditing\n ? h(FieldGroup, null, { default: () => h(\"div\", { \"data-row\": \"\" }, [\n h(Button, { block: true, color: \"danger\", variant: \"ghost\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onRemove() } }, { default: () => \"Remove Link\" }),\n ]) })\n : null,\n ])\n : h(\"div\", { ref: fields, class: s.LinkDialogFields, onKeydown }, [\n h(Field, { label: \"URL\" }, { default: urlInput }),\n h(Field, { label: \"Link title\" }, { default: titleInput }),\n ]) }),\n phone.value ? null : h(DialogFooter, null, { default: () => [\n props.isEditing ? h(Button, { color: \"danger\", variant: \"soft\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onRemove() } }, { default: () => \"Remove\" }) : null,\n h(Button, { color: \"secondary\", variant: \"soft\", onClick: () => props.onCancel() }, { default: () => \"Cancel\" }),\n h(Button, { color: \"primary\", disabled: props.disabled, onClick: save }, { default: () => \"Save\" }),\n ] }),\n ] }) })\n },\n})\n\nconst ToolbarButton = defineComponent({\n name: \"MarkdownEditorToolbarButton\",\n props: {\n tooltip: { type: String, required: true },\n active: { type: Boolean, default: false },\n disabled: { type: Boolean, default: false },\n icon: { type: [Object, Function] as PropType<Component>, required: true },\n onClick: { type: Function as PropType<() => void>, required: true },\n },\n setup(props) {\n return () =>\n h(\n Tooltip,\n { content: props.tooltip, compact: true },\n {\n default: () =>\n h(\n Button,\n {\n \"color\": \"secondary\", \"variant\": \"ghost\", \"size\": \"2xs\", \"iconSize\": \"sm\", \"uniform\": true, \"mobileMaterial\": \"flat\",\n \"class\": s.ToolbarButton,\n \"data-active\": props.active || undefined,\n \"selected\": props.active,\n // Formatting buttons are toggles: announce their on/off state\n \"aria-pressed\": props.active,\n // React DOM never calls onClick on a disabled button, even\n // for a dispatched event; Vue's listener would run\n \"onClick\": () => {\n if (!props.disabled) props.onClick()\n },\n \"disabled\": props.disabled,\n \"aria-label\": props.tooltip,\n },\n { default: () => h(props.icon) },\n ),\n },\n )\n },\n})\n\nconst MarkdownEditorComponent = defineComponent({\n name: \"MarkdownEditor\",\n inheritAttrs: false,\n props: {\n /** Visual style of the editor. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\">>, default: \"outline\" },\n /** Disables editing and the toolbar. @default false */\n disabled: { type: Boolean, default: false },\n /** Marks the editor as invalid. @default false */\n invalid: { type: Boolean, default: false },\n /** Placeholder text when empty (read when the editor is created) */\n placeholder: String,\n /** Controlled value as a markdown string (`v-model:value`) */\n value: { type: String, default: undefined },\n /** Default value as a markdown string for uncontrolled mode */\n defaultValue: { type: String, default: undefined },\n /**\n * The formats the editor offers, read when the editor is created. A format left out has no toolbar button,\n * shortcut or input rule; in pasted text its markers stay text, as typed, pasted HTML and incoming markdown keep\n * its text without it, and the markdown does not write it.\n * @default [\"bold\", \"italic\", \"orderedList\", \"bulletList\", \"link\"]\n */\n formats: { type: Array as PropType<MarkdownEditorFormat[]>, default: undefined },\n /**\n * A single newline is a line break, read and written as one \"\\n\", read when the editor is created. Without it a\n * line break is written as a backslash and a newline, and a single newline joins the lines. @default false\n */\n breaks: { type: Boolean, default: false },\n /** Minimum visible rows. @default 1 */\n rows: { type: Number, default: 1 },\n /** `id` of the editable element */\n id: String,\n /** Accessible name of the editable element; a `<label for>` cannot name a contenteditable region */\n ariaLabel: String,\n /** Id of the element that names the editor, such as a Field label */\n ariaLabelledby: String,\n /** `aria-describedby` of the editable element */\n ariaDescribedby: String,\n /** Sets `aria-invalid=\"true\"` on the editable element and the invalid style */\n ariaInvalid: { type: Boolean, default: undefined },\n },\n emits: {\n /** The editor's markdown after a change (`v-model:value`) */\n \"update:value\": (markdown: string) => typeof markdown === \"string\",\n /** Same as `update:value` (React's `onChange`) */\n \"change\": (markdown: string) => typeof markdown === \"string\",\n },\n setup(props, { slots, attrs, emit }) {\n // The schema is the editor's, made once with it, as the toolbar offers what the schema has\n const schema = markdownEditorSchema(props.formats, props.breaks)\n const focused = ref(false)\n const linkDialogOpen = ref(false)\n const linkDialogInitial = ref({ url: \"\", title: \"\" })\n const activeMarks = reactive({\n bold: false,\n italic: false,\n link: false,\n orderedList: false,\n bulletList: false,\n })\n const isControlled = () => props.value !== undefined\n let suppressChange = false\n let linkSelection: LinkSelection | null = null\n let restoreEditorFocus = false\n\n const syncToolbar = (e: EditorLike) => {\n Object.assign(activeMarks, {\n bold: e.isActive(\"bold\"),\n italic: e.isActive(\"italic\"),\n link: e.isActive(\"link\"),\n orderedList: e.isActive(\"orderedList\"),\n bulletList: e.isActive(\"bulletList\"),\n })\n }\n\n const editorAttributes = () => ({\n \"class\": s.EditorContent,\n \"role\": \"textbox\",\n \"aria-multiline\": \"true\",\n ...(props.id && { id: props.id }),\n ...(props.ariaLabel && { \"aria-label\": props.ariaLabel }),\n ...(props.ariaLabelledby && { \"aria-labelledby\": props.ariaLabelledby }),\n ...(props.ariaDescribedby && { \"aria-describedby\": props.ariaDescribedby }),\n ...(props.ariaInvalid && { \"aria-invalid\": \"true\" }),\n })\n\n const editor = useEditor({\n extensions: markdownEditorExtensions(schema, props.placeholder),\n content: props.value ?? props.defaultValue ?? \"\",\n editable: !props.disabled,\n editorProps: {\n attributes: editorAttributes(),\n },\n onFocus: () => {\n focused.value = true\n },\n onBlur: () => {\n focused.value = false\n },\n onUpdate: ({ editor: e }) => {\n if (suppressChange) return\n const md = getMarkdown(e)\n emit(\"update:value\", md)\n emit(\"change\", md)\n },\n onSelectionUpdate: ({ editor: e }) => syncToolbar(e),\n onTransaction: ({ editor: e }) => {\n syncToolbar(e)\n if (linkSelection && linkSelection.doc !== e.state.doc) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n })\n\n // React re-applies the editor props on every render\n watch(editorAttributes, (attributes) => {\n editor.value?.setOptions({ editorProps: { attributes } })\n })\n\n watch(\n () => [editor.value, props.value, isControlled()] as const,\n ([instance, value, controlled]) => {\n if (!instance || !controlled) return\n const currentMd = getMarkdown(instance)\n if (value !== currentMd) {\n suppressChange = true\n instance.commands.setContent(value || \"\", { emitUpdate: false })\n suppressChange = false\n }\n },\n )\n\n watch(\n () => [editor.value, props.disabled] as const,\n ([instance, disabled]) => {\n if (instance) instance.setEditable(!disabled)\n if (disabled) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n )\n\n const handleContainerMouseDown = (evt: MouseEvent) => {\n const instance = editor.value\n if (props.disabled || !instance) return\n const target = evt.target\n if (!(target instanceof Element) || !(evt.currentTarget instanceof Element) || !evt.currentTarget.contains(target)) return\n if (target.closest(\"button, [type='button'], [role='button'], a, input, label\")) return\n // A press in the text places the caret there itself\n if (instance.view.dom.contains(target)) return\n if (instance.isFocused) return\n evt.preventDefault()\n instance.commands.focus(\"end\")\n }\n\n const openLinkDialog = () => {\n const instance = editor.value\n if (!instance || props.disabled) return\n const url = instance.getAttributes(\"link\").href ?? \"\"\n const selection = instance.state.selection\n const range = selection.empty && instance.isActive(\"link\")\n ? getMarkRange(selection.$from, instance.schema.marks.link, { href: url })\n : selection\n if (!range) return\n linkSelection = { from: range.from, to: range.to, doc: instance.state.doc }\n restoreEditorFocus = true\n linkDialogInitial.value = { url, title: instance.state.doc.textBetween(range.from, range.to, \"\") }\n linkDialogOpen.value = true\n }\n const handleLinkSave = (url: string, title: string) => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n const selectedText = instance.state.doc.textBetween(range.from, range.to, \"\")\n const chain = instance.chain().setTextSelection({ from: range.from, to: range.to })\n if (!url) chain.unsetLink().run()\n // With no text selected the link is new text at the caret: its title, or the address itself\n else if (range.from === range.to) chain.insertContent(linkText(title || url, url)).run()\n else if (title && title !== selectedText) chain.insertContent(linkText(title, url)).run()\n else chain.setLink({ href: url }).run()\n }\n const handleLinkRemove = () => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n instance.chain().setTextSelection({ from: range.from, to: range.to }).unsetLink().run()\n }\n const handleLinkCancel = () => { linkDialogOpen.value = false }\n const handleRestoreFocus = (event: Event) => {\n keepMovedFocus(event)\n const shouldRestore = restoreEditorFocus && !event.defaultPrevented\n event.preventDefault()\n restoreEditorFocus = false\n linkSelection = null\n const instance = editor.value\n if (shouldRestore && instance && !instance.isDestroyed && !props.disabled) {\n const closingScope = event.target\n requestAnimationFrame(() => {\n if (instance.isDestroyed || !instance.isEditable) return\n const doc = instance.view.dom.ownerDocument\n const active = doc.activeElement\n if (active && active !== doc.body && !instance.view.dom.contains(active)\n && !(closingScope instanceof Node && closingScope.contains(active))) return\n // Check at the actual restore, then focus synchronously: Tiptap's\n // focus command queues another frame that could steal moved focus.\n instance.view.focus()\n })\n }\n }\n\n return () => {\n const { variant, disabled, invalid, ariaInvalid, rows } = props\n const isInvalid = invalid || ariaInvalid\n const minHeight = 20 * rows + 16\n // React renders the slot only for a truthy `toolbarEnd`\n const toolbarEnd = slots.toolbarEnd?.()\n const hasToolbarEnd = flattenSlot(toolbarEnd).length > 0\n const offered = schema.formats\n // Groups of the offered formats, a separator between two of them\n const groups = [\n [\n offered.has(\"bold\") && h(ToolbarButton, {\n tooltip: \"Bold\",\n active: activeMarks.bold,\n disabled,\n icon: BoldIcon,\n onClick: () => editor.value?.chain().focus().toggleBold().run(),\n }),\n offered.has(\"italic\") && h(ToolbarButton, {\n tooltip: \"Italic\",\n active: activeMarks.italic,\n disabled,\n icon: ItalicIcon,\n onClick: () => editor.value?.chain().focus().toggleItalic().run(),\n }),\n ],\n [\n offered.has(\"orderedList\") && h(ToolbarButton, {\n tooltip: \"Numbered list\",\n active: activeMarks.orderedList,\n disabled,\n icon: ListNumbersIcon,\n onClick: () => editor.value?.chain().focus().toggleOrderedList().run(),\n }),\n offered.has(\"bulletList\") && h(ToolbarButton, {\n tooltip: \"Bullet list\",\n active: activeMarks.bulletList,\n disabled,\n icon: ListIcon,\n onClick: () => editor.value?.chain().focus().toggleBulletList().run(),\n }),\n ],\n [\n offered.has(\"link\") && h(ToolbarButton, {\n tooltip: \"Link\",\n active: activeMarks.link,\n disabled,\n icon: LinkIcon,\n onClick: openLinkDialog,\n }),\n ],\n ].map((group) => group.filter((button) => button !== false)).filter((group) => group.length > 0)\n\n return h(\n \"div\",\n {\n \"class\": [s.Container, attrs.class],\n \"data-variant\": variant,\n \"data-focused\": String(focused.value),\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-invalid\": isInvalid ? \"\" : undefined,\n \"onMousedown\": handleContainerMouseDown,\n },\n [\n groups.length || hasToolbarEnd\n ? h(\"div\", { class: s.Toolbar, onMousedown: (e: MouseEvent) => e.preventDefault() }, [\n h(\"div\", { class: s.ToolbarGroup }, [\n ...groups.flatMap((group, index) => [\n ...(index ? [h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" })] : []),\n ...group,\n ]),\n ...(hasToolbarEnd\n ? [\n ...(groups.length ? [h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" })] : []),\n h(\"div\", { class: s.ToolbarEnd }, toolbarEnd),\n ]\n : []),\n ]),\n ])\n : null,\n\n h(\"div\", { class: s.Editor, style: { minHeight: `${minHeight}px` } }, [\n editor.value\n ? h(EditorContent, { editor: editor.value })\n : editorFirstFrame(props.value ?? props.defaultValue ?? \"\", props.placeholder, props.disabled, schema),\n ]),\n\n h(LinkDialog, {\n open: linkDialogOpen.value,\n initialUrl: linkDialogInitial.value.url,\n initialTitle: linkDialogInitial.value.title,\n isEditing: !!linkDialogInitial.value.url,\n disabled,\n onRestoreFocus: handleRestoreFocus,\n onSave: handleLinkSave,\n onRemove: handleLinkRemove,\n onCancel: handleLinkCancel,\n }),\n ],\n )\n }\n },\n})\n\n/**\n * The content before the editor exists, on the server and until it mounts: the markdown as the editor will show it,\n * in its schema and its own boxes (EditorContent's, then ProseMirror's), so the page does not move when ProseMirror\n * takes over, as in React. An empty editor shows its placeholder while it can be edited (`showOnlyWhenEditable`).\n */\nconst editorFirstFrame = (markdown: string, placeholder: string | undefined, disabled: boolean, schema: MarkdownEditorSchema) => {\n const hint = placeholder && !disabled ? placeholder : undefined\n return h(\"div\", null, [\n h(\"div\", { class: [\"tiptap\", s.EditorContent] }, [\n markdown.trim()\n ? renderMarkdown({\n children: markdown,\n remarkPlugins: schema.breaks ? [remarkWithoutHtml, remarkLineBreaks] : [remarkWithoutHtml],\n rehypePlugins: [rehypeEditorSchema(schema, hint)],\n })\n : h(\"p\", { class: hint ? \"is-editor-empty\" : undefined, \"data-placeholder\": hint ? placeholder : undefined }, [h(\"br\")]),\n ]),\n ])\n}\n\n/**\n * Compact rich text editor for markdown, with a formatting toolbar (bold,\n * italic, lists, links). Bind the markdown with `v-model:value`.\n */\nexport const MarkdownEditor = MarkdownEditorComponent\n\nexport type MarkdownEditorProps = InstanceType<typeof MarkdownEditorComponent>[\"$props\"]\n"]}
|
|
@@ -20,6 +20,15 @@ export declare function createMarkdownDirective<T extends ValidDirectiveProps>({
|
|
|
20
20
|
name: string;
|
|
21
21
|
mode: "inline" | "block";
|
|
22
22
|
}): MarkdownDirective<T>;
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Directives become elements only when the Markdown knows them: a `directives` entry or a `components` key, with
|
|
25
|
+
* their attributes minus event handlers, `style` and `srcdoc`. Any other directive stays what was written: an inline
|
|
26
|
+
* or leaf one its source text, a container one its content in a plain `div`. Text from elsewhere (a server, a user)
|
|
27
|
+
* can't make an element of its choosing with attributes of its choosing.
|
|
28
|
+
*/
|
|
29
|
+
export declare function markdownRemarkDirective(options?: {
|
|
30
|
+
names?: Iterable<string>;
|
|
31
|
+
}): (tree: any, file?: {
|
|
32
|
+
value?: unknown;
|
|
33
|
+
}) => void;
|
|
25
34
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.1",
|
|
4
4
|
"description": "Plex UI components for Vue 3, built on Reka UI and the shared @plexui/styles CSS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@maskito/core": "5.2.2",
|
|
78
78
|
"@maskito/kit": "5.2.2",
|
|
79
79
|
"@maskito/vue": "5.2.2",
|
|
80
|
-
"@plexui/styles": "^0.16.
|
|
80
|
+
"@plexui/styles": "^0.16.6",
|
|
81
81
|
"@tanstack/table-core": "8.21.3",
|
|
82
82
|
"@tanstack/vue-table": "8.21.3",
|
|
83
83
|
"@tiptap/core": "3.21.0",
|