@innovastudio/contentbox 1.6.100 → 1.6.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26507,67 +26507,21 @@ class Snippets {
|
|
26507
26507
|
outline: transparent 1px solid;
|
26508
26508
|
}
|
26509
26509
|
|
26510
|
-
|
26511
|
-
|
26512
26510
|
/* Scrollbar for modal */
|
26513
|
-
|
26514
|
-
|
26515
|
-
|
26516
|
-
scrollbar-width: thin;
|
26517
|
-
scrollbar-color: rgb(78 78 78 / 62%) auto;
|
26518
|
-
}
|
26519
|
-
.dark *::-webkit-scrollbar {
|
26520
|
-
width: 12px;
|
26521
|
-
}
|
26522
|
-
.dark *::-webkit-scrollbar-track {
|
26523
|
-
background: transparent;
|
26511
|
+
.is-design-list {
|
26512
|
+
scrollbar-width: thin;
|
26513
|
+
scrollbar-color: #aaa #f0f0f0;
|
26524
26514
|
}
|
26525
|
-
.dark
|
26526
|
-
background-color:rgb(78 78 78 / 62%);
|
26527
|
-
}
|
26528
|
-
|
26529
|
-
.colored-dark * {
|
26515
|
+
.dark .is-design-list {
|
26530
26516
|
scrollbar-width: thin;
|
26531
|
-
scrollbar-color:
|
26532
|
-
|
26533
|
-
.colored-dark *::-webkit-scrollbar {
|
26534
|
-
width: 12px;
|
26535
|
-
}
|
26536
|
-
.colored-dark *::-webkit-scrollbar-track {
|
26537
|
-
background: transparent;
|
26517
|
+
scrollbar-color: #696969 #a1a1a1;
|
26518
|
+
/* scrollbar-color: rgba(255, 255, 255, 0.3) rgb(80, 80, 80); */
|
26538
26519
|
}
|
26539
|
-
.colored-dark
|
26540
|
-
background-color:rgb(100, 100, 100);
|
26541
|
-
}
|
26542
|
-
|
26543
|
-
.colored * {
|
26520
|
+
.colored-dark .is-design-list {
|
26544
26521
|
scrollbar-width: thin;
|
26545
|
-
scrollbar-color:
|
26546
|
-
}
|
26547
|
-
.colored *::-webkit-scrollbar {
|
26548
|
-
width: 12px;
|
26522
|
+
scrollbar-color: #7a7a7a #bebebe;
|
26549
26523
|
}
|
26550
|
-
.colored *::-webkit-scrollbar-track {
|
26551
|
-
background: transparent;
|
26552
|
-
}
|
26553
|
-
.colored *::-webkit-scrollbar-thumb {
|
26554
|
-
background-color: rgba(0, 0, 0, 0.4);
|
26555
|
-
}
|
26556
26524
|
|
26557
|
-
.light * {
|
26558
|
-
scrollbar-width: thin;
|
26559
|
-
scrollbar-color: rgba(0, 0, 0, 0.4) auto;
|
26560
|
-
}
|
26561
|
-
.light *::-webkit-scrollbar {
|
26562
|
-
width: 12px;
|
26563
|
-
}
|
26564
|
-
.light *::-webkit-scrollbar-track {
|
26565
|
-
background: transparent;
|
26566
|
-
}
|
26567
|
-
.light *::-webkit-scrollbar-thumb {
|
26568
|
-
background-color: rgba(0, 0, 0, 0.4);
|
26569
|
-
}
|
26570
|
-
|
26571
26525
|
svg {
|
26572
26526
|
fill: ${this.builder.styleSnippetColor};
|
26573
26527
|
}
|
@@ -31442,9 +31396,10 @@ class Util$1 {
|
|
31442
31396
|
const dom = this.dom;
|
31443
31397
|
pop.style.display = '';
|
31444
31398
|
dom.removeClass(pop, 'active');
|
31445
|
-
|
31446
|
-
|
31447
|
-
//
|
31399
|
+
|
31400
|
+
// this.builder.doc.activeElement.blur();
|
31401
|
+
// document.activeElement.blur();
|
31402
|
+
this.builder.doc.body.focus();
|
31448
31403
|
pop.setAttribute('aria-hidden', true);
|
31449
31404
|
|
31450
31405
|
// pop.removeEventListener('keydown', this.handlePopKeyDown);
|
@@ -76415,6 +76370,12 @@ class Module {
|
|
76415
76370
|
moduleModal.querySelector('div:not(.is-modal-overlay)').style.width = '90vw';
|
76416
76371
|
moduleModal.querySelector('div:not(.is-modal-overlay)').style.maxWidth = w;
|
76417
76372
|
moduleModal.querySelector('div:not(.is-modal-overlay)').style.height = h;
|
76373
|
+
var themeLight = module.getAttribute('data-theme-light');
|
76374
|
+
if (themeLight || modulename === 'form-builder') {
|
76375
|
+
moduleModal.classList.add('theme-light');
|
76376
|
+
} else {
|
76377
|
+
moduleModal.classList.remove('theme-light');
|
76378
|
+
}
|
76418
76379
|
let btnClose = moduleModal.querySelector('.is-modal-close');
|
76419
76380
|
dom.addEventListener(btnClose, 'click', () => {
|
76420
76381
|
util.hideModal(moduleModal);
|
@@ -76508,6 +76469,7 @@ class Module {
|
|
76508
76469
|
class Code {
|
76509
76470
|
constructor(builder) {
|
76510
76471
|
this.builder = builder;
|
76472
|
+
this.renderTool();
|
76511
76473
|
}
|
76512
76474
|
renderTool() {
|
76513
76475
|
const builderStuff = this.builder.builderStuff;
|
@@ -78178,6 +78140,8 @@ class RowTool {
|
|
78178
78140
|
constructor(builder) {
|
78179
78141
|
this.builder = builder;
|
78180
78142
|
this.grid = new Grid(builder); // a must (also for ContentBox's command.js)
|
78143
|
+
|
78144
|
+
this.renderRowMore();
|
78181
78145
|
}
|
78182
78146
|
|
78183
78147
|
// Render row & column tools on each row
|
@@ -80072,6 +80036,7 @@ class ColumnTool {
|
|
80072
80036
|
});
|
80073
80037
|
});
|
80074
80038
|
}
|
80039
|
+
this.renderColMore();
|
80075
80040
|
}
|
80076
80041
|
renderColMore() {
|
80077
80042
|
const builder = this.builder;
|
@@ -146782,7 +146747,285 @@ class Lib {
|
|
146782
146747
|
description: 'User requests to add a new section with 4 boxes.'
|
146783
146748
|
}
|
146784
146749
|
},
|
146785
|
-
required: [
|
146750
|
+
required: []
|
146751
|
+
}
|
146752
|
+
}];
|
146753
|
+
}
|
146754
|
+
|
146755
|
+
getFunctionsInitial() {
|
146756
|
+
return [{
|
146757
|
+
name: 'get_intent',
|
146758
|
+
description: 'analyze user command to modify or create section/content',
|
146759
|
+
parameters: {
|
146760
|
+
type: 'object',
|
146761
|
+
properties: {
|
146762
|
+
new_section: {
|
146763
|
+
type: 'boolean',
|
146764
|
+
description: 'User requests to add a new section and not updating current section.'
|
146765
|
+
} // edit_section: {
|
146766
|
+
// type: 'boolean',
|
146767
|
+
// description: 'User provides section to edit, such as improve content or rewrite.',
|
146768
|
+
// },
|
146769
|
+
|
146770
|
+
},
|
146771
|
+
required: []
|
146772
|
+
}
|
146773
|
+
}];
|
146774
|
+
}
|
146775
|
+
|
146776
|
+
getFunctionsMore() {
|
146777
|
+
return [{
|
146778
|
+
name: 'get_intent',
|
146779
|
+
description: 'analyze user command to modify or create section/content',
|
146780
|
+
parameters: {
|
146781
|
+
type: 'object',
|
146782
|
+
properties: {
|
146783
|
+
asking_info: {
|
146784
|
+
type: 'boolean',
|
146785
|
+
description: 'User request an information.'
|
146786
|
+
},
|
146787
|
+
add_info: {
|
146788
|
+
// Without this, adding info will be considered as asking_info. Tha add_info should be the same as change_text
|
146789
|
+
type: 'boolean',
|
146790
|
+
description: 'User request an information to be added to the current content.'
|
146791
|
+
},
|
146792
|
+
// Add new Column or Block (in General Mode)
|
146793
|
+
add_column_or_block: {
|
146794
|
+
type: 'boolean',
|
146795
|
+
description: 'User requests to add a column or a block.'
|
146796
|
+
},
|
146797
|
+
change_text: {
|
146798
|
+
type: 'boolean',
|
146799
|
+
description: 'User explicitely requests to update text of the current content, rewrite, paraphrase, translate or change text.'
|
146800
|
+
},
|
146801
|
+
write_based_on_the_current_content: {
|
146802
|
+
type: 'boolean',
|
146803
|
+
description: 'User request to create new content based on the current content, such as to summarize, expand, make short, create a tweet or social media post, etc'
|
146804
|
+
},
|
146805
|
+
add_headline: {
|
146806
|
+
type: 'boolean',
|
146807
|
+
description: 'If requested to add a headline.'
|
146808
|
+
},
|
146809
|
+
add_paragraph: {
|
146810
|
+
type: 'boolean',
|
146811
|
+
description: 'If requested to add a paragraph.'
|
146812
|
+
},
|
146813
|
+
add_space: {
|
146814
|
+
type: 'boolean',
|
146815
|
+
description: 'If requested to add a space.'
|
146816
|
+
},
|
146817
|
+
add_button: {
|
146818
|
+
type: 'boolean',
|
146819
|
+
description: 'If requested to add a button.'
|
146820
|
+
},
|
146821
|
+
add_youtube: {
|
146822
|
+
type: 'boolean',
|
146823
|
+
description: 'If requested to add a youtube/vimeo video.'
|
146824
|
+
},
|
146825
|
+
add_video: {
|
146826
|
+
type: 'boolean',
|
146827
|
+
description: 'If requested to add a video.'
|
146828
|
+
},
|
146829
|
+
add_audio: {
|
146830
|
+
type: 'boolean',
|
146831
|
+
description: 'If requested to add an audio.'
|
146832
|
+
},
|
146833
|
+
add_map: {
|
146834
|
+
type: 'boolean',
|
146835
|
+
description: 'If requested to add a google map.'
|
146836
|
+
},
|
146837
|
+
add_code: {
|
146838
|
+
type: 'boolean',
|
146839
|
+
description: 'If requested to add a custom code block.'
|
146840
|
+
},
|
146841
|
+
add_article: {
|
146842
|
+
type: 'boolean',
|
146843
|
+
description: 'If requested to add an article.'
|
146844
|
+
},
|
146845
|
+
add_image: {
|
146846
|
+
type: 'string',
|
146847
|
+
description: 'User request to add image or gallery. Possible value: image, gallery'
|
146848
|
+
},
|
146849
|
+
add_list: {
|
146850
|
+
type: 'boolean',
|
146851
|
+
description: 'If requested to add a list (eg. features, benefits, or list of items to explain).'
|
146852
|
+
},
|
146853
|
+
add_list_with_image: {
|
146854
|
+
type: 'boolean',
|
146855
|
+
description: 'If requested to add a list with an image for each list item.'
|
146856
|
+
},
|
146857
|
+
add_list_with_icon: {
|
146858
|
+
type: 'boolean',
|
146859
|
+
description: 'If requested to add a list with an icon.'
|
146860
|
+
},
|
146861
|
+
add_list_with_number: {
|
146862
|
+
type: 'boolean',
|
146863
|
+
description: 'If requested to add a list with numbering.'
|
146864
|
+
},
|
146865
|
+
// freeform
|
146866
|
+
new_content: {
|
146867
|
+
type: 'boolean',
|
146868
|
+
description: 'User requests to add a new content.'
|
146869
|
+
},
|
146870
|
+
add_block: {
|
146871
|
+
type: 'boolean',
|
146872
|
+
description: 'User requests to add a block.'
|
146873
|
+
},
|
146874
|
+
|
146875
|
+
/*
|
146876
|
+
To make 2 columns not mixed with 2 boxes, each has to be identified separately
|
146877
|
+
*/
|
146878
|
+
redesign_layout: {
|
146879
|
+
type: 'boolean',
|
146880
|
+
description: 'If redesigning the layout is requested.'
|
146881
|
+
},
|
146882
|
+
change_style: {
|
146883
|
+
type: 'boolean',
|
146884
|
+
description: 'If changing element style is requested.'
|
146885
|
+
},
|
146886
|
+
change_font: {
|
146887
|
+
type: 'boolean',
|
146888
|
+
description: 'User requests to change font of the current section.'
|
146889
|
+
},
|
146890
|
+
change_section_height: {
|
146891
|
+
type: 'number',
|
146892
|
+
description: 'Requested height (percentage) of the section. Possible value: 10, 15, 20, 25, 30, 40, 50, 60, 70, 75, 80, 85, 90, 100'
|
146893
|
+
},
|
146894
|
+
section_background: {
|
146895
|
+
type: 'string',
|
146896
|
+
description: 'User request to add or remove section background that can be a background image, video or slider. Possible value: image, video, slider, remove'
|
146897
|
+
}
|
146898
|
+
},
|
146899
|
+
required: []
|
146900
|
+
}
|
146901
|
+
}];
|
146902
|
+
}
|
146903
|
+
|
146904
|
+
getFunctionsFinal() {
|
146905
|
+
return [{
|
146906
|
+
name: 'get_intent',
|
146907
|
+
description: 'categorize user intent',
|
146908
|
+
parameters: {
|
146909
|
+
type: 'object',
|
146910
|
+
properties: {
|
146911
|
+
change_color_individual_text: {
|
146912
|
+
type: 'boolean',
|
146913
|
+
description: 'User requests to change the color of a headline, paragraph of specific element/text.'
|
146914
|
+
},
|
146915
|
+
change_content_dark: {
|
146916
|
+
type: 'boolean',
|
146917
|
+
description: 'If requested to change text/content color to dark/black.'
|
146918
|
+
},
|
146919
|
+
change_content_light: {
|
146920
|
+
type: 'boolean',
|
146921
|
+
description: 'If requested to change text/content color to light/white.'
|
146922
|
+
},
|
146923
|
+
align_individual_text: {
|
146924
|
+
type: 'boolean',
|
146925
|
+
description: 'If requested to align an individual text/element, such as a headline, a paragraph, buttons, etc to left, center or right'
|
146926
|
+
},
|
146927
|
+
align_whole_content: {
|
146928
|
+
type: 'string',
|
146929
|
+
description: 'User requests to align the whole text/content. Possible value: left, center or right'
|
146930
|
+
},
|
146931
|
+
|
146932
|
+
/*
|
146933
|
+
// Block Mode (in General Mode)
|
146934
|
+
block_task: {
|
146935
|
+
type: 'string',
|
146936
|
+
description: 'User requests to move, duplicate, or delete block/row. Possible values: move-up, move-down, duplicate, remove'
|
146937
|
+
},
|
146938
|
+
column_task: {
|
146939
|
+
type: 'string',
|
146940
|
+
description: 'User requests to duplicate column, or delete column. Possible values: duplicate, remove'
|
146941
|
+
},
|
146942
|
+
move_column: {
|
146943
|
+
type: 'string',
|
146944
|
+
description: 'User requests to move column. Possible values: move-up, move-down, move-left, move-right'
|
146945
|
+
},
|
146946
|
+
increase_decrease_column: {
|
146947
|
+
type: 'string',
|
146948
|
+
description: 'User requests to increase/enlarge or decrease/reduce column size/width. Possible values: increase, decrease'
|
146949
|
+
},
|
146950
|
+
move_content_left: {
|
146951
|
+
type: 'boolean',
|
146952
|
+
description: 'Move content to the left',
|
146953
|
+
},
|
146954
|
+
move_content_center: {
|
146955
|
+
type: 'boolean',
|
146956
|
+
description: 'Move content to the center',
|
146957
|
+
},
|
146958
|
+
move_content_right: {
|
146959
|
+
type: 'boolean',
|
146960
|
+
description: 'Move content to the right',
|
146961
|
+
},
|
146962
|
+
move_content_top: {
|
146963
|
+
type: 'boolean',
|
146964
|
+
description: 'Move content to the top',
|
146965
|
+
},
|
146966
|
+
move_content_bottom: {
|
146967
|
+
type: 'boolean',
|
146968
|
+
description: 'Move content to the bottom',
|
146969
|
+
},
|
146970
|
+
*/
|
146971
|
+
content_width: {
|
146972
|
+
type: 'string',
|
146973
|
+
description: 'User requests to increase or decrease content width/size. Possible value: increase, decrease'
|
146974
|
+
},
|
146975
|
+
line_height_paragraph: {
|
146976
|
+
type: 'string',
|
146977
|
+
description: 'User requests to increase/decrease the line height of the paragraph. Possible value: increase, decrease'
|
146978
|
+
},
|
146979
|
+
line_height_individual_text: {
|
146980
|
+
type: 'boolean',
|
146981
|
+
description: 'User requests to increase/decrease the line height of an individual text/element (eg. headline).'
|
146982
|
+
},
|
146983
|
+
font_size_paragraph: {
|
146984
|
+
type: 'string',
|
146985
|
+
description: 'User requests to increase/decrease the font size of the paragraph. Possible value: increase, decrease'
|
146986
|
+
},
|
146987
|
+
font_size_individual_text: {
|
146988
|
+
type: 'boolean',
|
146989
|
+
description: 'User requests to increase/decrease the font size of an individual text/element (eg. headline).'
|
146990
|
+
}
|
146991
|
+
/*
|
146992
|
+
animation: {
|
146993
|
+
type: 'string',
|
146994
|
+
description: 'User requests to add animation. Possible value: fade-in, slide-up, zoom-in, remove'
|
146995
|
+
},
|
146996
|
+
section_task: {
|
146997
|
+
type: 'string',
|
146998
|
+
description: 'User requests to move, duplicate, or delet section. Possible values: move-up, move-top, move-down, move-bottom, duplicate, remove'
|
146999
|
+
},
|
147000
|
+
select_section: {
|
147001
|
+
type: 'string',
|
147002
|
+
description: 'User requests to select a section. Value can be: current, next, previous, first, last.'
|
147003
|
+
},
|
147004
|
+
select_block: {
|
147005
|
+
type: 'string',
|
147006
|
+
description: 'User requests to select a block. Value can be: block, headline, title, paragraph, image, next, previous, first, last'
|
147007
|
+
},
|
147008
|
+
unselect_block: {
|
147009
|
+
type: 'boolean',
|
147010
|
+
description: 'User requests to unselect block'
|
147011
|
+
},
|
147012
|
+
*/
|
147013
|
+
// Must be placed on the last for more precise
|
147014
|
+
// new_section_two_boxes: {
|
147015
|
+
// type: 'boolean',
|
147016
|
+
// description: 'User requests to add a new section with 2 boxes.'
|
147017
|
+
// },
|
147018
|
+
// new_section_three_boxes: {
|
147019
|
+
// type: 'boolean',
|
147020
|
+
// description: 'User requests to add a new section with 3 boxes.'
|
147021
|
+
// },
|
147022
|
+
// new_section_four_boxes: {
|
147023
|
+
// type: 'boolean',
|
147024
|
+
// description: 'User requests to add a new section with 4 boxes.'
|
147025
|
+
// },
|
147026
|
+
|
147027
|
+
},
|
147028
|
+
required: []
|
146786
147029
|
}
|
146787
147030
|
}];
|
146788
147031
|
}
|
@@ -147049,6 +147292,7 @@ Button Example:
|
|
147049
147292
|
|
147050
147293
|
isCanvasMode() {
|
147051
147294
|
let activeBox = this.builder.activeBox;
|
147295
|
+
if (!activeBox) return false;
|
147052
147296
|
let canvasMode = activeBox.classList.contains('box-canvas');
|
147053
147297
|
return canvasMode;
|
147054
147298
|
}
|
@@ -148395,7 +148639,8 @@ ${blockContent}
|
|
148395
148639
|
|
148396
148640
|
if (activeCol) {
|
148397
148641
|
// && numberOfIntents<=2) {
|
148398
|
-
// Update Column or Block (in General Mode)
|
148642
|
+
if (this.builder.consoleLog) console.log('branch block'); // Update Column or Block (in General Mode)
|
148643
|
+
|
148399
148644
|
if (args.align_individual_text || args.font_size_individual_text || args.line_height_individual_text) {
|
148400
148645
|
sendUpdateBlockCommand(question, args);
|
148401
148646
|
return;
|
@@ -148433,6 +148678,8 @@ ${blockContent}
|
|
148433
148678
|
if (container) currentContent = this.builder.editor.readHtml(container, false, false);
|
148434
148679
|
|
148435
148680
|
if (args.add_block || args.new_content || args.new_section || currentContent.trim() === '') {
|
148681
|
+
if (this.builder.consoleLog) console.log('branch 1');
|
148682
|
+
|
148436
148683
|
if (args.add_image === 'gallery') {
|
148437
148684
|
context = cl.new_section_with_gallery;
|
148438
148685
|
} else if (args.add_list_with_image) {
|
@@ -148462,6 +148709,7 @@ ${blockContent}
|
|
148462
148709
|
}
|
148463
148710
|
} else {
|
148464
148711
|
//if(args.redesign_layout || args.change_text || args.change_style || args.add_info) {
|
148712
|
+
if (this.builder.consoleLog) console.log('branch 2');
|
148465
148713
|
let currentHtml = '<div class="is-container">' + currentContent + '</div>';
|
148466
148714
|
let redesign_request = '';
|
148467
148715
|
|
@@ -148604,10 +148852,30 @@ ${currentHtml}
|
|
148604
148852
|
}
|
148605
148853
|
} // if(this.builder.sendCommandUrl==='') return;
|
148606
148854
|
|
148855
|
+
/*
|
148856
|
+
let response = await this.sendCommandSync('analyze',
|
148857
|
+
`This is the command: "${question}"`,
|
148858
|
+
'',
|
148859
|
+
'You will analyze the user\'s command and return what the user needs.',
|
148860
|
+
this.lib.getFunctionsInitial());
|
148861
|
+
const args1 = JSON.parse(response);
|
148862
|
+
response = await this.sendCommandSync('analyze',
|
148863
|
+
`This is the command: "${question}"`,
|
148864
|
+
'',
|
148865
|
+
'You will analyze the user\'s command and return what the user needs.',
|
148866
|
+
this.lib.getFunctionsMore());
|
148867
|
+
const args2 = JSON.parse(response);
|
148868
|
+
response = await this.sendCommandSync('analyze',
|
148869
|
+
`This is the command: "${question}"`,
|
148870
|
+
'',
|
148871
|
+
'You will analyze the user\'s command and return what the user needs.',
|
148872
|
+
this.lib.getFunctionsFinal());
|
148873
|
+
const args3 = JSON.parse(response);
|
148874
|
+
const args = { ...args1, ...args2, ...args3 };
|
148875
|
+
*/
|
148607
148876
|
|
148608
|
-
|
148609
|
-
|
148610
|
-
if (this.builder.consoleLog) console.log(args);
|
148877
|
+
|
148878
|
+
const processGeneralCommand = args => {
|
148611
148879
|
const canvasMode = this.isCanvasMode();
|
148612
148880
|
|
148613
148881
|
if (args.add_block && canvasMode) ; else {
|
@@ -148631,14 +148899,17 @@ ${currentHtml}
|
|
148631
148899
|
|
148632
148900
|
if (activeCol) {
|
148633
148901
|
// && numberOfIntents<=2) {
|
148634
|
-
// Update Column or Block (in General Mode)
|
148902
|
+
if (this.builder.consoleLog) console.log('branch block'); // Update Column or Block (in General Mode)
|
148903
|
+
|
148635
148904
|
if (args.align_individual_text || args.font_size_individual_text || args.line_height_individual_text) {
|
148905
|
+
if (this.builder.consoleLog) console.log('sendUpdateBlockCommand');
|
148636
148906
|
sendUpdateBlockCommand(question, args);
|
148637
148907
|
return;
|
148638
148908
|
} // Add new Column or Block (in General Mode)
|
148639
148909
|
|
148640
148910
|
|
148641
148911
|
if (args.add_column_or_block) {
|
148912
|
+
if (this.builder.consoleLog) console.log('sendBlockCommand');
|
148642
148913
|
sendBlockCommand(question);
|
148643
148914
|
return;
|
148644
148915
|
}
|
@@ -148646,7 +148917,8 @@ ${currentHtml}
|
|
148646
148917
|
|
148647
148918
|
|
148648
148919
|
if (activeBox && numberOfIntents === 1) {
|
148649
|
-
// Block Mode (in General Mode)
|
148920
|
+
if (this.builder.consoleLog) console.log('single intent'); // Block Mode (in General Mode)
|
148921
|
+
|
148650
148922
|
let result = this.blockAction(args);
|
148651
148923
|
|
148652
148924
|
if (result) {
|
@@ -148661,7 +148933,7 @@ ${currentHtml}
|
|
148661
148933
|
activeBox.setAttribute('data-selectbox',1);
|
148662
148934
|
this.section.sectionDuplicate();
|
148663
148935
|
activeBox.removeAttribute('data-selectbox');
|
148664
|
-
|
148936
|
+
this.builder.sectionStack();
|
148665
148937
|
const nextBox = this.builder.wrapperEl.querySelector('[data-selectbox]');
|
148666
148938
|
if(nextBox) {
|
148667
148939
|
nextBox.removeAttribute('data-selectbox');
|
@@ -148932,6 +149204,7 @@ ${currentHtml}
|
|
148932
149204
|
let context = '';
|
148933
149205
|
|
148934
149206
|
if (args.add_block && canvasMode) {
|
149207
|
+
if (this.builder.consoleLog) console.log('branch 1');
|
148935
149208
|
cl = cl2;
|
148936
149209
|
|
148937
149210
|
if (args.add_image === 'gallery') {
|
@@ -148974,7 +149247,11 @@ ${currentHtml}
|
|
148974
149247
|
context = context.replaceAll('{{_IMAGEURL}}', imageUrl);
|
148975
149248
|
}
|
148976
149249
|
} else if (args.new_section || args.new_section_two_boxes || args.new_section_three_boxes || args.new_section_four_boxes) {
|
149250
|
+
if (this.builder.consoleLog) console.log('branch 2');
|
149251
|
+
|
148977
149252
|
if (args.new_section) {
|
149253
|
+
if (this.builder.consoleLog) console.log('branch 2.1');
|
149254
|
+
|
148978
149255
|
if (args.add_image === 'gallery') {
|
148979
149256
|
context = cl.new_section_with_gallery;
|
148980
149257
|
} else if (args.add_list_with_image) {
|
@@ -149015,6 +149292,8 @@ ${currentHtml}
|
|
149015
149292
|
context = context.replaceAll('{{_IMAGEURL}}', imageUrl);
|
149016
149293
|
}
|
149017
149294
|
} else if (args.new_section_two_boxes || args.new_section_three_boxes || args.new_section_four_boxes) {
|
149295
|
+
if (this.builder.consoleLog) console.log('branch 2.2');
|
149296
|
+
|
149018
149297
|
if (args.new_section_two_boxes) {
|
149019
149298
|
context = cl.new_section_two_boxes;
|
149020
149299
|
} else if (args.new_section_three_boxes) {
|
@@ -149050,10 +149329,13 @@ ${currentHtml}
|
|
149050
149329
|
context = context.replaceAll('{{_IMAGEURL}}', imageUrl);
|
149051
149330
|
}
|
149052
149331
|
} else {
|
149332
|
+
if (this.builder.consoleLog) console.log('branch 2.3');
|
149053
149333
|
context = this.chooseContext(cl.new_section_article); // Or use: context = cl.new_section_others;
|
149054
149334
|
}
|
149055
149335
|
} else {
|
149056
149336
|
//if(args.redesign_layout || args.change_text || args.change_style || args.add_info) {
|
149337
|
+
if (this.builder.consoleLog) console.log('branch 3');
|
149338
|
+
|
149057
149339
|
if (!this.checkSelectedContent(activeBox)) {
|
149058
149340
|
this.dictation.finish(true);
|
149059
149341
|
return;
|
@@ -149117,13 +149399,16 @@ ${currentHtml}
|
|
149117
149399
|
|
149118
149400
|
|
149119
149401
|
question = `${redesign_request}${question}. Modify my section according to this instruction and returns the modified section HTML.
|
149402
|
+
Do not replace existing content unless requested.
|
149120
149403
|
|
149121
149404
|
This is my section:
|
149122
|
-
|
149405
|
+
|
149123
149406
|
${currentHtml}
|
149124
149407
|
`;
|
149125
149408
|
|
149126
149409
|
if (args.change_text) ; else {
|
149410
|
+
if (this.builder.consoleLog) console.log('branch 4');
|
149411
|
+
|
149127
149412
|
if ((args.add_headline || args.add_paragraph) && args.add_image === 'image') {
|
149128
149413
|
context += '\n' + cl.update_section_with_image;
|
149129
149414
|
} else if (args.add_image === 'gallery') {
|
@@ -149173,6 +149458,7 @@ ${currentHtml}
|
|
149173
149458
|
|
149174
149459
|
if (!(args.add_block && canvasMode || args.new_section || args.new_section_two_boxes || args.new_section_three_boxes || args.new_section_four_boxes)) {
|
149175
149460
|
// Redesign & Editing (text or style)
|
149461
|
+
if (this.builder.consoleLog) console.log('callback 1');
|
149176
149462
|
html = this.fixButtons(html);
|
149177
149463
|
html = this.fixCustomCode(html);
|
149178
149464
|
html = this.analyzeTitle(html, context); // Merge div.is-overlay-content
|
@@ -149216,7 +149502,10 @@ ${currentHtml}
|
|
149216
149502
|
this.renderResult(html);
|
149217
149503
|
} else {
|
149218
149504
|
// New Section
|
149505
|
+
if (this.builder.consoleLog) console.log('callback 2');
|
149506
|
+
|
149219
149507
|
if (args.add_block && canvasMode) {
|
149508
|
+
if (this.builder.consoleLog) console.log('callback 2.1');
|
149220
149509
|
html = this.fixHtml(html);
|
149221
149510
|
|
149222
149511
|
if (!html) {
|
@@ -149230,6 +149519,7 @@ ${currentHtml}
|
|
149230
149519
|
|
149231
149520
|
this.renderResult_Block(html);
|
149232
149521
|
} else {
|
149522
|
+
if (this.builder.consoleLog) console.log('callback 2.2');
|
149233
149523
|
html = this.fixButtons(html);
|
149234
149524
|
html = this.fixBgImage(html); // only if box has inline bg image, which is incorrect
|
149235
149525
|
|
@@ -149286,7 +149576,14 @@ ${currentHtml}
|
|
149286
149576
|
|
149287
149577
|
|
149288
149578
|
this.sendCommand('html', question, context, systemCmd, [], callback);
|
149289
|
-
}
|
149579
|
+
};
|
149580
|
+
|
149581
|
+
this.sendCommand('analyze', `This is the command: "${question}"`, '', 'You will analyze the user\'s command and return what the user needs.', this.lib.getFunctions(), response => {
|
149582
|
+
const args = JSON.parse(response);
|
149583
|
+
if (this.builder.consoleLog) console.log(args);
|
149584
|
+
processGeneralCommand(args);
|
149585
|
+
}); // console.log(args);
|
149586
|
+
// processGeneralCommand(args);
|
149290
149587
|
};
|
149291
149588
|
|
149292
149589
|
this.dictation.opts.send = question => {
|
@@ -149311,15 +149608,19 @@ ${currentHtml}
|
|
149311
149608
|
const activeBlock = this.activeBlock();
|
149312
149609
|
|
149313
149610
|
if (activeBlock) {
|
149314
|
-
// Special: If current box is a canvas and there is a selected block
|
149611
|
+
if (this.builder.consoleLog) console.log('sendGeneralCommand_CanvasMode'); // Special: If current box is a canvas and there is a selected block
|
149612
|
+
|
149315
149613
|
sendGeneralCommand_CanvasMode(question);
|
149316
149614
|
} else {
|
149317
149615
|
// Normal
|
149616
|
+
if (this.builder.consoleLog) console.log('sendGeneralCommand');
|
149318
149617
|
sendGeneralCommand(question);
|
149319
149618
|
}
|
149320
149619
|
} else if (this.builder.editor.assistantMode === 'others') {
|
149620
|
+
if (this.builder.consoleLog) console.log('sendOtherCommand');
|
149321
149621
|
sendOtherCommand(question);
|
149322
149622
|
} else if (this.builder.editor.assistantMode === 'block') {
|
149623
|
+
if (this.builder.consoleLog) console.log('sendBlockCommand');
|
149323
149624
|
sendBlockCommand(question);
|
149324
149625
|
}
|
149325
149626
|
};
|
@@ -150516,6 +150817,8 @@ ${currentHtml}
|
|
150516
150817
|
|
150517
150818
|
chooseContext(list, num) {
|
150518
150819
|
// random, but will be different from two previous results.
|
150820
|
+
console.log(list);
|
150821
|
+
|
150519
150822
|
if (typeof num !== 'undefined') {
|
150520
150823
|
return list[num];
|
150521
150824
|
}
|
@@ -151620,8 +151923,143 @@ ${currentHtml}
|
|
151620
151923
|
}
|
151621
151924
|
}
|
151622
151925
|
|
151926
|
+
async sendCommandSync(mode, question, context, system, functs) {
|
151927
|
+
this.dictation.startSending(); // Shows sending status & Abort button
|
151928
|
+
|
151929
|
+
this.controller = new AbortController(); // Create a new AbortController
|
151930
|
+
|
151931
|
+
this.signal = this.controller.signal; // Get a new signal object
|
151932
|
+
|
151933
|
+
let temperature = localStorage.getItem('_temp') || this.builder.temperature;
|
151934
|
+
let topP = localStorage.getItem('_top_p') || this.builder.topP;
|
151935
|
+
let num = 1;
|
151936
|
+
const messages = {
|
151937
|
+
question,
|
151938
|
+
context,
|
151939
|
+
system,
|
151940
|
+
functs,
|
151941
|
+
temperature,
|
151942
|
+
topP,
|
151943
|
+
num
|
151944
|
+
};
|
151945
|
+
|
151946
|
+
try {
|
151947
|
+
/*
|
151948
|
+
const response = await fetch(this.builder.sendCommandUrl, {
|
151949
|
+
signal: this.signal, // Abort
|
151950
|
+
method: 'POST',
|
151951
|
+
headers: {
|
151952
|
+
'Content-Type': 'application/json',
|
151953
|
+
},
|
151954
|
+
body: JSON.stringify(messages),
|
151955
|
+
});
|
151956
|
+
const data = await response.json();
|
151957
|
+
*/
|
151958
|
+
let data;
|
151959
|
+
|
151960
|
+
if (this.builder.sendCommand) {
|
151961
|
+
data = await this.builder.sendCommand(messages);
|
151962
|
+
} else {
|
151963
|
+
let headers = { ...this.builder.headers,
|
151964
|
+
...this.builder.defaultHeaders
|
151965
|
+
};
|
151966
|
+
const response = await fetch(this.builder.sendCommandUrl, {
|
151967
|
+
signal: this.signal,
|
151968
|
+
// Abort
|
151969
|
+
method: 'POST',
|
151970
|
+
headers,
|
151971
|
+
body: JSON.stringify(messages)
|
151972
|
+
});
|
151973
|
+
data = await response.json();
|
151974
|
+
}
|
151975
|
+
|
151976
|
+
if (data.error) {
|
151977
|
+
// Error response from OpenAI goes here.
|
151978
|
+
console.log('Error:\n' + data.error); // ex. wrong API Key => Request failed with status code 401
|
151979
|
+
|
151980
|
+
this.builder.showMessage(out('Request failed.'));
|
151981
|
+
this.dictation.finish(); // Must be called after finished
|
151982
|
+
|
151983
|
+
return;
|
151984
|
+
}
|
151985
|
+
|
151986
|
+
if (mode === 'html') {
|
151987
|
+
// console.log(data.answer.usage);
|
151988
|
+
data.answer.choices.forEach(item => {
|
151989
|
+
let html = item.message.content;
|
151990
|
+
html = this.getHtmlResult(html);
|
151991
|
+
|
151992
|
+
if (!html) {
|
151993
|
+
this.builder.showMessage(out('Oops! The response received is insufficient. Please try again.'));
|
151994
|
+
this.dictation.finish(); // Must be called after finished
|
151995
|
+
|
151996
|
+
return;
|
151997
|
+
} // callback(html);
|
151998
|
+
|
151999
|
+
|
152000
|
+
return html;
|
152001
|
+
});
|
152002
|
+
} else if (mode === 'assistant') {
|
152003
|
+
data.answer.choices.forEach(item => {
|
152004
|
+
let answer = item.message.content; // callback(answer);
|
152005
|
+
|
152006
|
+
return answer;
|
152007
|
+
});
|
152008
|
+
} else {
|
152009
|
+
// mode===analyze
|
152010
|
+
|
152011
|
+
/*
|
152012
|
+
Handle Unrelated Request
|
152013
|
+
If OpenAI Function Call stopped (when user is asking unrelated things), it returns:
|
152014
|
+
{
|
152015
|
+
role: 'assistant',
|
152016
|
+
content: 'The user is asking for information.'
|
152017
|
+
}
|
152018
|
+
*/
|
152019
|
+
if (data.answer.role && data.answer.content) {
|
152020
|
+
// callback(JSON.stringify({new_section: true, others: true})); // Just create a new section
|
152021
|
+
// return;
|
152022
|
+
return JSON.stringify({
|
152023
|
+
new_section: true,
|
152024
|
+
others: true
|
152025
|
+
});
|
152026
|
+
} // callback(data.answer);
|
152027
|
+
|
152028
|
+
|
152029
|
+
return data.answer;
|
152030
|
+
}
|
152031
|
+
} catch (error) {
|
152032
|
+
if (error.name === 'AbortError') ; else {
|
152033
|
+
// CORS or code errors goes here
|
152034
|
+
console.error('Error:', error); // console.log('Error:\n'+error);
|
152035
|
+
|
152036
|
+
this.dictation.finish(); // Must be called after finished
|
152037
|
+
// Debug
|
152038
|
+
|
152039
|
+
if (this.builder.consoleLog) {
|
152040
|
+
if (!(error + '').includes('Failed to fetch')) {
|
152041
|
+
// Only if not CORS error
|
152042
|
+
let headers = { ...this.builder.headers,
|
152043
|
+
...this.builder.defaultHeaders
|
152044
|
+
};
|
152045
|
+
const response = await fetch(this.builder.sendCommandUrl, {
|
152046
|
+
method: 'POST',
|
152047
|
+
headers,
|
152048
|
+
body: JSON.stringify(messages)
|
152049
|
+
});
|
152050
|
+
const data = await response.text();
|
152051
|
+
console.log('Response:\n' + data); // Shows code error
|
152052
|
+
}
|
152053
|
+
}
|
152054
|
+
|
152055
|
+
this.builder.showMessage(out('Service Unavailable.'));
|
152056
|
+
}
|
152057
|
+
}
|
152058
|
+
}
|
152059
|
+
|
151623
152060
|
isCanvasMode() {
|
151624
152061
|
let activeBox = this.builder.activeBox;
|
152062
|
+
if (!activeBox) return false;
|
151625
152063
|
let canvasMode = activeBox.classList.contains('box-canvas');
|
151626
152064
|
return canvasMode;
|
151627
152065
|
}
|