We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { Quill } from 'react-quill' const Clipboard = Quill.import('modules/clipboard') class CreateLinkFromURL extends Clipboard { onPaste(e: ClipboardEvent): void { let clipboardData = e.clipboardData || (window as any).clipboardData let pastedText = clipboardData.getData('Text') // URLを検出する正規表現パターン // クエリパラメータやフラグメントを含むURLにも対応 const urlPattern = /^(https?:\/\/[\w\.-]+(?:\:[0-9]+)?(?:\/[^\s]*)?)/ // ペーストされたテキストがURLかどうかをチェック if (urlPattern.test(pastedText)) { e.preventDefault() // デフォルトのペースト処理をキャンセル const matchedUrl = pastedText.match(urlPattern)[0] // リンクとして挿入 const index = (this.quill.getSelection(true) || {}).index || this.quill.getLength() this.quill.insertText(index, matchedUrl, 'link', matchedUrl) } else { super.onPaste(e) } } } CreateLinkFromURL.blotName = 'createLinkFromURL' CreateLinkFromURL.className = 'create-link-from-url' export default CreateLinkFromURL
Quill.register('modules/clipboard', CreateLinkFromURL)
.ql-clipboard { position: fixed !important; left: 50% !important; top: 50% !important; display: none; }
quill-auto-links
clipboard
const Clipboard = Quill.import('modules/clipboard') class CustomClipboard extends Clipboard { onPaste(e: ClipboardEvent): void { alert('onPaste') super.onPaste(e) } } Quill.register('modules/clipboard', CustomClipboard)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
結論
登録時は以下のようにする
CSSも以下を設定していた方が確実かも
解決までの過程
quill-auto-links
が機能しなくなったclipboard
のカスタマイズは以下をもとに行う参考
The text was updated successfully, but these errors were encountered: