File tree Expand file tree Collapse file tree 3 files changed +36
-6
lines changed Expand file tree Collapse file tree 3 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,8 @@ Entry.Workspace = class Workspace {
204204 Entry . hwLite . banClassAllHardwareLite ( ) ;
205205 Entry . playground . dataTable . removeAllBlocks ( ) ;
206206 Entry . aiLearning . removeAllBlocks ( ) ;
207+ Util . removeNotSupportedBlock ( ) ;
208+ Entry . playground . blockMenu . banClass ( 'python_disable' ) ;
207209 // 블럭 삭제되고 처리
208210 requestAnimationFrame ( ( ) => {
209211 changeToPythonMode ( ) ;
@@ -237,6 +239,7 @@ Entry.Workspace = class Workspace {
237239 try {
238240 this . board . show ( ) ;
239241 blockMenu . unbanClass ( 'functionInit' , true ) ;
242+ Entry . playground . blockMenu . unbanClass ( 'python_disable' ) ;
240243 this . set ( { selectedBoard : this . board } ) ;
241244 this . textToCode ( this . oldMode , this . oldTextType ) ;
242245 if ( this . overlayBoard ) {
Original file line number Diff line number Diff line change @@ -64,10 +64,17 @@ Entry.BlockToPyParser = class {
6464 let contentResult = '' ;
6565
6666 blocks . forEach ( ( block , index ) => {
67- if ( index === 0 && Entry . TextCodingUtil . isEventBlock ( block ) ) {
68- rootResult = `${ this . Block ( block ) } \n` ;
69- } else {
70- contentResult += `${ this . Block ( block ) } \n` ;
67+ try {
68+ if ( index === 0 && Entry . TextCodingUtil . isEventBlock ( block ) ) {
69+ rootResult = `${ this . Block ( block ) } \n` ;
70+ } else {
71+ contentResult += `${ this . Block ( block ) } \n` ;
72+ }
73+ } catch ( e ) {
74+ Entry . toast . alert (
75+ Lang . TextCoding . title_converting ,
76+ Lang . TextCoding . alert_legacy_no_support
77+ ) ;
7178 }
7279 } ) ;
7380
@@ -350,7 +357,7 @@ Entry.BlockToPyParser = class {
350357 schema = datum ;
351358 }
352359
353- if ( schema && schema . syntax ) {
360+ if ( schema && schema . syntax && schema . syntax . py && schema . syntax . py . length > 0 ) {
354361 const syntaxes = schema . syntax . py . concat ( ) ;
355362 while ( syntaxes . length ) {
356363 let isFail = false ;
Original file line number Diff line number Diff line change @@ -508,12 +508,16 @@ class TextCodingUtil {
508508 const isNotPythonSupportFunciton = Object . keys ( functions ) . some (
509509 ( key ) => functions [ key ] . useLocalVariables || functions [ key ] . type === 'value'
510510 ) ;
511+ const isNotSupportedUsed = this . getNotSupportedBlocks ( ) . some ( ( name ) =>
512+ Entry . Utils . isUsedBlockType ( name )
513+ ) ;
511514 if (
512515 activatedExpansionBlocks . length > 0 ||
513516 activatedUtilizeBlock . length > 0 ||
514517 Entry . aiLearning . isLoaded ||
515518 isNotPythonSupportFunciton ||
516- tables . length > 0
519+ tables . length > 0 ||
520+ isNotSupportedUsed
517521 ) {
518522 return {
519523 message : Lang . TextCoding [ Entry . TextCodingError . ALERT_API_NO_SUPPORT ] ,
@@ -522,6 +526,22 @@ class TextCodingUtil {
522526 }
523527 }
524528
529+ getNotSupportedBlocks ( ) {
530+ if ( EntryStatic . pythonDisabled ) {
531+ return EntryStatic . pythonDisabled ;
532+ }
533+ EntryStatic . pythonDisabled = Object . keys ( Entry . block ) . filter (
534+ ( key ) => Entry . block [ key ] ?. isNotFor . indexOf ( 'python_disable' ) >= 0
535+ ) ;
536+ return EntryStatic . pythonDisabled ;
537+ }
538+
539+ removeNotSupportedBlock ( names = [ ] ) {
540+ this . getNotSupportedBlocks ( ) . forEach ( ( blockType ) => {
541+ Entry . Utils . removeBlockByType ( blockType ) ;
542+ } ) ;
543+ }
544+
525545 /**
526546 * 현재 코드 내 변수, 리스트에 대해 공백/특수문자/예약어/숫자시작 여부를 검사한다.
527547 * @return {Object } 에러오브젝트
You can’t perform that action at this time.
0 commit comments