Server IP : 23.254.227.96 / Your IP : 216.73.216.46 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/viralblo/public_html/quill/blots/ |
Upload File : |
import Parchment from 'parchment'; import TextBlot from './text'; const GUARD_TEXT = "\uFEFF"; class Embed extends Parchment.Embed { constructor(node) { super(node); this.contentNode = document.createElement('span'); this.contentNode.setAttribute('contenteditable', false); [].slice.call(this.domNode.childNodes).forEach((childNode) => { this.contentNode.appendChild(childNode); }); this.leftGuard = document.createTextNode(GUARD_TEXT); this.rightGuard = document.createTextNode(GUARD_TEXT); this.domNode.appendChild(this.leftGuard); this.domNode.appendChild(this.contentNode); this.domNode.appendChild(this.rightGuard); } index(node, offset) { if (node === this.leftGuard) return 0; if (node === this.rightGuard) return 1; return super.index(node, offset); } restore(node) { let range, textNode; let text = node.data.split(GUARD_TEXT).join(''); if (node === this.leftGuard) { if (this.prev instanceof TextBlot) { let prevLength = this.prev.length(); this.prev.insertAt(prevLength, text); range = { startNode: this.prev.domNode, startOffset: prevLength + text.length }; } else { textNode = document.createTextNode(text); this.parent.insertBefore(Parchment.create(textNode), this); range = { startNode: textNode, startOffset: text.length }; } } else if (node === this.rightGuard) { if (this.next instanceof TextBlot) { this.next.insertAt(0, text); range = { startNode: this.next.domNode, startOffset: text.length } } else { textNode = document.createTextNode(text); this.parent.insertBefore(Parchment.create(textNode), this.next); range = { startNode: textNode, startOffset: text.length }; } } node.data = GUARD_TEXT; return range; } update(mutations, context) { mutations.forEach((mutation) => { if (mutation.type === 'characterData' && (mutation.target === this.leftGuard || mutation.target === this.rightGuard)) { let range = this.restore(mutation.target); if (range) context.range = range; } }); } } export default Embed;