UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

35 lines (34 loc) 1.13 kB
/** * DevExtreme (esm/__internal/ui/html_editor/converters/m_delta.js) * Version: 24.2.7 * Build date: Mon Apr 28 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import ConverterController from "../m_converterController"; class DeltaConverter { setQuillInstance(quillInstance) { this.quillInstance = quillInstance } toHtml() { if (!this.quillInstance) { return } return this._isQuillEmpty() ? "" : this.quillInstance.getSemanticHTML(0, this.quillInstance.getLength() + 1) } _isQuillEmpty() { const delta = this.quillInstance.getContents(); return 1 === delta.length() && this._isDeltaEmpty(delta) } _isDeltaEmpty(delta) { return delta.reduce(((__, _ref) => { let { insert: insert } = _ref; return -1 !== insert.indexOf("\n") })) } } ConverterController.addConverter("delta", DeltaConverter); export default DeltaConverter;