@onetype/framework 2.0.26 → 2.0.27
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.
- package/addons/core/assets/back/functions/utils/transform.js +1 -1
- package/addons/render/directives/front/js/functions/process/data.js +0 -1
- package/addons/render/transforms/addon.js +2 -0
- package/addons/render/transforms/functions/data.js +21 -0
- package/addons/render/transforms/functions/run.js +11 -0
- package/addons/render/transforms/item/functions/load.js +55 -0
- package/addons/render/transforms/item/functions/run.js +12 -0
- package/addons/render/transforms/items/directives/transform.js +15 -18
- package/lib/items/elements/global/heading/heading.css +1 -1
- package/lib/items/elements/global/markdown/markdown.js +207 -3
- package/lib/items/elements/{sections → navigation}/navbar/navbar.css +9 -9
- package/lib/items/elements/{sections → navigation}/navbar/navbar.js +2 -2
- package/lib/items/elements/navigation/sidebar/sidebar.css +101 -0
- package/lib/items/elements/navigation/sidebar/sidebar.js +56 -0
- package/lib/items/elements/{global → navigation}/tabs/tabs.css +6 -6
- package/lib/items/elements/{global → navigation}/tabs/tabs.js +2 -2
- package/lib/items/elements/sections/pricing/pricing.css +148 -0
- package/lib/items/elements/sections/pricing/pricing.js +76 -0
- package/lib/items/transforms/accordion/accordion.js +139 -141
- package/lib/items/transforms/chart/area.js +130 -133
- package/lib/items/transforms/chart/bar.js +116 -119
- package/lib/items/transforms/chart/bubble.js +142 -145
- package/lib/items/transforms/chart/doughnut.js +104 -107
- package/lib/items/transforms/chart/line.js +127 -130
- package/lib/items/transforms/chart/pie.js +102 -105
- package/lib/items/transforms/chart/radar.js +134 -137
- package/lib/items/transforms/chart/scatter.js +127 -130
- package/lib/items/transforms/codeflask/codeflask.js +10 -12
- package/lib/items/transforms/codemirror/codemirror.js +186 -189
- package/lib/items/transforms/comparison/comparison.js +130 -133
- package/lib/items/transforms/heatmap/heatmap.js +406 -407
- package/lib/items/transforms/interact/interact.js +240 -241
- package/lib/items/transforms/particles/particles.js +282 -283
- package/lib/items/transforms/sparkline/sparkline.js +207 -208
- package/lib/items/transforms/swiper/swiper.js +115 -118
- package/lib/items/transforms/tabs/tabs.js +383 -384
- package/lib/items/transforms/typed/typed.js +146 -147
- package/lib/load.js +8 -16
- package/lib/src/mixins/addons.js +10 -10
- package/lib/styles/variables.css +1 -1
- package/package.json +1 -1
- package/addons/render/transforms/functions/load/assets.js +0 -49
- /package/{addons/render/directives/front/js/items → lib/items/directives}/100-if.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/1000-render.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/110-show.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/160-slot.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/200-for.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-blur.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-change.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click-outside.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-click.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-double-click.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-focus.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-input.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keydown.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-keyup.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-enter.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-leave.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-mouse-move.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-scroll.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/500-submit.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/650-fetch.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/660-form.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/700-text.js +0 -0
- /package/{addons/render/directives/front/js/items → lib/items/directives}/750-html.js +0 -0
|
@@ -1,157 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
],
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
transforms.ItemAdd({
|
|
2
|
+
id: 'ot-chart-radar',
|
|
3
|
+
icon: 'radar',
|
|
4
|
+
name: 'Radar Chart',
|
|
5
|
+
description: 'Spider/radar chart visualization. Display multivariate data in a radial layout.',
|
|
6
|
+
js: [
|
|
7
|
+
'https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js'
|
|
8
|
+
],
|
|
9
|
+
config: {
|
|
10
|
+
'labels': ['array', ['Speed', 'Strength', 'Defense', 'Attack', 'Agility']],
|
|
11
|
+
'datasets': ['array', []],
|
|
12
|
+
'fill': ['boolean', true],
|
|
13
|
+
'options': ['object', {}]
|
|
14
|
+
},
|
|
15
|
+
code: function(data, node, transformer)
|
|
16
|
+
{
|
|
17
|
+
this.setup = () =>
|
|
18
18
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
node.innerHTML = '';
|
|
22
|
-
node.classList.add('ot-chart-radar');
|
|
19
|
+
node.innerHTML = '';
|
|
20
|
+
node.classList.add('ot-chart-radar');
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const canvas = document.createElement('canvas');
|
|
23
|
+
this.canvas = canvas;
|
|
24
|
+
node.appendChild(canvas);
|
|
25
|
+
};
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
this.colors = () =>
|
|
28
|
+
{
|
|
29
|
+
const style = getComputedStyle(document.body);
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
31
|
+
return {
|
|
32
|
+
brand: style.getPropertyValue('--ot-brand').trim(),
|
|
33
|
+
blue: style.getPropertyValue('--ot-blue').trim(),
|
|
34
|
+
green: style.getPropertyValue('--ot-green').trim(),
|
|
35
|
+
orange: style.getPropertyValue('--ot-orange').trim(),
|
|
36
|
+
red: style.getPropertyValue('--ot-red').trim(),
|
|
37
|
+
brandOpacity: style.getPropertyValue('--ot-brand-opacity').trim(),
|
|
38
|
+
blueOpacity: style.getPropertyValue('--ot-blue-opacity').trim(),
|
|
39
|
+
greenOpacity: style.getPropertyValue('--ot-green-opacity').trim(),
|
|
40
|
+
orangeOpacity: style.getPropertyValue('--ot-orange-opacity').trim(),
|
|
41
|
+
redOpacity: style.getPropertyValue('--ot-red-opacity').trim()
|
|
45
42
|
};
|
|
43
|
+
};
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if(datasets.length === 0)
|
|
56
|
-
{
|
|
57
|
-
return [{
|
|
58
|
-
label: 'Sample Data',
|
|
59
|
-
data: [75, 60, 85, 70, 80],
|
|
60
|
-
backgroundColor: fill ? paletteOpacity[0] : 'transparent',
|
|
61
|
-
borderColor: palette[0],
|
|
62
|
-
borderWidth: 2,
|
|
63
|
-
pointBackgroundColor: palette[0],
|
|
64
|
-
pointBorderColor: '#fff',
|
|
65
|
-
pointHoverBackgroundColor: '#fff',
|
|
66
|
-
pointHoverBorderColor: palette[0]
|
|
67
|
-
}];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return datasets.map((dataset, index) =>
|
|
71
|
-
{
|
|
72
|
-
const color = palette[index % palette.length];
|
|
73
|
-
const colorOpacity = paletteOpacity[index % paletteOpacity.length];
|
|
45
|
+
this.datasets = () =>
|
|
46
|
+
{
|
|
47
|
+
const datasets = data['datasets'];
|
|
48
|
+
const colors = this.colors();
|
|
49
|
+
const palette = [colors.brand, colors.blue, colors.green, colors.orange, colors.red];
|
|
50
|
+
const paletteOpacity = [colors.brandOpacity, colors.blueOpacity, colors.greenOpacity, colors.orangeOpacity, colors.redOpacity];
|
|
51
|
+
const fill = data['fill'];
|
|
74
52
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
53
|
+
if(datasets.length === 0)
|
|
54
|
+
{
|
|
55
|
+
return [{
|
|
56
|
+
label: 'Sample Data',
|
|
57
|
+
data: [75, 60, 85, 70, 80],
|
|
58
|
+
backgroundColor: fill ? paletteOpacity[0] : 'transparent',
|
|
59
|
+
borderColor: palette[0],
|
|
60
|
+
borderWidth: 2,
|
|
61
|
+
pointBackgroundColor: palette[0],
|
|
62
|
+
pointBorderColor: '#fff',
|
|
63
|
+
pointHoverBackgroundColor: '#fff',
|
|
64
|
+
pointHoverBorderColor: palette[0]
|
|
65
|
+
}];
|
|
66
|
+
}
|
|
87
67
|
|
|
88
|
-
|
|
68
|
+
return datasets.map((dataset, index) =>
|
|
89
69
|
{
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const gridColor = style.getPropertyValue('--ot-bg-3-border').trim();
|
|
70
|
+
const color = palette[index % palette.length];
|
|
71
|
+
const colorOpacity = paletteOpacity[index % paletteOpacity.length];
|
|
93
72
|
|
|
94
73
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
74
|
+
...dataset,
|
|
75
|
+
backgroundColor: dataset.backgroundColor || (fill ? colorOpacity : 'transparent'),
|
|
76
|
+
borderColor: dataset.borderColor || color,
|
|
77
|
+
borderWidth: dataset.borderWidth || 2,
|
|
78
|
+
pointBackgroundColor: dataset.pointBackgroundColor || color,
|
|
79
|
+
pointBorderColor: dataset.pointBorderColor || '#fff',
|
|
80
|
+
pointHoverBackgroundColor: dataset.pointHoverBackgroundColor || '#fff',
|
|
81
|
+
pointHoverBorderColor: dataset.pointHoverBorderColor || color
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
this.config = () =>
|
|
87
|
+
{
|
|
88
|
+
const style = getComputedStyle(document.body);
|
|
89
|
+
const textColor = style.getPropertyValue('--ot-text-1').trim();
|
|
90
|
+
const gridColor = style.getPropertyValue('--ot-bg-3-border').trim();
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
type: 'radar',
|
|
94
|
+
data: {
|
|
95
|
+
labels: data['labels'],
|
|
96
|
+
datasets: this.datasets()
|
|
97
|
+
},
|
|
98
|
+
options: {
|
|
99
|
+
responsive: true,
|
|
100
|
+
maintainAspectRatio: false,
|
|
101
|
+
plugins: {
|
|
102
|
+
legend: {
|
|
103
|
+
labels: {
|
|
104
|
+
color: textColor,
|
|
105
|
+
font: {
|
|
106
|
+
family: style.getPropertyValue('--ot-font-primary').trim()
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
scales: {
|
|
112
|
+
r: {
|
|
113
|
+
angleLines: {
|
|
114
|
+
color: gridColor
|
|
115
|
+
},
|
|
116
|
+
grid: {
|
|
117
|
+
color: gridColor
|
|
118
|
+
},
|
|
119
|
+
pointLabels: {
|
|
120
|
+
color: textColor
|
|
121
|
+
},
|
|
122
|
+
ticks: {
|
|
123
|
+
color: textColor,
|
|
124
|
+
backdropColor: 'transparent'
|
|
125
|
+
},
|
|
126
|
+
beginAtZero: true
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
...data['options']
|
|
130
|
+
}
|
|
134
131
|
};
|
|
132
|
+
};
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
this.initialize = () =>
|
|
135
|
+
{
|
|
136
|
+
setTimeout(() =>
|
|
137
137
|
{
|
|
138
|
-
|
|
138
|
+
if(typeof Chart === 'undefined')
|
|
139
139
|
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
140
|
+
console.error('Chart.js library not loaded');
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
145
143
|
|
|
146
|
-
|
|
147
|
-
|
|
144
|
+
const context = this.canvas.getContext('2d');
|
|
145
|
+
this.instance = new Chart(context, this.config());
|
|
148
146
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
node.chart = this.instance;
|
|
148
|
+
}, 100);
|
|
149
|
+
};
|
|
152
150
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
151
|
+
this.setup();
|
|
152
|
+
this.initialize();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
@@ -1,152 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
],
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
transforms.ItemAdd({
|
|
2
|
+
id: 'ot-chart-scatter',
|
|
3
|
+
icon: 'scatter_plot',
|
|
4
|
+
name: 'Scatter Plot',
|
|
5
|
+
description: 'Scatter plot for correlation data. Show relationship between two variables with points.',
|
|
6
|
+
js: [
|
|
7
|
+
'https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js'
|
|
8
|
+
],
|
|
9
|
+
config: {
|
|
10
|
+
'datasets': ['array', []],
|
|
11
|
+
'options': ['object', {}]
|
|
12
|
+
},
|
|
13
|
+
code: function(data, node, transformer)
|
|
14
|
+
{
|
|
15
|
+
this.setup = () =>
|
|
16
16
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
node.innerHTML = '';
|
|
20
|
-
node.classList.add('ot-chart-scatter');
|
|
17
|
+
node.innerHTML = '';
|
|
18
|
+
node.classList.add('ot-chart-scatter');
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const canvas = document.createElement('canvas');
|
|
21
|
+
this.canvas = canvas;
|
|
22
|
+
node.appendChild(canvas);
|
|
23
|
+
};
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
this.colors = () =>
|
|
26
|
+
{
|
|
27
|
+
const style = getComputedStyle(document.body);
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
29
|
+
return {
|
|
30
|
+
brand: style.getPropertyValue('--ot-brand').trim(),
|
|
31
|
+
blue: style.getPropertyValue('--ot-blue').trim(),
|
|
32
|
+
green: style.getPropertyValue('--ot-green').trim(),
|
|
33
|
+
orange: style.getPropertyValue('--ot-orange').trim(),
|
|
34
|
+
red: style.getPropertyValue('--ot-red').trim()
|
|
38
35
|
};
|
|
36
|
+
};
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if(datasets.length === 0)
|
|
47
|
-
{
|
|
48
|
-
return [{
|
|
49
|
-
label: 'Sample Data',
|
|
50
|
-
data: [
|
|
51
|
-
{x: 10, y: 20},
|
|
52
|
-
{x: 15, y: 35},
|
|
53
|
-
{x: 20, y: 30},
|
|
54
|
-
{x: 25, y: 45},
|
|
55
|
-
{x: 30, y: 40},
|
|
56
|
-
{x: 35, y: 55}
|
|
57
|
-
],
|
|
58
|
-
backgroundColor: palette[0],
|
|
59
|
-
borderColor: palette[0],
|
|
60
|
-
borderWidth: 1,
|
|
61
|
-
pointRadius: 5
|
|
62
|
-
}];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return datasets.map((dataset, index) =>
|
|
66
|
-
{
|
|
67
|
-
const color = palette[index % palette.length];
|
|
38
|
+
this.datasets = () =>
|
|
39
|
+
{
|
|
40
|
+
const datasets = data['datasets'];
|
|
41
|
+
const colors = this.colors();
|
|
42
|
+
const palette = [colors.brand, colors.blue, colors.green, colors.orange, colors.red];
|
|
68
43
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
if(datasets.length === 0)
|
|
45
|
+
{
|
|
46
|
+
return [{
|
|
47
|
+
label: 'Sample Data',
|
|
48
|
+
data: [
|
|
49
|
+
{x: 10, y: 20},
|
|
50
|
+
{x: 15, y: 35},
|
|
51
|
+
{x: 20, y: 30},
|
|
52
|
+
{x: 25, y: 45},
|
|
53
|
+
{x: 30, y: 40},
|
|
54
|
+
{x: 35, y: 55}
|
|
55
|
+
],
|
|
56
|
+
backgroundColor: palette[0],
|
|
57
|
+
borderColor: palette[0],
|
|
58
|
+
borderWidth: 1,
|
|
59
|
+
pointRadius: 5
|
|
60
|
+
}];
|
|
61
|
+
}
|
|
78
62
|
|
|
79
|
-
|
|
63
|
+
return datasets.map((dataset, index) =>
|
|
80
64
|
{
|
|
81
|
-
const
|
|
82
|
-
const textColor = style.getPropertyValue('--ot-text-1').trim();
|
|
83
|
-
const gridColor = style.getPropertyValue('--ot-bg-3-border').trim();
|
|
65
|
+
const color = palette[index % palette.length];
|
|
84
66
|
|
|
85
67
|
return {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
68
|
+
...dataset,
|
|
69
|
+
backgroundColor: dataset.backgroundColor || color,
|
|
70
|
+
borderColor: dataset.borderColor || color,
|
|
71
|
+
borderWidth: dataset.borderWidth || 1,
|
|
72
|
+
pointRadius: dataset.pointRadius || 5
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
this.config = () =>
|
|
78
|
+
{
|
|
79
|
+
const style = getComputedStyle(document.body);
|
|
80
|
+
const textColor = style.getPropertyValue('--ot-text-1').trim();
|
|
81
|
+
const gridColor = style.getPropertyValue('--ot-bg-3-border').trim();
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
type: 'scatter',
|
|
85
|
+
data: {
|
|
86
|
+
datasets: this.datasets()
|
|
87
|
+
},
|
|
88
|
+
options: {
|
|
89
|
+
responsive: true,
|
|
90
|
+
maintainAspectRatio: false,
|
|
91
|
+
plugins: {
|
|
92
|
+
legend: {
|
|
93
|
+
labels: {
|
|
94
|
+
color: textColor,
|
|
95
|
+
font: {
|
|
96
|
+
family: style.getPropertyValue('--ot-font-primary').trim()
|
|
100
97
|
}
|
|
101
98
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
},
|
|
115
|
-
y: {
|
|
116
|
-
type: 'linear',
|
|
117
|
-
ticks: { color: textColor },
|
|
118
|
-
grid: { color: gridColor },
|
|
119
|
-
title: {
|
|
120
|
-
display: true,
|
|
121
|
-
text: 'Y Axis',
|
|
122
|
-
color: textColor
|
|
123
|
-
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
scales: {
|
|
102
|
+
x: {
|
|
103
|
+
type: 'linear',
|
|
104
|
+
position: 'bottom',
|
|
105
|
+
ticks: { color: textColor },
|
|
106
|
+
grid: { color: gridColor },
|
|
107
|
+
title: {
|
|
108
|
+
display: true,
|
|
109
|
+
text: 'X Axis',
|
|
110
|
+
color: textColor
|
|
124
111
|
}
|
|
125
112
|
},
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
113
|
+
y: {
|
|
114
|
+
type: 'linear',
|
|
115
|
+
ticks: { color: textColor },
|
|
116
|
+
grid: { color: gridColor },
|
|
117
|
+
title: {
|
|
118
|
+
display: true,
|
|
119
|
+
text: 'Y Axis',
|
|
120
|
+
color: textColor
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
...data['options']
|
|
125
|
+
}
|
|
129
126
|
};
|
|
127
|
+
};
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
this.initialize = () =>
|
|
130
|
+
{
|
|
131
|
+
setTimeout(() =>
|
|
132
132
|
{
|
|
133
|
-
|
|
133
|
+
if(typeof Chart === 'undefined')
|
|
134
134
|
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
135
|
+
console.error('Chart.js library not loaded');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
140
138
|
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
const context = this.canvas.getContext('2d');
|
|
140
|
+
this.instance = new Chart(context, this.config());
|
|
143
141
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
node.chart = this.instance;
|
|
143
|
+
}, 100);
|
|
144
|
+
};
|
|
147
145
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
146
|
+
this.setup();
|
|
147
|
+
this.initialize();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
onetype.AddonReady('transforms', (transforms) =>
|
|
2
|
-
{
|
|
3
1
|
transforms.ItemAdd({
|
|
4
2
|
id: 'codeflask',
|
|
5
3
|
icon: 'code',
|
|
@@ -15,14 +13,14 @@ onetype.AddonReady('transforms', (transforms) =>
|
|
|
15
13
|
'readonly': ['boolean', false],
|
|
16
14
|
'onUpdate': ['function']
|
|
17
15
|
},
|
|
18
|
-
code: function(data,
|
|
16
|
+
code: function(data, node, transformer)
|
|
19
17
|
{
|
|
20
18
|
this.setup = () =>
|
|
21
19
|
{
|
|
22
20
|
node.classList.add('codeflask-editor');
|
|
23
21
|
node.classList.add('codeflask-editor-' + identifier);
|
|
24
22
|
|
|
25
|
-
const initialValue = data['value']
|
|
23
|
+
const initialValue = data['value'] || node.textContent || '';
|
|
26
24
|
node.innerHTML = '';
|
|
27
25
|
|
|
28
26
|
this.container = document.createElement('div');
|
|
@@ -36,17 +34,17 @@ onetype.AddonReady('transforms', (transforms) =>
|
|
|
36
34
|
{
|
|
37
35
|
const style = document.createElement('style');
|
|
38
36
|
style.textContent = `
|
|
39
|
-
.codeflask-editor-${
|
|
37
|
+
.codeflask-editor-${id}
|
|
40
38
|
{
|
|
41
39
|
height: 100%;
|
|
42
40
|
width: 100%;
|
|
43
41
|
}
|
|
44
|
-
.codeflask-editor-${
|
|
42
|
+
.codeflask-editor-${id} .codeflask-container
|
|
45
43
|
{
|
|
46
44
|
height: 100%;
|
|
47
45
|
width: 100%;
|
|
48
46
|
}
|
|
49
|
-
.codeflask-editor-${
|
|
47
|
+
.codeflask-editor-${id} .codeflask
|
|
50
48
|
{
|
|
51
49
|
height: 100%;
|
|
52
50
|
}
|
|
@@ -66,9 +64,9 @@ onetype.AddonReady('transforms', (transforms) =>
|
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
const flask = new CodeFlask(this.container, {
|
|
69
|
-
language: data['language']
|
|
70
|
-
lineNumbers: data['line-numbers']
|
|
71
|
-
readonly: data['readonly']
|
|
67
|
+
language: data['language'] || 'markup',
|
|
68
|
+
lineNumbers: data['line-numbers'] !== false,
|
|
69
|
+
readonly: data['readonly'] === true
|
|
72
70
|
});
|
|
73
71
|
|
|
74
72
|
flask.updateCode(this.initialValue);
|
|
@@ -77,7 +75,7 @@ onetype.AddonReady('transforms', (transforms) =>
|
|
|
77
75
|
|
|
78
76
|
flask.onUpdate((code) =>
|
|
79
77
|
{
|
|
80
|
-
// const onUpdate = data['onUpdate']
|
|
78
|
+
// const onUpdate = data['onUpdate'];
|
|
81
79
|
// if(typeof onUpdate === 'function')
|
|
82
80
|
// {
|
|
83
81
|
// onUpdate({value: code, node});
|
|
@@ -96,4 +94,4 @@ onetype.AddonReady('transforms', (transforms) =>
|
|
|
96
94
|
this.initialize();
|
|
97
95
|
}
|
|
98
96
|
});
|
|
99
|
-
|
|
97
|
+
|