Update package version to 1.1.0 and enhance link insertion logic in EditPagesComponent for improved safety and usability
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "miriamgemeinde",
|
"name": "miriamgemeinde",
|
||||||
"version": "0.1.0",
|
"version": "1.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
|
|||||||
@@ -322,10 +322,20 @@ export default {
|
|||||||
addLinkDialog.value.openAddLinkDialog();
|
addLinkDialog.value.openAddLinkDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
const insertLink = ({ url, text }) => {
|
const insertLink = (url, text) => {
|
||||||
if (url && text && editor.value) {
|
if (!editor.value) return;
|
||||||
editor.value.chain().focus().extendMarkRange('link').setLink({ href: url }).insertContent(text).run();
|
if (!url) return;
|
||||||
}
|
const selectionText = editor.value.state.doc.textBetween(
|
||||||
|
editor.value.state.selection.from,
|
||||||
|
editor.value.state.selection.to
|
||||||
|
);
|
||||||
|
const linkText = (text && text.trim()) || selectionText || url;
|
||||||
|
// Einfaches Escaping für Text
|
||||||
|
const escapeHtml = (s) => s.replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"','\'':'''}[c]));
|
||||||
|
const safeText = escapeHtml(linkText);
|
||||||
|
const safeUrl = url.trim();
|
||||||
|
// Direkter HTML Insert, damit der Link garantiert entsteht
|
||||||
|
editor.value.chain().focus().insertContent(`<a href="${safeUrl}" target="_blank" rel="noopener noreferrer">${safeText}</a>`).run();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openAddDownloadDialog = () => {
|
const openAddDownloadDialog = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user