-
Notifications
You must be signed in to change notification settings - Fork 2
/
script.js
181 lines (159 loc) · 4.58 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
const editor = grapesjs.init({
// Indicate where to init the editor. You can also pass an HTMLElement
container: '#gjs',
// Get the content for the canvas directly from the element
// As an alternative we could use: `components: '<h1>Hello World Component!</h1>'`,
fromElement: true,
// Size of the editor
height: '500px',
width: 'auto',
// Disable the storage manager for the moment
storageManager: { type: null },
// Avoid any default panel
allowScripts: 1,
canvas: {
scripts: ['https://unpkg.com/arweave/bundles/web.bundle.js']
},
panels: { defaults: [] },
plugins: ['gjs-preset-webpage'],
pluginsOpts: {
'gjs-preset-webpage': {
// options
},
},
blockManager: {
appendTo: '#blocks',
blocks: [
{
id: 'section', // id is mandatory
label: '<b>Section</b>', // You can use HTML/SVG inside labels
attributes: { class:'gjs-block-section' },
content: `<section>
<h1>This is a simple title</h1>
<div>This is just a Lorem text: Lorem ipsum dolor sit amet</div>
</section>`,
}, {
id: 'text',
label: 'Text',
content: '<div data-gjs-type="text">Insert your text here</div>',
}, {
id: 'image',
label: 'Image',
// Select the component once it's dropped
select: true,
// You can pass components as a JSON instead of a simple HTML string,
// in this case we also use a defined component type `image`
content: { type: 'image' },
// This triggers `active` event on dropped components and the `image`
// reacts by opening the AssetManager
activate: true,
}
]
},
});
/*editor.Panels.addPanel({
id: 'panel-top',
el: '.panel__top',
});
editor.Panels.addPanel({
id: 'basic-actions',
el: '.panel__basic-actions',
buttons: [
{
id: 'visibility',
active: true, // active by default
className: 'btn-toggle-borders',
label: '<u>B</u>',
command: 'sw-visibility', // Built-in command
}, {
id: 'export',
className: 'btn-open-export',
label: 'Exp',
command: 'export-template',
context: 'export-template', // For grouping context of buttons from the same panel
}, {
id: 'show-json',
className: 'btn-show-json',
label: 'JSON',
context: 'show-json',
command(editor) {
editor.Modal.setTitle('Components JSON')
.setContent(`<textarea style="width:100%; height: 250px;">
${JSON.stringify(editor.getComponents())}
</textarea>`)
.open();
},
}, {
id: "save",
className: "fa fa-floppy-o icon-blank",
command: 'open-assets',
attributes: { title: 'Save Template' }
}
],
});
*/
editor.on('run:export-template:before', opts => {
console.log('Before the command run');
if (0 /* some condition */) {
opts.abort = 1;
}
});
editor.on('run:export-template', () => console.log('After the command run'));
editor.on('abort:export-template', () => console.log('Command aborted'));
//Let;'s do this
const blockManager = editor.BlockManager;
blockManager.add("RightPanel", {
label: `<div>
<img src="https://picsum.photos/70/70"/>
<div class="my-label-block">GetBalance</div>
</div>`,
content: {
script: function scriptfunc() {
var getwallet = prompt("whats your wallet mate");
var script = document.createElement('script');
script.onload = function () {
let arweave = Arweave.init({
host: 'arweave.net',
port: '80',
protocol: 'https'
});
arweave.wallets.getBalance(getwallet).then((balance) => {
let winston = balance;
let ar = arweave.ar.winstonToAr(balance);
console.log(winston);
console.log(ar);
}); };
script.src = 'https://unpkg.com/arweave/bundles/web.bundle.js';
document.body.appendChild(script);
},
traits: [
// strings are automatically converted to text types
'Wallet',
{
type: 'select',
label: 'ARorWINSTON',
name: 'ARorWINSTON',
options: [
{value: 'Ar', name: 'AR'},
{value: 'Winston', name: 'WINSTON'},
]
},
],
components: [
{
tagName: 'div',
name: "test",
components: console.log("fuck this api bruh"),
}
]
},
style: {
width: "100px",
height: "100px",
'background-color': "red",
},
category: 'Arweave (WORK IN PROGRESS)',
attributes: {
title: 'Insert h1 block'
}
});