Кажется, не может сохранить встроенные элементы, такие как , с индивидуальным блотомHtml

Программисты Html
Ответить
Anonymous
 Кажется, не может сохранить встроенные элементы, такие как , с индивидуальным блотом

Сообщение Anonymous »

Я создал CustomBlot , чтобы обрабатывать преобразование SPAN, но по какой -то причине любой текст после
рассматривается как 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;
});
jsfiddle


Подробнее здесь: https://stackoverflow.com/questions/793 ... ustom-blot
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Html»