@lapismd/mira 0.0.5 → 0.1.0
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/CHANGELOG.md +30 -0
- package/dist/extensions/index.d.ts +12 -7
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +13 -3
- package/dist/extensions/inline-links.d.ts +8 -0
- package/dist/extensions/inline-links.d.ts.map +1 -0
- package/dist/extensions/inline-links.js +120 -0
- package/dist/extensions/markdown-editing.d.ts +32 -0
- package/dist/extensions/markdown-editing.d.ts.map +1 -0
- package/dist/extensions/markdown-editing.js +1 -0
- package/dist/internal/codemirror/base/index.d.ts.map +1 -1
- package/dist/internal/codemirror/base/index.js +3 -0
- package/dist/internal/codemirror/markdown/index.d.ts.map +1 -1
- package/dist/internal/codemirror/markdown/index.js +2 -1
- package/dist/internal/codemirror/rich/block-controls.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/block-controls.js +2 -0
- package/dist/internal/codemirror/rich/block-gutter-accessibility.d.ts +15 -0
- package/dist/internal/codemirror/rich/block-gutter-accessibility.d.ts.map +1 -0
- package/dist/internal/codemirror/rich/block-gutter-accessibility.js +67 -0
- package/dist/internal/codemirror/rich/index.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/index.js +43 -9
- package/dist/internal/codemirror/rich/utils/images.d.ts +6 -3
- package/dist/internal/codemirror/rich/utils/images.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/utils/images.js +16 -29
- package/dist/internal/codemirror/rich/utils/references.d.ts +15 -0
- package/dist/internal/codemirror/rich/utils/references.d.ts.map +1 -0
- package/dist/internal/codemirror/rich/utils/references.js +86 -0
- package/dist/internal/codemirror/rich/widgets/preview-widgets.d.ts +3 -0
- package/dist/internal/codemirror/rich/widgets/preview-widgets.d.ts.map +1 -1
- package/dist/internal/codemirror/rich/widgets/preview-widgets.js +31 -3
- package/dist/internal/inline-links/icons.d.ts +115 -0
- package/dist/internal/inline-links/icons.d.ts.map +1 -0
- package/dist/internal/inline-links/icons.js +148 -0
- package/dist/internal/inline-links/live-preview.d.ts +5 -0
- package/dist/internal/inline-links/live-preview.d.ts.map +1 -0
- package/dist/internal/inline-links/live-preview.js +135 -0
- package/dist/internal/inline-links/registry.d.ts +44 -0
- package/dist/internal/inline-links/registry.d.ts.map +1 -0
- package/dist/internal/inline-links/registry.js +153 -0
- package/dist/mira.svelte.d.ts +1 -1
- package/dist/preview/asset-url-lease.d.ts +6 -0
- package/dist/preview/asset-url-lease.d.ts.map +1 -0
- package/dist/preview/asset-url-lease.js +28 -0
- package/dist/preview/components/embed.svelte +10 -5
- package/dist/preview/components/embed.svelte.d.ts.map +1 -1
- package/dist/preview/components/image.svelte +7 -2
- package/dist/preview/components/image.svelte.d.ts.map +1 -1
- package/dist/preview/components/inline-link.svelte +94 -0
- package/dist/preview/components/inline-link.svelte.d.ts +16 -0
- package/dist/preview/components/inline-link.svelte.d.ts.map +1 -0
- package/dist/preview/components/link-destination-tooltip.svelte +63 -0
- package/dist/preview/components/link-destination-tooltip.svelte.d.ts +7 -0
- package/dist/preview/components/link-destination-tooltip.svelte.d.ts.map +1 -0
- package/dist/preview/components/link-site-icon.svelte +39 -0
- package/dist/preview/components/link-site-icon.svelte.d.ts +10 -0
- package/dist/preview/components/link-site-icon.svelte.d.ts.map +1 -0
- package/dist/preview/components/link.svelte +19 -9
- package/dist/preview/components/link.svelte.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/editable-markdown-surface.svelte +6 -1
- package/dist/preview/editable-markdown-preview/editable-markdown-surface.svelte.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/editing-session.d.ts +2 -0
- package/dist/preview/editable-markdown-preview/editing-session.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/editing-session.js +59 -6
- package/dist/preview/editable-markdown-preview/serialized-writer.d.ts +6 -8
- package/dist/preview/editable-markdown-preview/serialized-writer.d.ts.map +1 -1
- package/dist/preview/editable-markdown-preview/serialized-writer.js +76 -6
- package/dist/preview/index.d.ts +2 -0
- package/dist/preview/index.d.ts.map +1 -1
- package/dist/preview/index.js +2 -0
- package/dist/preview/markdown-preview.svelte +11 -0
- package/dist/preview/markdown-preview.svelte.d.ts.map +1 -1
- package/dist/preview/renderer/utils.js +0 -2
- package/dist/preview/styles/inline-links.css +38 -0
- package/dist/preview/styles/links-embeds-tags.css +2 -2
- package/dist/preview/styles/mermaid-highlight.css +4 -3
- package/dist/preview/styles/references.css +72 -0
- package/dist/preview/styles.css +2 -0
- package/dist/tables/editor-column.svelte +20 -7
- package/dist/tables/editor-column.svelte.d.ts +2 -0
- package/dist/tables/editor-column.svelte.d.ts.map +1 -1
- package/dist/tables/editor-table.svelte +4 -0
- package/dist/tables/editor-table.svelte.d.ts +2 -0
- package/dist/tables/editor-table.svelte.d.ts.map +1 -1
- package/dist/tables/grid-editor-column.svelte +6 -2
- package/dist/tables/grid-editor-column.svelte.d.ts +2 -0
- package/dist/tables/grid-editor-column.svelte.d.ts.map +1 -1
- package/dist/tables/grid-editor-table.svelte +4 -0
- package/dist/tables/grid-editor-table.svelte.d.ts +2 -0
- package/dist/tables/grid-editor-table.svelte.d.ts.map +1 -1
- package/dist/tables/index.d.ts +1 -0
- package/dist/tables/index.d.ts.map +1 -1
- package/dist/tables/index.js +1 -0
- package/dist/tables/markdown-table-data-cell.svelte +4 -0
- package/dist/tables/markdown-table-data-cell.svelte.d.ts +2 -0
- package/dist/tables/markdown-table-data-cell.svelte.d.ts.map +1 -1
- package/dist/tables/table-reader.svelte +101 -0
- package/dist/tables/table-reader.svelte.d.ts +21 -0
- package/dist/tables/table-reader.svelte.d.ts.map +1 -0
- package/dist/tables/types.d.ts +2 -0
- package/dist/tables/types.d.ts.map +1 -1
- package/dist/tables/widgets/grid-table-widget.d.ts +1 -1
- package/dist/tables/widgets/grid-table-widget.d.ts.map +1 -1
- package/dist/tables/widgets/grid-table-widget.js +5 -2
- package/dist/tables/widgets/lifecycle.d.ts +4 -0
- package/dist/tables/widgets/lifecycle.d.ts.map +1 -0
- package/dist/tables/widgets/lifecycle.js +13 -0
- package/dist/tables/widgets/pipe-table-widget.d.ts +1 -1
- package/dist/tables/widgets/pipe-table-widget.d.ts.map +1 -1
- package/dist/tables/widgets/pipe-table-widget.js +5 -2
- package/dist/ui/context-menu/context-menu-radio-group.svelte.d.ts +1 -1
- package/dist/ui/dropdown-menu/dropdown-menu-radio-group.svelte.d.ts +1 -1
- package/dist/ui/toolbar/toolbar-group.svelte.d.ts +1 -1
- package/inline-links-NOTICE.md +31 -0
- package/package.json +2 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Simple Icons 16.0.0, except Slack 15.0.0 (CC0-1.0).
|
|
2
|
+
// Provenance and license are shipped in inline-links-NOTICE.md.
|
|
3
|
+
export const bundledLinkIcons = {
|
|
4
|
+
github: {
|
|
5
|
+
name: "GitHub",
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
paths: [
|
|
8
|
+
{
|
|
9
|
+
d: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12",
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
gitlab: {
|
|
14
|
+
name: "GitLab",
|
|
15
|
+
viewBox: "0 0 24 24",
|
|
16
|
+
paths: [
|
|
17
|
+
{
|
|
18
|
+
d: "m23.6004 9.5927-.0337-.0862L20.3.9814a.851.851 0 0 0-.3362-.405.8748.8748 0 0 0-.9997.0539.8748.8748 0 0 0-.29.4399l-2.2055 6.748H7.5375l-2.2057-6.748a.8573.8573 0 0 0-.29-.4412.8748.8748 0 0 0-.9997-.0537.8585.8585 0 0 0-.3362.4049L.4332 9.5015l-.0325.0862a6.0657 6.0657 0 0 0 2.0119 7.0105l.0113.0087.03.0213 4.976 3.7264 2.462 1.8633 1.4995 1.1321a1.0085 1.0085 0 0 0 1.2197 0l1.4995-1.1321 2.4619-1.8633 5.006-3.7489.0125-.01a6.0682 6.0682 0 0 0 2.0094-7.003z",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
forgejo: {
|
|
23
|
+
name: "Forgejo",
|
|
24
|
+
viewBox: "0 0 24 24",
|
|
25
|
+
paths: [
|
|
26
|
+
{
|
|
27
|
+
d: "M16.7773 0c1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.1175a7.0759 7.0759 0 0 1 4.148-1.4205l.1176-.001 1.3385.0002c.4973-.8827 1.4434-1.4788 2.5288-1.4788 1.6018 0 2.9004 1.2986 2.9004 2.9005s-1.2986 2.9004-2.9004 2.9004c-1.0854 0-2.0315-.596-2.5288-1.4787H12.91c-2.3322 0-4.2272 1.8718-4.2649 4.195l-.0007 2.319c.8827.4973 1.4788 1.4434 1.4788 2.5287 0 1.602-1.2986 2.9005-2.9005 2.9005-1.6018 0-2.9004-1.2986-2.9004-2.9005 0-1.0853.596-2.0314 1.4788-2.5287l-.0002-9.9831c0-3.887 3.1195-7.0453 6.9915-7.108l.1176-.001h1.3385C14.7458.5962 15.692 0 16.7773 0ZM7.2227 19.9052c-.6596 0-1.1943.5347-1.1943 1.1943s.5347 1.1943 1.1943 1.1943 1.1944-.5347 1.1944-1.1943-.5348-1.1943-1.1944-1.1943Zm9.5546-10.4644c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Zm0-7.7346c-.6596 0-1.1944.5347-1.1944 1.1943s.5348 1.1943 1.1944 1.1943c.6596 0 1.1943-.5347 1.1943-1.1943s-.5347-1.1943-1.1943-1.1943Z",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
codeberg: {
|
|
32
|
+
name: "Codeberg",
|
|
33
|
+
viewBox: "0 0 24 24",
|
|
34
|
+
paths: [
|
|
35
|
+
{
|
|
36
|
+
d: "M11.999.747A11.974 11.974 0 0 0 0 12.75c0 2.254.635 4.465 1.833 6.376L11.837 6.19c.072-.092.251-.092.323 0l4.178 5.402h-2.992l.065.239h3.113l.882 1.138h-3.674l.103.374h3.86l.777 1.003h-4.358l.135.483h4.593l.695.894h-5.038l.165.589h5.326l.609.785h-5.717l.182.65h6.038l.562.727h-6.397l.183.65h6.717A12.003 12.003 0 0 0 24 12.75 11.977 11.977 0 0 0 11.999.747zm3.654 19.104.182.65h5.326c.173-.204.353-.433.513-.65zm.385 1.377.18.65h3.563c.233-.198.485-.428.712-.65zm.383 1.377.182.648h1.203c.356-.204.685-.412 1.042-.648zz",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
bitbucket: {
|
|
41
|
+
name: "Bitbucket",
|
|
42
|
+
viewBox: "0 0 24 24",
|
|
43
|
+
paths: [
|
|
44
|
+
{
|
|
45
|
+
d: "M.778 1.213a.768.768 0 00-.768.892l3.263 19.81c.084.5.515.868 1.022.873H19.95a.772.772 0 00.77-.646l3.27-20.03a.768.768 0 00-.768-.891zM14.52 15.53H9.522L8.17 8.466h7.561z",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
facebook: {
|
|
50
|
+
name: "Facebook",
|
|
51
|
+
viewBox: "0 0 24 24",
|
|
52
|
+
paths: [
|
|
53
|
+
{
|
|
54
|
+
d: "M9.101 23.691v-7.98H6.627v-3.667h2.474v-1.58c0-4.085 1.848-5.978 5.858-5.978.401 0 .955.042 1.468.103a8.68 8.68 0 0 1 1.141.195v3.325a8.623 8.623 0 0 0-.653-.036 26.805 26.805 0 0 0-.733-.009c-.707 0-1.259.096-1.675.309a1.686 1.686 0 0 0-.679.622c-.258.42-.374.995-.374 1.752v1.297h3.919l-.386 2.103-.287 1.564h-3.246v8.245C19.396 23.238 24 18.179 24 12.044c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.628 3.874 10.35 9.101 11.647Z",
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
x: {
|
|
59
|
+
name: "X",
|
|
60
|
+
viewBox: "0 0 24 24",
|
|
61
|
+
paths: [
|
|
62
|
+
{
|
|
63
|
+
d: "M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
google: {
|
|
68
|
+
name: "Google",
|
|
69
|
+
viewBox: "0 0 24 24",
|
|
70
|
+
paths: [
|
|
71
|
+
{
|
|
72
|
+
d: "M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
slack: {
|
|
77
|
+
name: "Slack",
|
|
78
|
+
viewBox: "0 0 24 24",
|
|
79
|
+
paths: [
|
|
80
|
+
{
|
|
81
|
+
d: "M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
linear: {
|
|
86
|
+
name: "Linear",
|
|
87
|
+
viewBox: "0 0 24 24",
|
|
88
|
+
paths: [
|
|
89
|
+
{
|
|
90
|
+
d: "M2.886 4.18A11.982 11.982 0 0 1 11.99 0C18.624 0 24 5.376 24 12.009c0 3.64-1.62 6.903-4.18 9.105L2.887 4.18ZM1.817 5.626l16.556 16.556c-.524.33-1.075.62-1.65.866L.951 7.277c.247-.575.537-1.126.866-1.65ZM.322 9.163l14.515 14.515c-.71.172-1.443.282-2.195.322L0 11.358a12 12 0 0 1 .322-2.195Zm-.17 4.862 9.823 9.824a12.02 12.02 0 0 1-9.824-9.824Z",
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
notion: {
|
|
95
|
+
name: "Notion",
|
|
96
|
+
viewBox: "0 0 24 24",
|
|
97
|
+
paths: [
|
|
98
|
+
{
|
|
99
|
+
d: "M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.01 2.295c-.466.046-.56.28-.374.466zm.793 3.08v13.904c0 .747.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.354c0-.606-.233-.933-.748-.887l-15.177.887c-.56.047-.747.327-.747.933zm14.337.745c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 19s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933zM1.936 1.035l13.31-.98c1.634-.14 2.055-.047 3.082.7l4.249 2.986c.7.513.934.653.934 1.213v16.378c0 1.026-.373 1.634-1.68 1.726l-15.458.934c-.98.047-1.448-.093-1.962-.747l-3.129-4.06c-.56-.747-.793-1.306-.793-1.96V2.667c0-.839.374-1.54 1.447-1.632z",
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
figma: {
|
|
104
|
+
name: "Figma",
|
|
105
|
+
viewBox: "0 0 24 24",
|
|
106
|
+
paths: [
|
|
107
|
+
{
|
|
108
|
+
d: "M15.852 8.981h-4.588V0h4.588c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.491-4.49 4.491zM12.735 7.51h3.117c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-3.117V7.51zm0 1.471H8.148c-2.476 0-4.49-2.014-4.49-4.49S5.672 0 8.148 0h4.588v8.981zm-4.587-7.51c-1.665 0-3.019 1.355-3.019 3.019s1.354 3.02 3.019 3.02h3.117V1.471H8.148zm4.587 15.019H8.148c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h4.588v8.98zM8.148 8.981c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h3.117V8.981H8.148zM8.172 24c-2.489 0-4.515-2.014-4.515-4.49s2.014-4.49 4.49-4.49h4.588v4.441c0 2.503-2.047 4.539-4.563 4.539zm-.024-7.51a3.023 3.023 0 0 0-3.019 3.019c0 1.665 1.365 3.019 3.044 3.019 1.705 0 3.093-1.376 3.093-3.068v-2.97H8.148zm7.704 0h-.098c-2.476 0-4.49-2.014-4.49-4.49s2.014-4.49 4.49-4.49h.098c2.476 0 4.49 2.014 4.49 4.49s-2.014 4.49-4.49 4.49zm-.097-7.509c-1.665 0-3.019 1.355-3.019 3.019s1.355 3.019 3.019 3.019h.098c1.665 0 3.019-1.355 3.019-3.019s-1.355-3.019-3.019-3.019h-.098z",
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
youtube: {
|
|
113
|
+
name: "YouTube",
|
|
114
|
+
viewBox: "0 0 24 24",
|
|
115
|
+
paths: [
|
|
116
|
+
{
|
|
117
|
+
d: "M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
discord: {
|
|
122
|
+
name: "Discord",
|
|
123
|
+
viewBox: "0 0 24 24",
|
|
124
|
+
paths: [
|
|
125
|
+
{
|
|
126
|
+
d: "M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z",
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
reddit: {
|
|
131
|
+
name: "Reddit",
|
|
132
|
+
viewBox: "0 0 24 24",
|
|
133
|
+
paths: [
|
|
134
|
+
{
|
|
135
|
+
d: "M12 0C5.373 0 0 5.373 0 12c0 3.314 1.343 6.314 3.515 8.485l-2.286 2.286C.775 23.225 1.097 24 1.738 24H12c6.627 0 12-5.373 12-12S18.627 0 12 0Zm4.388 3.199c1.104 0 1.999.895 1.999 1.999 0 1.105-.895 2-1.999 2-.946 0-1.739-.657-1.947-1.539v.002c-1.147.162-2.032 1.15-2.032 2.341v.007c1.776.067 3.4.567 4.686 1.363.473-.363 1.064-.58 1.707-.58 1.547 0 2.802 1.254 2.802 2.802 0 1.117-.655 2.081-1.601 2.531-.088 3.256-3.637 5.876-7.997 5.876-4.361 0-7.905-2.617-7.998-5.87-.954-.447-1.614-1.415-1.614-2.538 0-1.548 1.255-2.802 2.803-2.802.645 0 1.239.218 1.712.585 1.275-.79 2.881-1.291 4.64-1.365v-.01c0-1.663 1.263-3.034 2.88-3.207.188-.911.993-1.595 1.959-1.595Zm-8.085 8.376c-.784 0-1.459.78-1.506 1.797-.047 1.016.64 1.429 1.426 1.429.786 0 1.371-.369 1.418-1.385.047-1.017-.553-1.841-1.338-1.841Zm7.406 0c-.786 0-1.385.824-1.338 1.841.047 1.017.634 1.385 1.418 1.385.785 0 1.473-.413 1.426-1.429-.046-1.017-.721-1.797-1.506-1.797Zm-3.703 4.013c-.974 0-1.907.048-2.77.135-.147.015-.241.168-.183.305.483 1.154 1.622 1.964 2.953 1.964 1.33 0 2.47-.81 2.953-1.964.057-.137-.037-.29-.184-.305-.863-.087-1.795-.135-2.769-.135Z",
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
stackoverflow: {
|
|
140
|
+
name: "Stack Overflow",
|
|
141
|
+
viewBox: "0 0 24 24",
|
|
142
|
+
paths: [
|
|
143
|
+
{
|
|
144
|
+
d: "M15.725 0l-1.72 1.277 6.39 8.588 1.716-1.277L15.725 0zm-3.94 3.418l-1.369 1.644 8.225 6.85 1.369-1.644-8.225-6.85zm-3.15 4.465l-.905 1.94 9.702 4.517.904-1.94-9.701-4.517zm-1.85 4.86l-.44 2.093 10.473 2.201.44-2.092-10.473-2.203zM1.89 15.47V24h19.19v-8.53h-2.133v6.397H4.021v-6.396H1.89zm4.265 2.133v2.13h10.66v-2.13H6.154Z",
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Extension } from "@codemirror/state";
|
|
2
|
+
import type { MiraExtensionContext } from "../../extensions";
|
|
3
|
+
import { type MiraLinkIconRegistry } from "./registry";
|
|
4
|
+
export declare function inlineLinkLivePreview(registry: MiraLinkIconRegistry, context: MiraExtensionContext): Extension;
|
|
5
|
+
//# sourceMappingURL=live-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-preview.d.ts","sourceRoot":"","sources":["../../../src/internal/inline-links/live-preview.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,SAAS,EAEf,MAAM,mBAAmB,CAAC;AAY3B,OAAO,KAAK,EAAiB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAwD3E,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,EAAE,oBAAoB,GAC5B,SAAS,CAmGX"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { syntaxTree } from "@codemirror/language";
|
|
2
|
+
import { StateField, } from "@codemirror/state";
|
|
3
|
+
import { Decoration, EditorView, WidgetType, } from "@codemirror/view";
|
|
4
|
+
import { unified } from "unified";
|
|
5
|
+
import remarkParse from "remark-parse";
|
|
6
|
+
import remarkGfm from "remark-gfm";
|
|
7
|
+
import { inlineLinksExtension } from "../../extensions/inline-links";
|
|
8
|
+
import { parseInlineLinkUrl } from "./registry";
|
|
9
|
+
const parser = unified().use(remarkParse).use(remarkGfm);
|
|
10
|
+
// Keep the bundled extension entry point independent of eager preview evaluation.
|
|
11
|
+
// The existing widget owns source selection, formatting and mount teardown.
|
|
12
|
+
class LinkPreviewWidget extends WidgetType {
|
|
13
|
+
config;
|
|
14
|
+
mounts = new Map();
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super();
|
|
17
|
+
this.config = config;
|
|
18
|
+
}
|
|
19
|
+
eq(other) {
|
|
20
|
+
return (this.config.from === other.config.from &&
|
|
21
|
+
this.config.to === other.config.to &&
|
|
22
|
+
this.config.markdown === other.config.markdown &&
|
|
23
|
+
this.config.options.extensions === other.config.options.extensions);
|
|
24
|
+
}
|
|
25
|
+
toDOM(view) {
|
|
26
|
+
const root = view.dom.ownerDocument.createElement("span");
|
|
27
|
+
root.textContent = this.config.markdown;
|
|
28
|
+
const state = { disposed: false };
|
|
29
|
+
this.mounts.set(root, state);
|
|
30
|
+
void import("../codemirror/rich/widgets/preview-widgets").then(({ InlineMarkdownWidget }) => {
|
|
31
|
+
if (state.disposed)
|
|
32
|
+
return;
|
|
33
|
+
state.widget = new InlineMarkdownWidget(this.config);
|
|
34
|
+
state.dom = state.widget.toDOM(view);
|
|
35
|
+
root.replaceChildren(state.dom);
|
|
36
|
+
});
|
|
37
|
+
return root;
|
|
38
|
+
}
|
|
39
|
+
destroy(root) {
|
|
40
|
+
const state = this.mounts.get(root);
|
|
41
|
+
if (state) {
|
|
42
|
+
state.disposed = true;
|
|
43
|
+
if (state.dom)
|
|
44
|
+
state.widget?.destroy(state.dom);
|
|
45
|
+
}
|
|
46
|
+
this.mounts.delete(root);
|
|
47
|
+
}
|
|
48
|
+
ignoreEvent() {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function inlineLinkLivePreview(registry, context) {
|
|
53
|
+
const extensions = context.extensions
|
|
54
|
+
? [...context.extensions]
|
|
55
|
+
: [inlineLinksExtension({ registry })];
|
|
56
|
+
const readonly = context.readonly;
|
|
57
|
+
return StateField.define({
|
|
58
|
+
create(state) {
|
|
59
|
+
const tree = parser.parse(state.doc.toString());
|
|
60
|
+
return { tree, decorations: build(state, tree) };
|
|
61
|
+
},
|
|
62
|
+
update(value, transaction) {
|
|
63
|
+
if (!transaction.docChanged && !transaction.selection)
|
|
64
|
+
return value;
|
|
65
|
+
const tree = transaction.docChanged
|
|
66
|
+
? parser.parse(transaction.state.doc.toString())
|
|
67
|
+
: value.tree;
|
|
68
|
+
return { tree, decorations: build(transaction.state, tree) };
|
|
69
|
+
},
|
|
70
|
+
provide: (field) => EditorView.decorations.from(field, (value) => value.decorations),
|
|
71
|
+
});
|
|
72
|
+
function build(state, tree) {
|
|
73
|
+
const ranges = [];
|
|
74
|
+
const definitions = new Map();
|
|
75
|
+
function collect(node) {
|
|
76
|
+
if (node.type === "definition")
|
|
77
|
+
definitions.set(node.identifier.toUpperCase(), node);
|
|
78
|
+
if ("children" in node)
|
|
79
|
+
for (const child of node.children)
|
|
80
|
+
collect(child);
|
|
81
|
+
}
|
|
82
|
+
collect(tree);
|
|
83
|
+
function walk(node) {
|
|
84
|
+
// Delegate nested rendered blocks to Mira's existing preview widgets.
|
|
85
|
+
if ([
|
|
86
|
+
"blockquote",
|
|
87
|
+
"table",
|
|
88
|
+
"html",
|
|
89
|
+
"code",
|
|
90
|
+
"inlineCode",
|
|
91
|
+
"image",
|
|
92
|
+
"imageReference",
|
|
93
|
+
].includes(node.type))
|
|
94
|
+
return;
|
|
95
|
+
if (node.type === "link" || node.type === "linkReference") {
|
|
96
|
+
const from = node.position?.start.offset;
|
|
97
|
+
const to = node.position?.end.offset;
|
|
98
|
+
const definition = node.type === "linkReference"
|
|
99
|
+
? definitions.get(node.identifier.toUpperCase())
|
|
100
|
+
: undefined;
|
|
101
|
+
const href = node.type === "link" ? node.url : definition?.url;
|
|
102
|
+
if (from === undefined ||
|
|
103
|
+
to === undefined ||
|
|
104
|
+
!href ||
|
|
105
|
+
!parseInlineLinkUrl(href))
|
|
106
|
+
return;
|
|
107
|
+
if (state.selection.ranges.some((range) => range.from <= to && range.to >= from))
|
|
108
|
+
return;
|
|
109
|
+
for (let parent = syntaxTree(state).resolveInner(from, 1); parent; parent = parent.parent) {
|
|
110
|
+
if (parent.name === "GridTable")
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
let markdown = state.sliceDoc(from, to);
|
|
114
|
+
if (definition?.position)
|
|
115
|
+
markdown +=
|
|
116
|
+
"\n\n" +
|
|
117
|
+
state.sliceDoc(definition.position.start.offset, definition.position.end.offset);
|
|
118
|
+
ranges.push(Decoration.replace({
|
|
119
|
+
widget: new LinkPreviewWidget({
|
|
120
|
+
from,
|
|
121
|
+
to,
|
|
122
|
+
markdown,
|
|
123
|
+
options: { extensions, readonly, sourcePath: context.sourcePath },
|
|
124
|
+
}),
|
|
125
|
+
}).range(from, to));
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if ("children" in node)
|
|
129
|
+
for (const child of node.children)
|
|
130
|
+
walk(child);
|
|
131
|
+
}
|
|
132
|
+
walk(tree);
|
|
133
|
+
return Decoration.set(ranges, true);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { bundledLinkIcons } from "./icons";
|
|
2
|
+
export type MiraLinkIconPath = Readonly<{
|
|
3
|
+
d: string;
|
|
4
|
+
fill?: "currentColor" | "none";
|
|
5
|
+
stroke?: "currentColor" | "none";
|
|
6
|
+
strokeWidth?: number;
|
|
7
|
+
strokeLinecap?: "butt" | "round" | "square";
|
|
8
|
+
strokeLinejoin?: "miter" | "round" | "bevel";
|
|
9
|
+
fillRule?: "nonzero" | "evenodd";
|
|
10
|
+
}>;
|
|
11
|
+
export type MiraLinkIconDefinition = Readonly<{
|
|
12
|
+
name?: string;
|
|
13
|
+
viewBox?: string;
|
|
14
|
+
paths: readonly MiraLinkIconPath[];
|
|
15
|
+
}>;
|
|
16
|
+
export type MiraResolvedLinkIcon = Readonly<{
|
|
17
|
+
id: string;
|
|
18
|
+
icon: MiraLinkIconDefinition | null;
|
|
19
|
+
}>;
|
|
20
|
+
export type MiraLinkIconRegistry = Readonly<{
|
|
21
|
+
resolve(href: string): MiraResolvedLinkIcon | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export type MiraLinkIconRegistryOptions = {
|
|
24
|
+
defaults?: boolean;
|
|
25
|
+
icons?: Readonly<Record<string, MiraLinkIconDefinition | null>>;
|
|
26
|
+
hosts?: Readonly<Record<string, string | null>>;
|
|
27
|
+
/** Matches descendants only, on a dot boundary. Does not match the root host. */
|
|
28
|
+
subdomains?: Readonly<Record<string, string | null>>;
|
|
29
|
+
fallback?: MiraLinkIconDefinition | null;
|
|
30
|
+
};
|
|
31
|
+
export declare const defaultMiraLinkIcons: Readonly<Record<keyof typeof bundledLinkIcons, MiraLinkIconDefinition>>;
|
|
32
|
+
export declare const defaultMiraLinkFallbackIcon: Readonly<{
|
|
33
|
+
name?: string;
|
|
34
|
+
viewBox?: string;
|
|
35
|
+
paths: readonly MiraLinkIconPath[];
|
|
36
|
+
}>;
|
|
37
|
+
export declare const defaultMiraLinkHosts: Readonly<Record<string, string>>;
|
|
38
|
+
/** Parse only explicit safe web destinations; never resolve or fetch a URL. */
|
|
39
|
+
export declare function parseInlineLinkUrl(href: string): URL | undefined;
|
|
40
|
+
export declare function createLinkIconRegistry(options?: MiraLinkIconRegistryOptions): MiraLinkIconRegistry;
|
|
41
|
+
export declare const defaultMiraLinkIconRegistry: Readonly<{
|
|
42
|
+
resolve(href: string): MiraResolvedLinkIcon | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/internal/inline-links/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAC/B,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAC7C,QAAQ,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC,CAAC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAC;CACzD,CAAC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC,CAAC,CAAC;IAChE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAChD,iFAAiF;IACjF,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAC1C,CAAC;AA+BF,eAAO,MAAM,oBAAoB,EAO5B,QAAQ,CAAC,MAAM,CAAC,MAAM,OAAO,gBAAgB,EAAE,sBAAsB,CAAC,CAAC,CAAC;AAE7E,eAAO,MAAM,2BAA2B;WA7D/B,MAAM;cACH,MAAM;WACT,SAAS,gBAAgB,EAAE;EA6ElC,CAAC;AAEH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiC9D,CAAC;AAEL,+EAA+E;AAC/E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,CAYhE;AAmBD,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,2BAAgC,GACxC,oBAAoB,CA4DtB;AAED,eAAO,MAAM,2BAA2B;kBAzMxB,MAAM,GAAG,oBAAoB,GAAG,SAAS;EAyMU,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { bundledLinkIcons } from "./icons";
|
|
2
|
+
function freezeIcon(icon) {
|
|
3
|
+
return Object.freeze({
|
|
4
|
+
name: icon.name,
|
|
5
|
+
viewBox: icon.viewBox ?? "0 0 24 24",
|
|
6
|
+
paths: Object.freeze(icon.paths.map((path) => {
|
|
7
|
+
for (const color of [path.fill, path.stroke])
|
|
8
|
+
if (color !== undefined &&
|
|
9
|
+
color !== "none" &&
|
|
10
|
+
color !== "currentColor")
|
|
11
|
+
throw new TypeError("Link icons accept local currentColor geometry only");
|
|
12
|
+
return Object.freeze({
|
|
13
|
+
d: path.d,
|
|
14
|
+
fill: path.fill,
|
|
15
|
+
stroke: path.stroke,
|
|
16
|
+
strokeWidth: path.strokeWidth,
|
|
17
|
+
strokeLinecap: path.strokeLinecap,
|
|
18
|
+
strokeLinejoin: path.strokeLinejoin,
|
|
19
|
+
fillRule: path.fillRule,
|
|
20
|
+
});
|
|
21
|
+
})),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export const defaultMiraLinkIcons = Object.freeze(Object.fromEntries(Object.entries(bundledLinkIcons).map(([id, icon]) => [
|
|
25
|
+
id,
|
|
26
|
+
freezeIcon(icon),
|
|
27
|
+
])));
|
|
28
|
+
export const defaultMiraLinkFallbackIcon = freezeIcon({
|
|
29
|
+
name: "Link",
|
|
30
|
+
paths: [
|
|
31
|
+
{
|
|
32
|
+
d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",
|
|
33
|
+
fill: "none",
|
|
34
|
+
stroke: "currentColor",
|
|
35
|
+
strokeWidth: 2,
|
|
36
|
+
strokeLinecap: "round",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",
|
|
40
|
+
fill: "none",
|
|
41
|
+
stroke: "currentColor",
|
|
42
|
+
strokeWidth: 2,
|
|
43
|
+
strokeLinecap: "round",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
export const defaultMiraLinkHosts = Object.freeze({
|
|
48
|
+
"github.com": "github",
|
|
49
|
+
"gitlab.com": "gitlab",
|
|
50
|
+
"forgejo.org": "forgejo",
|
|
51
|
+
"code.forgejo.org": "forgejo",
|
|
52
|
+
"codeberg.org": "codeberg",
|
|
53
|
+
"bitbucket.org": "bitbucket",
|
|
54
|
+
"facebook.com": "facebook",
|
|
55
|
+
"m.facebook.com": "facebook",
|
|
56
|
+
"fb.com": "facebook",
|
|
57
|
+
"x.com": "x",
|
|
58
|
+
"twitter.com": "x",
|
|
59
|
+
"mobile.twitter.com": "x",
|
|
60
|
+
"google.com": "google",
|
|
61
|
+
"docs.google.com": "google",
|
|
62
|
+
"drive.google.com": "google",
|
|
63
|
+
"mail.google.com": "google",
|
|
64
|
+
"calendar.google.com": "google",
|
|
65
|
+
"meet.google.com": "google",
|
|
66
|
+
"slack.com": "slack",
|
|
67
|
+
"linear.app": "linear",
|
|
68
|
+
"notion.so": "notion",
|
|
69
|
+
"notion.site": "notion",
|
|
70
|
+
"figma.com": "figma",
|
|
71
|
+
"youtube.com": "youtube",
|
|
72
|
+
"m.youtube.com": "youtube",
|
|
73
|
+
"youtu.be": "youtube",
|
|
74
|
+
"discord.com": "discord",
|
|
75
|
+
"discord.gg": "discord",
|
|
76
|
+
"reddit.com": "reddit",
|
|
77
|
+
"old.reddit.com": "reddit",
|
|
78
|
+
"stackoverflow.com": "stackoverflow",
|
|
79
|
+
});
|
|
80
|
+
/** Parse only explicit safe web destinations; never resolve or fetch a URL. */
|
|
81
|
+
export function parseInlineLinkUrl(href) {
|
|
82
|
+
try {
|
|
83
|
+
const url = new URL(href);
|
|
84
|
+
if ((url.protocol === "http:" || url.protocol === "https:") &&
|
|
85
|
+
!url.username &&
|
|
86
|
+
!url.password)
|
|
87
|
+
return url;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
/* Non-web and relative links retain their existing renderer. */
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function normalizeHost(host) {
|
|
94
|
+
const url = new URL(`https://${host}`);
|
|
95
|
+
if (!host ||
|
|
96
|
+
url.pathname !== "/" ||
|
|
97
|
+
url.search ||
|
|
98
|
+
url.hash ||
|
|
99
|
+
url.port ||
|
|
100
|
+
url.username ||
|
|
101
|
+
url.password ||
|
|
102
|
+
/[\s/\\?#@:]/u.test(host)) {
|
|
103
|
+
throw new TypeError(`Expected a hostname, received ${host}`);
|
|
104
|
+
}
|
|
105
|
+
return url.hostname.toLowerCase().replace(/\.$/u, "");
|
|
106
|
+
}
|
|
107
|
+
export function createLinkIconRegistry(options = {}) {
|
|
108
|
+
const icons = new Map(Object.entries(options.defaults === false ? {} : defaultMiraLinkIcons));
|
|
109
|
+
for (const [id, icon] of Object.entries(options.icons ?? {}))
|
|
110
|
+
icons.set(id, icon === null ? null : freezeIcon(icon));
|
|
111
|
+
const fallback = options.fallback === undefined
|
|
112
|
+
? defaultMiraLinkFallbackIcon
|
|
113
|
+
: options.fallback === null
|
|
114
|
+
? null
|
|
115
|
+
: freezeIcon(options.fallback);
|
|
116
|
+
const hosts = new Map();
|
|
117
|
+
const subdomains = new Map();
|
|
118
|
+
function add(target, entries) {
|
|
119
|
+
for (const [host, id] of Object.entries(entries)) {
|
|
120
|
+
if (id !== null && !icons.has(id))
|
|
121
|
+
throw new TypeError(`Unknown link icon: ${id}`);
|
|
122
|
+
target.set(normalizeHost(host), Object.freeze({
|
|
123
|
+
id: id ?? "disabled",
|
|
124
|
+
icon: id === null ? null : icons.get(id),
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (options.defaults !== false) {
|
|
129
|
+
add(hosts, defaultMiraLinkHosts);
|
|
130
|
+
// Keep www aliases explicit rather than stripping arbitrary host labels.
|
|
131
|
+
add(hosts, Object.fromEntries(Object.entries(defaultMiraLinkHosts).map(([host, id]) => [
|
|
132
|
+
`www.${host}`,
|
|
133
|
+
id,
|
|
134
|
+
])));
|
|
135
|
+
add(subdomains, { "slack.com": "slack" });
|
|
136
|
+
}
|
|
137
|
+
add(hosts, options.hosts ?? {});
|
|
138
|
+
add(subdomains, options.subdomains ?? {});
|
|
139
|
+
const suffixes = [...subdomains].sort(([a], [b]) => b.length - a.length);
|
|
140
|
+
const unknown = Object.freeze({ id: "unknown", icon: fallback });
|
|
141
|
+
return Object.freeze({
|
|
142
|
+
resolve(href) {
|
|
143
|
+
const url = parseInlineLinkUrl(href);
|
|
144
|
+
if (!url)
|
|
145
|
+
return;
|
|
146
|
+
const host = url.hostname.toLowerCase().replace(/\.$/u, "");
|
|
147
|
+
return (hosts.get(host) ??
|
|
148
|
+
suffixes.find(([suffix]) => host.endsWith(`.${suffix}`))?.[1] ??
|
|
149
|
+
unknown);
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
export const defaultMiraLinkIconRegistry = createLinkIconRegistry();
|
package/dist/mira.svelte.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare const Mira: import("svelte").Component<MiraProps, {
|
|
|
17
17
|
insertMarkdown: (markdown: string, selection?: MiraTemplateSelection) => void;
|
|
18
18
|
applyMarkdownAction: (action: MiraMarkdownActionId) => boolean;
|
|
19
19
|
insertImage: () => void;
|
|
20
|
-
}, "
|
|
20
|
+
}, "value" | "mode">;
|
|
21
21
|
type Mira = ReturnType<typeof Mira>;
|
|
22
22
|
export default Mira;
|
|
23
23
|
//# sourceMappingURL=mira.svelte.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MiraFileAdapter, MiraFileRef } from "@lapismd/mira/extensions";
|
|
2
|
+
export declare function createAssetUrlLease(adapter: MiraFileAdapter, file: MiraFileRef): {
|
|
3
|
+
result: Promise<string | null>;
|
|
4
|
+
release(): void;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=asset-url-lease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-url-lease.d.ts","sourceRoot":"","sources":["../../src/preview/asset-url-lease.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE7E,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,WAAW;;;EA0BlB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function createAssetUrlLease(adapter, file) {
|
|
2
|
+
let disposed = false;
|
|
3
|
+
let held = null;
|
|
4
|
+
const result = Promise.resolve()
|
|
5
|
+
.then(() => adapter.readAssetUrl?.(file) ?? null)
|
|
6
|
+
.then((url) => {
|
|
7
|
+
if (disposed) {
|
|
8
|
+
if (url !== null)
|
|
9
|
+
adapter.releaseAssetUrl?.(url);
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
held = url;
|
|
13
|
+
return url;
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
result,
|
|
17
|
+
release() {
|
|
18
|
+
if (disposed)
|
|
19
|
+
return;
|
|
20
|
+
disposed = true;
|
|
21
|
+
if (held !== null) {
|
|
22
|
+
const url = held;
|
|
23
|
+
held = null;
|
|
24
|
+
adapter.releaseAssetUrl?.(url);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
selectMarkdownEmbedFragment,
|
|
11
11
|
} from "../embed-target";
|
|
12
12
|
import EmbeddedMarkdownPreview from "./embedded-markdown-preview.svelte";
|
|
13
|
+
import { createAssetUrlLease } from "../asset-url-lease";
|
|
13
14
|
|
|
14
15
|
type Props = {
|
|
15
16
|
href?: string;
|
|
@@ -43,7 +44,9 @@
|
|
|
43
44
|
|
|
44
45
|
const target = $derived(id || href);
|
|
45
46
|
const activeSourcePath = $derived(sourcePath || markdown.sourcePath);
|
|
46
|
-
const parsedTarget = $derived(
|
|
47
|
+
const parsedTarget = $derived(
|
|
48
|
+
parseMiraFileTarget(target, activeSourcePath, { decodeUri: !id }),
|
|
49
|
+
);
|
|
47
50
|
const imageDetails = $derived(
|
|
48
51
|
parseMiraImageDetails(
|
|
49
52
|
text || label,
|
|
@@ -162,10 +165,11 @@
|
|
|
162
165
|
}
|
|
163
166
|
|
|
164
167
|
let cancelled = false;
|
|
165
|
-
Promise.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
const nextMarkdown = Promise.resolve().then(
|
|
169
|
+
() => adapter.readMarkdown?.(file) ?? null,
|
|
170
|
+
);
|
|
171
|
+
const asset = createAssetUrlLease(adapter, file);
|
|
172
|
+
Promise.all([nextMarkdown, asset.result]).then(
|
|
169
173
|
([nextMarkdown, nextAssetUrl]) => {
|
|
170
174
|
if (!cancelled) {
|
|
171
175
|
if (nextMarkdown !== null) {
|
|
@@ -189,6 +193,7 @@
|
|
|
189
193
|
|
|
190
194
|
return () => {
|
|
191
195
|
cancelled = true;
|
|
196
|
+
asset.release();
|
|
192
197
|
};
|
|
193
198
|
});
|
|
194
199
|
</script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed.svelte.d.ts","sourceRoot":"","sources":["../../../src/preview/components/embed.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"embed.svelte.d.ts","sourceRoot":"","sources":["../../../src/preview/components/embed.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAcpC,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC1B,CAAC;AAmNJ,QAAA,MAAM,KAAK,8CAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import { useMarkdownContext } from "../renderer/context.svelte";
|
|
8
8
|
import { isImageDataUri } from "../remark";
|
|
9
9
|
import { parseMiraImageDetails } from "../embed-target";
|
|
10
|
+
import { createAssetUrlLease } from "../asset-url-lease";
|
|
10
11
|
|
|
11
12
|
type Props = {
|
|
12
13
|
src?: string;
|
|
@@ -24,7 +25,9 @@
|
|
|
24
25
|
let targetRevision = $state(0);
|
|
25
26
|
let contentRevision = $state(0);
|
|
26
27
|
|
|
27
|
-
const target = $derived(
|
|
28
|
+
const target = $derived(
|
|
29
|
+
parseMiraFileTarget(src, markdown.sourcePath, { decodeUri: true }),
|
|
30
|
+
);
|
|
28
31
|
const imageDetails = $derived(parseMiraImageDetails(alt));
|
|
29
32
|
const resolvedAlt = $derived(imageDetails.alt);
|
|
30
33
|
|
|
@@ -108,7 +111,8 @@
|
|
|
108
111
|
contentRevision;
|
|
109
112
|
if (resolvedFile && markdown.fileAdapter?.readAssetUrl) {
|
|
110
113
|
let cancelled = false;
|
|
111
|
-
|
|
114
|
+
const asset = createAssetUrlLease(markdown.fileAdapter, resolvedFile);
|
|
115
|
+
asset.result.then(
|
|
112
116
|
(url) => {
|
|
113
117
|
if (!cancelled) {
|
|
114
118
|
adapterSrc = url ?? null;
|
|
@@ -122,6 +126,7 @@
|
|
|
122
126
|
);
|
|
123
127
|
return () => {
|
|
124
128
|
cancelled = true;
|
|
129
|
+
asset.release();
|
|
125
130
|
};
|
|
126
131
|
}
|
|
127
132
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../src/preview/components/image.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../src/preview/components/image.svelte.ts"],"names":[],"mappings":"AAcE,KAAK,KAAK,GAAG;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAC/B,CAAC;AAqNJ,QAAA,MAAM,KAAK,8CAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|