mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
published alpha library for test
This commit is contained in:
parent
d8f1405a4f
commit
f9d000bf81
1379
frontend/package-lock.json
generated
1379
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
1039
lib/package-lock.json
generated
1039
lib/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -126,7 +126,6 @@
|
||||
"date-fns": "^3.3.1",
|
||||
"leaflet": "^1.9.4",
|
||||
"leaflet.locatecontrol": "^0.79.0",
|
||||
"mdast-util-to-string": "^4.0.0",
|
||||
"prosemirror-markdown": "^1.13.2",
|
||||
"prosemirror-state": "^1.4.3",
|
||||
"radash": "^12.1.0",
|
||||
@ -137,20 +136,13 @@
|
||||
"react-inlinesvg": "^4.2.0",
|
||||
"react-leaflet": "^4.2.1",
|
||||
"react-leaflet-cluster": "^2.1.0",
|
||||
"react-markdown": "^9.0.1",
|
||||
"react-photo-album": "^3.0.2",
|
||||
"react-router-dom": "^6.23.0",
|
||||
"react-toastify": "^9.1.3",
|
||||
"rehype-raw": "^7.0.0",
|
||||
"rehype-sanitize": "^6.0.0",
|
||||
"remark-breaks": "^4.0.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"remark-parse": "^11.0.0",
|
||||
"remove-markdown": "^0.6.2",
|
||||
"tippy.js": "^6.3.7",
|
||||
"tiptap-markdown": "^0.8.10",
|
||||
"unified": "^11.0.5",
|
||||
"unist-util-visit": "^5.0.0",
|
||||
"remark-parse": "^11.0.0",
|
||||
"yet-another-react-lightbox": "^3.21.7"
|
||||
},
|
||||
"imports": {
|
||||
|
||||
@ -177,7 +177,7 @@ export function RichTextEditor({
|
||||
{editor ? (
|
||||
<>
|
||||
{showMenu && !readOnly ? <TextEditorMenu editor={editor} /> : null}
|
||||
<EditorContent editor={editor}/>
|
||||
<EditorContent editor={editor} />
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@ -4,13 +4,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
import Markdown from 'react-markdown'
|
||||
import { Link as RouterLink } from 'react-router-dom'
|
||||
import rehypeRaw from 'rehype-raw'
|
||||
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize'
|
||||
import remarkBreaks from 'remark-breaks'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import { visit } from 'unist-util-visit'
|
||||
|
||||
import { RichTextEditor } from '#components/Input/RichTextEditor/RichTextEditor'
|
||||
import { useAddFilterTag } from '#components/Map/hooks/useFilter'
|
||||
@ -21,7 +15,6 @@ import { fixUrls, mailRegex } from '#utils/ReplaceURLs'
|
||||
|
||||
import type { Item } from '#types/Item'
|
||||
import type { Tag } from '#types/Tag'
|
||||
import type { Root } from 'hast'
|
||||
|
||||
/**
|
||||
* @category Map
|
||||
@ -67,12 +60,6 @@ export const TextView = ({
|
||||
})
|
||||
}
|
||||
|
||||
if (replacedText) {
|
||||
replacedText = replacedText.replace(hashTagRegex, (match) => {
|
||||
return `[${match}](${match})`
|
||||
})
|
||||
}
|
||||
|
||||
const HashTag = ({ children, tag, itemId }: { children: string; tag: Tag; itemId?: string }) => {
|
||||
return (
|
||||
<a
|
||||
@ -191,63 +178,4 @@ function truncateText(text, limit) {
|
||||
}
|
||||
|
||||
return truncated.trim()
|
||||
}
|
||||
|
||||
export const sanitizeSchema = {
|
||||
...defaultSchema,
|
||||
|
||||
tagNames: [...(defaultSchema.tagNames ?? []), 'div', 'iframe'],
|
||||
attributes: {
|
||||
...defaultSchema.attributes,
|
||||
div: [...(defaultSchema.attributes?.div ?? []), 'data-youtube-video'],
|
||||
iframe: [
|
||||
...(defaultSchema.attributes?.iframe ?? []),
|
||||
'src',
|
||||
'width',
|
||||
'height',
|
||||
'allowfullscreen',
|
||||
'autoplay',
|
||||
'disablekbcontrols',
|
||||
'enableiframeapi',
|
||||
'endtime',
|
||||
'ivloadpolicy',
|
||||
'modestbranding',
|
||||
'origin',
|
||||
'playlist',
|
||||
'rel',
|
||||
'start',
|
||||
],
|
||||
img: [...(defaultSchema.attributes?.img ?? []), 'style'],
|
||||
},
|
||||
|
||||
protocols: {
|
||||
...defaultSchema.protocols,
|
||||
src: [...(defaultSchema.protocols?.src ?? []), 'https'],
|
||||
},
|
||||
}
|
||||
|
||||
export function rehypeFilterYouTubeIframes() {
|
||||
return (tree: Root) => {
|
||||
visit(tree, 'element', (node) => {
|
||||
// node ist hier typischerweise ein HAST-Element
|
||||
const el = node
|
||||
|
||||
if (el.tagName === 'iframe') {
|
||||
const src = String(el.properties?.src ?? '')
|
||||
|
||||
// Nur echte YouTube-Embed-URLs zulassen
|
||||
if (
|
||||
// eslint-disable-next-line security/detect-unsafe-regex
|
||||
!/^https:\/\/(?:www\.)?(?:youtube\.com|youtube-nocookie\.com)\/embed\/[A-Za-z0-9_-]+(?:\?.*)?$/.test(
|
||||
src,
|
||||
)
|
||||
) {
|
||||
// ersetze es durch einen leeren div
|
||||
el.tagName = 'div'
|
||||
el.properties = {}
|
||||
el.children = []
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user