Browse Source

feat: add dist

wxyyxc1992 5 years ago
parent
commit
1cc4d964d4
89 changed files with 1474 additions and 791 deletions
  1. 42
    0
      dist/cjs/board/Baseboard/index.js
  2. 280
    0
      dist/cjs/board/Drawboard/index.js
  3. 122
    0
      dist/cjs/board/WhitePage/index.js
  4. 214
    0
      dist/cjs/board/Whiteboard/index.js
  5. 2
    0
      dist/cjs/board/types.js
  6. 2
    0
      dist/cjs/event/Event.js
  7. 24
    0
      dist/cjs/event/EventHub.js
  8. 4
    0
      dist/cjs/index.js
  9. 6
    4
      dist/cjs/markers/ArrowMarker/index.js
  10. 2
    2
      dist/cjs/markers/BaseMarker/ResizeGrip.js
  11. 40
    15
      dist/cjs/markers/BaseMarker/index.js
  12. 8
    5
      dist/cjs/markers/CoverMarker/index.js
  13. 8
    5
      dist/cjs/markers/HighlightMarker/index.js
  14. 9
    6
      dist/cjs/markers/LineMarker/index.js
  15. 48
    27
      dist/cjs/markers/LinearMarker/index.js
  16. 14
    13
      dist/cjs/markers/RectMarker/RectBaseMarker.js
  17. 8
    5
      dist/cjs/markers/RectMarker/index.js
  18. 0
    0
      dist/cjs/markers/RectangularMarker/RectangularMarkerGrips.js
  19. 53
    19
      dist/cjs/markers/RectangularMarker/index.js
  20. 21
    14
      dist/cjs/markers/TextMarker/index.js
  21. 0
    14
      dist/cjs/markers/arrow/ArrowMarkerToolbarItem.js
  22. 0
    14
      dist/cjs/markers/cover/CoverMarkerToolbarItem.js
  23. 0
    14
      dist/cjs/markers/highlight/HighlightMarkerToolbarItem.js
  24. 0
    14
      dist/cjs/markers/line/LineMarkerToolbarItem.js
  25. 0
    14
      dist/cjs/markers/rect/RectMarkerToolbarItem.js
  26. 0
    14
      dist/cjs/markers/text/TextMarkerToolbarItem.js
  27. 30
    0
      dist/cjs/markers/types.js
  28. 0
    20
      dist/cjs/render/Activator.js
  29. 0
    305
      dist/cjs/render/MarkerArea.js
  30. 0
    0
      dist/cjs/renderer/SvgHelper/index.js
  31. 9
    5
      dist/cjs/renderer/Synthetizer/index.js
  32. 12
    1
      dist/cjs/toolbar/Toolbar.js
  33. 2
    2
      dist/cjs/toolbar/ToolbarButton.js
  34. 11
    0
      dist/cjs/toolbar/ToolbarItem.js
  35. 93
    0
      dist/cjs/toolbar/toolbar-items.js
  36. 20
    0
      dist/cjs/utils/dom.js
  37. 4
    0
      dist/cjs/utils/uuid.js
  38. 9
    0
      dist/cjs/utils/validator.js
  39. 1
    1
      dist/index.js
  40. 15
    0
      dist/types/board/Baseboard/index.d.ts
  41. 53
    0
      dist/types/board/Drawboard/index.d.ts
  42. 28
    0
      dist/types/board/WhitePage/index.d.ts
  43. 41
    0
      dist/types/board/Whiteboard/index.d.ts
  44. 5
    0
      dist/types/board/types.d.ts
  45. 11
    0
      dist/types/event/Event.d.ts
  46. 3
    0
      dist/types/event/EventHub.d.ts
  47. 1
    0
      dist/types/index.d.ts
  48. 9
    0
      dist/types/markers/ArrowMarker/index.d.ts
  49. 0
    0
      dist/types/markers/BaseMarker/ResizeGrip.d.ts
  50. 41
    0
      dist/types/markers/BaseMarker/index.d.ts
  51. 8
    0
      dist/types/markers/CoverMarker/index.d.ts
  52. 8
    0
      dist/types/markers/HighlightMarker/index.d.ts
  53. 8
    0
      dist/types/markers/LineMarker/index.d.ts
  54. 32
    0
      dist/types/markers/LinearMarker/index.d.ts
  55. 9
    0
      dist/types/markers/RectMarker/RectBaseMarker.d.ts
  56. 8
    0
      dist/types/markers/RectMarker/index.d.ts
  57. 1
    1
      dist/types/markers/RectangularMarker/RectangularMarkerGrips.d.ts
  58. 28
    0
      dist/types/markers/RectangularMarker/index.d.ts
  59. 26
    0
      dist/types/markers/TextMarker/index.d.ts
  60. 0
    6
      dist/types/markers/arrow/ArrowMarker.d.ts
  61. 0
    8
      dist/types/markers/arrow/ArrowMarkerToolbarItem.d.ts
  62. 0
    27
      dist/types/markers/base/MarkerBase.d.ts
  63. 0
    25
      dist/types/markers/base/RectangularMarkerBase.d.ts
  64. 0
    5
      dist/types/markers/cover/CoverMarker.d.ts
  65. 0
    8
      dist/types/markers/cover/CoverMarkerToolbarItem.d.ts
  66. 0
    5
      dist/types/markers/highlight/HighlightMarker.d.ts
  67. 0
    8
      dist/types/markers/highlight/HighlightMarkerToolbarItem.d.ts
  68. 0
    5
      dist/types/markers/line/LineMarker.d.ts
  69. 0
    30
      dist/types/markers/line/LineMarkerBase.d.ts
  70. 0
    8
      dist/types/markers/line/LineMarkerToolbarItem.d.ts
  71. 0
    5
      dist/types/markers/rect/RectMarker.d.ts
  72. 0
    7
      dist/types/markers/rect/RectMarkerBase.d.ts
  73. 0
    8
      dist/types/markers/rect/RectMarkerToolbarItem.d.ts
  74. 0
    21
      dist/types/markers/text/TextMarker.d.ts
  75. 0
    8
      dist/types/markers/text/TextMarkerToolbarItem.d.ts
  76. 3
    0
      dist/types/markers/types.d.ts
  77. 0
    4
      dist/types/render/Activator.d.ts
  78. 0
    55
      dist/types/render/MarkerArea.d.ts
  79. 0
    3
      dist/types/render/Renderer.d.ts
  80. 0
    0
      dist/types/renderer/SvgHelper/index.d.ts
  81. 3
    0
      dist/types/renderer/Synthetizer/index.d.ts
  82. 3
    0
      dist/types/toolbar/Toolbar.d.ts
  83. 12
    6
      dist/types/toolbar/ToolbarItem.d.ts
  84. 13
    0
      dist/types/toolbar/toolbar-items.d.ts
  85. 2
    0
      dist/types/utils/dom.d.ts
  86. 1
    0
      dist/types/utils/uuid.d.ts
  87. 1
    0
      dist/types/utils/validator.d.ts
  88. 2
    2
      scripts/base/webpack.config.prod.js
  89. 1
    3
      tsconfig.json

+ 42
- 0
dist/cjs/board/Baseboard/index.js View File

@@ -0,0 +1,42 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+var uuid_1 = require("./../../utils/uuid");
4
+var index_1 = require("./../../renderer/SvgHelper/index");
5
+var Baseboard = (function () {
6
+    function Baseboard(source) {
7
+        var _this = this;
8
+        this.id = uuid_1.uuid();
9
+        this.initBoard = function () {
10
+            _this.boardHolder = document.createElement('div');
11
+            _this.boardHolder.id = "fcw-board-holder-" + _this.id;
12
+            _this.boardHolder.style.setProperty('touch-action', 'none');
13
+            _this.boardHolder.style.setProperty('-ms-touch-action', 'none');
14
+            document.body.appendChild(_this.boardHolder);
15
+            _this.boardCanvas = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
16
+            _this.boardCanvas.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
17
+            _this.boardCanvas.setAttribute('width', _this.width.toString());
18
+            _this.boardCanvas.setAttribute('height', _this.height.toString());
19
+            _this.boardCanvas.setAttribute('viewBox', '0 0 ' + _this.width.toString() + ' ' + _this.height.toString());
20
+            _this.boardHolder.style.position = 'absolute';
21
+            _this.boardHolder.style.width = _this.width + "px";
22
+            _this.boardHolder.style.height = _this.height + "px";
23
+            _this.boardHolder.style.transformOrigin = 'top left';
24
+            _this.positionBoard();
25
+            _this.defs = index_1.SvgHelper.createDefs();
26
+            _this.boardCanvas.appendChild(_this.defs);
27
+            _this.boardHolder.appendChild(_this.boardCanvas);
28
+        };
29
+        this.positionBoard = function () {
30
+            _this.boardHolder.style.top = _this.targetRect.top + 'px';
31
+            _this.boardHolder.style.left = _this.targetRect.left + 'px';
32
+        };
33
+        this.source = source;
34
+        if (source.imgEle) {
35
+            this.target = source.imgEle;
36
+            this.width = this.target.clientWidth;
37
+            this.height = this.target.clientHeight;
38
+        }
39
+    }
40
+    return Baseboard;
41
+}());
42
+exports.Baseboard = Baseboard;

+ 280
- 0
dist/cjs/board/Drawboard/index.js View File

@@ -0,0 +1,280 @@
1
+"use strict";
2
+var __extends = (this && this.__extends) || (function () {
3
+    var extendStatics = function (d, b) {
4
+        extendStatics = Object.setPrototypeOf ||
5
+            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+        return extendStatics(d, b);
8
+    };
9
+    return function (d, b) {
10
+        extendStatics(d, b);
11
+        function __() { this.constructor = d; }
12
+        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+    };
14
+})();
15
+Object.defineProperty(exports, "__esModule", { value: true });
16
+var index_1 = require("./../Baseboard/index");
17
+var toolbar_items_1 = require("./../../toolbar/toolbar-items");
18
+var Synthetizer_1 = require("../../renderer/Synthetizer");
19
+var Toolbar_1 = require("../../toolbar/Toolbar");
20
+require("./index.less");
21
+var Drawboard = (function (_super) {
22
+    __extends(Drawboard, _super);
23
+    function Drawboard(source, _a) {
24
+        var _b = _a === void 0 ? {} : _a, page = _b.page, onChange = _b.onChange;
25
+        var _this = _super.call(this, source) || this;
26
+        _this.scale = 1.0;
27
+        _this.onComplete = function () { };
28
+        _this.onChange = function () { };
29
+        _this.open = function (onComplete, onCancel) {
30
+            if (onComplete) {
31
+                _this.onComplete = onComplete;
32
+            }
33
+            if (onCancel) {
34
+                _this.onCancel = onCancel;
35
+            }
36
+            _this.setTargetRect();
37
+            _this.initBoard();
38
+            _this.attachEvents();
39
+            _this.setStyles();
40
+            window.addEventListener('resize', _this.adjustUI);
41
+            if (_this.page.mode === 'master') {
42
+                _this.showUI();
43
+            }
44
+        };
45
+        _this.hide = function () {
46
+            if (_this.source.imgSrc) {
47
+                _this.target.style.display = 'none';
48
+            }
49
+            _this.boardHolder.style.opacity = '0';
50
+            _this.boardHolder.style.zIndex = '-1';
51
+            if (_this.toolbar) {
52
+                _this.toolbar.hide();
53
+            }
54
+        };
55
+        _this.show = function () {
56
+            if (_this.source.imgSrc) {
57
+                _this.target.style.display = 'block';
58
+            }
59
+            _this.boardHolder.style.opacity = '1';
60
+            _this.boardHolder.style.zIndex = '9999';
61
+            if (_this.toolbar) {
62
+                _this.toolbar.show();
63
+            }
64
+        };
65
+        _this.close = function () {
66
+            if (_this.toolbarUI) {
67
+                document.body.removeChild(_this.toolbarUI);
68
+            }
69
+            if (_this.boardCanvas) {
70
+                document.body.removeChild(_this.boardHolder);
71
+            }
72
+        };
73
+        _this.render = function (onComplete, onCancel) {
74
+            _this.onComplete = onComplete;
75
+            if (onCancel) {
76
+                _this.onCancel = onCancel;
77
+            }
78
+            _this.selectMarker(null);
79
+            _this.startRender(_this.renderFinished);
80
+        };
81
+        _this.addMarker = function (markerType, _a) {
82
+            var id = (_a === void 0 ? {} : _a).id;
83
+            var marker = markerType.createMarker(_this.page);
84
+            if (id) {
85
+                marker.id = id;
86
+            }
87
+            marker.onSelected = _this.selectMarker;
88
+            marker.onChange = _this.onChange;
89
+            if (marker.defs && marker.defs.length > 0) {
90
+                for (var _i = 0, _b = marker.defs; _i < _b.length; _i++) {
91
+                    var d = _b[_i];
92
+                    if (d.id && !_this.boardCanvas.getElementById(d.id)) {
93
+                        _this.defs.appendChild(d);
94
+                    }
95
+                }
96
+            }
97
+            _this.onChange({
98
+                target: 'marker',
99
+                parentId: _this.page ? _this.page.id : _this.id,
100
+                event: 'add',
101
+                data: { type: marker.type, id: marker.id }
102
+            });
103
+            _this.markers.push(marker);
104
+            _this.selectMarker(marker);
105
+            _this.boardCanvas.appendChild(marker.visual);
106
+            var bbox = marker.visual.getBBox();
107
+            var x = _this.width / 2 / _this.scale - bbox.width / 2;
108
+            var y = _this.height / 2 / _this.scale - bbox.height / 2;
109
+            var translate = marker.visual.transform.baseVal.getItem(0);
110
+            translate.setMatrix(translate.matrix.translate(x, y));
111
+            marker.visual.transform.baseVal.replaceItem(translate, 0);
112
+        };
113
+        _this.deleteActiveMarker = function () {
114
+            if (_this.activeMarker) {
115
+                if (_this.onChange) {
116
+                    _this.onChange({
117
+                        event: 'remove',
118
+                        id: _this.activeMarker.id,
119
+                        target: 'marker',
120
+                        data: { id: _this.activeMarker.id }
121
+                    });
122
+                }
123
+                _this.deleteMarker(_this.activeMarker);
124
+            }
125
+        };
126
+        _this.setTargetRect = function () {
127
+            var targetRect = _this.target.getBoundingClientRect();
128
+            var bodyRect = document.body.parentElement.getBoundingClientRect();
129
+            _this.targetRect = {
130
+                left: targetRect.left - bodyRect.left,
131
+                top: targetRect.top - bodyRect.top
132
+            };
133
+        };
134
+        _this.startRender = function (done) {
135
+            var renderer = new Synthetizer_1.Synthetizer();
136
+            renderer.rasterize(_this.target, _this.boardCanvas, done);
137
+        };
138
+        _this.attachEvents = function () {
139
+            _this.boardCanvas.addEventListener('mousedown', _this.mouseDown);
140
+            _this.boardCanvas.addEventListener('mousemove', _this.mouseMove);
141
+            _this.boardCanvas.addEventListener('mouseup', _this.mouseUp);
142
+        };
143
+        _this.mouseDown = function (ev) {
144
+            if (_this.activeMarker && (ev.buttons & 1) > 0) {
145
+                _this.activeMarker.deselect();
146
+                _this.activeMarker = null;
147
+            }
148
+        };
149
+        _this.mouseMove = function (ev) {
150
+            if (_this.activeMarker && (ev.buttons & 1) > 0) {
151
+                _this.activeMarker.manipulate(ev);
152
+            }
153
+        };
154
+        _this.mouseUp = function (ev) {
155
+            if (_this.activeMarker) {
156
+                _this.activeMarker.endManipulation();
157
+            }
158
+        };
159
+        _this.adjustUI = function (ev) {
160
+            _this.adjustSize();
161
+            _this.positionUI();
162
+        };
163
+        _this.adjustSize = function () {
164
+            _this.width = _this.target.clientWidth;
165
+            _this.height = _this.target.clientHeight;
166
+            var scale = _this.target.clientWidth / _this.boardHolder.clientWidth;
167
+            if (scale !== 1.0) {
168
+                _this.scale *= scale;
169
+                _this.boardHolder.style.width = _this.width + "px";
170
+                _this.boardHolder.style.height = _this.height + "px";
171
+                _this.boardHolder.style.transform = "scale(" + _this.scale + ")";
172
+            }
173
+        };
174
+        _this.positionUI = function () {
175
+            _this.setTargetRect();
176
+            _this.positionBoard();
177
+            _this.positionToolbar();
178
+        };
179
+        _this.positionToolbar = function () {
180
+            _this.toolbarUI.style.left = _this.targetRect.left +
181
+                _this.target.offsetWidth -
182
+                _this.toolbarUI.clientWidth + "px";
183
+            _this.toolbarUI.style.top = _this.targetRect.top - _this.toolbarUI.clientHeight + "px";
184
+        };
185
+        _this.showUI = function () {
186
+            _this.toolbar = new Toolbar_1.Toolbar(_this.toolbars, _this.toolbarClick);
187
+            _this.toolbarUI = _this.toolbar.getUI();
188
+            document.body.appendChild(_this.toolbarUI);
189
+            _this.toolbarUI.style.position = 'absolute';
190
+            _this.positionToolbar();
191
+        };
192
+        _this.setStyles = function () {
193
+            var editorStyleSheet = document.createElementNS('http://www.w3.org/2000/svg', 'style');
194
+            editorStyleSheet.innerHTML = "\n            .rect-marker .render-visual {\n                stroke: #ff0000;\n                stroke-width: 3;\n                fill: transparent;\n            }\n            .cover-marker .render-visual {\n                stroke-width: 0;\n                fill: #000000;\n            }\n            .highlight-marker .render-visual {\n                stroke: transparent;\n                stroke-width: 0;\n                fill: #ffff00;\n                fill-opacity: 0.4;\n            }\n            .line-marker .render-visual {\n                stroke: #ff0000;\n                stroke-width: 3;\n                fill: transparent;\n            }\n            .arrow-marker .render-visual {\n                stroke: #ff0000;\n                stroke-width: 3;\n                fill: transparent;\n            }\n            .arrow-marker-tip {\n                stroke-width: 0;\n                fill: #ff0000;\n            }\n            .text-marker text {\n                fill: #ff0000;\n                font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\",\n                    Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\",\n                    \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n            }\n            .fc-whiteboard-rect-control-box .fc-whiteboard-rect-control-rect {\n                stroke: black;\n                stroke-width: 1;\n                stroke-opacity: 0.5;\n                stroke-dasharray: 3, 2;\n                fill: transparent;\n            }\n            .fc-whiteboard-control-grip {\n                fill: #cccccc;\n                stroke: #333333;\n                stroke-width: 2;\n            }\n        ";
195
+            _this.boardCanvas.appendChild(editorStyleSheet);
196
+        };
197
+        _this.toolbarClick = function (ev, toolbarItem) {
198
+            if (toolbarItem.markerType) {
199
+                _this.addMarker(toolbarItem.markerType);
200
+            }
201
+            else {
202
+                switch (toolbarItem.name) {
203
+                    case 'delete': {
204
+                        _this.deleteActiveMarker();
205
+                        break;
206
+                    }
207
+                    case 'pointer': {
208
+                        if (_this.activeMarker) {
209
+                            _this.selectMarker(null);
210
+                        }
211
+                        break;
212
+                    }
213
+                    case 'close': {
214
+                        _this.cancel();
215
+                        break;
216
+                    }
217
+                    case 'ok': {
218
+                        _this.complete();
219
+                        break;
220
+                    }
221
+                    default:
222
+                        break;
223
+                }
224
+            }
225
+        };
226
+        _this.selectMarker = function (marker) {
227
+            if (_this.activeMarker && _this.activeMarker !== marker) {
228
+                _this.activeMarker.deselect();
229
+            }
230
+            _this.activeMarker = marker;
231
+        };
232
+        _this.deleteMarker = function (marker) {
233
+            _this.boardCanvas.removeChild(marker.visual);
234
+            if (_this.activeMarker === marker) {
235
+                _this.activeMarker = null;
236
+            }
237
+            _this.markers.splice(_this.markers.indexOf(marker), 1);
238
+        };
239
+        _this.complete = function () {
240
+            _this.selectMarker(null);
241
+            _this.startRender(_this.renderFinishedClose);
242
+        };
243
+        _this.cancel = function () {
244
+            _this.close();
245
+            if (_this.onCancel) {
246
+                _this.onCancel();
247
+            }
248
+        };
249
+        _this.renderFinished = function (dataUrl) {
250
+            _this.onComplete(dataUrl);
251
+        };
252
+        _this.renderFinishedClose = function (dataUrl) {
253
+            _this.close();
254
+            _this.onComplete(dataUrl);
255
+        };
256
+        if (page) {
257
+            _this.page = page;
258
+        }
259
+        _this.markers = [];
260
+        _this.activeMarker = null;
261
+        _this.toolbars = toolbar_items_1.getToolbars(page);
262
+        if (onChange) {
263
+            _this.onChange = onChange;
264
+        }
265
+        return _this;
266
+    }
267
+    Object.defineProperty(Drawboard.prototype, "markerMap", {
268
+        get: function () {
269
+            var map = {};
270
+            this.markers.forEach(function (marker) {
271
+                map[marker.id] = marker;
272
+            });
273
+            return map;
274
+        },
275
+        enumerable: true,
276
+        configurable: true
277
+    });
278
+    return Drawboard;
279
+}(index_1.Baseboard));
280
+exports.Drawboard = Drawboard;

+ 122
- 0
dist/cjs/board/WhitePage/index.js View File

@@ -0,0 +1,122 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+var index_1 = require("./../Drawboard/index");
4
+var uuid_1 = require("./../../utils/uuid");
5
+var types_1 = require("../../markers/types");
6
+require("./index.less");
7
+var dom_1 = require("../../utils/dom");
8
+var prefix = 'fcw-page';
9
+var WhitePage = (function () {
10
+    function WhitePage(source, _a) {
11
+        var _b = _a === void 0 ? {} : _a, mode = _b.mode, eventHub = _b.eventHub, parentContainer = _b.parentContainer;
12
+        this.id = uuid_1.uuid();
13
+        this.mode = 'master';
14
+        if (mode) {
15
+            this.mode = mode;
16
+        }
17
+        this.eventHub = eventHub;
18
+        this.parentContainer = parentContainer;
19
+        this.initSource(source);
20
+        if (this.mode === 'master') {
21
+            this.initMaster();
22
+        }
23
+        if (this.mode === 'mirror') {
24
+            this.initMirror();
25
+        }
26
+    }
27
+    WhitePage.prototype.open = function () {
28
+        this.drawboard.open();
29
+    };
30
+    WhitePage.prototype.hide = function () {
31
+        this.drawboard.hide();
32
+    };
33
+    WhitePage.prototype.show = function () {
34
+        this.drawboard.show();
35
+    };
36
+    WhitePage.prototype.close = function () {
37
+        this.drawboard.close();
38
+    };
39
+    WhitePage.prototype.initSource = function (source) {
40
+        if (typeof source.imgSrc === 'string' && !this.parentContainer) {
41
+            throw new Error('Invalid source, If you set image url, you must also set parentContainer');
42
+        }
43
+        this.source = source;
44
+        if (source.imgEle) {
45
+            this.target = source.imgEle;
46
+        }
47
+        if (typeof source.imgSrc === 'string') {
48
+            this.container = dom_1.createDivWithClassName(prefix, this.parentContainer);
49
+            this.container.id = this.id;
50
+            this.target = document.createElement('img');
51
+            this.target.src = source.imgSrc;
52
+            this.target.alt = 'Siema image';
53
+            this.container.appendChild(this.target);
54
+        }
55
+    };
56
+    WhitePage.prototype.initMaster = function () {
57
+        var _this = this;
58
+        if (this.eventHub) {
59
+            this.drawboard = new index_1.Drawboard({ imgEle: this.target }, {
60
+                page: this,
61
+                onChange: function (ev) { return _this.eventHub.emit('sync', ev); }
62
+            });
63
+        }
64
+        else {
65
+            this.drawboard = new index_1.Drawboard({ imgEle: this.target }, { page: this });
66
+        }
67
+    };
68
+    WhitePage.prototype.initMirror = function () {
69
+        var _this = this;
70
+        if (!this.eventHub) {
71
+            throw new Error('Invalid eventHub');
72
+        }
73
+        this.drawboard = new index_1.Drawboard({ imgEle: this.target }, { page: this });
74
+        this.eventHub.on('sync', function (ev) {
75
+            try {
76
+                if (ev.target === 'page' && ev.id === _this.id) {
77
+                    _this.onPageSync();
78
+                }
79
+                if (ev.target === 'marker') {
80
+                    _this.onMarkerSync(ev);
81
+                }
82
+            }
83
+            catch (e) {
84
+                console.warn(e);
85
+            }
86
+        });
87
+    };
88
+    WhitePage.prototype.onPageSync = function () { };
89
+    WhitePage.prototype.onMarkerSync = function (ev) {
90
+        if (ev.event === 'add' && ev.parentId === this.id) {
91
+            var data = ev.data;
92
+            var marker = this.drawboard.markerMap[data.id];
93
+            if (!marker) {
94
+                this.drawboard.addMarker(types_1.getMarkerByType(data.type), { id: data.id });
95
+            }
96
+        }
97
+        if (!ev.id) {
98
+            return;
99
+        }
100
+        if (ev.event === 'remove') {
101
+            var data = ev.data;
102
+            var marker = this.drawboard.markerMap[data.id];
103
+            if (marker) {
104
+                this.drawboard.deleteMarker(marker);
105
+            }
106
+        }
107
+        if (ev.event === 'move' || ev.event === 'resize') {
108
+            var marker = this.drawboard.markerMap[ev.id];
109
+            if (marker) {
110
+                marker.reactToManipulation(ev.event, ev.data);
111
+            }
112
+        }
113
+        if (ev.event === 'changeText') {
114
+            var marker = this.drawboard.markerMap[ev.id];
115
+            if (marker) {
116
+                marker.setText(ev.data);
117
+            }
118
+        }
119
+    };
120
+    return WhitePage;
121
+}());
122
+exports.WhitePage = WhitePage;

+ 214
- 0
dist/cjs/board/Whiteboard/index.js View File

@@ -0,0 +1,214 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+var Siema = require("siema");
4
+var index_1 = require("../WhitePage/index");
5
+var uuid_1 = require("../../utils/uuid");
6
+var dom_1 = require("../../utils/dom");
7
+require("./index.less");
8
+var LeftArrowIcon = require('../../assets/bx-left-arrow.svg');
9
+var RightArrowIcon = require('../../assets/bx-right-arrow.svg');
10
+var prefix = 'fcw-board';
11
+var SerializableWhiteboard = (function () {
12
+    function SerializableWhiteboard() {
13
+    }
14
+    return SerializableWhiteboard;
15
+}());
16
+exports.SerializableWhiteboard = SerializableWhiteboard;
17
+var Whiteboard = (function () {
18
+    function Whiteboard(target, _a) {
19
+        var _b = _a === void 0 ? {} : _a, sources = _b.sources, eventHub = _b.eventHub, mode = _b.mode, visiblePageIndex = _b.visiblePageIndex;
20
+        this.id = uuid_1.uuid();
21
+        this.sources = [];
22
+        this.mode = 'master';
23
+        this.isFullscreen = false;
24
+        this.pages = [];
25
+        this.isInitialized = false;
26
+        this.visiblePageIndex = 0;
27
+        if (target) {
28
+            this.target = target;
29
+        }
30
+        else {
31
+            this.target = document.createElement('div');
32
+            document.body.appendChild(this.target);
33
+        }
34
+        if (!this.target.id) {
35
+            this.target.id = this.id;
36
+        }
37
+        dom_1.addClassName(this.target, prefix);
38
+        if (sources) {
39
+            this.sources = sources;
40
+        }
41
+        this.eventHub = eventHub;
42
+        if (mode) {
43
+            this.mode = mode;
44
+        }
45
+        if (typeof visiblePageIndex !== 'undefined') {
46
+            this.visiblePageIndex = visiblePageIndex;
47
+        }
48
+        this.init();
49
+    }
50
+    Whiteboard.prototype.open = function () {
51
+        var _this = this;
52
+        this.pages.forEach(function (page, i) {
53
+            page.open();
54
+            if (i !== _this.visiblePageIndex) {
55
+                page.hide();
56
+            }
57
+        });
58
+    };
59
+    Whiteboard.prototype.close = function () {
60
+        if (this.emitInterval) {
61
+            clearInterval(this.emitInterval);
62
+        }
63
+    };
64
+    Whiteboard.prototype.snap = function () {
65
+        return {
66
+            id: this.id,
67
+            sources: this.sources,
68
+            pageIds: this.pages.map(function (page) { return page.id; }),
69
+            visiblePageIndex: this.visiblePageIndex
70
+        };
71
+    };
72
+    Whiteboard.prototype.init = function () {
73
+        this.imgsContainer = dom_1.createDivWithClassName(prefix + "-imgs", this.target);
74
+        this.pagesContainer = dom_1.createDivWithClassName(prefix + "-pages", this.target);
75
+        if (this.mode === 'master') {
76
+            this.initMaster();
77
+            this.emitSnapshot();
78
+        }
79
+        if (this.mode === 'mirror') {
80
+            this.initMirror();
81
+        }
82
+    };
83
+    Whiteboard.prototype.initMaster = function () {
84
+        var _this = this;
85
+        this.sources.forEach(function (source) {
86
+            var page = new index_1.WhitePage({ imgSrc: source }, {
87
+                mode: _this.mode,
88
+                eventHub: _this.eventHub,
89
+                parentContainer: _this.pagesContainer
90
+            });
91
+            page.container.style.opacity = '0';
92
+            _this.pages.push(page);
93
+        });
94
+        this.initSiema();
95
+        var controller = dom_1.createDivWithClassName(prefix + "-controller", this.target);
96
+        var prevEle = dom_1.createDivWithClassName(prefix + "-flip-arrow", controller);
97
+        prevEle.innerHTML = LeftArrowIcon;
98
+        var nextEle = dom_1.createDivWithClassName(prefix + "-flip-arrow", controller);
99
+        nextEle.innerHTML = RightArrowIcon;
100
+        nextEle.addEventListener('click', function () {
101
+            var nextPageIndex = _this.visiblePageIndex + 1 > _this.pages.length - 1 ? 0 : _this.visiblePageIndex + 1;
102
+            _this.onPageChange(nextPageIndex);
103
+        });
104
+        prevEle.addEventListener('click', function () {
105
+            var nextPageIndex = _this.visiblePageIndex - 1 < 0 ? _this.pages.length - 1 : _this.visiblePageIndex - 1;
106
+            _this.onPageChange(nextPageIndex);
107
+        });
108
+    };
109
+    Whiteboard.prototype.initMirror = function () {
110
+        var _this = this;
111
+        if (!this.eventHub) {
112
+            throw new Error('Invalid eventHub');
113
+        }
114
+        this.eventHub.on('sync', function (ev) {
115
+            if (ev.target !== 'whiteboard') {
116
+                return;
117
+            }
118
+            if (ev.event === 'snap') {
119
+                if (_this.isInitialized) {
120
+                    return;
121
+                }
122
+                _this.onSnapshot(ev.data);
123
+            }
124
+            if (ev.event === 'changeIndex' && ev.id === _this.id) {
125
+                if (_this.isInitialized) {
126
+                    _this.onPageChange(ev.data);
127
+                }
128
+            }
129
+        });
130
+    };
131
+    Whiteboard.prototype.initSiema = function () {
132
+        var _this = this;
133
+        this.sources.forEach(function (source) {
134
+            var imgEle = document.createElement('img');
135
+            dom_1.addClassName(imgEle, prefix + "-img");
136
+            imgEle.src = source;
137
+            imgEle.alt = 'Siema image';
138
+            _this.imgsContainer.appendChild(imgEle);
139
+        });
140
+        this.siema = new Siema({
141
+            selector: this.imgsContainer,
142
+            duration: 200,
143
+            easing: 'ease-out',
144
+            perPage: 1,
145
+            startIndex: 0,
146
+            draggable: false,
147
+            multipleDrag: true,
148
+            threshold: 20,
149
+            loop: false,
150
+            rtl: false
151
+        });
152
+    };
153
+    Whiteboard.prototype.onPageChange = function (nextPageIndex) {
154
+        this.siema.goTo(nextPageIndex);
155
+        this.visiblePageIndex = nextPageIndex;
156
+        this.pages.forEach(function (page, i) {
157
+            if (nextPageIndex === i) {
158
+                page.show();
159
+            }
160
+            else {
161
+                page.hide();
162
+            }
163
+        });
164
+        if (this.mode === 'master' && this.eventHub) {
165
+            this.eventHub.emit('sync', {
166
+                event: 'changeIndex',
167
+                id: this.id,
168
+                target: 'whiteboard',
169
+                data: nextPageIndex
170
+            });
171
+        }
172
+    };
173
+    Whiteboard.prototype.emitSnapshot = function () {
174
+        var _this = this;
175
+        var innerFunc = function () {
176
+            if (_this.eventHub) {
177
+                _this.eventHub.emit('sync', {
178
+                    event: 'snap',
179
+                    id: _this.id,
180
+                    target: 'whiteboard',
181
+                    data: _this.snap()
182
+                });
183
+            }
184
+        };
185
+        this.emitInterval = setInterval(function () {
186
+            innerFunc();
187
+        }, 5 * 1000);
188
+        setTimeout(innerFunc, 500);
189
+    };
190
+    Whiteboard.prototype.onSnapshot = function (snap) {
191
+        var _this = this;
192
+        var id = snap.id, sources = snap.sources, pageIds = snap.pageIds, visiblePageIndex = snap.visiblePageIndex;
193
+        if (!this.isInitialized) {
194
+            this.id = id;
195
+            this.sources = sources;
196
+            this.initSiema();
197
+            this.sources.forEach(function (source, i) {
198
+                var page = new index_1.WhitePage({ imgSrc: source }, {
199
+                    mode: _this.mode,
200
+                    eventHub: _this.eventHub,
201
+                    parentContainer: _this.pagesContainer
202
+                });
203
+                page.id = pageIds[i];
204
+                page.container.style.opacity = '0';
205
+                _this.pages.push(page);
206
+                page.open();
207
+            });
208
+        }
209
+        this.isInitialized = true;
210
+        this.onPageChange(visiblePageIndex);
211
+    };
212
+    return Whiteboard;
213
+}());
214
+exports.Whiteboard = Whiteboard;

+ 2
- 0
dist/cjs/board/types.js View File

@@ -0,0 +1,2 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });

+ 2
- 0
dist/cjs/event/Event.js View File

@@ -0,0 +1,2 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });

+ 24
- 0
dist/cjs/event/EventHub.js View File

@@ -0,0 +1,24 @@
1
+"use strict";
2
+var __extends = (this && this.__extends) || (function () {
3
+    var extendStatics = function (d, b) {
4
+        extendStatics = Object.setPrototypeOf ||
5
+            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+        return extendStatics(d, b);
8
+    };
9
+    return function (d, b) {
10
+        extendStatics(d, b);
11
+        function __() { this.constructor = d; }
12
+        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+    };
14
+})();
15
+Object.defineProperty(exports, "__esModule", { value: true });
16
+var EventEmitter = require("eventemitter3");
17
+var EventHub = (function (_super) {
18
+    __extends(EventHub, _super);
19
+    function EventHub() {
20
+        return _super !== null && _super.apply(this, arguments) || this;
21
+    }
22
+    return EventHub;
23
+}(EventEmitter));
24
+exports.EventHub = EventHub;

+ 4
- 0
dist/cjs/index.js View File

@@ -0,0 +1,4 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+var Drawboard_1 = require("./board/Drawboard");
4
+exports.Drawboard = Drawboard_1.Drawboard;

dist/cjs/markers/arrow/ArrowMarker.js → dist/cjs/markers/ArrowMarker/index.js View File

@@ -13,12 +13,13 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var LineMarkerBase_1 = require("../line/LineMarkerBase");
17
-var SvgHelper_1 = require("../../utils/SvgHelper");
16
+var LinearMarker_1 = require("../LinearMarker");
17
+var SvgHelper_1 = require("../../renderer/SvgHelper");
18 18
 var ArrowMarker = (function (_super) {
19 19
     __extends(ArrowMarker, _super);
20 20
     function ArrowMarker() {
21 21
         var _this = _super !== null && _super.apply(this, arguments) || this;
22
+        _this.type = 'arrow';
22 23
         _this.ARROW_SIZE = 6;
23 24
         return _this;
24 25
     }
@@ -29,11 +30,12 @@ var ArrowMarker = (function (_super) {
29 30
         this.defs.push(SvgHelper_1.SvgHelper.createMarker('arrow-marker-head', 'auto', this.ARROW_SIZE, this.ARROW_SIZE, this.ARROW_SIZE - 1, this.ARROW_SIZE / 2, tip));
30 31
         this.markerLine.setAttribute('marker-end', 'url(#arrow-marker-head');
31 32
     };
32
-    ArrowMarker.createMarker = function () {
33
+    ArrowMarker.createMarker = function (page) {
33 34
         var marker = new ArrowMarker();
35
+        marker.page = page;
34 36
         marker.setup();
35 37
         return marker;
36 38
     };
37 39
     return ArrowMarker;
38
-}(LineMarkerBase_1.LineMarkerBase));
40
+}(LinearMarker_1.LinearMarker));
39 41
 exports.ArrowMarker = ArrowMarker;

dist/cjs/markers/base/ResizeGrip.js → dist/cjs/markers/BaseMarker/ResizeGrip.js View File

@@ -1,10 +1,10 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3
-var SvgHelper_1 = require("../../utils/SvgHelper");
3
+var SvgHelper_1 = require("../../renderer/SvgHelper");
4 4
 var ResizeGrip = (function () {
5 5
     function ResizeGrip() {
6 6
         this.GRIP_SIZE = 10;
7
-        this.visual = SvgHelper_1.SvgHelper.createCircle(this.GRIP_SIZE, [['class', 'fc-whiteboardcontrol-grip']]);
7
+        this.visual = SvgHelper_1.SvgHelper.createCircle(this.GRIP_SIZE, [['class', 'fc-whiteboard-control-grip']]);
8 8
     }
9 9
     return ResizeGrip;
10 10
 }());

dist/cjs/markers/base/MarkerBase.js → dist/cjs/markers/BaseMarker/index.js View File

@@ -1,26 +1,33 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3
-var SvgHelper_1 = require("../../utils/SvgHelper");
4
-var MarkerBase = (function () {
5
-    function MarkerBase() {
3
+var uuid = require("uuid/v1");
4
+var SvgHelper_1 = require("../../renderer/SvgHelper");
5
+var BaseMarker = (function () {
6
+    function BaseMarker() {
6 7
         var _this = this;
8
+        this.id = uuid();
9
+        this.type = 'base';
10
+        this.onChange = function () { };
7 11
         this.defs = [];
8 12
         this.width = 200;
9 13
         this.height = 50;
10 14
         this.isActive = true;
15
+        this.isDragging = false;
11 16
         this.isResizing = false;
12 17
         this.previousMouseX = 0;
13 18
         this.previousMouseY = 0;
14
-        this.isDragging = false;
15 19
         this.manipulate = function (ev) {
16 20
             var scale = _this.visual.getScreenCTM().a;
17 21
             var dx = (ev.screenX - _this.previousMouseX) / scale;
18 22
             var dy = (ev.screenY - _this.previousMouseY) / scale;
19 23
             if (_this.isDragging) {
24
+                _this.onChange({ target: 'marker', id: _this.id, event: 'move', data: { dx: dx, dy: dy } });
20 25
                 _this.move(dx, dy);
21 26
             }
22 27
             if (_this.isResizing) {
23
-                _this.resize(dx, dy);
28
+                _this.resize(dx, dy, function (pos) {
29
+                    _this.onChange({ target: 'marker', id: _this.id, event: 'resize', data: { dx: dx, dy: dy, pos: pos } });
30
+                });
24 31
             }
25 32
             _this.previousMouseX = ev.screenX;
26 33
             _this.previousMouseY = ev.screenY;
@@ -33,6 +40,9 @@ var MarkerBase = (function () {
33 40
         };
34 41
         this.mouseDown = function (ev) {
35 42
             ev.stopPropagation();
43
+            if (_this.page && _this.page.mode === 'mirror') {
44
+                return;
45
+            }
36 46
             _this.select();
37 47
             _this.isDragging = true;
38 48
             _this.previousMouseX = ev.screenX;
@@ -52,23 +62,32 @@ var MarkerBase = (function () {
52 62
             _this.visual.transform.baseVal.replaceItem(translate, 0);
53 63
         };
54 64
     }
55
-    MarkerBase.prototype.endManipulation = function () {
65
+    BaseMarker.prototype.reactToManipulation = function (type, _a) {
66
+        var dx = _a.dx, dy = _a.dy, pos = _a.pos;
67
+        if (type === 'move') {
68
+            this.move(dx, dy);
69
+        }
70
+        if (type === 'resize') {
71
+            this.resizeByEvent(dx, dy, pos);
72
+        }
73
+    };
74
+    BaseMarker.prototype.endManipulation = function () {
56 75
         this.isDragging = false;
57 76
         this.isResizing = false;
58 77
     };
59
-    MarkerBase.prototype.select = function () {
78
+    BaseMarker.prototype.select = function () {
60 79
         this.isActive = true;
61 80
         if (this.onSelected) {
62 81
             this.onSelected(this);
63 82
         }
64 83
         return;
65 84
     };
66
-    MarkerBase.prototype.deselect = function () {
85
+    BaseMarker.prototype.deselect = function () {
67 86
         this.isActive = false;
68 87
         this.endManipulation();
69 88
         return;
70 89
     };
71
-    MarkerBase.prototype.setup = function () {
90
+    BaseMarker.prototype.setup = function () {
72 91
         this.visual = SvgHelper_1.SvgHelper.createGroup();
73 92
         this.visual.transform.baseVal.appendItem(SvgHelper_1.SvgHelper.createTransform());
74 93
         this.visual.addEventListener('mousedown', this.mouseDown);
@@ -80,10 +99,13 @@ var MarkerBase = (function () {
80 99
         this.renderVisual = SvgHelper_1.SvgHelper.createGroup([['class', 'render-visual']]);
81 100
         this.visual.appendChild(this.renderVisual);
82 101
     };
83
-    MarkerBase.prototype.resize = function (x, y) {
102
+    BaseMarker.prototype.resize = function (x, y, cb) {
103
+        return;
104
+    };
105
+    BaseMarker.prototype.resizeByEvent = function (x, y, pos) {
84 106
         return;
85 107
     };
86
-    MarkerBase.prototype.onTouch = function (ev) {
108
+    BaseMarker.prototype.onTouch = function (ev) {
87 109
         ev.preventDefault();
88 110
         var newEvt = document.createEvent('MouseEvents');
89 111
         var touch = ev.changedTouches[0];
@@ -98,15 +120,18 @@ var MarkerBase = (function () {
98 120
             case 'touchend':
99 121
                 type = 'mouseup';
100 122
                 break;
123
+            default:
124
+                break;
101 125
         }
102 126
         newEvt.initMouseEvent(type, true, true, window, 0, touch.screenX, touch.screenY, touch.clientX, touch.clientY, ev.ctrlKey, ev.altKey, ev.shiftKey, ev.metaKey, 0, null);
103 127
         ev.target.dispatchEvent(newEvt);
104 128
     };
105
-    MarkerBase.createMarker = function () {
106
-        var marker = new MarkerBase();
129
+    BaseMarker.createMarker = function (page) {
130
+        var marker = new BaseMarker();
131
+        marker.page = page;
107 132
         marker.setup();
108 133
         return marker;
109 134
     };
110
-    return MarkerBase;
135
+    return BaseMarker;
111 136
 }());
112
-exports.MarkerBase = MarkerBase;
137
+exports.BaseMarker = BaseMarker;

dist/cjs/markers/cover/CoverMarker.js → dist/cjs/markers/CoverMarker/index.js View File

@@ -13,22 +13,25 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var RectMarkerBase_1 = require("../rect/RectMarkerBase");
16
+var SvgHelper_1 = require("../../renderer/SvgHelper");
17
+var RectBaseMarker_1 = require("../RectMarker/RectBaseMarker");
18 18
 var CoverMarker = (function (_super) {
19 19
     __extends(CoverMarker, _super);
20 20
     function CoverMarker() {
21
-        return _super !== null && _super.apply(this, arguments) || this;
21
+        var _this = _super !== null && _super.apply(this, arguments) || this;
22
+        _this.type = 'cover';
23
+        return _this;
22 24
     }
23 25
     CoverMarker.prototype.setup = function () {
24 26
         _super.prototype.setup.call(this);
25 27
         SvgHelper_1.SvgHelper.setAttributes(this.visual, [['class', 'cover-marker']]);
26 28
     };
27
-    CoverMarker.createMarker = function () {
29
+    CoverMarker.createMarker = function (page) {
28 30
         var marker = new CoverMarker();
31
+        marker.page = page;
29 32
         marker.setup();
30 33
         return marker;
31 34
     };
32 35
     return CoverMarker;
33
-}(RectMarkerBase_1.RectMarkerBase));
36
+}(RectBaseMarker_1.RectBaseMarker));
34 37
 exports.CoverMarker = CoverMarker;

dist/cjs/markers/highlight/HighlightMarker.js → dist/cjs/markers/HighlightMarker/index.js View File

@@ -13,22 +13,25 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var RectMarkerBase_1 = require("../rect/RectMarkerBase");
16
+var SvgHelper_1 = require("../../renderer/SvgHelper");
17
+var RectBaseMarker_1 = require("../RectMarker/RectBaseMarker");
18 18
 var HighlightMarker = (function (_super) {
19 19
     __extends(HighlightMarker, _super);
20 20
     function HighlightMarker() {
21
-        return _super !== null && _super.apply(this, arguments) || this;
21
+        var _this = _super !== null && _super.apply(this, arguments) || this;
22
+        _this.type = 'highlight';
23
+        return _this;
22 24
     }
23 25
     HighlightMarker.prototype.setup = function () {
24 26
         _super.prototype.setup.call(this);
25 27
         SvgHelper_1.SvgHelper.setAttributes(this.visual, [['class', 'highlight-marker']]);
26 28
     };
27
-    HighlightMarker.createMarker = function () {
29
+    HighlightMarker.createMarker = function (page) {
28 30
         var marker = new HighlightMarker();
31
+        marker.page = page;
29 32
         marker.setup();
30 33
         return marker;
31 34
     };
32 35
     return HighlightMarker;
33
-}(RectMarkerBase_1.RectMarkerBase));
36
+}(RectBaseMarker_1.RectBaseMarker));
34 37
 exports.HighlightMarker = HighlightMarker;

dist/cjs/markers/line/LineMarker.js → dist/cjs/markers/LineMarker/index.js View File

@@ -13,22 +13,25 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var LineMarkerBase_1 = require("./LineMarkerBase");
16
+var LinearMarker_1 = require("../LinearMarker");
17
+var index_1 = require("./../../renderer/SvgHelper/index");
18 18
 var LineMarker = (function (_super) {
19 19
     __extends(LineMarker, _super);
20 20
     function LineMarker() {
21
-        return _super !== null && _super.apply(this, arguments) || this;
21
+        var _this = _super !== null && _super.apply(this, arguments) || this;
22
+        _this.type = 'line';
23
+        return _this;
22 24
     }
23 25
     LineMarker.prototype.setup = function () {
24 26
         _super.prototype.setup.call(this);
25
-        SvgHelper_1.SvgHelper.setAttributes(this.visual, [['class', 'line-marker']]);
27
+        index_1.SvgHelper.setAttributes(this.visual, [['class', 'line-marker']]);
26 28
     };
27
-    LineMarker.createMarker = function () {
29
+    LineMarker.createMarker = function (page) {
28 30
         var marker = new LineMarker();
31
+        marker.page = page;
29 32
         marker.setup();
30 33
         return marker;
31 34
     };
32 35
     return LineMarker;
33
-}(LineMarkerBase_1.LineMarkerBase));
36
+}(LinearMarker_1.LinearMarker));
34 37
 exports.LineMarker = LineMarker;

dist/cjs/markers/line/LineMarkerBase.js → dist/cjs/markers/LinearMarker/index.js View File

@@ -13,12 +13,12 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var MarkerBase_1 = require("../base/MarkerBase");
18
-var ResizeGrip_1 = require("../base/ResizeGrip");
19
-var LineMarkerBase = (function (_super) {
20
-    __extends(LineMarkerBase, _super);
21
-    function LineMarkerBase() {
16
+var BaseMarker_1 = require("../BaseMarker");
17
+var ResizeGrip_1 = require("../BaseMarker/ResizeGrip");
18
+var SvgHelper_1 = require("../../renderer/SvgHelper");
19
+var LinearMarker = (function (_super) {
20
+    __extends(LinearMarker, _super);
21
+    function LinearMarker() {
22 22
         var _this = _super !== null && _super.apply(this, arguments) || this;
23 23
         _this.MIN_LENGTH = 20;
24 24
         _this.x1 = 0;
@@ -31,7 +31,7 @@ var LineMarkerBase = (function (_super) {
31 31
             return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
32 32
         };
33 33
         _this.addControlBox = function () {
34
-            _this.controlBox = SvgHelper_1.SvgHelper.createGroup([['class', 'fc-whiteboardline-control-box']]);
34
+            _this.controlBox = SvgHelper_1.SvgHelper.createGroup([['class', 'fc-whiteboard-line-control-box']]);
35 35
             _this.addToVisual(_this.controlBox);
36 36
             _this.addControlGrips();
37 37
         };
@@ -39,8 +39,10 @@ var LineMarkerBase = (function (_super) {
39 39
             _this.positionGrips();
40 40
         };
41 41
         _this.addControlGrips = function () {
42
-            _this.controlGrip1 = _this.createGrip();
43
-            _this.controlGrip2 = _this.createGrip();
42
+            _this.controlGrips = {
43
+                left: _this.createGrip(),
44
+                right: _this.createGrip()
45
+            };
44 46
             _this.positionGrips();
45 47
         };
46 48
         _this.createGrip = function () {
@@ -56,13 +58,13 @@ var LineMarkerBase = (function (_super) {
56 58
             return grip;
57 59
         };
58 60
         _this.positionGrips = function () {
59
-            var gripSize = _this.controlGrip1.GRIP_SIZE;
61
+            var gripSize = _this.controlGrips.left.GRIP_SIZE;
60 62
             var x1 = _this.x1 - gripSize / 2;
61 63
             var y1 = _this.y1 - gripSize / 2;
62 64
             var x2 = _this.x2 - gripSize / 2;
63 65
             var y2 = _this.y2 - gripSize / 2;
64
-            _this.positionGrip(_this.controlGrip1.visual, x1, y1);
65
-            _this.positionGrip(_this.controlGrip2.visual, x2, y2);
66
+            _this.positionGrip(_this.controlGrips.left.visual, x1, y1);
67
+            _this.positionGrip(_this.controlGrips.right.visual, x2, y2);
66 68
         };
67 69
         _this.positionGrip = function (grip, x, y) {
68 70
             var translate = grip.transform.baseVal.getItem(0);
@@ -72,9 +74,9 @@ var LineMarkerBase = (function (_super) {
72 74
         _this.gripMouseDown = function (ev) {
73 75
             _this.isResizing = true;
74 76
             _this.activeGrip =
75
-                ev.target === _this.controlGrip1.visual
76
-                    ? _this.controlGrip1
77
-                    : _this.controlGrip2;
77
+                ev.target === _this.controlGrips.left.visual
78
+                    ? _this.controlGrips.left
79
+                    : _this.controlGrips.right;
78 80
             _this.previousMouseX = ev.screenX;
79 81
             _this.previousMouseY = ev.screenY;
80 82
             ev.stopPropagation();
@@ -91,20 +93,20 @@ var LineMarkerBase = (function (_super) {
91 93
         };
92 94
         return _this;
93 95
     }
94
-    LineMarkerBase.prototype.endManipulation = function () {
96
+    LinearMarker.prototype.endManipulation = function () {
95 97
         _super.prototype.endManipulation.call(this);
96 98
         this.isResizing = false;
97 99
         this.activeGrip = null;
98 100
     };
99
-    LineMarkerBase.prototype.select = function () {
101
+    LinearMarker.prototype.select = function () {
100 102
         _super.prototype.select.call(this);
101 103
         this.controlBox.style.display = '';
102 104
     };
103
-    LineMarkerBase.prototype.deselect = function () {
105
+    LinearMarker.prototype.deselect = function () {
104 106
         _super.prototype.deselect.call(this);
105 107
         this.controlBox.style.display = 'none';
106 108
     };
107
-    LineMarkerBase.prototype.setup = function () {
109
+    LinearMarker.prototype.setup = function () {
108 110
         _super.prototype.setup.call(this);
109 111
         this.markerBgLine = SvgHelper_1.SvgHelper.createLine(0, 0, this.x2, 0, [
110 112
             ['stroke', 'transparent'],
@@ -114,10 +116,13 @@ var LineMarkerBase = (function (_super) {
114 116
         this.markerLine = SvgHelper_1.SvgHelper.createLine(0, 0, this.x2, 0);
115 117
         this.addToRenderVisual(this.markerLine);
116 118
         this.addControlBox();
119
+        if (this.page && this.page.mode === 'mirror') {
120
+            this.controlBox.style.display = 'none';
121
+        }
117 122
     };
118
-    LineMarkerBase.prototype.resize = function (x, y) {
123
+    LinearMarker.prototype.resize = function (x, y, onPosition) {
119 124
         if (this.activeGrip) {
120
-            if (this.activeGrip === this.controlGrip1 &&
125
+            if (this.activeGrip === this.controlGrips.left &&
121 126
                 this.getLineLength(this.x1 + x, this.y1 + 1, this.x2, this.y2) >= this.MIN_LENGTH) {
122 127
                 this.x1 += x;
123 128
                 this.y1 += y;
@@ -125,8 +130,11 @@ var LineMarkerBase = (function (_super) {
125 130
                 this.markerBgLine.setAttribute('y1', this.y1.toString());
126 131
                 this.markerLine.setAttribute('x1', this.x1.toString());
127 132
                 this.markerLine.setAttribute('y1', this.y1.toString());
133
+                if (onPosition) {
134
+                    onPosition('left');
135
+                }
128 136
             }
129
-            else if (this.activeGrip === this.controlGrip2 &&
137
+            else if (this.activeGrip === this.controlGrips.right &&
130 138
                 this.getLineLength(this.x1, this.y1, this.x2 + x, this.y2 + y) >= this.MIN_LENGTH) {
131 139
                 this.x2 += x;
132 140
                 this.y2 += y;
@@ -134,15 +142,28 @@ var LineMarkerBase = (function (_super) {
134 142
                 this.markerBgLine.setAttribute('y2', this.y2.toString());
135 143
                 this.markerLine.setAttribute('x2', this.x2.toString());
136 144
                 this.markerLine.setAttribute('y2', this.y2.toString());
145
+                if (onPosition) {
146
+                    onPosition('right');
147
+                }
137 148
             }
138 149
         }
139 150
         this.adjustControlBox();
140 151
     };
141
-    LineMarkerBase.createMarker = function () {
142
-        var marker = new LineMarkerBase();
152
+    LinearMarker.prototype.resizeByEvent = function (x, y, pos) {
153
+        if (pos === 'left') {
154
+            this.activeGrip = this.controlGrips.left;
155
+        }
156
+        else {
157
+            this.activeGrip = this.controlGrips.right;
158
+        }
159
+        this.resize(x, y);
160
+    };
161
+    LinearMarker.createMarker = function (page) {
162
+        var marker = new LinearMarker();
163
+        marker.page = page;
143 164
         marker.setup();
144 165
         return marker;
145 166
     };
146
-    return LineMarkerBase;
147
-}(MarkerBase_1.MarkerBase));
148
-exports.LineMarkerBase = LineMarkerBase;
167
+    return LinearMarker;
168
+}(BaseMarker_1.BaseMarker));
169
+exports.LinearMarker = LinearMarker;

dist/cjs/markers/rect/RectMarkerBase.js → dist/cjs/markers/RectMarker/RectBaseMarker.js View File

@@ -13,28 +13,29 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var RectangularMarkerBase_1 = require("../base/RectangularMarkerBase");
18
-var RectMarkerBase = (function (_super) {
19
-    __extends(RectMarkerBase, _super);
20
-    function RectMarkerBase() {
16
+var SvgHelper_1 = require("../../renderer/SvgHelper");
17
+var RectangularMarker_1 = require("../RectangularMarker");
18
+var RectBaseMarker = (function (_super) {
19
+    __extends(RectBaseMarker, _super);
20
+    function RectBaseMarker() {
21 21
         return _super !== null && _super.apply(this, arguments) || this;
22 22
     }
23
-    RectMarkerBase.prototype.setup = function () {
23
+    RectBaseMarker.prototype.setup = function () {
24 24
         _super.prototype.setup.call(this);
25 25
         this.markerRect = SvgHelper_1.SvgHelper.createRect(this.width, this.height);
26 26
         this.addToRenderVisual(this.markerRect);
27 27
     };
28
-    RectMarkerBase.prototype.resize = function (x, y) {
29
-        _super.prototype.resize.call(this, x, y);
28
+    RectBaseMarker.prototype.resize = function (x, y, onPosition) {
29
+        _super.prototype.resize.call(this, x, y, onPosition);
30 30
         this.markerRect.setAttribute('width', this.width.toString());
31 31
         this.markerRect.setAttribute('height', this.height.toString());
32 32
     };
33
-    RectMarkerBase.createMarker = function () {
34
-        var marker = new RectMarkerBase();
33
+    RectBaseMarker.createMarker = function (page) {
34
+        var marker = new RectBaseMarker();
35
+        marker.page = page;
35 36
         marker.setup();
36 37
         return marker;
37 38
     };
38
-    return RectMarkerBase;
39
-}(RectangularMarkerBase_1.RectangularMarkerBase));
40
-exports.RectMarkerBase = RectMarkerBase;
39
+    return RectBaseMarker;
40
+}(RectangularMarker_1.RectangularMarker));
41
+exports.RectBaseMarker = RectBaseMarker;

dist/cjs/markers/rect/RectMarker.js → dist/cjs/markers/RectMarker/index.js View File

@@ -13,22 +13,25 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var RectMarkerBase_1 = require("./RectMarkerBase");
16
+var RectBaseMarker_1 = require("./RectBaseMarker");
17
+var SvgHelper_1 = require("../../renderer/SvgHelper");
18 18
 var RectMarker = (function (_super) {
19 19
     __extends(RectMarker, _super);
20 20
     function RectMarker() {
21
-        return _super !== null && _super.apply(this, arguments) || this;
21
+        var _this = _super !== null && _super.apply(this, arguments) || this;
22
+        _this.type = 'rect';
23
+        return _this;
22 24
     }
23 25
     RectMarker.prototype.setup = function () {
24 26
         _super.prototype.setup.call(this);
25 27
         SvgHelper_1.SvgHelper.setAttributes(this.visual, [['class', 'rect-marker']]);
26 28
     };
27
-    RectMarker.createMarker = function () {
29
+    RectMarker.createMarker = function (page) {
28 30
         var marker = new RectMarker();
31
+        marker.page = page;
29 32
         marker.setup();
30 33
         return marker;
31 34
     };
32 35
     return RectMarker;
33
-}(RectMarkerBase_1.RectMarkerBase));
36
+}(RectBaseMarker_1.RectBaseMarker));
34 37
 exports.RectMarker = RectMarker;

dist/cjs/markers/base/RectangularMarkerGrips.js → dist/cjs/markers/RectangularMarker/RectangularMarkerGrips.js View File


dist/cjs/markers/base/RectangularMarkerBase.js → dist/cjs/markers/RectangularMarker/index.js View File

@@ -13,23 +13,23 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var MarkerBase_1 = require("./MarkerBase");
18 16
 var RectangularMarkerGrips_1 = require("./RectangularMarkerGrips");
19
-var ResizeGrip_1 = require("./ResizeGrip");
20
-var RectangularMarkerBase = (function (_super) {
21
-    __extends(RectangularMarkerBase, _super);
22
-    function RectangularMarkerBase() {
17
+var BaseMarker_1 = require("../BaseMarker");
18
+var ResizeGrip_1 = require("../BaseMarker/ResizeGrip");
19
+var SvgHelper_1 = require("../../renderer/SvgHelper");
20
+var RectangularMarker = (function (_super) {
21
+    __extends(RectangularMarker, _super);
22
+    function RectangularMarker() {
23 23
         var _this = _super !== null && _super.apply(this, arguments) || this;
24 24
         _this.MIN_SIZE = 5;
25 25
         _this.CB_DISTANCE = 10;
26 26
         _this.addControlBox = function () {
27
-            _this.controlBox = SvgHelper_1.SvgHelper.createGroup([['class', 'fc-whiteboardrect-control-box']]);
27
+            _this.controlBox = SvgHelper_1.SvgHelper.createGroup([['class', 'fc-whiteboard-rect-control-box']]);
28 28
             var translate = SvgHelper_1.SvgHelper.createTransform();
29 29
             translate.setTranslate(-_this.CB_DISTANCE / 2, -_this.CB_DISTANCE / 2);
30 30
             _this.controlBox.transform.baseVal.appendItem(translate);
31 31
             _this.addToVisual(_this.controlBox);
32
-            _this.controlRect = SvgHelper_1.SvgHelper.createRect(_this.width + _this.CB_DISTANCE, _this.height + _this.CB_DISTANCE, [['class', 'fc-whiteboardrect-control-rect']]);
32
+            _this.controlRect = SvgHelper_1.SvgHelper.createRect(_this.width + _this.CB_DISTANCE, _this.height + _this.CB_DISTANCE, [['class', 'fc-whiteboard-rect-control-rect']]);
33 33
             _this.controlBox.appendChild(_this.controlRect);
34 34
             _this.controlGrips = new RectangularMarkerGrips_1.RectangularMarkerGrips();
35 35
             _this.addControlGrips();
@@ -103,24 +103,31 @@ var RectangularMarkerBase = (function (_super) {
103 103
         };
104 104
         return _this;
105 105
     }
106
-    RectangularMarkerBase.prototype.endManipulation = function () {
106
+    RectangularMarker.prototype.endManipulation = function () {
107 107
         _super.prototype.endManipulation.call(this);
108 108
         this.isResizing = false;
109 109
         this.activeGrip = null;
110 110
     };
111
-    RectangularMarkerBase.prototype.select = function () {
111
+    RectangularMarker.prototype.select = function () {
112 112
         _super.prototype.select.call(this);
113 113
         this.controlBox.style.display = '';
114 114
     };
115
-    RectangularMarkerBase.prototype.deselect = function () {
115
+    RectangularMarker.prototype.deselect = function () {
116 116
         _super.prototype.deselect.call(this);
117 117
         this.controlBox.style.display = 'none';
118 118
     };
119
-    RectangularMarkerBase.prototype.setup = function () {
119
+    RectangularMarker.prototype.setup = function () {
120 120
         _super.prototype.setup.call(this);
121 121
         this.addControlBox();
122
+        if (this.page && this.page.mode === 'mirror') {
123
+            this.controlBox.style.display = 'none';
124
+        }
125
+    };
126
+    RectangularMarker.prototype.resizeByEvent = function (x, y, pos) {
127
+        this.activeGrip = this.controlGrips[pos];
128
+        this.resize(x, y);
122 129
     };
123
-    RectangularMarkerBase.prototype.resize = function (x, y) {
130
+    RectangularMarker.prototype.resize = function (x, y, onPosition) {
124 131
         var translateX = 0;
125 132
         var translateY = 0;
126 133
         switch (this.activeGrip) {
@@ -129,34 +136,60 @@ var RectangularMarkerBase = (function (_super) {
129 136
                 this.height -= y;
130 137
                 translateX += x;
131 138
                 translateY += y;
139
+                if (onPosition) {
140
+                    onPosition('topLeft');
141
+                }
132 142
                 break;
133 143
             case this.controlGrips.bottomLeft:
134 144
                 this.width -= x;
135 145
                 this.height += y;
136 146
                 translateX += x;
147
+                if (onPosition) {
148
+                    onPosition('bottomLeft');
149
+                }
137 150
                 break;
138 151
             case this.controlGrips.topRight:
139 152
                 this.width += x;
140 153
                 this.height -= y;
141 154
                 translateY += y;
155
+                if (onPosition) {
156
+                    onPosition('topRight');
157
+                }
142 158
                 break;
143 159
             case this.controlGrips.bottomRight:
144 160
                 this.width += x;
145 161
                 this.height += y;
162
+                if (onPosition) {
163
+                    onPosition('bottomRight');
164
+                }
146 165
                 break;
147 166
             case this.controlGrips.centerLeft:
148 167
                 this.width -= x;
149 168
                 translateX += x;
169
+                if (onPosition) {
170
+                    onPosition('centerLeft');
171
+                }
150 172
                 break;
151 173
             case this.controlGrips.centerRight:
152 174
                 this.width += x;
175
+                if (onPosition) {
176
+                    onPosition('centerRight');
177
+                }
153 178
                 break;
154 179
             case this.controlGrips.topCenter:
155 180
                 this.height -= y;
156 181
                 translateY += y;
182
+                if (onPosition) {
183
+                    onPosition('topCenter');
184
+                }
157 185
                 break;
158 186
             case this.controlGrips.bottomCenter:
159 187
                 this.height += y;
188
+                if (onPosition) {
189
+                    onPosition('bottomCenter');
190
+                }
191
+                break;
192
+            default:
160 193
                 break;
161 194
         }
162 195
         if (this.width < this.MIN_SIZE) {
@@ -180,14 +213,15 @@ var RectangularMarkerBase = (function (_super) {
180 213
         }
181 214
         this.adjustControlBox();
182 215
     };
183
-    RectangularMarkerBase.prototype.onTouch = function (ev) {
216
+    RectangularMarker.prototype.onTouch = function (ev) {
184 217
         _super.prototype.onTouch.call(this, ev);
185 218
     };
186
-    RectangularMarkerBase.createMarker = function () {
187
-        var marker = new RectangularMarkerBase();
219
+    RectangularMarker.createMarker = function (page) {
220
+        var marker = new RectangularMarker();
221
+        marker.page = page;
188 222
         marker.setup();
189 223
         return marker;
190 224
     };
191
-    return RectangularMarkerBase;
192
-}(MarkerBase_1.MarkerBase));
193
-exports.RectangularMarkerBase = RectangularMarkerBase;
225
+    return RectangularMarker;
226
+}(BaseMarker_1.BaseMarker));
227
+exports.RectangularMarker = RectangularMarker;

dist/cjs/markers/text/TextMarker.js → dist/cjs/markers/TextMarker/index.js View File

@@ -13,14 +13,15 @@ var __extends = (this && this.__extends) || (function () {
13 13
     };
14 14
 })();
15 15
 Object.defineProperty(exports, "__esModule", { value: true });
16
-var SvgHelper_1 = require("../../utils/SvgHelper");
17
-var RectangularMarkerBase_1 = require("../base/RectangularMarkerBase");
18
-var check_svg_1 = require("./check.svg");
19
-var times_svg_1 = require("./times.svg");
16
+var RectangularMarker_1 = require("../RectangularMarker");
17
+var SvgHelper_1 = require("../../renderer/SvgHelper");
18
+var OkIcon = require('../../assets/check.svg');
19
+var CancelIcon = require('../../assets/times.svg');
20 20
 var TextMarker = (function (_super) {
21 21
     __extends(TextMarker, _super);
22 22
     function TextMarker() {
23 23
         var _this = _super !== null && _super.apply(this, arguments) || this;
24
+        _this.type = 'text';
24 25
         _this.MIN_SIZE = 50;
25 26
         _this.DEFAULT_TEXT = 'Double-click to edit text';
26 27
         _this.text = _this.DEFAULT_TEXT;
@@ -72,7 +73,7 @@ var TextMarker = (function (_super) {
72 73
         };
73 74
         _this.showEditor = function () {
74 75
             _this.editor = document.createElement('div');
75
-            _this.editor.className = 'fc-whiteboardtext-editor';
76
+            _this.editor.className = 'fc-whiteboard-text-editor';
76 77
             _this.editorTextArea = document.createElement('textarea');
77 78
             if (_this.text !== _this.DEFAULT_TEXT) {
78 79
                 _this.editorTextArea.value = _this.text;
@@ -81,16 +82,16 @@ var TextMarker = (function (_super) {
81 82
             _this.editor.appendChild(_this.editorTextArea);
82 83
             document.body.appendChild(_this.editor);
83 84
             var buttons = document.createElement('div');
84
-            buttons.className = 'fc-whiteboardtext-editor-button-bar';
85
+            buttons.className = 'fc-whiteboard-text-editor-button-bar';
85 86
             _this.editor.appendChild(buttons);
86 87
             var okButton = document.createElement('div');
87
-            okButton.className = 'fc-whiteboardtext-editor-button';
88
-            okButton.innerHTML = check_svg_1.default;
88
+            okButton.className = 'fc-whiteboard-text-editor-button';
89
+            okButton.innerHTML = OkIcon;
89 90
             okButton.addEventListener('click', _this.onEditorOkClick);
90 91
             buttons.appendChild(okButton);
91 92
             var cancelButton = document.createElement('div');
92
-            cancelButton.className = 'fc-whiteboardtext-editor-button';
93
-            cancelButton.innerHTML = times_svg_1.default;
93
+            cancelButton.className = 'fc-whiteboard-text-editor-button';
94
+            cancelButton.innerHTML = CancelIcon;
94 95
             cancelButton.addEventListener('click', _this.closeEditor);
95 96
             buttons.appendChild(cancelButton);
96 97
         };
@@ -101,6 +102,7 @@ var TextMarker = (function (_super) {
101 102
             else {
102 103
                 _this.text = _this.DEFAULT_TEXT;
103 104
             }
105
+            _this.onChange({ target: 'marker', id: _this.id, event: 'changeText', data: _this.text });
104 106
             _this.renderText();
105 107
             _this.closeEditor();
106 108
         };
@@ -115,6 +117,10 @@ var TextMarker = (function (_super) {
115 117
         };
116 118
         return _this;
117 119
     }
120
+    TextMarker.prototype.setText = function (text) {
121
+        this.text = text;
122
+        this.renderText();
123
+    };
118 124
     TextMarker.prototype.setup = function () {
119 125
         _super.prototype.setup.call(this);
120 126
         this.textElement = SvgHelper_1.SvgHelper.createText();
@@ -126,15 +132,16 @@ var TextMarker = (function (_super) {
126 132
         this.visual.addEventListener('dblclick', this.onDblClick);
127 133
         this.visual.addEventListener('touchstart', this.onTap);
128 134
     };
129
-    TextMarker.prototype.resize = function (x, y) {
130
-        _super.prototype.resize.call(this, x, y);
135
+    TextMarker.prototype.resize = function (x, y, onPosition) {
136
+        _super.prototype.resize.call(this, x, y, onPosition);
131 137
         this.sizeText();
132 138
     };
133
-    TextMarker.createMarker = function () {
139
+    TextMarker.createMarker = function (page) {
134 140
         var marker = new TextMarker();
141
+        marker.page = page;
135 142
         marker.setup();
136 143
         return marker;
137 144
     };
138 145
     return TextMarker;
139
-}(RectangularMarkerBase_1.RectangularMarkerBase));
146
+}(RectangularMarker_1.RectangularMarker));
140 147
 exports.TextMarker = TextMarker;

+ 0
- 14
dist/cjs/markers/arrow/ArrowMarkerToolbarItem.js View File

@@ -1,14 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var ArrowMarker_1 = require("./ArrowMarker");
4
-var arrow_marker_toolbar_icon_svg_1 = require("./arrow-marker-toolbar-icon.svg");
5
-var ArrowMarkerToolbarItem = (function () {
6
-    function ArrowMarkerToolbarItem() {
7
-        this.name = 'arrow-marker';
8
-        this.tooltipText = 'Arrow';
9
-        this.icon = arrow_marker_toolbar_icon_svg_1.default;
10
-        this.markerType = ArrowMarker_1.ArrowMarker;
11
-    }
12
-    return ArrowMarkerToolbarItem;
13
-}());
14
-exports.ArrowMarkerToolbarItem = ArrowMarkerToolbarItem;

+ 0
- 14
dist/cjs/markers/cover/CoverMarkerToolbarItem.js View File

@@ -1,14 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var CoverMarker_1 = require("./CoverMarker");
4
-var cover_marker_toolbar_icon_svg_1 = require("./cover-marker-toolbar-icon.svg");
5
-var CoverMarkerToolbarItem = (function () {
6
-    function CoverMarkerToolbarItem() {
7
-        this.name = 'cover-marker';
8
-        this.tooltipText = 'Cover';
9
-        this.icon = cover_marker_toolbar_icon_svg_1.default;
10
-        this.markerType = CoverMarker_1.CoverMarker;
11
-    }
12
-    return CoverMarkerToolbarItem;
13
-}());
14
-exports.CoverMarkerToolbarItem = CoverMarkerToolbarItem;

+ 0
- 14
dist/cjs/markers/highlight/HighlightMarkerToolbarItem.js View File

@@ -1,14 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var HighlightMarker_1 = require("./HighlightMarker");
4
-var highlight_marker_toolbar_icon_svg_1 = require("./highlight-marker-toolbar-icon.svg");
5
-var HighlightMarkerToolbarItem = (function () {
6
-    function HighlightMarkerToolbarItem() {
7
-        this.name = 'cover-marker';
8
-        this.tooltipText = 'Cover';
9
-        this.icon = highlight_marker_toolbar_icon_svg_1.default;
10
-        this.markerType = HighlightMarker_1.HighlightMarker;
11
-    }
12
-    return HighlightMarkerToolbarItem;
13
-}());
14
-exports.HighlightMarkerToolbarItem = HighlightMarkerToolbarItem;

+ 0
- 14
dist/cjs/markers/line/LineMarkerToolbarItem.js View File

@@ -1,14 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var LineMarker_1 = require("./LineMarker");
4
-var line_marker_toolbar_icon_svg_1 = require("./line-marker-toolbar-icon.svg");
5
-var LineMarkerToolbarItem = (function () {
6
-    function LineMarkerToolbarItem() {
7
-        this.name = 'line-marker';
8
-        this.tooltipText = 'Line';
9
-        this.icon = line_marker_toolbar_icon_svg_1.default;
10
-        this.markerType = LineMarker_1.LineMarker;
11
-    }
12
-    return LineMarkerToolbarItem;
13
-}());
14
-exports.LineMarkerToolbarItem = LineMarkerToolbarItem;

+ 0
- 14
dist/cjs/markers/rect/RectMarkerToolbarItem.js View File

@@ -1,14 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var RectMarker_1 = require("./RectMarker");
4
-var rect_marker_toolbar_icon_svg_1 = require("./rect-marker-toolbar-icon.svg");
5
-var RectMarkerToolbarItem = (function () {
6
-    function RectMarkerToolbarItem() {
7
-        this.name = "rect-marker";
8
-        this.tooltipText = "Rectangle";
9
-        this.icon = rect_marker_toolbar_icon_svg_1.default;
10
-        this.markerType = RectMarker_1.RectMarker;
11
-    }
12
-    return RectMarkerToolbarItem;
13
-}());
14
-exports.RectMarkerToolbarItem = RectMarkerToolbarItem;

+ 0
- 14
dist/cjs/markers/text/TextMarkerToolbarItem.js View File

@@ -1,14 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var TextMarker_1 = require("./TextMarker");
4
-var text_marker_toolbar_icon_svg_1 = require("./text-marker-toolbar-icon.svg");
5
-var TextMarkerToolbarItem = (function () {
6
-    function TextMarkerToolbarItem() {
7
-        this.name = "text-marker";
8
-        this.tooltipText = "Text";
9
-        this.icon = text_marker_toolbar_icon_svg_1.default;
10
-        this.markerType = TextMarker_1.TextMarker;
11
-    }
12
-    return TextMarkerToolbarItem;
13
-}());
14
-exports.TextMarkerToolbarItem = TextMarkerToolbarItem;

+ 30
- 0
dist/cjs/markers/types.js View File

@@ -0,0 +1,30 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+var index_1 = require("./HighlightMarker/index");
4
+var index_2 = require("./TextMarker/index");
5
+var index_3 = require("./ArrowMarker/index");
6
+var index_4 = require("./BaseMarker/index");
7
+var CoverMarker_1 = require("./CoverMarker");
8
+var LineMarker_1 = require("./LineMarker");
9
+var RectMarker_1 = require("./RectMarker");
10
+function getMarkerByType(type) {
11
+    switch (type) {
12
+        case 'arrow':
13
+            return index_3.ArrowMarker;
14
+        case 'base':
15
+            return index_4.BaseMarker;
16
+        case 'cover':
17
+            return CoverMarker_1.CoverMarker;
18
+        case 'highlight':
19
+            return index_1.HighlightMarker;
20
+        case 'line':
21
+            return LineMarker_1.LineMarker;
22
+        case 'rect':
23
+            return RectMarker_1.RectMarker;
24
+        case 'text':
25
+            return index_2.TextMarker;
26
+        default:
27
+            return index_4.BaseMarker;
28
+    }
29
+}
30
+exports.getMarkerByType = getMarkerByType;

+ 0
- 20
dist/cjs/render/Activator.js View File

@@ -1,20 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var Activator = (function () {
4
-    function Activator() {
5
-    }
6
-    Object.defineProperty(Activator, "isLicensed", {
7
-        get: function () {
8
-            if (Activator.key) {
9
-                return true;
10
-            }
11
-            else {
12
-                return false;
13
-            }
14
-        },
15
-        enumerable: true,
16
-        configurable: true
17
-    });
18
-    return Activator;
19
-}());
20
-exports.Activator = Activator;

+ 0
- 305
dist/cjs/render/MarkerArea.js View File

@@ -1,305 +0,0 @@
1
-"use strict";
2
-Object.defineProperty(exports, "__esModule", { value: true });
3
-var Activator_1 = require("./Activator");
4
-var SvgHelper_1 = require("../utils/SvgHelper");
5
-var Renderer_1 = require("./Renderer");
6
-var Toolbar_1 = require("../toolbar/Toolbar");
7
-var ArrowMarkerToolbarItem_1 = require("../markers/arrow/ArrowMarkerToolbarItem");
8
-var CoverMarkerToolbarItem_1 = require("../markers/cover/CoverMarkerToolbarItem");
9
-var HighlightMarkerToolbarItem_1 = require("../markers/highlight/HighlightMarkerToolbarItem");
10
-var LineMarkerToolbarItem_1 = require("../markers/line/LineMarkerToolbarItem");
11
-var RectMarkerToolbarItem_1 = require("../markers/rect/RectMarkerToolbarItem");
12
-var TextMarkerToolbarItem_1 = require("../markers/text/TextMarkerToolbarItem");
13
-var check_svg_1 = require("./assets/core-toolbar-icons/check.svg");
14
-var eraser_svg_1 = require("./assets/core-toolbar-icons/eraser.svg");
15
-var mouse_pointer_svg_1 = require("./assets/core-toolbar-icons/mouse-pointer.svg");
16
-var times_svg_1 = require("./assets/core-toolbar-icons/times.svg");
17
-var markerjs_logo_m_svg_1 = require("./assets/fc-whiteboardlogo-m.svg");
18
-var MarkerArea = (function () {
19
-    function MarkerArea(target) {
20
-        var _this = this;
21
-        this.toolbars = [
22
-            {
23
-                icon: mouse_pointer_svg_1.default,
24
-                name: 'pointer',
25
-                tooltipText: 'Pointer'
26
-            },
27
-            {
28
-                icon: eraser_svg_1.default,
29
-                name: 'delete',
30
-                tooltipText: 'Delete'
31
-            },
32
-            {
33
-                name: 'separator',
34
-                tooltipText: ''
35
-            },
36
-            new RectMarkerToolbarItem_1.RectMarkerToolbarItem(),
37
-            new CoverMarkerToolbarItem_1.CoverMarkerToolbarItem(),
38
-            new HighlightMarkerToolbarItem_1.HighlightMarkerToolbarItem(),
39
-            new LineMarkerToolbarItem_1.LineMarkerToolbarItem(),
40
-            new ArrowMarkerToolbarItem_1.ArrowMarkerToolbarItem(),
41
-            new TextMarkerToolbarItem_1.TextMarkerToolbarItem(),
42
-            {
43
-                name: 'separator',
44
-                tooltipText: ''
45
-            },
46
-            {
47
-                icon: check_svg_1.default,
48
-                name: 'ok',
49
-                tooltipText: 'OK'
50
-            },
51
-            {
52
-                icon: times_svg_1.default,
53
-                name: 'close',
54
-                tooltipText: 'Close'
55
-            }
56
-        ];
57
-        this.scale = 1.0;
58
-        this.show = function (completeCallback, cancelCallback) {
59
-            _this.completeCallback = completeCallback;
60
-            if (cancelCallback) {
61
-                _this.cancelCallback = cancelCallback;
62
-            }
63
-            _this.open();
64
-            _this.showUI();
65
-        };
66
-        this.open = function () {
67
-            _this.setTargetRect();
68
-            _this.initMarkerCanvas();
69
-            _this.attachEvents();
70
-            _this.setStyles();
71
-            if (!Activator_1.Activator.isLicensed) {
72
-                _this.adLogo();
73
-            }
74
-            window.addEventListener('resize', _this.adjustUI);
75
-        };
76
-        this.render = function (completeCallback, cancelCallback) {
77
-            _this.completeCallback = completeCallback;
78
-            if (cancelCallback) {
79
-                _this.cancelCallback = cancelCallback;
80
-            }
81
-            _this.selectMarker(null);
82
-            _this.startRender(_this.renderFinished);
83
-        };
84
-        this.close = function () {
85
-            if (_this.toolbarUI) {
86
-                document.body.removeChild(_this.toolbarUI);
87
-            }
88
-            if (_this.markerImage) {
89
-                document.body.removeChild(_this.markerImageHolder);
90
-            }
91
-            if (_this.logoUI) {
92
-                document.body.removeChild(_this.logoUI);
93
-            }
94
-        };
95
-        this.addMarker = function (markerType) {
96
-            var marker = markerType.createMarker();
97
-            marker.onSelected = _this.selectMarker;
98
-            if (marker.defs && marker.defs.length > 0) {
99
-                for (var _i = 0, _a = marker.defs; _i < _a.length; _i++) {
100
-                    var d = _a[_i];
101
-                    if (d.id && !_this.markerImage.getElementById(d.id)) {
102
-                        _this.defs.appendChild(d);
103
-                    }
104
-                }
105
-            }
106
-            _this.markers.push(marker);
107
-            _this.selectMarker(marker);
108
-            _this.markerImage.appendChild(marker.visual);
109
-            var bbox = marker.visual.getBBox();
110
-            var x = _this.width / 2 / _this.scale - bbox.width / 2;
111
-            var y = _this.height / 2 / _this.scale - bbox.height / 2;
112
-            var translate = marker.visual.transform.baseVal.getItem(0);
113
-            translate.setMatrix(translate.matrix.translate(x, y));
114
-            marker.visual.transform.baseVal.replaceItem(translate, 0);
115
-        };
116
-        this.deleteActiveMarker = function () {
117
-            if (_this.activeMarker) {
118
-                _this.deleteMarker(_this.activeMarker);
119
-            }
120
-        };
121
-        this.setTargetRect = function () {
122
-            var targetRect = _this.target.getBoundingClientRect();
123
-            var bodyRect = document.body.parentElement.getBoundingClientRect();
124
-            _this.targetRect = {
125
-                left: targetRect.left - bodyRect.left,
126
-                top: targetRect.top - bodyRect.top
127
-            };
128
-        };
129
-        this.startRender = function (done) {
130
-            var renderer = new Renderer_1.Renderer();
131
-            renderer.rasterize(_this.target, _this.markerImage, done);
132
-        };
133
-        this.attachEvents = function () {
134
-            _this.markerImage.addEventListener('mousedown', _this.mouseDown);
135
-            _this.markerImage.addEventListener('mousemove', _this.mouseMove);
136
-            _this.markerImage.addEventListener('mouseup', _this.mouseUp);
137
-        };
138
-        this.mouseDown = function (ev) {
139
-            if (_this.activeMarker && (ev.buttons & 1) > 0) {
140
-                _this.activeMarker.deselect();
141
-                _this.activeMarker = null;
142
-            }
143
-        };
144
-        this.mouseMove = function (ev) {
145
-            if (_this.activeMarker && (ev.buttons & 1) > 0) {
146
-                _this.activeMarker.manipulate(ev);
147
-            }
148
-        };
149
-        this.mouseUp = function (ev) {
150
-            if (_this.activeMarker) {
151
-                _this.activeMarker.endManipulation();
152
-            }
153
-        };
154
-        this.initMarkerCanvas = function () {
155
-            _this.markerImageHolder = document.createElement('div');
156
-            _this.markerImageHolder.style.setProperty('touch-action', 'none');
157
-            _this.markerImageHolder.style.setProperty('-ms-touch-action', 'none');
158
-            _this.markerImage = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
159
-            _this.markerImage.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
160
-            _this.markerImage.setAttribute('width', _this.width.toString());
161
-            _this.markerImage.setAttribute('height', _this.height.toString());
162
-            _this.markerImage.setAttribute('viewBox', '0 0 ' + _this.width.toString() + ' ' + _this.height.toString());
163
-            _this.markerImageHolder.style.position = 'absolute';
164
-            _this.markerImageHolder.style.width = _this.width + "px";
165
-            _this.markerImageHolder.style.height = _this.height + "px";
166
-            _this.markerImageHolder.style.transformOrigin = 'top left';
167
-            _this.positionMarkerImage();
168
-            _this.defs = SvgHelper_1.SvgHelper.createDefs();
169
-            _this.markerImage.appendChild(_this.defs);
170
-            _this.markerImageHolder.appendChild(_this.markerImage);
171
-            document.body.appendChild(_this.markerImageHolder);
172
-        };
173
-        this.adjustUI = function (ev) {
174
-            _this.adjustSize();
175
-            _this.positionUI();
176
-        };
177
-        this.adjustSize = function () {
178
-            _this.width = _this.target.clientWidth;
179
-            _this.height = _this.target.clientHeight;
180
-            var scale = _this.target.clientWidth / _this.markerImageHolder.clientWidth;
181
-            if (scale !== 1.0) {
182
-                _this.scale *= scale;
183
-                _this.markerImageHolder.style.width = _this.width + "px";
184
-                _this.markerImageHolder.style.height = _this.height + "px";
185
-                _this.markerImageHolder.style.transform = "scale(" + _this.scale + ")";
186
-            }
187
-        };
188
-        this.positionUI = function () {
189
-            _this.setTargetRect();
190
-            _this.positionMarkerImage();
191
-            _this.positionToolbar();
192
-            if (_this.logoUI) {
193
-                _this.positionLogo();
194
-            }
195
-        };
196
-        this.positionMarkerImage = function () {
197
-            _this.markerImageHolder.style.top = _this.targetRect.top + 'px';
198
-            _this.markerImageHolder.style.left = _this.targetRect.left + 'px';
199
-        };
200
-        this.positionToolbar = function () {
201
-            _this.toolbarUI.style.left = _this.targetRect.left +
202
-                _this.target.offsetWidth -
203
-                _this.toolbarUI.clientWidth + "px";
204
-            _this.toolbarUI.style.top = _this.targetRect.top - _this.toolbarUI.clientHeight + "px";
205
-        };
206
-        this.showUI = function () {
207
-            _this.toolbar = new Toolbar_1.Toolbar(_this.toolbars, _this.toolbarClick);
208
-            _this.toolbarUI = _this.toolbar.getUI();
209
-            document.body.appendChild(_this.toolbarUI);
210
-            _this.toolbarUI.style.position = 'absolute';
211
-            _this.positionToolbar();
212
-        };
213
-        this.setStyles = function () {
214
-            var editorStyleSheet = document.createElementNS('http://www.w3.org/2000/svg', 'style');
215
-            editorStyleSheet.innerHTML = "\n            .rect-marker .render-visual {\n                stroke: #ff0000;\n                stroke-width: 3;\n                fill: transparent;\n            }\n            .cover-marker .render-visual {\n                stroke-width: 0;\n                fill: #000000;\n            }\n            .highlight-marker .render-visual {\n                stroke: transparent;\n                stroke-width: 0;\n                fill: #ffff00;\n                fill-opacity: 0.4;\n            }\n            .line-marker .render-visual {\n                stroke: #ff0000;\n                stroke-width: 3;\n                fill: transparent;\n            }\n            .arrow-marker .render-visual {\n                stroke: #ff0000;\n                stroke-width: 3;\n                fill: transparent;\n            }\n            .arrow-marker-tip {\n                stroke-width: 0;\n                fill: #ff0000;\n            }\n            .text-marker text {\n                fill: #ff0000;\n                font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\",\n                    Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\",\n                    \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n            }\n            .fc-whiteboardrect-control-box .fc-whiteboardrect-control-rect {\n                stroke: black;\n                stroke-width: 1;\n                stroke-opacity: 0.5;\n                stroke-dasharray: 3, 2;\n                fill: transparent;\n            }\n            .fc-whiteboardcontrol-grip {\n                fill: #cccccc;\n                stroke: #333333;\n                stroke-width: 2;\n            }\n        ";
216
-            _this.markerImage.appendChild(editorStyleSheet);
217
-        };
218
-        this.toolbarClick = function (ev, toolbarItem) {
219
-            if (toolbarItem.markerType) {
220
-                _this.addMarker(toolbarItem.markerType);
221
-            }
222
-            else {
223
-                switch (toolbarItem.name) {
224
-                    case 'delete': {
225
-                        _this.deleteActiveMarker();
226
-                        break;
227
-                    }
228
-                    case 'pointer': {
229
-                        if (_this.activeMarker) {
230
-                            _this.selectMarker(null);
231
-                        }
232
-                        break;
233
-                    }
234
-                    case 'close': {
235
-                        _this.cancel();
236
-                        break;
237
-                    }
238
-                    case 'ok': {
239
-                        _this.complete();
240
-                        break;
241
-                    }
242
-                }
243
-            }
244
-        };
245
-        this.selectMarker = function (marker) {
246
-            if (_this.activeMarker && _this.activeMarker !== marker) {
247
-                _this.activeMarker.deselect();
248
-            }
249
-            _this.activeMarker = marker;
250
-        };
251
-        this.deleteMarker = function (marker) {
252
-            _this.markerImage.removeChild(marker.visual);
253
-            if (_this.activeMarker === marker) {
254
-                _this.activeMarker = null;
255
-            }
256
-            _this.markers.splice(_this.markers.indexOf(marker), 1);
257
-        };
258
-        this.complete = function () {
259
-            _this.selectMarker(null);
260
-            _this.startRender(_this.renderFinishedClose);
261
-        };
262
-        this.cancel = function () {
263
-            _this.close();
264
-            if (_this.cancelCallback) {
265
-                _this.cancelCallback();
266
-            }
267
-        };
268
-        this.renderFinished = function (dataUrl) {
269
-            _this.completeCallback(dataUrl);
270
-        };
271
-        this.renderFinishedClose = function (dataUrl) {
272
-            _this.close();
273
-            _this.completeCallback(dataUrl);
274
-        };
275
-        this.positionLogo = function () {
276
-            if (_this.logoUI) {
277
-                _this.logoUI.style.left = _this.targetRect.left + 10 + "px";
278
-                _this.logoUI.style.top = _this.targetRect.top +
279
-                    _this.target.offsetHeight -
280
-                    _this.logoUI.clientHeight -
281
-                    10 + "px";
282
-            }
283
-        };
284
-        this.adLogo = function () {
285
-            _this.logoUI = document.createElement('div');
286
-            _this.logoUI.className = 'fc-whiteboardlogo';
287
-            var link = document.createElement('a');
288
-            link.href = 'https://markerjs.com/';
289
-            link.target = '_blank';
290
-            link.innerHTML = markerjs_logo_m_svg_1.default;
291
-            link.title = 'Powered by marker.js';
292
-            _this.logoUI.appendChild(link);
293
-            document.body.appendChild(_this.logoUI);
294
-            _this.logoUI.style.position = 'absolute';
295
-            _this.positionLogo();
296
-        };
297
-        this.target = target;
298
-        this.width = target.clientWidth;
299
-        this.height = target.clientHeight;
300
-        this.markers = [];
301
-        this.activeMarker = null;
302
-    }
303
-    return MarkerArea;
304
-}());
305
-exports.MarkerArea = MarkerArea;

dist/cjs/utils/SvgHelper/index.js → dist/cjs/renderer/SvgHelper/index.js View File


dist/cjs/render/Renderer.js → dist/cjs/renderer/Synthetizer/index.js View File

@@ -1,9 +1,13 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3
-var Renderer = (function () {
4
-    function Renderer() {
3
+var validator_1 = require("../../utils/validator");
4
+var Synthetizer = (function () {
5
+    function Synthetizer() {
5 6
     }
6
-    Renderer.prototype.rasterize = function (target, markerImage, done) {
7
+    Synthetizer.prototype.rasterize = function (target, markerImage, done) {
8
+        if (!validator_1.isHTMLImageElement(target)) {
9
+            throw new Error('Error: only support export HTMLImageElement');
10
+        }
7 11
         var canvas = document.createElement('canvas');
8 12
         canvas.width = markerImage.width.baseVal.value;
9 13
         canvas.height = markerImage.height.baseVal.value;
@@ -25,6 +29,6 @@ var Renderer = (function () {
25 29
         };
26 30
         img.src = url;
27 31
     };
28
-    return Renderer;
32
+    return Synthetizer;
29 33
 }());
30
-exports.Renderer = Renderer;
34
+exports.Synthetizer = Synthetizer;

+ 12
- 1
dist/cjs/toolbar/Toolbar.js View File

@@ -1,12 +1,15 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3 3
 var ToolbarButton_1 = require("./ToolbarButton");
4
+var uuid_1 = require("../utils/uuid");
4 5
 var Toolbar = (function () {
5 6
     function Toolbar(toolbarItems, clickHandler) {
6 7
         var _this = this;
8
+        this.id = uuid_1.uuid();
7 9
         this.getUI = function () {
8 10
             _this.toolbarUI = document.createElement('div');
9
-            _this.toolbarUI.className = 'fc-whiteboardtoolbar';
11
+            _this.toolbarUI.id = "fcw-toolbar-" + _this.id;
12
+            _this.toolbarUI.className = 'fc-whiteboard-toolbar';
10 13
             for (var _i = 0, _a = _this.toolbarItems; _i < _a.length; _i++) {
11 14
                 var toolbarItem = _a[_i];
12 15
                 var toolbarButton = new ToolbarButton_1.ToolbarButton(toolbarItem, _this.clickHandler);
@@ -17,6 +20,14 @@ var Toolbar = (function () {
17 20
         this.toolbarItems = toolbarItems;
18 21
         this.clickHandler = clickHandler;
19 22
     }
23
+    Toolbar.prototype.hide = function () {
24
+        this.toolbarUI.style.opacity = '0';
25
+        this.toolbarUI.style.zIndex = '-1';
26
+    };
27
+    Toolbar.prototype.show = function () {
28
+        this.toolbarUI.style.opacity = '1';
29
+        this.toolbarUI.style.zIndex = '999';
30
+    };
20 31
     return Toolbar;
21 32
 }());
22 33
 exports.Toolbar = Toolbar;

+ 2
- 2
dist/cjs/toolbar/ToolbarButton.js View File

@@ -6,7 +6,7 @@ var ToolbarButton = (function () {
6 6
         this.getElement = function () {
7 7
             var div = document.createElement('div');
8 8
             if (_this.toolbarItem.name !== 'separator') {
9
-                div.className = 'fc-whiteboardtoolbar-button';
9
+                div.className = 'fc-whiteboard-toolbar-button';
10 10
                 if (_this.clickHandler) {
11 11
                     div.addEventListener('click', function (ev) {
12 12
                         if (_this.clickHandler) {
@@ -23,7 +23,7 @@ var ToolbarButton = (function () {
23 23
                 }
24 24
             }
25 25
             else {
26
-                div.className = 'fc-whiteboardtoolbar-separator';
26
+                div.className = 'fc-whiteboard-toolbar-separator';
27 27
             }
28 28
             return div;
29 29
         };

+ 11
- 0
dist/cjs/toolbar/ToolbarItem.js View File

@@ -1,2 +1,13 @@
1 1
 "use strict";
2 2
 Object.defineProperty(exports, "__esModule", { value: true });
3
+var ToolbarItem = (function () {
4
+    function ToolbarItem(_a) {
5
+        var name = _a.name, tooltipText = _a.tooltipText, icon = _a.icon, markerType = _a.markerType;
6
+        this.name = name;
7
+        this.tooltipText = tooltipText;
8
+        this.icon = icon;
9
+        this.markerType = markerType;
10
+    }
11
+    return ToolbarItem;
12
+}());
13
+exports.ToolbarItem = ToolbarItem;

+ 93
- 0
dist/cjs/toolbar/toolbar-items.js View File

@@ -0,0 +1,93 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+var index_1 = require("./../markers/RectMarker/index");
4
+var index_2 = require("./../markers/CoverMarker/index");
5
+var index_3 = require("./../markers/TextMarker/index");
6
+var index_4 = require("./../markers/ArrowMarker/index");
7
+var index_5 = require("./../markers/HighlightMarker/index");
8
+var ToolbarItem_1 = require("./ToolbarItem");
9
+var LineMarker_1 = require("../markers/LineMarker");
10
+var OkIcon = require('../assets/check.svg');
11
+var DeleteIcon = require('../assets/eraser.svg');
12
+var PointerIcon = require('../assets/mouse-pointer.svg');
13
+var CloseIcon = require('../assets/times.svg');
14
+exports.highlightMarkerToolbarItem = new ToolbarItem_1.ToolbarItem({
15
+    name: 'cover-marker',
16
+    tooltipText: 'Cover',
17
+    icon: require('../assets/highlight.svg'),
18
+    markerType: index_5.HighlightMarker
19
+});
20
+exports.arrowMarkerToolbarItem = new ToolbarItem_1.ToolbarItem({
21
+    name: 'arrow-marker',
22
+    tooltipText: 'Arrow',
23
+    icon: require('../assets/arrow.svg'),
24
+    markerType: index_4.ArrowMarker
25
+});
26
+exports.textMarkerToolbarItem = new ToolbarItem_1.ToolbarItem({
27
+    name: 'text-marker',
28
+    tooltipText: 'Text',
29
+    icon: require('../assets/text.svg'),
30
+    markerType: index_3.TextMarker
31
+});
32
+exports.coverMarkerToolbarItem = new ToolbarItem_1.ToolbarItem({
33
+    name: 'cover-marker',
34
+    tooltipText: 'Cover',
35
+    icon: require('../assets/cover.svg'),
36
+    markerType: index_2.CoverMarker
37
+});
38
+exports.rectMarkerToolbarItem = new ToolbarItem_1.ToolbarItem({
39
+    name: 'rect-marker',
40
+    tooltipText: 'Rectangle',
41
+    icon: require('../assets/rect.svg'),
42
+    markerType: index_1.RectMarker
43
+});
44
+exports.lineMarkerToolbarItem = new ToolbarItem_1.ToolbarItem({
45
+    name: 'line-marker',
46
+    tooltipText: 'Line',
47
+    icon: require('../assets/line.svg'),
48
+    markerType: LineMarker_1.LineMarker
49
+});
50
+function getToolbars(page) {
51
+    var toolbars = [
52
+        {
53
+            icon: PointerIcon,
54
+            name: 'pointer',
55
+            tooltipText: 'Pointer'
56
+        },
57
+        {
58
+            icon: DeleteIcon,
59
+            name: 'delete',
60
+            tooltipText: 'Delete'
61
+        },
62
+        {
63
+            name: 'separator',
64
+            tooltipText: ''
65
+        },
66
+        exports.rectMarkerToolbarItem,
67
+        exports.coverMarkerToolbarItem,
68
+        exports.highlightMarkerToolbarItem,
69
+        exports.lineMarkerToolbarItem,
70
+        exports.arrowMarkerToolbarItem,
71
+        exports.textMarkerToolbarItem,
72
+        {
73
+            name: 'separator',
74
+            tooltipText: ''
75
+        }
76
+    ];
77
+    if (!page) {
78
+        toolbars.push.apply(toolbars, [
79
+            {
80
+                icon: OkIcon,
81
+                name: 'ok',
82
+                tooltipText: 'OK'
83
+            }
84
+        ]);
85
+    }
86
+    toolbars.push({
87
+        icon: CloseIcon,
88
+        name: 'close',
89
+        tooltipText: 'Close'
90
+    });
91
+    return toolbars;
92
+}
93
+exports.getToolbars = getToolbars;

+ 20
- 0
dist/cjs/utils/dom.js View File

@@ -0,0 +1,20 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+function createDivWithClassName(className, parent) {
4
+    var ele = document.createElement('div');
5
+    if (parent) {
6
+        parent.appendChild(ele);
7
+    }
8
+    if (className) {
9
+        addClassName(ele, className);
10
+    }
11
+    return ele;
12
+}
13
+exports.createDivWithClassName = createDivWithClassName;
14
+function addClassName(ele, className) {
15
+    if (!ele) {
16
+        return;
17
+    }
18
+    ele.className = ((ele.className || '') + " " + className).trim();
19
+}
20
+exports.addClassName = addClassName;

+ 4
- 0
dist/cjs/utils/uuid.js View File

@@ -0,0 +1,4 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+var uuidV1 = require("uuid/v1");
4
+exports.uuid = uuidV1;

+ 9
- 0
dist/cjs/utils/validator.js View File

@@ -0,0 +1,9 @@
1
+"use strict";
2
+Object.defineProperty(exports, "__esModule", { value: true });
3
+function isHTMLImageElement(ele) {
4
+    if (typeof ele === 'object' && ele instanceof HTMLImageElement) {
5
+        return true;
6
+    }
7
+    return false;
8
+}
9
+exports.isHTMLImageElement = isHTMLImageElement;

+ 1
- 1
dist/index.js
File diff suppressed because it is too large
View File


+ 15
- 0
dist/types/board/Baseboard/index.d.ts View File

@@ -0,0 +1,15 @@
1
+import { WhitePageSource } from './../types';
2
+export declare class Baseboard {
3
+    id: string;
4
+    source: WhitePageSource;
5
+    target: HTMLImageElement;
6
+    targetRect: ClientRect;
7
+    boardCanvas: SVGSVGElement;
8
+    boardHolder: HTMLDivElement;
9
+    defs: SVGDefsElement;
10
+    width: number;
11
+    height: number;
12
+    constructor(source: WhitePageSource);
13
+    protected initBoard: () => void;
14
+    protected positionBoard: () => void;
15
+}

+ 53
- 0
dist/types/board/Drawboard/index.d.ts View File

@@ -0,0 +1,53 @@
1
+import { WhitePageSource } from './../types';
2
+import { Baseboard } from './../Baseboard/index';
3
+import { BaseMarker } from './../../markers/BaseMarker/index';
4
+import { WhitePage } from './../WhitePage/index';
5
+import { onSyncFunc } from './../../event/Event';
6
+import './index.less';
7
+export declare class Drawboard extends Baseboard {
8
+    private scale;
9
+    page: WhitePage;
10
+    private markers;
11
+    readonly markerMap: {
12
+        [key: string]: BaseMarker;
13
+    };
14
+    private activeMarker;
15
+    private toolbar;
16
+    private toolbars;
17
+    private toolbarUI;
18
+    private onComplete;
19
+    private onChange;
20
+    private onCancel;
21
+    constructor(source: WhitePageSource, { page, onChange }?: {
22
+        page?: WhitePage;
23
+        onChange?: onSyncFunc;
24
+    });
25
+    open: (onComplete?: ((dataUrl: string) => void) | undefined, onCancel?: (() => void) | undefined) => void;
26
+    hide: () => void;
27
+    show: () => void;
28
+    close: () => void;
29
+    render: (onComplete: (dataUrl: string) => void, onCancel?: (() => void) | undefined) => void;
30
+    addMarker: (markerType: typeof BaseMarker, { id }?: {
31
+        id?: string | undefined;
32
+    }) => void;
33
+    deleteActiveMarker: () => void;
34
+    private setTargetRect;
35
+    private startRender;
36
+    private attachEvents;
37
+    private mouseDown;
38
+    private mouseMove;
39
+    private mouseUp;
40
+    private adjustUI;
41
+    private adjustSize;
42
+    private positionUI;
43
+    private positionToolbar;
44
+    private showUI;
45
+    private setStyles;
46
+    private toolbarClick;
47
+    private selectMarker;
48
+    deleteMarker: (marker: BaseMarker) => void;
49
+    private complete;
50
+    private cancel;
51
+    private renderFinished;
52
+    private renderFinishedClose;
53
+}

+ 28
- 0
dist/types/board/WhitePage/index.d.ts View File

@@ -0,0 +1,28 @@
1
+import { EventHub } from '../../event/EventHub';
2
+import { WhiteboardMode, WhitePageSource } from './../types';
3
+import { Drawboard } from './../Drawboard/index';
4
+import './index.less';
5
+export declare class WhitePage {
6
+    id: string;
7
+    source: WhitePageSource;
8
+    target: HTMLImageElement;
9
+    container: HTMLDivElement;
10
+    parentContainer?: HTMLDivElement;
11
+    mode: WhiteboardMode;
12
+    drawboard: Drawboard;
13
+    eventHub?: EventHub;
14
+    constructor(source: WhitePageSource, { mode, eventHub, parentContainer }?: {
15
+        mode?: WhiteboardMode;
16
+        eventHub?: EventHub;
17
+        parentContainer?: HTMLDivElement;
18
+    });
19
+    open(): void;
20
+    hide(): void;
21
+    show(): void;
22
+    close(): void;
23
+    private initSource;
24
+    protected initMaster(): void;
25
+    protected initMirror(): void;
26
+    private onPageSync;
27
+    private onMarkerSync;
28
+}

+ 41
- 0
dist/types/board/Whiteboard/index.d.ts View File

@@ -0,0 +1,41 @@
1
+import { WhiteboardMode } from '../types';
2
+import { WhitePage } from '../WhitePage/index';
3
+import { EventHub } from '../../event/EventHub';
4
+import './index.less';
5
+export declare class SerializableWhiteboard {
6
+    id: string;
7
+    sources: string[];
8
+    pageIds: string[];
9
+    visiblePageIndex: number;
10
+}
11
+export declare class Whiteboard {
12
+    id: string;
13
+    sources: string[];
14
+    target: HTMLDivElement;
15
+    imgsContainer: HTMLDivElement;
16
+    pagesContainer: HTMLDivElement;
17
+    eventHub?: EventHub;
18
+    mode: WhiteboardMode;
19
+    isFullscreen: boolean;
20
+    pages: WhitePage[];
21
+    siema: any;
22
+    isInitialized: boolean;
23
+    visiblePageIndex: number;
24
+    emitInterval: any;
25
+    constructor(target: HTMLDivElement, { sources, eventHub, mode, visiblePageIndex }?: {
26
+        sources?: string[];
27
+        eventHub?: EventHub;
28
+        mode?: WhiteboardMode;
29
+        visiblePageIndex?: number;
30
+    });
31
+    open(): void;
32
+    close(): void;
33
+    snap(): SerializableWhiteboard;
34
+    private init;
35
+    private initMaster;
36
+    private initMirror;
37
+    private initSiema;
38
+    private onPageChange;
39
+    private emitSnapshot;
40
+    private onSnapshot;
41
+}

+ 5
- 0
dist/types/board/types.d.ts View File

@@ -0,0 +1,5 @@
1
+export declare type WhiteboardMode = 'master' | 'mirror';
2
+export declare type WhitePageSource = {
3
+    imgEle?: HTMLImageElement;
4
+    imgSrc?: string;
5
+};

+ 11
- 0
dist/types/event/Event.d.ts View File

@@ -0,0 +1,11 @@
1
+export declare type TargetType = 'whiteboard' | 'page' | 'marker';
2
+export declare type EventType = 'snap' | 'add' | 'resize' | 'move' | 'remove' | 'changeIndex' | 'changeText';
3
+export declare type PositionType = 'left' | 'right' | 'topLeft' | 'bottomLeft' | 'topRight' | 'bottomRight' | 'centerLeft' | 'centerRight' | 'topCenter' | 'bottomCenter';
4
+export interface SyncEvent {
5
+    target: TargetType;
6
+    id?: string;
7
+    parentId?: string;
8
+    event: EventType;
9
+    data?: object | string | number;
10
+}
11
+export declare type onSyncFunc = (ev: SyncEvent) => void;

+ 3
- 0
dist/types/event/EventHub.d.ts View File

@@ -0,0 +1,3 @@
1
+import * as EventEmitter from 'eventemitter3';
2
+export declare class EventHub extends EventEmitter<'sync'> {
3
+}

+ 1
- 0
dist/types/index.d.ts View File

@@ -0,0 +1 @@
1
+export { Drawboard } from './board/Drawboard';

+ 9
- 0
dist/types/markers/ArrowMarker/index.d.ts View File

@@ -0,0 +1,9 @@
1
+import { MarkerType } from './../types';
2
+import { LinearMarker } from '../LinearMarker';
3
+import { WhitePage } from '../../board/WhitePage';
4
+export declare class ArrowMarker extends LinearMarker {
5
+    type: MarkerType;
6
+    static createMarker: (page?: WhitePage | undefined) => LinearMarker;
7
+    private readonly ARROW_SIZE;
8
+    protected setup(): void;
9
+}

dist/types/markers/base/ResizeGrip.d.ts → dist/types/markers/BaseMarker/ResizeGrip.d.ts View File


+ 41
- 0
dist/types/markers/BaseMarker/index.d.ts View File

@@ -0,0 +1,41 @@
1
+import { WhitePage } from './../../board/WhitePage/index';
2
+import { PositionType } from '../../event/Event';
3
+import { onSyncFunc, EventType } from '../../event/Event';
4
+import { MarkerType } from '../types';
5
+export declare class BaseMarker {
6
+    id: string;
7
+    type: MarkerType;
8
+    page?: WhitePage;
9
+    onChange: onSyncFunc;
10
+    static createMarker: (page?: WhitePage | undefined) => BaseMarker;
11
+    visual: SVGGElement;
12
+    renderVisual: SVGGElement;
13
+    onSelected: (marker: BaseMarker) => void;
14
+    defs: SVGElement[];
15
+    protected width: number;
16
+    protected height: number;
17
+    protected isActive: boolean;
18
+    protected isDragging: boolean;
19
+    protected isResizing: boolean;
20
+    protected previousMouseX: number;
21
+    protected previousMouseY: number;
22
+    reactToManipulation(type: EventType, { dx, dy, pos }: {
23
+        dx: number;
24
+        dy: number;
25
+        pos: PositionType;
26
+    }): void;
27
+    manipulate: (ev: MouseEvent) => void;
28
+    endManipulation(): void;
29
+    select(): void;
30
+    deselect(): void;
31
+    protected setup(): void;
32
+    protected addToVisual: (el: SVGElement) => void;
33
+    protected addToRenderVisual: (el: SVGElement) => void;
34
+    protected resize(x: number, y: number, cb?: Function): void;
35
+    protected resizeByEvent(x: number, y: number, pos?: PositionType): void;
36
+    protected onTouch(ev: TouchEvent): void;
37
+    private mouseDown;
38
+    private mouseUp;
39
+    private mouseMove;
40
+    private move;
41
+}

+ 8
- 0
dist/types/markers/CoverMarker/index.d.ts View File

@@ -0,0 +1,8 @@
1
+import { MarkerType } from './../types';
2
+import { RectBaseMarker } from '../RectMarker/RectBaseMarker';
3
+import { WhitePage } from '../../board/WhitePage';
4
+export declare class CoverMarker extends RectBaseMarker {
5
+    type: MarkerType;
6
+    static createMarker: (page?: WhitePage | undefined) => RectBaseMarker;
7
+    protected setup(): void;
8
+}

+ 8
- 0
dist/types/markers/HighlightMarker/index.d.ts View File

@@ -0,0 +1,8 @@
1
+import { MarkerType } from './../types';
2
+import { RectBaseMarker } from '../RectMarker/RectBaseMarker';
3
+import { WhitePage } from '../../board/WhitePage';
4
+export declare class HighlightMarker extends RectBaseMarker {
5
+    type: MarkerType;
6
+    static createMarker: (page?: WhitePage | undefined) => RectBaseMarker;
7
+    protected setup(): void;
8
+}

+ 8
- 0
dist/types/markers/LineMarker/index.d.ts View File

@@ -0,0 +1,8 @@
1
+import { MarkerType } from './../types';
2
+import { LinearMarker } from '../LinearMarker';
3
+import { WhitePage } from '../../board/WhitePage';
4
+export declare class LineMarker extends LinearMarker {
5
+    type: MarkerType;
6
+    static createMarker: (page?: WhitePage | undefined) => LinearMarker;
7
+    protected setup(): void;
8
+}

+ 32
- 0
dist/types/markers/LinearMarker/index.d.ts View File

@@ -0,0 +1,32 @@
1
+import { WhitePage } from './../../board/WhitePage/index';
2
+import { BaseMarker } from '../BaseMarker';
3
+import { PositionType } from '../../event/Event';
4
+export declare class LinearMarker extends BaseMarker {
5
+    static createMarker: (page?: WhitePage | undefined) => LinearMarker;
6
+    protected markerLine: SVGLineElement;
7
+    private readonly MIN_LENGTH;
8
+    private markerBgLine;
9
+    private controlBox;
10
+    private controlGrips;
11
+    private activeGrip;
12
+    private x1;
13
+    private y1;
14
+    private x2;
15
+    private y2;
16
+    endManipulation(): void;
17
+    select(): void;
18
+    deselect(): void;
19
+    protected setup(): void;
20
+    protected resize(x: number, y: number, onPosition?: (pos: PositionType) => void): void;
21
+    protected resizeByEvent(x: number, y: number, pos?: PositionType): void;
22
+    private getLineLength;
23
+    private addControlBox;
24
+    private adjustControlBox;
25
+    private addControlGrips;
26
+    private createGrip;
27
+    private positionGrips;
28
+    private positionGrip;
29
+    private gripMouseDown;
30
+    private gripMouseUp;
31
+    private gripMouseMove;
32
+}

+ 9
- 0
dist/types/markers/RectMarker/RectBaseMarker.d.ts View File

@@ -0,0 +1,9 @@
1
+import { PositionType } from '../../event/Event';
2
+import { RectangularMarker } from '../RectangularMarker';
3
+import { WhitePage } from '../../board/WhitePage';
4
+export declare class RectBaseMarker extends RectangularMarker {
5
+    static createMarker: (page?: WhitePage | undefined) => RectBaseMarker;
6
+    private markerRect;
7
+    protected setup(): void;
8
+    protected resize(x: number, y: number, onPosition?: (pos: PositionType) => void): void;
9
+}

+ 8
- 0
dist/types/markers/RectMarker/index.d.ts View File

@@ -0,0 +1,8 @@
1
+import { WhitePage } from './../../board/WhitePage/index';
2
+import { MarkerType } from './../types';
3
+import { RectBaseMarker } from './RectBaseMarker';
4
+export declare class RectMarker extends RectBaseMarker {
5
+    type: MarkerType;
6
+    static createMarker: (page?: WhitePage | undefined) => RectBaseMarker;
7
+    protected setup(): void;
8
+}

dist/types/markers/base/RectangularMarkerGrips.d.ts → dist/types/markers/RectangularMarker/RectangularMarkerGrips.d.ts View File

@@ -1,4 +1,4 @@
1
-import { ResizeGrip } from './ResizeGrip';
1
+import { ResizeGrip } from '../BaseMarker/ResizeGrip';
2 2
 export declare class RectangularMarkerGrips {
3 3
     topLeft: ResizeGrip;
4 4
     topCenter: ResizeGrip;

+ 28
- 0
dist/types/markers/RectangularMarker/index.d.ts View File

@@ -0,0 +1,28 @@
1
+import { BaseMarker } from '../BaseMarker';
2
+import { PositionType } from '../../event/Event';
3
+import { WhitePage } from '../../board/WhitePage';
4
+export declare class RectangularMarker extends BaseMarker {
5
+    static createMarker: (page?: WhitePage | undefined) => RectangularMarker;
6
+    protected MIN_SIZE: number;
7
+    private controlBox;
8
+    private readonly CB_DISTANCE;
9
+    private controlRect;
10
+    private controlGrips;
11
+    private activeGrip;
12
+    endManipulation(): void;
13
+    select(): void;
14
+    deselect(): void;
15
+    protected setup(): void;
16
+    protected resizeByEvent(x: number, y: number, pos: PositionType): void;
17
+    protected resize(x: number, y: number, onPosition?: (pos: PositionType) => void): void;
18
+    protected onTouch(ev: TouchEvent): void;
19
+    private addControlBox;
20
+    private adjustControlBox;
21
+    private addControlGrips;
22
+    private createGrip;
23
+    private positionGrips;
24
+    private positionGrip;
25
+    private gripMouseDown;
26
+    private gripMouseUp;
27
+    private gripMouseMove;
28
+}

+ 26
- 0
dist/types/markers/TextMarker/index.d.ts View File

@@ -0,0 +1,26 @@
1
+import { MarkerType } from '../types';
2
+import { RectangularMarker } from '../RectangularMarker';
3
+import { PositionType } from '../../event/Event';
4
+import { WhitePage } from '../../board/WhitePage';
5
+export declare class TextMarker extends RectangularMarker {
6
+    type: MarkerType;
7
+    static createMarker: (page?: WhitePage | undefined) => TextMarker;
8
+    setText(text: string): void;
9
+    protected readonly MIN_SIZE = 50;
10
+    private readonly DEFAULT_TEXT;
11
+    private text;
12
+    private textElement;
13
+    private inDoubleTap;
14
+    private editor;
15
+    private editorTextArea;
16
+    protected setup(): void;
17
+    protected resize(x: number, y: number, onPosition?: (pos: PositionType) => void): void;
18
+    private renderText;
19
+    private sizeText;
20
+    private onDblClick;
21
+    private onTap;
22
+    private showEditor;
23
+    private onEditorOkClick;
24
+    private closeEditor;
25
+    private onEditorKeyDown;
26
+}

+ 0
- 6
dist/types/markers/arrow/ArrowMarker.d.ts View File

@@ -1,6 +0,0 @@
1
-import { LineMarkerBase } from '../line/LineMarkerBase';
2
-export declare class ArrowMarker extends LineMarkerBase {
3
-  static createMarker: () => LineMarkerBase;
4
-  private readonly ARROW_SIZE;
5
-  protected setup(): void;
6
-}

+ 0
- 8
dist/types/markers/arrow/ArrowMarkerToolbarItem.d.ts View File

@@ -1,8 +0,0 @@
1
-import { ToolbarItem } from '../../toolbar/ToolbarItem';
2
-import { ArrowMarker } from './ArrowMarker';
3
-export declare class ArrowMarkerToolbarItem implements ToolbarItem {
4
-    name: string;
5
-    tooltipText: string;
6
-    icon: string;
7
-    markerType: typeof ArrowMarker;
8
-}

+ 0
- 27
dist/types/markers/base/MarkerBase.d.ts View File

@@ -1,27 +0,0 @@
1
-export declare class MarkerBase {
2
-  static createMarker: () => MarkerBase;
3
-  visual: SVGGElement;
4
-  renderVisual: SVGGElement;
5
-  onSelected: (marker: MarkerBase) => void;
6
-  defs: SVGElement[];
7
-  protected width: number;
8
-  protected height: number;
9
-  protected isActive: boolean;
10
-  protected isResizing: boolean;
11
-  protected previousMouseX: number;
12
-  protected previousMouseY: number;
13
-  private isDragging;
14
-  manipulate: (ev: MouseEvent) => void;
15
-  endManipulation(): void;
16
-  select(): void;
17
-  deselect(): void;
18
-  protected setup(): void;
19
-  protected addToVisual: (el: SVGElement) => void;
20
-  protected addToRenderVisual: (el: SVGElement) => void;
21
-  protected resize(x: number, y: number): void;
22
-  protected onTouch(ev: TouchEvent): void;
23
-  private mouseDown;
24
-  private mouseUp;
25
-  private mouseMove;
26
-  private move;
27
-}

+ 0
- 25
dist/types/markers/base/RectangularMarkerBase.d.ts View File

@@ -1,25 +0,0 @@
1
-import { MarkerBase } from './MarkerBase';
2
-export declare class RectangularMarkerBase extends MarkerBase {
3
-  static createMarker: () => RectangularMarkerBase;
4
-  protected MIN_SIZE: number;
5
-  private controlBox;
6
-  private readonly CB_DISTANCE;
7
-  private controlRect;
8
-  private controlGrips;
9
-  private activeGrip;
10
-  endManipulation(): void;
11
-  select(): void;
12
-  deselect(): void;
13
-  protected setup(): void;
14
-  protected resize(x: number, y: number): void;
15
-  protected onTouch(ev: TouchEvent): void;
16
-  private addControlBox;
17
-  private adjustControlBox;
18
-  private addControlGrips;
19
-  private createGrip;
20
-  private positionGrips;
21
-  private positionGrip;
22
-  private gripMouseDown;
23
-  private gripMouseUp;
24
-  private gripMouseMove;
25
-}

+ 0
- 5
dist/types/markers/cover/CoverMarker.d.ts View File

@@ -1,5 +0,0 @@
1
-import { RectMarkerBase } from '../rect/RectMarkerBase';
2
-export declare class CoverMarker extends RectMarkerBase {
3
-  static createMarker: () => RectMarkerBase;
4
-  protected setup(): void;
5
-}

+ 0
- 8
dist/types/markers/cover/CoverMarkerToolbarItem.d.ts View File

@@ -1,8 +0,0 @@
1
-import { ToolbarItem } from '../../toolbar/ToolbarItem';
2
-import { CoverMarker } from './CoverMarker';
3
-export declare class CoverMarkerToolbarItem implements ToolbarItem {
4
-    name: string;
5
-    tooltipText: string;
6
-    icon: string;
7
-    markerType: typeof CoverMarker;
8
-}

+ 0
- 5
dist/types/markers/highlight/HighlightMarker.d.ts View File

@@ -1,5 +0,0 @@
1
-import { RectMarkerBase } from '../rect/RectMarkerBase';
2
-export declare class HighlightMarker extends RectMarkerBase {
3
-  static createMarker: () => RectMarkerBase;
4
-  protected setup(): void;
5
-}

+ 0
- 8
dist/types/markers/highlight/HighlightMarkerToolbarItem.d.ts View File

@@ -1,8 +0,0 @@
1
-import { ToolbarItem } from '../../toolbar/ToolbarItem';
2
-import { HighlightMarker } from './HighlightMarker';
3
-export declare class HighlightMarkerToolbarItem implements ToolbarItem {
4
-    name: string;
5
-    tooltipText: string;
6
-    icon: string;
7
-    markerType: typeof HighlightMarker;
8
-}

+ 0
- 5
dist/types/markers/line/LineMarker.d.ts View File

@@ -1,5 +0,0 @@
1
-import { LineMarkerBase } from './LineMarkerBase';
2
-export declare class LineMarker extends LineMarkerBase {
3
-  static createMarker: () => LineMarkerBase;
4
-  protected setup(): void;
5
-}

+ 0
- 30
dist/types/markers/line/LineMarkerBase.d.ts View File

@@ -1,30 +0,0 @@
1
-import { MarkerBase } from '../base/MarkerBase';
2
-export declare class LineMarkerBase extends MarkerBase {
3
-  static createMarker: () => LineMarkerBase;
4
-  protected markerLine: SVGLineElement;
5
-  private readonly MIN_LENGTH;
6
-  private markerBgLine;
7
-  private controlBox;
8
-  private controlGrip1;
9
-  private controlGrip2;
10
-  private activeGrip;
11
-  private x1;
12
-  private y1;
13
-  private x2;
14
-  private y2;
15
-  endManipulation(): void;
16
-  select(): void;
17
-  deselect(): void;
18
-  protected setup(): void;
19
-  protected resize(x: number, y: number): void;
20
-  private getLineLength;
21
-  private addControlBox;
22
-  private adjustControlBox;
23
-  private addControlGrips;
24
-  private createGrip;
25
-  private positionGrips;
26
-  private positionGrip;
27
-  private gripMouseDown;
28
-  private gripMouseUp;
29
-  private gripMouseMove;
30
-}

+ 0
- 8
dist/types/markers/line/LineMarkerToolbarItem.d.ts View File

@@ -1,8 +0,0 @@
1
-import { ToolbarItem } from '../../toolbar/ToolbarItem';
2
-import { LineMarker } from './LineMarker';
3
-export declare class LineMarkerToolbarItem implements ToolbarItem {
4
-    name: string;
5
-    tooltipText: string;
6
-    icon: string;
7
-    markerType: typeof LineMarker;
8
-}

+ 0
- 5
dist/types/markers/rect/RectMarker.d.ts View File

@@ -1,5 +0,0 @@
1
-import { RectMarkerBase } from './RectMarkerBase';
2
-export declare class RectMarker extends RectMarkerBase {
3
-  static createMarker: () => RectMarkerBase;
4
-  protected setup(): void;
5
-}

+ 0
- 7
dist/types/markers/rect/RectMarkerBase.d.ts View File

@@ -1,7 +0,0 @@
1
-import { RectangularMarkerBase } from '../base/RectangularMarkerBase';
2
-export declare class RectMarkerBase extends RectangularMarkerBase {
3
-  static createMarker: () => RectMarkerBase;
4
-  private markerRect;
5
-  protected setup(): void;
6
-  protected resize(x: number, y: number): void;
7
-}

+ 0
- 8
dist/types/markers/rect/RectMarkerToolbarItem.d.ts View File

@@ -1,8 +0,0 @@
1
-import { ToolbarItem } from "../../toolbar/ToolbarItem";
2
-import { RectMarker } from "./RectMarker";
3
-export declare class RectMarkerToolbarItem implements ToolbarItem {
4
-    name: string;
5
-    tooltipText: string;
6
-    icon: string;
7
-    markerType: typeof RectMarker;
8
-}

+ 0
- 21
dist/types/markers/text/TextMarker.d.ts View File

@@ -1,21 +0,0 @@
1
-import { RectangularMarkerBase } from '../base/RectangularMarkerBase';
2
-export declare class TextMarker extends RectangularMarkerBase {
3
-  static createMarker: () => TextMarker;
4
-  protected readonly MIN_SIZE = 50;
5
-  private readonly DEFAULT_TEXT;
6
-  private text;
7
-  private textElement;
8
-  private inDoubleTap;
9
-  private editor;
10
-  private editorTextArea;
11
-  protected setup(): void;
12
-  protected resize(x: number, y: number): void;
13
-  private renderText;
14
-  private sizeText;
15
-  private onDblClick;
16
-  private onTap;
17
-  private showEditor;
18
-  private onEditorOkClick;
19
-  private closeEditor;
20
-  private onEditorKeyDown;
21
-}

+ 0
- 8
dist/types/markers/text/TextMarkerToolbarItem.d.ts View File

@@ -1,8 +0,0 @@
1
-import { ToolbarItem } from "../../toolbar/ToolbarItem";
2
-import { TextMarker } from "./TextMarker";
3
-export declare class TextMarkerToolbarItem implements ToolbarItem {
4
-    name: string;
5
-    tooltipText: string;
6
-    icon: string;
7
-    markerType: typeof TextMarker;
8
-}

+ 3
- 0
dist/types/markers/types.d.ts View File

@@ -0,0 +1,3 @@
1
+import { BaseMarker } from './BaseMarker/index';
2
+export declare type MarkerType = 'base' | 'arrow' | 'cover' | 'line' | 'rect' | 'text' | 'highlight';
3
+export declare function getMarkerByType(type: MarkerType): typeof BaseMarker;

+ 0
- 4
dist/types/render/Activator.d.ts View File

@@ -1,4 +0,0 @@
1
-export declare class Activator {
2
-    static key: string;
3
-    static readonly isLicensed: boolean;
4
-}

+ 0
- 55
dist/types/render/MarkerArea.d.ts View File

@@ -1,55 +0,0 @@
1
-import { MarkerBase } from '../markers/base/MarkerBase';
2
-export declare class MarkerArea {
3
-  private target;
4
-  private markerImage;
5
-  private markerImageHolder;
6
-  private defs;
7
-  private targetRect;
8
-  private width;
9
-  private height;
10
-  private markers;
11
-  private activeMarker;
12
-  private toolbar;
13
-  private toolbarUI;
14
-  private logoUI;
15
-  private completeCallback;
16
-  private cancelCallback;
17
-  private toolbars;
18
-  private scale;
19
-  constructor(target: HTMLImageElement);
20
-  show: (
21
-    completeCallback: (dataUrl: string) => void,
22
-    cancelCallback?: (() => void) | undefined
23
-  ) => void;
24
-  open: () => void;
25
-  render: (
26
-    completeCallback: (dataUrl: string) => void,
27
-    cancelCallback?: (() => void) | undefined
28
-  ) => void;
29
-  close: () => void;
30
-  addMarker: (markerType: typeof MarkerBase) => void;
31
-  deleteActiveMarker: () => void;
32
-  private setTargetRect;
33
-  private startRender;
34
-  private attachEvents;
35
-  private mouseDown;
36
-  private mouseMove;
37
-  private mouseUp;
38
-  private initMarkerCanvas;
39
-  private adjustUI;
40
-  private adjustSize;
41
-  private positionUI;
42
-  private positionMarkerImage;
43
-  private positionToolbar;
44
-  private showUI;
45
-  private setStyles;
46
-  private toolbarClick;
47
-  private selectMarker;
48
-  private deleteMarker;
49
-  private complete;
50
-  private cancel;
51
-  private renderFinished;
52
-  private renderFinishedClose;
53
-  private positionLogo;
54
-  private adLogo;
55
-}

+ 0
- 3
dist/types/render/Renderer.d.ts View File

@@ -1,3 +0,0 @@
1
-export declare class Renderer {
2
-    rasterize(target: HTMLImageElement, markerImage: SVGSVGElement, done: (dataUrl: string) => void): void;
3
-}

dist/types/utils/SvgHelper/index.d.ts → dist/types/renderer/SvgHelper/index.d.ts View File


+ 3
- 0
dist/types/renderer/Synthetizer/index.d.ts View File

@@ -0,0 +1,3 @@
1
+export declare class Synthetizer {
2
+    rasterize(target: HTMLImageElement | HTMLDivElement, markerImage: SVGSVGElement, done: (dataUrl: string) => void): void;
3
+}

+ 3
- 0
dist/types/toolbar/Toolbar.d.ts View File

@@ -1,8 +1,11 @@
1 1
 import { ToolbarItem } from './ToolbarItem';
2 2
 export declare class Toolbar {
3
+    id: string;
3 4
     private toolbarItems;
4 5
     private toolbarUI;
5 6
     private clickHandler;
6 7
     constructor(toolbarItems: ToolbarItem[], clickHandler: (ev: MouseEvent, toolbarItem: ToolbarItem) => void);
7 8
     getUI: () => HTMLElement;
9
+    hide(): void;
10
+    show(): void;
8 11
 }

+ 12
- 6
dist/types/toolbar/ToolbarItem.d.ts View File

@@ -1,7 +1,13 @@
1
-import { MarkerBase } from '../markers/base/MarkerBase';
2
-export interface ToolbarItem {
3
-  name: string;
4
-  tooltipText: string;
5
-  icon?: string;
6
-  markerType?: typeof MarkerBase;
1
+import { BaseMarker } from './../markers/BaseMarker/index';
2
+export declare class ToolbarItem {
3
+    name: string;
4
+    tooltipText: string;
5
+    icon?: string;
6
+    markerType?: typeof BaseMarker;
7
+    constructor({ name, tooltipText, icon, markerType }: {
8
+        name: string;
9
+        tooltipText: string;
10
+        icon?: string;
11
+        markerType?: typeof BaseMarker;
12
+    });
7 13
 }

+ 13
- 0
dist/types/toolbar/toolbar-items.d.ts View File

@@ -0,0 +1,13 @@
1
+import { WhitePage } from './../board/WhitePage/index';
2
+import { ToolbarItem } from './ToolbarItem';
3
+export declare const highlightMarkerToolbarItem: ToolbarItem;
4
+export declare const arrowMarkerToolbarItem: ToolbarItem;
5
+export declare const textMarkerToolbarItem: ToolbarItem;
6
+export declare const coverMarkerToolbarItem: ToolbarItem;
7
+export declare const rectMarkerToolbarItem: ToolbarItem;
8
+export declare const lineMarkerToolbarItem: ToolbarItem;
9
+export declare function getToolbars(page?: WhitePage): (ToolbarItem | {
10
+    icon: any;
11
+    name: string;
12
+    tooltipText: string;
13
+})[];

+ 2
- 0
dist/types/utils/dom.d.ts View File

@@ -0,0 +1,2 @@
1
+export declare function createDivWithClassName(className?: string, parent?: HTMLElement): HTMLDivElement;
2
+export declare function addClassName(ele: HTMLElement, className: string): void;

+ 1
- 0
dist/types/utils/uuid.d.ts View File

@@ -0,0 +1 @@
1
+export declare const uuid: import("uuid/interfaces").v1;

+ 1
- 0
dist/types/utils/validator.d.ts View File

@@ -0,0 +1 @@
1
+export declare function isHTMLImageElement(ele: any): boolean;

+ 2
- 2
scripts/base/webpack.config.prod.js View File

@@ -25,13 +25,13 @@ const config = {
25 25
       ),
26 26
       {
27 27
         test: /\.css$/,
28
-        use: ['style - loader', 'css-loader', 'postcss-loader']
28
+        use: ['style-loader', 'css-loader', 'postcss-loader']
29 29
       },
30 30
       {
31 31
         test: /\.less$/,
32 32
         exclude: /node_modules/,
33 33
         use: [
34
-          'style - loader',
34
+          'style-loader',
35 35
           baseConfig.extra.moduleCSSLoader,
36 36
           'postcss-loader',
37 37
           baseConfig.extra.lessLoader

+ 1
- 3
tsconfig.json View File

@@ -21,9 +21,7 @@
21 21
     "noUnusedLocals": true,
22 22
     "allowSyntheticDefaultImports": true,
23 23
     "skipLibCheck": true,
24
-    "paths": {
25
-      "lego-form-core": ["lego-form-core/src/"]
26
-    }
24
+    "paths": {}
27 25
   },
28 26
   "include": ["**/*.js", "**/*.ts", "**/*.tsx"],
29 27
   "exclude": [