More package and configuration related updates.
This commit is contained in:
@@ -7,29 +7,29 @@ import ShadEditor from '$lib/components/shad-editor/shad-editor.svelte';
|
||||
|
||||
|
||||
// Import Tiptap related modules
|
||||
import { Editor } from "@tiptap/core";
|
||||
import StarterKit from "@tiptap/starter-kit";
|
||||
import Bold from '@tiptap/extension-bold';
|
||||
import BulletList from '@tiptap/extension-bullet-list';
|
||||
import CodeBlock from '@tiptap/extension-code-block';
|
||||
import Code from '@tiptap/extension-code';
|
||||
import Color from '@tiptap/extension-color';
|
||||
import Document from '@tiptap/extension-document';
|
||||
import Heading from '@tiptap/extension-heading';
|
||||
import Highlight from '@tiptap/extension-highlight';
|
||||
import History from '@tiptap/extension-history';
|
||||
import Italic from '@tiptap/extension-italic';
|
||||
import Link from '@tiptap/extension-link';
|
||||
import ListItem from '@tiptap/extension-list-item';
|
||||
import OrderedList from '@tiptap/extension-ordered-list';
|
||||
import Paragraph from '@tiptap/extension-paragraph';
|
||||
import Strike from '@tiptap/extension-strike';
|
||||
import Text from '@tiptap/extension-text';
|
||||
import TextStyle from '@tiptap/extension-text-style';
|
||||
import Typography from '@tiptap/extension-typography';
|
||||
import Underline from '@tiptap/extension-underline';
|
||||
// import { Editor } from "@tiptap/core";
|
||||
// import StarterKit from "@tiptap/starter-kit";
|
||||
// import Bold from '@tiptap/extension-bold';
|
||||
// import BulletList from '@tiptap/extension-bullet-list';
|
||||
// import CodeBlock from '@tiptap/extension-code-block';
|
||||
// import Code from '@tiptap/extension-code';
|
||||
// import Color from '@tiptap/extension-color';
|
||||
// import Document from '@tiptap/extension-document';
|
||||
// import Heading from '@tiptap/extension-heading';
|
||||
// import Highlight from '@tiptap/extension-highlight';
|
||||
// import History from '@tiptap/extension-history';
|
||||
// import Italic from '@tiptap/extension-italic';
|
||||
// import Link from '@tiptap/extension-link';
|
||||
// import ListItem from '@tiptap/extension-list-item';
|
||||
// import OrderedList from '@tiptap/extension-ordered-list';
|
||||
// import Paragraph from '@tiptap/extension-paragraph';
|
||||
// import Strike from '@tiptap/extension-strike';
|
||||
// import Text from '@tiptap/extension-text';
|
||||
// import TextStyle from '@tiptap/extension-text-style';
|
||||
// import Typography from '@tiptap/extension-typography';
|
||||
// import Underline from '@tiptap/extension-underline';
|
||||
|
||||
import "./element_tiptap_editor.scss";
|
||||
import './element_tiptap_editor.scss';
|
||||
|
||||
// https://tiptap.dev/docs/examples/basics/default-text-editor
|
||||
// https://tiptap.dev/docs/examples/basics/formatting
|
||||
@@ -120,129 +120,11 @@ if (show_button_kv) {
|
||||
export let new_html: string = '';
|
||||
|
||||
onMount(() => {
|
||||
editor = new Editor({
|
||||
// element: element,
|
||||
// extensions: [
|
||||
// // StarterKit,
|
||||
// Bold, // part of StarterKit
|
||||
// Code, // part of StarterKit
|
||||
// CodeBlock, // part of StarterKit
|
||||
// Italic, // part of StarterKit
|
||||
// Strike, // part of StarterKit
|
||||
// Underline, // part of StarterKit
|
||||
// BulletList, // part of StarterKit
|
||||
// // Color.configure({ types: [TextStyle.name, ListItem.name] }),
|
||||
// // TextStyle.configure({ types: [ListItem.name] }),
|
||||
// // Heading.configure({ levels: [1, 2, 3, 4, 5, 6] }),
|
||||
// Highlight,
|
||||
// History.configure({
|
||||
// depth: 100,
|
||||
// newGroupDelay: 500
|
||||
// }),
|
||||
// Link.configure({
|
||||
// openOnClick: false,
|
||||
// autolink: true,
|
||||
// defaultProtocol: 'https',
|
||||
// protocols: ['http', 'https'],
|
||||
// isAllowedUri: (url, ctx) => {
|
||||
// try {
|
||||
// // construct URL
|
||||
// const parsedUrl = url.includes(':') ? new URL(url) : new URL(`${ctx.defaultProtocol}://${url}`)
|
||||
|
||||
// // use default validation
|
||||
// if (!ctx.defaultValidate(parsedUrl.href)) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// // disallowed protocols
|
||||
// const disallowedProtocols = ['ftp', 'file', 'mailto']
|
||||
// const protocol = parsedUrl.protocol.replace(':', '')
|
||||
|
||||
// if (disallowedProtocols.includes(protocol)) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// // only allow protocols specified in ctx.protocols
|
||||
// const allowedProtocols = ctx.protocols.map(p => (typeof p === 'string' ? p : p.scheme))
|
||||
|
||||
// if (!allowedProtocols.includes(protocol)) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// // disallowed domains
|
||||
// const disallowedDomains = ['example-phishing.com', 'malicious-site.net']
|
||||
// const domain = parsedUrl.hostname
|
||||
|
||||
// if (disallowedDomains.includes(domain)) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
// // all checks have passed
|
||||
// return true
|
||||
// } catch (error) {
|
||||
// return false
|
||||
// }
|
||||
// },
|
||||
// shouldAutoLink: url => {
|
||||
// try {
|
||||
// // construct URL
|
||||
// const parsedUrl = url.includes(':') ? new URL(url) : new URL(`https://${url}`)
|
||||
|
||||
// // only auto-link if the domain is not in the disallowed list
|
||||
// const disallowedDomains = ['example-no-autolink.com', 'another-no-autolink.com']
|
||||
// const domain = parsedUrl.hostname
|
||||
|
||||
// return !disallowedDomains.includes(domain)
|
||||
// } catch (error) {
|
||||
// return false
|
||||
// }
|
||||
// },
|
||||
// }),
|
||||
// ListItem,
|
||||
// Document,
|
||||
// OrderedList, // part of StarterKit
|
||||
// Paragraph,
|
||||
// Text,
|
||||
// Typography,
|
||||
// ],
|
||||
// content: html_text,
|
||||
// onTransaction: ({ editor, transaction }) => {
|
||||
// // console.log('onTransaction');
|
||||
// // force re-render so `editor.isActive` works as expected
|
||||
// // editor = editor;
|
||||
|
||||
// // let updated_html = editor.getHTML();
|
||||
// // if (updated_html == '<p></p>') {
|
||||
// // new_html = '';
|
||||
// // } else {
|
||||
// // new_html = updated_html;
|
||||
// // }
|
||||
// },
|
||||
// onUpdate: ({ editor }) => {
|
||||
// // console.log('onUpdate', editor.getHTML());
|
||||
// // let updated_html = editor.getHTML();
|
||||
// // if (updated_html == '<p></p>') {
|
||||
// // new_html = '';
|
||||
// // } else {
|
||||
// // new_html = updated_html;
|
||||
// // }
|
||||
// }
|
||||
});
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
function getContent() {
|
||||
if (editor) {
|
||||
return editor.getHTML();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
let mouse_entered_timer: any;
|
||||
let mouse_enter_wait: number = 500;
|
||||
let mouse_leave_wait: number = 2000;
|
||||
|
||||
Reference in New Issue
Block a user