рассматривается как SPAN также и вызывает следующее:
uncaught s: [пергамент] Невозможно создать [Object htmlSpanelement] Blot < /p>
< /blockquote>
Это тестовый пример Я использую < /p>
Код: Выделить всё
this is text is here replaceable
< /code>
Код ниже сохраняется, но он неправильно преобразует смену < /p>
var Inline = Quill.import('blots/inline');
var Delta = Quill.import('delta');
class CustomSpan extends Inline {
static blotName = 'customSpan';
static tagName = 'span';
static formats(domNode) {
const className = domNode.getAttribute('class');
console.log('Formats called with:', className, domNode);
return className ? { customSpan: className } : {};
}
format(name, value) {
if (name === 'customSpan') {
if (value) {
this.domNode.setAttribute('class', value);
} else {
this.domNode.removeAttribute('class');
}
} else {
super.format(name, value);
}
}
}
Quill.register(CustomSpan,false);
const quill = new Quill("#editor", {
modules: {
toolbar: false,
},
theme: "snow" ,
});
quill.clipboard.addMatcher('SPAN', function(node, delta) {
const className = node.getAttribute('class');
console.log('Processing span with class:', className);
if (!className) return delta; // Ignore spans without class
let newDelta = new Delta();
// Apply customSpan format only to the text inside the span
delta.ops.forEach(op => {
if (typeof op.insert === 'string') {
newDelta.insert(op.insert, { customSpan: className });
} else {
newDelta.insert(op.insert);
}
});
return newDelta;
});
Подробнее здесь: https://stackoverflow.com/questions/793 ... ustom-blot
Мобильная версия