File tree Expand file tree Collapse file tree
src/addons/addons/ai-integration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,16 @@ export default class Attachment {
1414 }
1515 Attachment . _blockly = blockly ;
1616 }
17+ static getAttachmentReady ( attachment ) {
18+ if ( attachment && attachment . nodeType === Node . ELEMENT_NODE ) {
19+ attachment = Attachment . _blockly . Xml . domToText ( attachment ) ;
20+ }
21+ // Remove unnecessary attributes and whitespace
22+ return attachment
23+ . replace ( / x = " [ ^ " ] + " | y = " [ ^ " ] + " | i d = " [ ^ " ] + " / g, "" )
24+ . replace ( / \s { 2 , } / g, " " )
25+ . replace ( " >" , ">" ) ;
26+ }
1727
1828 attachment ( attachment , spriteName = "Sprite1" ) {
1929 if ( Attachment . _blockly === null ) {
Original file line number Diff line number Diff line change @@ -408,11 +408,11 @@ function popupFunctionality() {
408408
409409 var attachmentCode = "" ;
410410 if ( attachmentType == "1" ) {
411- attachmentCode = "\nAttached Code:" + Blockly . Xml . domToText ( attachment . GetAttachment ( Blockly . Xml . workspaceToDom ( mainWorkspace ) ) ) ;
411+ attachmentCode = "\nAttached Code:" + Attachment . getAttachmentReady ( attachment . GetAttachment ( Blockly . Xml . workspaceToDom ( mainWorkspace ) ) ) ;
412412 } else if ( attachmentType == "2" ) {
413- attachmentCode = "\nAttached Code:" + Blockly . Xml . domToText ( Blockly . Xml . workspaceToDom ( mainWorkspace ) ) ;
413+ attachmentCode = "\nAttached Code:" + Attachment . getAttachmentReady ( Blockly . Xml . workspaceToDom ( mainWorkspace ) ) ;
414414 } else if ( attachmentType == "3" ) {
415- attachmentCode = "\nAttached Code:" + helpers . returnEntireProjectAsXML ( Gaddon ) ;
415+ attachmentCode = "\nAttached Code:" + Attachment . getAttachmentReady ( helpers . returnEntireProjectAsXML ( Gaddon ) ) ;
416416 }
417417 const messageContents = input . value + attachmentCode + "\n\n\nContext:\nSprite Customes: " + customNames + "\nSprite Sounds: " + soundNames + "\nAll Sprites Names: " + allSpriteNames + "\nCurrent Sprite Name:" + vm . runtime . getEditingTarget ( ) . sprite . name ;
418418 input . value = '' ;
@@ -943,7 +943,6 @@ export default async function ({ addon, console }) {
943943 } ) ;
944944
945945 window . addEventListener ( 'ai-button-clicked' , function ( ) {
946- //HANDLE ATTACHMENT
947946 createBasePopup ( 2 , "" ) ;
948947 } ) ;
949948}
You can’t perform that action at this time.
0 commit comments