Browse Source

Additional fixes

pull/5895/head
Artur Arseniev 2 years ago
parent
commit
dab40b3bf9
  1. 12
      src/dom_components/index.ts
  2. 1
      src/parser/model/ParserHtml.ts
  3. 8
      test/specs/parser/model/ParserHtml.ts

12
src/dom_components/index.ts

@ -252,9 +252,9 @@ export default class ComponentManager extends ItemManagerModule<DomComponentsCon
view: ComponentTextNodeView,
},
{
id: 'text',
model: ComponentText,
view: ComponentTextView,
id: typeHead,
model: ComponentHead,
view: ComponentView,
},
{
id: 'wrapper',
@ -262,9 +262,9 @@ export default class ComponentManager extends ItemManagerModule<DomComponentsCon
view: ComponentWrapperView,
},
{
id: typeHead,
model: ComponentHead,
view: ComponentView,
id: 'text',
model: ComponentText,
view: ComponentTextView,
},
{
id: 'default',

1
src/parser/model/ParserHtml.ts

@ -363,6 +363,7 @@ const ParserHtml = (em?: EditorModel, config: ParserConfig & { returnArray?: boo
let resHtml: HTMLParseResult['html'] = [];
if (asDocument) {
console.log(this.detectNode(docEl.head, cf));
res.head = this.parseNode(docEl.head, cf);
res.root = this.parseNodeAttr(root);
resHtml = this.parseNode(docEl.body, cf);

8
test/specs/parser/model/ParserHtml.ts

@ -535,7 +535,6 @@ describe('ParserHtml', () => {
const result = [
{
tagName: 'div',
attributes: {},
type: 'text',
test: {
prop1: 'value1',
@ -553,7 +552,6 @@ describe('ParserHtml', () => {
const result = [
{
tagName: 'div',
attributes: {},
type: 'text',
test: ['value1', 'value2'],
components: { type: 'textnode', content: 'test2 ' },
@ -655,7 +653,7 @@ describe('ParserHtml', () => {
expect(obj.parse(str, null, { preParser }).html).toEqual([result]);
});
test.only('parsing as document', () => {
test('parsing as document', () => {
const str = `
<!DOCTYPE html>
<html class="cls-html" lang="en" data-gjs-htmlp="true">
@ -672,13 +670,13 @@ describe('ParserHtml', () => {
</body>
</html>
`;
// asDocument: true
console.log(obj.parse(str, null, { asDocument: true }));
expect(obj.parse(str, null, { asDocument: true })).toEqual({
doctype: '<!DOCTYPE html>',
root: { classes: ['cls-html'], attributes: { lang: 'en' }, htmlp: true },
head: {
type: 'head',
tagName: 'head',
headp: true,
classes: ['cls-head'],
components: [

Loading…
Cancel
Save