comparison src/formats/xhtml.js @ 46:ab2dc8736d88

fix paste html and cleanup
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 30 Aug 2022 14:33:27 -0600
parents c23475f3f466
children
comparison
equal deleted inserted replaced
45:bc1bce78276d 46:ab2dc8736d88
536 * @param {Document} context 536 * @param {Document} context
537 * @param {HTMLElement} [parent] 537 * @param {HTMLElement} [parent]
538 * @return {string} 538 * @return {string}
539 * @memberOf jQuery.sceditor.plugins.xhtml.prototype 539 * @memberOf jQuery.sceditor.plugins.xhtml.prototype
540 */ 540 */
541 function toSource(isFragment) { 541 function toSource(html, context, parent, asFragment) {
542 return function(html, context) { 542 var xhtml,
543 var xhtml, 543 container = context.createElement('div');
544 container = context.createElement('div'); 544 container.innerHTML = html;
545 container.innerHTML = html; 545
546 546 css(container, 'visibility', 'hidden');
547 css(container, 'visibility', 'hidden'); 547 context.body.appendChild(container);
548 context.body.appendChild(container); 548
549 549 convertTags(container);
550 convertTags(container); 550 removeTags(container);
551 removeTags(container); 551 removeAttribs(container);
552 removeAttribs(container); 552
553 553 if (!asFragment) {
554 if (!isFragment) { 554 wrapInlines(container);
555 wrapInlines(container); 555 }
556 } 556
557 557 xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true);
558 xhtml = (new sceditor.XHTMLSerializer()).serialize(container, true); 558
559 559 context.body.removeChild(container);
560 context.body.removeChild(container); 560
561 561 return xhtml;
562 return xhtml;
563 };
564 } 562 }
565 563
566 base.toSource = toSource(false); 564 base.toSource = toSource;
567
568 base.fragmentToSource = toSource(true);;
569 565
570 /** 566 /**
571 * Runs all converters for the specified tagName 567 * Runs all converters for the specified tagName
572 * against the DOM node. 568 * against the DOM node.
573 * @param {string} tagName 569 * @param {string} tagName