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

1
src/parser/model/ParserHtml.ts

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

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

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

Loading…
Cancel
Save