Skip to content

Commit d604e8b

Browse files
committed
working html merging and instructions.
1 parent 498badc commit d604e8b

8 files changed

Lines changed: 609 additions & 6488 deletions

File tree

package-lock.json

Lines changed: 0 additions & 6219 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
"dependencies": {
1010
"@anthropic-ai/sdk": "^0.39.0",
1111
"@parcel/config-default": "^2.14.4",
12+
"@xmldom/xmldom": "^0.9.8",
1213
"escodegen": "^2.1.0",
1314
"esprima-next": "^6.0.3",
1415
"estraverse": "^5.3.0",
1516
"highlight.js": "^11.11.1",
17+
"htmlparser2": "^10.0.0",
1618
"js-beautify": "^1.15.4",
1719
"jsdom": "^26.1.0",
1820
"linkedom": "^0.18.9",

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ChatUI } from './chat';
1212
import { deleteFile } from './llmCall';
1313
import { javascriptManipulator } from './mergeTools/javascript/javascript';
1414
import { cssManipulator } from './mergeTools/css/css';
15-
import { htmlManipulator } from './mergeTools/html/html';
15+
import { mergeHTML } from './mergeTools/html/html';
1616
//import { getMonacoWorker } from './monaco-editor-workers.js';
1717

1818

@@ -439,12 +439,14 @@ class aiFiddleEditor {
439439
this.switchTab('JS');
440440
}
441441
if (language === 'html') {
442-
const manipulator = new htmlManipulator();
443-
await manipulator.setCode(this.editors['HTML'].getValue());
444-
await manipulator.parse();
445-
await manipulator.mergeCode(snippet);
446-
const newCode = await manipulator.generateCode();
447-
await this.editors['HTML'].setValue(newCode);
442+
let baseHtmlTemplate=`
443+
<html><head></head><body></body></html>
444+
`
445+
446+
baseHtmlTemplate = await mergeHTML(await this.editors['HTML'].getValue(), snippet)
447+
448+
449+
await this.editors['HTML'].setValue(baseHtmlTemplate, snippet);
448450
this.saveEditorValues();
449451
this.switchTab('HTML');
450452
}

0 commit comments

Comments
 (0)