@odoo/o-spreadsheet 14.0.1 → 14.0.2
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/dist/o_spreadsheet.cjs.js +17836 -0
- package/dist/o_spreadsheet.d.ts +4102 -0
- package/dist/o_spreadsheet.esm.js +17801 -0
- package/dist/o_spreadsheet.iife.js +17838 -0
- package/dist/o_spreadsheet.iife.min.js +1440 -0
- package/package.json +27 -7
- package/readme.md +10 -0
- package/.eslintrc.json +0 -20
- package/.husky/post-checkout +0 -9
- package/.husky/pre-commit +0 -39
- package/.prettierignore +0 -1
- package/astToFormula.patch +0 -0
- package/demo/data.js +0 -255
- package/demo/index.html +0 -9
- package/demo/libs/Chart.bundle.js +0 -20755
- package/demo/main.js +0 -101
- package/doc/readme.md +0 -46
- package/rollup.config.js +0 -23
- package/src/base_plugin.ts +0 -102
- package/src/components/autofill.ts +0 -146
- package/src/components/bottom_bar.ts +0 -199
- package/src/components/color_picker.ts +0 -150
- package/src/components/composer/autocomplete_dropdown.ts +0 -135
- package/src/components/composer/composer.ts +0 -487
- package/src/components/composer/content_editable_helper.ts +0 -146
- package/src/components/figures/chart.ts +0 -70
- package/src/components/figures/container.ts +0 -268
- package/src/components/figures/text_figure.ts +0 -36
- package/src/components/grid.ts +0 -635
- package/src/components/helpers/dom_helpers.ts +0 -7
- package/src/components/helpers/drag_and_drop.ts +0 -17
- package/src/components/icons.ts +0 -36
- package/src/components/index.ts +0 -1
- package/src/components/menu.ts +0 -288
- package/src/components/overlay.ts +0 -457
- package/src/components/scrollbar.ts +0 -22
- package/src/components/selection_input.ts +0 -168
- package/src/components/side_panel/cell_is_rule_editor.ts +0 -169
- package/src/components/side_panel/chart_panel.ts +0 -104
- package/src/components/side_panel/color_scale_rule_editor.ts +0 -145
- package/src/components/side_panel/conditional_formatting.ts +0 -396
- package/src/components/side_panel/side_panel.ts +0 -127
- package/src/components/side_panel/translations_terms.ts +0 -45
- package/src/components/spreadsheet.ts +0 -198
- package/src/components/top_bar.ts +0 -535
- package/src/constants.ts +0 -26
- package/src/data.ts +0 -149
- package/src/fonts.ts +0 -41
- package/src/formulas/compiler.ts +0 -258
- package/src/formulas/composer_tokenizer.ts +0 -70
- package/src/formulas/index.ts +0 -15
- package/src/formulas/normalize.ts +0 -52
- package/src/formulas/parser.ts +0 -280
- package/src/formulas/range_tokenizer.ts +0 -97
- package/src/formulas/tokenizer.ts +0 -242
- package/src/functions/arguments.ts +0 -114
- package/src/functions/dates.ts +0 -302
- package/src/functions/helpers.ts +0 -592
- package/src/functions/index.ts +0 -52
- package/src/functions/module_database.ts +0 -282
- package/src/functions/module_date.ts +0 -743
- package/src/functions/module_info.ts +0 -69
- package/src/functions/module_logical.ts +0 -208
- package/src/functions/module_lookup.ts +0 -185
- package/src/functions/module_math.ts +0 -1252
- package/src/functions/module_operators.ts +0 -291
- package/src/functions/module_statistical.ts +0 -882
- package/src/functions/module_text.ts +0 -370
- package/src/helpers/color.ts +0 -30
- package/src/helpers/coordinates.ts +0 -71
- package/src/helpers/grid_manipulation.ts +0 -68
- package/src/helpers/index.ts +0 -7
- package/src/helpers/misc.ts +0 -76
- package/src/helpers/numbers.ts +0 -117
- package/src/helpers/uuid.ts +0 -19
- package/src/helpers/zones.ts +0 -263
- package/src/history.ts +0 -186
- package/src/index.ts +0 -84
- package/src/model.ts +0 -261
- package/src/plugins/autofill.ts +0 -412
- package/src/plugins/chart.ts +0 -404
- package/src/plugins/clipboard.ts +0 -461
- package/src/plugins/conditional_format.ts +0 -445
- package/src/plugins/core.ts +0 -1502
- package/src/plugins/edition.ts +0 -157
- package/src/plugins/evaluation.ts +0 -428
- package/src/plugins/figures.ts +0 -123
- package/src/plugins/formatting.ts +0 -630
- package/src/plugins/highlight.ts +0 -187
- package/src/plugins/index.ts +0 -32
- package/src/plugins/merge.ts +0 -524
- package/src/plugins/renderer.ts +0 -571
- package/src/plugins/selection.ts +0 -562
- package/src/plugins/selection_inputs.ts +0 -326
- package/src/registries/autofill_modifiers.ts +0 -76
- package/src/registries/autofill_rules.ts +0 -98
- package/src/registries/figure_registry.ts +0 -30
- package/src/registries/index.ts +0 -7
- package/src/registries/menu_items_registry.ts +0 -110
- package/src/registries/menus/cell_menu_registry.ts +0 -79
- package/src/registries/menus/col_menu_registry.ts +0 -63
- package/src/registries/menus/index.ts +0 -6
- package/src/registries/menus/menu_items_actions.ts +0 -425
- package/src/registries/menus/row_menu_registry.ts +0 -63
- package/src/registries/menus/sheet_menu_registry.ts +0 -75
- package/src/registries/menus/topbar_menu_registry.ts +0 -204
- package/src/registries/side_panel_registry.ts +0 -26
- package/src/registries/topbar_component_registry.ts +0 -12
- package/src/registry.ts +0 -51
- package/src/translation.ts +0 -44
- package/src/types/autofill.ts +0 -48
- package/src/types/chart.ts +0 -26
- package/src/types/commands.ts +0 -716
- package/src/types/conditional_formatting.ts +0 -124
- package/src/types/env.ts +0 -13
- package/src/types/functions.ts +0 -35
- package/src/types/getters.ts +0 -103
- package/src/types/index.ts +0 -20
- package/src/types/misc.ts +0 -143
- package/src/types/rendering.ts +0 -41
- package/src/types/workbook_data.ts +0 -62
- package/tests/__mocks__/uuid.ts +0 -7
- package/tests/canvas.mock.ts +0 -34
- package/tests/components/__mocks__/content_editable_helper.ts +0 -79
- package/tests/components/__mocks__/scrollbar.ts +0 -18
- package/tests/components/__snapshots__/autocomplete_dropdown_test.ts.snap +0 -29
- package/tests/components/__snapshots__/bottom_bar_test.ts.snap +0 -75
- package/tests/components/__snapshots__/context_menu_test.ts.snap +0 -88
- package/tests/components/__snapshots__/grid_test.ts.snap +0 -60
- package/tests/components/__snapshots__/spreadsheet_test.ts.snap +0 -455
- package/tests/components/__snapshots__/top_bar_test.ts.snap +0 -705
- package/tests/components/autocomplete_dropdown_test.ts +0 -315
- package/tests/components/autofill_test.ts +0 -167
- package/tests/components/bottom_bar_test.ts +0 -262
- package/tests/components/chart_side_panel_test.ts +0 -123
- package/tests/components/composer_test.ts +0 -400
- package/tests/components/context_menu_test.ts +0 -825
- package/tests/components/grid_manipulation_test.ts +0 -163
- package/tests/components/grid_test.ts +0 -581
- package/tests/components/overlay_test.ts +0 -541
- package/tests/components/selection_input_test.ts +0 -259
- package/tests/components/side_panel_test.ts +0 -148
- package/tests/components/spreadsheet_test.ts +0 -194
- package/tests/components/top_bar_test.ts +0 -427
- package/tests/data_test.ts +0 -175
- package/tests/dom_helper.ts +0 -42
- package/tests/formulas/__snapshots__/compiler_test.ts.snap +0 -302
- package/tests/formulas/compiler_test.ts +0 -266
- package/tests/formulas/composer_tokenizer_test.ts +0 -137
- package/tests/formulas/expressions_test.ts +0 -57
- package/tests/formulas/formulas_test.ts +0 -80
- package/tests/formulas/normalize_test.ts +0 -82
- package/tests/formulas/parser_test.ts +0 -224
- package/tests/formulas/range_tokenizer_test.ts +0 -187
- package/tests/formulas/tokenizer_test.ts +0 -164
- package/tests/functions/arguments_test.ts +0 -141
- package/tests/functions/dates_test.ts +0 -1081
- package/tests/functions/functions_test.ts +0 -53
- package/tests/functions/helper_test.ts +0 -98
- package/tests/functions/module_database_test.ts +0 -311
- package/tests/functions/module_date_test.ts +0 -941
- package/tests/functions/module_info_test.ts +0 -139
- package/tests/functions/module_logical_test.ts +0 -369
- package/tests/functions/module_lookup_test.ts +0 -541
- package/tests/functions/module_math_test.ts +0 -2482
- package/tests/functions/module_operators_test.ts +0 -955
- package/tests/functions/module_statistical_test.ts +0 -2014
- package/tests/functions/module_text_test.ts +0 -667
- package/tests/helpers/coordinates_test.ts +0 -25
- package/tests/helpers/misc_test.ts +0 -95
- package/tests/helpers/numbers_test.ts +0 -196
- package/tests/helpers/zones_test.ts +0 -97
- package/tests/helpers.ts +0 -384
- package/tests/menu_items_registry_test.ts +0 -540
- package/tests/model/plugins/__snapshots__/chart_test.ts.snap +0 -90
- package/tests/model/plugins/chart_test.ts +0 -562
- package/tests/model_test.ts +0 -82
- package/tests/plugins/__snapshots__/conditional_formatting_test.ts.snap +0 -131
- package/tests/plugins/__snapshots__/renderer_test.ts.snap +0 -371
- package/tests/plugins/autofill_test.ts +0 -457
- package/tests/plugins/borders_test.ts +0 -295
- package/tests/plugins/clipboard_test.ts +0 -1180
- package/tests/plugins/conditional_formatting_test.ts +0 -1253
- package/tests/plugins/core_test.ts +0 -614
- package/tests/plugins/edition_test.ts +0 -100
- package/tests/plugins/evaluation_async_test.ts +0 -332
- package/tests/plugins/evaluation_dates_test.ts +0 -79
- package/tests/plugins/evaluation_test.ts +0 -901
- package/tests/plugins/figures_test.ts +0 -327
- package/tests/plugins/formatting_test.ts +0 -391
- package/tests/plugins/grid_manipulation_test.ts +0 -1366
- package/tests/plugins/highlight_test.ts +0 -413
- package/tests/plugins/history_test.ts +0 -142
- package/tests/plugins/import_export_test.ts +0 -276
- package/tests/plugins/merges_test.ts +0 -490
- package/tests/plugins/navigation_test.ts +0 -181
- package/tests/plugins/plugins/evaluation_test.ts +0 -111
- package/tests/plugins/renderer_test.ts +0 -598
- package/tests/plugins/resizing_test.ts +0 -152
- package/tests/plugins/selection_input_test.ts +0 -409
- package/tests/plugins/selection_test.ts +0 -442
- package/tests/plugins/sheets_test.ts +0 -643
- package/tests/plugins/style_test.ts +0 -90
- package/tsconfig.json +0 -22
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import * as owl from "@odoo/owl";
|
|
2
|
-
import { Component } from "@odoo/owl";
|
|
3
|
-
import { HEADER_HEIGHT, HEADER_WIDTH, SELECTION_BORDER_COLOR } from "../../constants";
|
|
4
|
-
import { figureRegistry } from "../../registries/index";
|
|
5
|
-
import { Figure, SpreadsheetEnv, Viewport } from "../../types/index";
|
|
6
|
-
import { startDnd } from "../helpers/drag_and_drop";
|
|
7
|
-
|
|
8
|
-
const { xml, css } = owl.tags;
|
|
9
|
-
const { useState } = owl;
|
|
10
|
-
|
|
11
|
-
interface FigureInfo {
|
|
12
|
-
id: string;
|
|
13
|
-
isSelected: boolean;
|
|
14
|
-
figure: Figure<any>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const TEMPLATE = xml/* xml */ `<div>
|
|
18
|
-
<t t-foreach="getFigures()" t-as="info" t-key="info.id">
|
|
19
|
-
<div class="o-figure-wrapper"
|
|
20
|
-
t-att-style="getStyle(info)"
|
|
21
|
-
t-on-mousedown="onMouseDown(info.figure)"
|
|
22
|
-
>
|
|
23
|
-
<div class="o-figure"
|
|
24
|
-
t-att-class="{active: info.isSelected, 'o-dragging': info.id === dnd.figureId}"
|
|
25
|
-
t-att-style="getDims(info)"
|
|
26
|
-
tabindex="0"
|
|
27
|
-
t-on-keydown.stop="onKeyDown(info.figure)">
|
|
28
|
-
<t t-component="figureRegistry.get(info.figure.tag).Component"
|
|
29
|
-
t-key="info.id"
|
|
30
|
-
figure="info.figure"/>
|
|
31
|
-
<t t-if="info.isSelected">
|
|
32
|
-
<div class="o-anchor o-top" t-on-mousedown.stop="resize(info.figure, 0,-1)"/>
|
|
33
|
-
<div class="o-anchor o-topRight" t-on-mousedown.stop="resize(info.figure, 1,-1)"/>
|
|
34
|
-
<div class="o-anchor o-right" t-on-mousedown.stop="resize(info.figure, 1,0)"/>
|
|
35
|
-
<div class="o-anchor o-bottomRight" t-on-mousedown.stop="resize(info.figure, 1,1)"/>
|
|
36
|
-
<div class="o-anchor o-bottom" t-on-mousedown.stop="resize(info.figure, 0,1)"/>
|
|
37
|
-
<div class="o-anchor o-bottomLeft" t-on-mousedown.stop="resize(info.figure, -1,1)"/>
|
|
38
|
-
<div class="o-anchor o-left" t-on-mousedown.stop="resize(info.figure, -1,0)"/>
|
|
39
|
-
<div class="o-anchor o-topLeft" t-on-mousedown.stop="resize(info.figure, -1,-1)"/>
|
|
40
|
-
</t>
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
</t>
|
|
44
|
-
</div>
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
// -----------------------------------------------------------------------------
|
|
48
|
-
// STYLE
|
|
49
|
-
// -----------------------------------------------------------------------------
|
|
50
|
-
const ANCHOR_SIZE = 8;
|
|
51
|
-
const BORDER_WIDTH = 1;
|
|
52
|
-
const ACTIVE_BORDER_WIDTH = 2;
|
|
53
|
-
const MIN_FIG_SIZE = 80;
|
|
54
|
-
|
|
55
|
-
const CSS = css/*SCSS*/ `
|
|
56
|
-
.o-figure-wrapper {
|
|
57
|
-
overflow: hidden;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.o-figure {
|
|
61
|
-
border: 1px solid black;
|
|
62
|
-
box-sizing: border-box;
|
|
63
|
-
position: absolute;
|
|
64
|
-
bottom: 3px;
|
|
65
|
-
right: 3px;
|
|
66
|
-
&:focus {
|
|
67
|
-
outline: none;
|
|
68
|
-
}
|
|
69
|
-
&.active {
|
|
70
|
-
border: ${ACTIVE_BORDER_WIDTH}px solid ${SELECTION_BORDER_COLOR};
|
|
71
|
-
z-index: 1;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&.o-dragging {
|
|
75
|
-
opacity: 0.9;
|
|
76
|
-
cursor: grabbing;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.o-anchor {
|
|
80
|
-
z-index: 1000;
|
|
81
|
-
position: absolute;
|
|
82
|
-
outline: ${BORDER_WIDTH}px solid white;
|
|
83
|
-
width: ${ANCHOR_SIZE}px;
|
|
84
|
-
height: ${ANCHOR_SIZE}px;
|
|
85
|
-
background-color: #1a73e8;
|
|
86
|
-
&.o-top {
|
|
87
|
-
top: -${ANCHOR_SIZE / 2}px;
|
|
88
|
-
right: 50%;
|
|
89
|
-
cursor: n-resize;
|
|
90
|
-
}
|
|
91
|
-
&.o-topRight {
|
|
92
|
-
top: -${ANCHOR_SIZE / 2}px;
|
|
93
|
-
right: -${ANCHOR_SIZE / 2}px;
|
|
94
|
-
cursor: ne-resize;
|
|
95
|
-
}
|
|
96
|
-
&.o-right {
|
|
97
|
-
right: -${ANCHOR_SIZE / 2}px;
|
|
98
|
-
top: 50%;
|
|
99
|
-
cursor: e-resize;
|
|
100
|
-
}
|
|
101
|
-
&.o-bottomRight {
|
|
102
|
-
bottom: -${ANCHOR_SIZE / 2}px;
|
|
103
|
-
right: -${ANCHOR_SIZE / 2}px;
|
|
104
|
-
cursor: se-resize;
|
|
105
|
-
}
|
|
106
|
-
&.o-bottom {
|
|
107
|
-
bottom: -${ANCHOR_SIZE / 2}px;
|
|
108
|
-
right: 50%;
|
|
109
|
-
cursor: s-resize;
|
|
110
|
-
}
|
|
111
|
-
&.o-bottomLeft {
|
|
112
|
-
bottom: -${ANCHOR_SIZE / 2}px;
|
|
113
|
-
left: -${ANCHOR_SIZE / 2}px;
|
|
114
|
-
cursor: sw-resize;
|
|
115
|
-
}
|
|
116
|
-
&.o-left {
|
|
117
|
-
bottom: 50%;
|
|
118
|
-
left: -${ANCHOR_SIZE / 2}px;
|
|
119
|
-
cursor: w-resize;
|
|
120
|
-
}
|
|
121
|
-
&.o-topLeft {
|
|
122
|
-
top: -${ANCHOR_SIZE / 2}px;
|
|
123
|
-
left: -${ANCHOR_SIZE / 2}px;
|
|
124
|
-
cursor: nw-resize;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
`;
|
|
129
|
-
|
|
130
|
-
export class FiguresContainer extends Component<{ viewport: Viewport }, SpreadsheetEnv> {
|
|
131
|
-
static template = TEMPLATE;
|
|
132
|
-
static style = CSS;
|
|
133
|
-
static components = {};
|
|
134
|
-
figureRegistry = figureRegistry;
|
|
135
|
-
|
|
136
|
-
dnd = useState({
|
|
137
|
-
figureId: "",
|
|
138
|
-
x: 0,
|
|
139
|
-
y: 0,
|
|
140
|
-
width: 0,
|
|
141
|
-
height: 0,
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
getters = this.env.getters;
|
|
145
|
-
dispatch = this.env.dispatch;
|
|
146
|
-
|
|
147
|
-
getFigures(): FigureInfo[] {
|
|
148
|
-
const selectedId = this.getters.getSelectedFigureId();
|
|
149
|
-
return this.getters.getFigures(this.props.viewport).map((f) => ({
|
|
150
|
-
id: f.id,
|
|
151
|
-
isSelected: f.id === selectedId,
|
|
152
|
-
figure: f,
|
|
153
|
-
}));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
getDims(info: FigureInfo) {
|
|
157
|
-
const { figure, isSelected } = info;
|
|
158
|
-
const borders = 2 * (isSelected ? ACTIVE_BORDER_WIDTH : BORDER_WIDTH);
|
|
159
|
-
const { width, height } = isSelected && this.dnd.figureId ? this.dnd : figure;
|
|
160
|
-
return `width:${width + borders}px;height:${height + borders}px`;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
getStyle(info: FigureInfo) {
|
|
164
|
-
const { figure, isSelected } = info;
|
|
165
|
-
const { offsetX, offsetY } = this.props.viewport;
|
|
166
|
-
const target = figure.id === (isSelected && this.dnd.figureId) ? this.dnd : figure;
|
|
167
|
-
const { width, height } = target;
|
|
168
|
-
let x = target.x - offsetX + HEADER_WIDTH - 1;
|
|
169
|
-
let y = target.y - offsetY + HEADER_HEIGHT - 1;
|
|
170
|
-
// width and height of wrapper need to be adjusted so we do not overlap
|
|
171
|
-
// with headers
|
|
172
|
-
const correctionX = Math.max(0, HEADER_WIDTH - x);
|
|
173
|
-
x += correctionX;
|
|
174
|
-
const correctionY = Math.max(0, HEADER_HEIGHT - y);
|
|
175
|
-
y += correctionY;
|
|
176
|
-
|
|
177
|
-
if (width < 0 || height < 0) {
|
|
178
|
-
return `position:absolute;display:none;`;
|
|
179
|
-
}
|
|
180
|
-
const offset =
|
|
181
|
-
ANCHOR_SIZE + ACTIVE_BORDER_WIDTH + (isSelected ? ACTIVE_BORDER_WIDTH : BORDER_WIDTH);
|
|
182
|
-
return `position:absolute; top:${y + 1}px; left:${x + 1}px; width:${
|
|
183
|
-
width - correctionX + offset
|
|
184
|
-
}px; height:${height - correctionY + offset}px`;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
mounted() {
|
|
188
|
-
// horrible, but necessary
|
|
189
|
-
// the following line ensures that we render the figures with the correct
|
|
190
|
-
// viewport. The reason is that whenever we initialize the grid
|
|
191
|
-
// component, we do not know yet the actual size of the viewport, so the
|
|
192
|
-
// first owl rendering is done with an empty viewport. Only then we can
|
|
193
|
-
// compute which figures should be displayed, so we have to force a
|
|
194
|
-
// new rendering
|
|
195
|
-
this.render();
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
resize(figure: Figure<any>, dirX: number, dirY: number, ev: MouseEvent) {
|
|
199
|
-
ev.stopPropagation();
|
|
200
|
-
const initialX = ev.clientX;
|
|
201
|
-
const initialY = ev.clientY;
|
|
202
|
-
this.dnd.figureId = figure.id;
|
|
203
|
-
this.dnd.x = figure.x;
|
|
204
|
-
this.dnd.y = figure.y;
|
|
205
|
-
this.dnd.width = figure.width;
|
|
206
|
-
this.dnd.height = figure.height;
|
|
207
|
-
|
|
208
|
-
const onMouseMove = (ev: MouseEvent) => {
|
|
209
|
-
const deltaX = dirX * (ev.clientX - initialX);
|
|
210
|
-
const deltaY = dirY * (ev.clientY - initialY);
|
|
211
|
-
this.dnd.width = Math.max(figure.width + deltaX, MIN_FIG_SIZE);
|
|
212
|
-
this.dnd.height = Math.max(figure.height + deltaY, MIN_FIG_SIZE);
|
|
213
|
-
if (dirX < 0) {
|
|
214
|
-
this.dnd.x = figure.x - deltaX;
|
|
215
|
-
}
|
|
216
|
-
if (dirY < 0) {
|
|
217
|
-
this.dnd.y = figure.y - deltaY;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
const onMouseUp = (ev: MouseEvent) => {
|
|
221
|
-
this.dnd.figureId = "";
|
|
222
|
-
const update: Partial<Figure<any>> = { id: figure.id, x: this.dnd.x, y: this.dnd.y };
|
|
223
|
-
if (dirX) {
|
|
224
|
-
update.width = this.dnd.width;
|
|
225
|
-
}
|
|
226
|
-
if (dirY) {
|
|
227
|
-
update.height = this.dnd.height;
|
|
228
|
-
}
|
|
229
|
-
this.dispatch("UPDATE_FIGURE", update as any);
|
|
230
|
-
};
|
|
231
|
-
startDnd(onMouseMove, onMouseUp);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
onMouseDown(figure: Figure<any>, ev: MouseEvent) {
|
|
235
|
-
if (ev.button > 0) {
|
|
236
|
-
// not main button, probably a context menu
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
this.dispatch("SELECT_FIGURE", { id: figure.id });
|
|
240
|
-
const initialX = ev.clientX;
|
|
241
|
-
const initialY = ev.clientY;
|
|
242
|
-
this.dnd.figureId = figure.id;
|
|
243
|
-
this.dnd.x = figure.x;
|
|
244
|
-
this.dnd.y = figure.y;
|
|
245
|
-
this.dnd.width = figure.width;
|
|
246
|
-
this.dnd.height = figure.height;
|
|
247
|
-
|
|
248
|
-
const onMouseMove = (ev: MouseEvent) => {
|
|
249
|
-
this.dnd.x = Math.max(figure.x - initialX + ev.clientX, 0);
|
|
250
|
-
this.dnd.y = Math.max(figure.y - initialY + ev.clientY, 0);
|
|
251
|
-
};
|
|
252
|
-
const onMouseUp = (ev: MouseEvent) => {
|
|
253
|
-
this.dnd.figureId = "";
|
|
254
|
-
this.dispatch("UPDATE_FIGURE", { id: figure.id, x: this.dnd.x, y: this.dnd.y });
|
|
255
|
-
};
|
|
256
|
-
startDnd(onMouseMove, onMouseUp);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
onKeyDown(figure: Figure<any>, ev: KeyboardEvent) {
|
|
260
|
-
switch (ev.key) {
|
|
261
|
-
case "Delete":
|
|
262
|
-
ev.preventDefault();
|
|
263
|
-
this.dispatch("DELETE_FIGURE", { id: figure.id });
|
|
264
|
-
this.trigger("figure-deleted");
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Component, tags } from "@odoo/owl";
|
|
2
|
-
import { Figure, SpreadsheetEnv } from "../../types/index";
|
|
3
|
-
|
|
4
|
-
const { xml, css } = tags;
|
|
5
|
-
|
|
6
|
-
const TEMPLATE = xml/* xml */ `
|
|
7
|
-
<div class="o-fig-text">
|
|
8
|
-
<p t-esc="props.figure.data"/>
|
|
9
|
-
</div>
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
// -----------------------------------------------------------------------------
|
|
13
|
-
// STYLE
|
|
14
|
-
// -----------------------------------------------------------------------------
|
|
15
|
-
const CSS = css/* scss */ `
|
|
16
|
-
.o-fig-text {
|
|
17
|
-
width: 100%;
|
|
18
|
-
height: 100%;
|
|
19
|
-
margin: 0px;
|
|
20
|
-
background-color: #eee;
|
|
21
|
-
position: absolute;
|
|
22
|
-
|
|
23
|
-
> p {
|
|
24
|
-
margin: 5px;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
interface Props {
|
|
30
|
-
figure: Figure<string>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class TextFigure extends Component<Props, SpreadsheetEnv> {
|
|
34
|
-
static template = TEMPLATE;
|
|
35
|
-
static style = CSS;
|
|
36
|
-
}
|