qms-angular 1.0.39 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/qms-angular.umd.js +2845 -253
- package/bundles/qms-angular.umd.js.map +1 -1
- package/esm2015/lib/model/en.js +14 -1
- package/esm2015/lib/model/no.js +18 -5
- package/esm2015/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.js +3 -1
- package/esm2015/lib/qms-ckeditor-components/common/constants/iconSvg.constants.js +8 -0
- package/esm2015/lib/qms-ckeditor-components/common/enums/image-mode.enum.js +9 -0
- package/esm2015/lib/qms-ckeditor-components/common/enums/protocol-type.enum.js +11 -3
- package/esm2015/lib/qms-ckeditor-components/common/enums/target-type.enum.js +8 -1
- package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +3 -1
- package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.js +1 -1
- package/esm2015/lib/qms-ckeditor-components/common/models/qms-ckeditor-input.model.js +1 -9
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +524 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.lib.js +1948 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.validator.js +7 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +4 -4
- package/esm2015/lib/qms-ckeditor-components/models/qms-ckeditor-imagemap.model.js +22 -0
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +45 -12
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.module.js +11 -1
- package/esm2015/qms-angular.js +3 -1
- package/fesm2015/qms-angular.js +2822 -252
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/model/en.d.ts +13 -0
- package/lib/model/no.d.ts +13 -0
- package/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.d.ts +2 -0
- package/lib/qms-ckeditor-components/common/constants/iconSvg.constants.d.ts +7 -0
- package/lib/qms-ckeditor-components/common/enums/image-mode.enum.d.ts +7 -0
- package/lib/qms-ckeditor-components/common/enums/protocol-type.enum.d.ts +9 -2
- package/lib/qms-ckeditor-components/common/enums/target-type.enum.d.ts +6 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +1 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-input.model.d.ts +7 -7
- package/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.d.ts +123 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.lib.d.ts +542 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.validator.d.ts +2 -0
- package/lib/qms-ckeditor-components/models/qms-ckeditor-imagemap.model.d.ts +20 -0
- package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +5 -4
- package/package.json +1 -1
- package/qms-angular.d.ts +2 -0
- package/qms-angular.metadata.json +1 -1
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +2 -2
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
- package/src/assets/qms-ckeditor-plugin/package-lock.json +12177 -9
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +3 -2
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorConstant.js +4 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorService.js +10 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/fullscreen/dist/qmsCKEditorFullscreenPlugin.dev.js +87 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/converters.js +378 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/imagemap.js +14 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/imagemapediting.js +183 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/imagemapui.js +49 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/insertimagemapcommand.js +127 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/resizeimagemapcommand.js +82 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/utils.js +234 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkediting.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkimage.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/ui/linkactionsview.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/ui/linkformview.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/inserttooltipcommand.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipediting.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/ui/actionsview.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/imagemap.svg +56 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/{tyles → styles}/anchor.css +0 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/{tyles → styles}/link.css +0 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/{tyles → styles}/linkactions.css +0 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/{tyles → styles}/linkform.css +0 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/{tyles → styles}/linkimage.css +0 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/{tyles → styles}/tooltip.css +0 -0
- package/src/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.scss +27 -0
- package/src/themes/_color.scss +8 -0
- package/src/themes/core/_colors.scss +2 -0
- package/src/themes/core/_tab.scss +50 -49
@@ -22,8 +22,6 @@ import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle.js';
|
|
22
22
|
import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar.js';
|
23
23
|
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload.js';
|
24
24
|
import List from '@ckeditor/ckeditor5-list/src/list.js';
|
25
|
-
// import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed.js';
|
26
|
-
// import MediaToolbar from "@ckeditor/ckeditor5-media-embed/src/mediaembedtoolbar.js";
|
27
25
|
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph.js';
|
28
26
|
import PasteFromOffice from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice';
|
29
27
|
import Table from '@ckeditor/ckeditor5-table/src/table.js';
|
@@ -61,6 +59,7 @@ import FindAndReplace from './plugins/ckeditor5-find-and-replace/src/findandrepl
|
|
61
59
|
import Tooltip from './plugins/tooltip/tooltip.js';
|
62
60
|
import QMSCKEditorBpmnPlugin from './plugins/bpmn/qmsCKEditorBpmnPlugin.js';
|
63
61
|
import PageBreak from '@ckeditor/ckeditor5-page-break/src/pagebreak';
|
62
|
+
import ImageMap from './plugins/imagemap/imagemap.js';
|
64
63
|
import Indent from '@ckeditor/ckeditor5-indent/src/indent';
|
65
64
|
import IndentBlock from '@ckeditor/ckeditor5-indent/src/indentblock';
|
66
65
|
|
@@ -122,6 +121,8 @@ Editor.builtinPlugins = [
|
|
122
121
|
PasteFromOffice,
|
123
122
|
Tooltip,
|
124
123
|
FindAndReplace,
|
124
|
+
PageBreak,
|
125
|
+
ImageMap,
|
125
126
|
QMSCKEditorBpmnPlugin,
|
126
127
|
PageBreak,
|
127
128
|
Indent,
|
@@ -13,6 +13,10 @@ export const QMSCK_LINK_OPTION = 'LINK_OPTION'
|
|
13
13
|
export const QMSCK_TOOLTIP_PLUGIN_MSG = 'QMSCK_TOOLTIP_PLUGIN_MSG';
|
14
14
|
export const QMSCK_TOOLTIP_PLUGIN_RESP = 'QMSCK_TOOLTIP_PLUGIN_RESP';
|
15
15
|
export const QMSCK_TOOLTIP_IS_PROCESSING = 'QMSCK_TOOLTIP_IS_PROCESSING';
|
16
|
+
/* ImageMap */
|
17
|
+
export const QMSCK_IMAGEMAP_PLUGIN_MSG = 'QMSCK_IMAGEMAP_PLUGIN_MSG';
|
18
|
+
export const QMSCK_IMAGEMAP_PLUGIN_RESP = 'QMSCK_IMAGEMAP_PLUGIN_RESP';
|
19
|
+
export const QMSCK_IMAGEMAP_IS_PROCESSING = 'QMSCK_IMAGEMAP_IS_PROCESSING';
|
16
20
|
/* Bpmn */
|
17
21
|
export const QMSCK_BPMN_PLUGIN_MSG = 'QMSCK_BPMN_PLUGIN_MSG';
|
18
22
|
export const QMSCK_BPMN_PLUGIN_RESP = 'QMSCK_BPMN_PLUGIN_RESP';
|
@@ -50,6 +50,16 @@ export function tooltipNotify(value) {
|
|
50
50
|
);
|
51
51
|
}
|
52
52
|
|
53
|
+
export function imageMapNotify(value) {
|
54
|
+
window.postMessage(
|
55
|
+
{
|
56
|
+
eventName: constant.QMSCK_IMAGEMAP_PLUGIN_MSG,
|
57
|
+
value
|
58
|
+
},
|
59
|
+
'*'
|
60
|
+
);
|
61
|
+
}
|
62
|
+
|
53
63
|
export function bpmnNotify(value) {
|
54
64
|
window.postMessage(
|
55
65
|
{
|
@@ -0,0 +1,87 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports["default"] = void 0;
|
7
|
+
|
8
|
+
var _plugin = _interopRequireDefault(require("@ckeditor/ckeditor5-core/src/plugin"));
|
9
|
+
|
10
|
+
var _buttonview = _interopRequireDefault(require("@ckeditor/ckeditor5-ui/src/button/buttonview"));
|
11
|
+
|
12
|
+
var _fullscreen = _interopRequireDefault(require("../../themes/icons/fullscreen.svg"));
|
13
|
+
|
14
|
+
var QMSCKEditorService = _interopRequireWildcard(require("../common/qmsCKEditorService"));
|
15
|
+
|
16
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
17
|
+
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
19
|
+
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
21
|
+
|
22
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
23
|
+
|
24
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
25
|
+
|
26
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
27
|
+
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
29
|
+
|
30
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
31
|
+
|
32
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
33
|
+
|
34
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
35
|
+
|
36
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
37
|
+
|
38
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
39
|
+
|
40
|
+
var QMSCKEditorFullscreenPlugin =
|
41
|
+
/*#__PURE__*/
|
42
|
+
function (_Plugin) {
|
43
|
+
_inherits(QMSCKEditorFullscreenPlugin, _Plugin);
|
44
|
+
|
45
|
+
function QMSCKEditorFullscreenPlugin() {
|
46
|
+
_classCallCheck(this, QMSCKEditorFullscreenPlugin);
|
47
|
+
|
48
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(QMSCKEditorFullscreenPlugin).apply(this, arguments));
|
49
|
+
}
|
50
|
+
|
51
|
+
_createClass(QMSCKEditorFullscreenPlugin, [{
|
52
|
+
key: "init",
|
53
|
+
value: function init() {
|
54
|
+
var editor = this.editor;
|
55
|
+
editor.editing.view.change(function (writer) {// writer.setStyle( 'height', 'calc(100vh - 180px)', editor.editing.view.document.getRoot() );
|
56
|
+
});
|
57
|
+
editor.ui.componentFactory.add('qmsFullscreen', function (locale) {
|
58
|
+
var view = new _buttonview["default"](locale);
|
59
|
+
view.set({
|
60
|
+
label: 'Maximine/Minimine',
|
61
|
+
icon: _fullscreen["default"],
|
62
|
+
tooltip: true
|
63
|
+
});
|
64
|
+
view.on('execute', function () {
|
65
|
+
var fullscreen = window.parent.document.getElementsByClassName('qmsckeditor__fullscreen');
|
66
|
+
|
67
|
+
if (fullscreen && fullscreen.length) {
|
68
|
+
editor.editing.view.change(function (writer) {
|
69
|
+
writer.setStyle('height', 'calc(100vh - 180px)', editor.editing.view.document.getRoot());
|
70
|
+
});
|
71
|
+
} else {
|
72
|
+
editor.editing.view.change(function (writer) {
|
73
|
+
writer.setStyle('height', 'calc(100vh - 150px)', editor.editing.view.document.getRoot());
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
QMSCKEditorService.fullscreenNotify(null);
|
78
|
+
});
|
79
|
+
return view;
|
80
|
+
});
|
81
|
+
}
|
82
|
+
}]);
|
83
|
+
|
84
|
+
return QMSCKEditorFullscreenPlugin;
|
85
|
+
}(_plugin["default"]);
|
86
|
+
|
87
|
+
exports["default"] = QMSCKEditorFullscreenPlugin;
|
@@ -0,0 +1,378 @@
|
|
1
|
+
import { getViewImgFromWidget } from '@ckeditor/ckeditor5-image/src/image/utils';
|
2
|
+
import { ImageMapAttributes, ImageMapElements, trimStart, HtmlAttributes, HtmlElements} from './utils';
|
3
|
+
import { first } from '@ckeditor/ckeditor5-utils';
|
4
|
+
|
5
|
+
export function dowcastMapAreaAttribute() {
|
6
|
+
return dispatcher => {
|
7
|
+
dispatcher.on(`attribute:${ImageMapAttributes.MAP_AREAS}:${ImageMapElements.MAP}`, (evt, data, conversionApi) => {
|
8
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
const viewWriter = conversionApi.writer;
|
12
|
+
const mapElement = conversionApi.mapper.toViewElement(data.item);
|
13
|
+
if(!mapElement){
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
if(data.attributeNewValue != data.attributeOldValue && !!data.attributeNewValue){
|
17
|
+
if(mapElement.childCount > 0){
|
18
|
+
Array.from(mapElement.getChildren()).forEach((child) =>{
|
19
|
+
viewWriter.remove(child);
|
20
|
+
});
|
21
|
+
}
|
22
|
+
const areas = JSON.parse(data.attributeNewValue || '[]');
|
23
|
+
if(!!areas && areas.length > 0){
|
24
|
+
areas.forEach(area => {
|
25
|
+
if(area.coords && area.shape){
|
26
|
+
let areaElement = viewWriter.createEmptyElement(HtmlElements.AREA, {
|
27
|
+
coords: area.coords,
|
28
|
+
alt: area.alt || '',
|
29
|
+
shape: area.shape || '',
|
30
|
+
href: area.href,
|
31
|
+
target: area.target
|
32
|
+
});
|
33
|
+
viewWriter.insert(viewWriter.createPositionAt(mapElement, 0), areaElement);
|
34
|
+
}
|
35
|
+
});
|
36
|
+
}
|
37
|
+
}
|
38
|
+
});
|
39
|
+
};
|
40
|
+
}
|
41
|
+
|
42
|
+
export function dowcastMapNameAttribute() {
|
43
|
+
return dispatcher => {
|
44
|
+
dispatcher.on(`attribute:${ImageMapAttributes.MAP_NAME}:${ImageMapElements.MAP}`, (evt, data, conversionApi) => {
|
45
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
const viewWriter = conversionApi.writer;
|
49
|
+
const mapElement = conversionApi.mapper.toViewElement(data.item);
|
50
|
+
if(!mapElement){
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
viewWriter.setAttribute(HtmlAttributes.NAME, data.attributeNewValue, mapElement);
|
54
|
+
viewWriter.setAttribute(HtmlAttributes.ID, data.attributeNewValue, mapElement);
|
55
|
+
});
|
56
|
+
};
|
57
|
+
}
|
58
|
+
|
59
|
+
export function dowcastMapWidthAttribute() {
|
60
|
+
return dispatcher => {
|
61
|
+
dispatcher.on(`attribute:${ImageMapAttributes.MAP_WIDTH}:${ImageMapElements.MAP}`, (evt, data, conversionApi) => {
|
62
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
63
|
+
return;
|
64
|
+
}
|
65
|
+
const viewWriter = conversionApi.writer;
|
66
|
+
const mapElement = conversionApi.mapper.toViewElement(data.item);
|
67
|
+
if(!mapElement){
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
viewWriter.setAttribute(HtmlAttributes.WIDTH, data.attributeNewValue || '', mapElement);
|
71
|
+
});
|
72
|
+
};
|
73
|
+
}
|
74
|
+
|
75
|
+
export function dowcastMapHeightAttribute() {
|
76
|
+
return dispatcher => {
|
77
|
+
dispatcher.on(`attribute:${ImageMapAttributes.MAP_HEIGHT}:${ImageMapElements.MAP}`, (evt, data, conversionApi) => {
|
78
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
const viewWriter = conversionApi.writer;
|
82
|
+
const mapElement = conversionApi.mapper.toViewElement(data.item);
|
83
|
+
if(!mapElement){
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
viewWriter.setAttribute(HtmlAttributes.HEIGHT, data.attributeNewValue || '', mapElement);
|
87
|
+
});
|
88
|
+
};
|
89
|
+
}
|
90
|
+
|
91
|
+
export function downcastMapElement() {
|
92
|
+
return dispatcher => {
|
93
|
+
dispatcher.on(`insert:${ImageMapElements.MAP}`, (evt, data, conversionApi)=> {
|
94
|
+
const { consumable, writer, mapper} = conversionApi;
|
95
|
+
if (!consumable.consume(data.item, 'insert')) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
const viewPosition = mapper.toViewPosition(data.range.start);
|
99
|
+
const viewElement = writer.createContainerElement(HtmlElements.MAP);
|
100
|
+
mapper.bindElements(data.item, viewElement);
|
101
|
+
writer.insert(viewPosition, viewElement );
|
102
|
+
});
|
103
|
+
};
|
104
|
+
}
|
105
|
+
|
106
|
+
export function downcastImageWidthAttribute() {
|
107
|
+
return dispatcher => {
|
108
|
+
dispatcher.on(`attribute:${ImageMapAttributes.IMAGE_WIDTH}:${ImageMapElements.IMAGE}`, (evt, data, conversionApi) => {
|
109
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
const viewWriter = conversionApi.writer;
|
113
|
+
const figure = conversionApi.mapper.toViewElement(data.item);
|
114
|
+
const img = getViewImgFromWidget(figure);
|
115
|
+
viewWriter.setAttribute(HtmlAttributes.WIDTH, data.attributeNewValue, img);
|
116
|
+
});
|
117
|
+
};
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
export function downcastImageHeightAttribute() {
|
122
|
+
return dispatcher => {
|
123
|
+
dispatcher.on(`attribute:${ImageMapAttributes.IMAGE_HEIGHT}:${ImageMapElements.IMAGE}`, (evt, data, conversionApi) => {
|
124
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
const viewWriter = conversionApi.writer;
|
128
|
+
const figure = conversionApi.mapper.toViewElement(data.item);
|
129
|
+
const img = getViewImgFromWidget(figure);
|
130
|
+
viewWriter.setAttribute(HtmlAttributes.HEIGHT, data.attributeNewValue, img);
|
131
|
+
});
|
132
|
+
};
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
export function downcastImageSavedSrcAttribute(isDataDowncast) {
|
137
|
+
const priority = isDataDowncast ? 'highest' : 'normal';
|
138
|
+
return dispatcher => {
|
139
|
+
dispatcher.on(`attribute:${ImageMapAttributes.IMAGE_SAVED_SRC}:${ImageMapElements.IMAGE}`, (evt, data, conversionApi) => {
|
140
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
|
144
|
+
const viewWriter = conversionApi.writer;
|
145
|
+
const figure = conversionApi.mapper.toViewElement(data.item);
|
146
|
+
const img = getViewImgFromWidget(figure);
|
147
|
+
|
148
|
+
if(isDataDowncast == true){
|
149
|
+
if(data.item.hasAttribute(data.attributeKey)){
|
150
|
+
const originalSrc = data.item.getAttribute(data.attributeKey);
|
151
|
+
viewWriter.setAttribute(HtmlAttributes.SRC, originalSrc, img);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
else {
|
155
|
+
viewWriter.setAttribute(HtmlAttributes.SAVED_SRC, data.attributeNewValue || '', img);
|
156
|
+
}
|
157
|
+
},
|
158
|
+
{
|
159
|
+
priority: priority
|
160
|
+
});
|
161
|
+
};
|
162
|
+
}
|
163
|
+
|
164
|
+
export function downcastImageMapAttribute() {
|
165
|
+
return dispatcher => {
|
166
|
+
dispatcher.on(`attribute:${ImageMapAttributes.IMAGE_USE_MAP}:${ImageMapElements.IMAGE}`, (evt, data, conversionApi)=> {
|
167
|
+
if (!conversionApi.consumable.consume(data.item, evt.name)) {
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
|
171
|
+
const viewWriter = conversionApi.writer;
|
172
|
+
const figure = conversionApi.mapper.toViewElement(data.item);
|
173
|
+
const img = getViewImgFromWidget(figure);
|
174
|
+
|
175
|
+
const newValue = data.attributeNewValue || '';
|
176
|
+
const oldValue = data.attributeOldValue || '';
|
177
|
+
|
178
|
+
if(!!newValue){
|
179
|
+
viewWriter.setAttribute(HtmlAttributes.USE_MAP, data.attributeNewValue, img);
|
180
|
+
} else if(!!oldValue){
|
181
|
+
viewWriter.removeAttribute(HtmlAttributes.USE_MAP, img);
|
182
|
+
}
|
183
|
+
});
|
184
|
+
};
|
185
|
+
}
|
186
|
+
|
187
|
+
export function upcastMapElement() {
|
188
|
+
return dispatcher => {
|
189
|
+
dispatcher.on(`element:${HtmlElements.MAP}`, (evt, data, conversionApi) => {
|
190
|
+
const viewMap = data.viewItem;
|
191
|
+
const currentPosition = data.modelCursor;
|
192
|
+
const modelWriter = conversionApi.writer;
|
193
|
+
|
194
|
+
// Do not convert if this is not an map.
|
195
|
+
if (!conversionApi.consumable.test(data.viewItem, {name: true})) {
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
|
199
|
+
const name = viewMap.getAttribute(HtmlAttributes.NAME);
|
200
|
+
// Do not convert if image element is missing 'name' attribute.
|
201
|
+
if (!name) {
|
202
|
+
return;
|
203
|
+
}
|
204
|
+
|
205
|
+
const areas = [];
|
206
|
+
if(viewMap.childCount > 0){
|
207
|
+
for (const child of Array.from(viewMap.getChildren())) {
|
208
|
+
let area = {};
|
209
|
+
area[HtmlAttributes.COORDS] = child.getAttribute(HtmlAttributes.COORDS);
|
210
|
+
area[HtmlAttributes.HREF] = child.getAttribute(HtmlAttributes.HREF);
|
211
|
+
area[HtmlAttributes.ALT] = child.getAttribute(HtmlAttributes.ALT) || '';
|
212
|
+
area[HtmlAttributes.SHAPE] = child.getAttribute(HtmlAttributes.SHAPE) || '';
|
213
|
+
area[HtmlAttributes.TARGET] = child.getAttribute(HtmlAttributes.TARGET);
|
214
|
+
areas.push(area);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
const width = viewMap.getAttribute(HtmlAttributes.WIDTH);
|
219
|
+
const height = viewMap.getAttribute(HtmlAttributes.HEIGHT);
|
220
|
+
let attrs = {};
|
221
|
+
attrs[ImageMapAttributes.MAP_NAME] = name;
|
222
|
+
attrs[ImageMapAttributes.MAP_AREAS] = JSON.stringify(areas);
|
223
|
+
attrs[ImageMapAttributes.MAP_WIDTH] = width;
|
224
|
+
attrs[ImageMapAttributes.MAP_HEIGHT] = height;
|
225
|
+
const modelMap = modelWriter.createElement(ImageMapElements.MAP, attrs);
|
226
|
+
|
227
|
+
//TODO: Insert map element as a direct child of root
|
228
|
+
modelWriter.insert(modelMap, currentPosition);
|
229
|
+
conversionApi.convertChildren(viewMap, modelMap);
|
230
|
+
conversionApi.updateConversionResult(modelMap, data);
|
231
|
+
},
|
232
|
+
{
|
233
|
+
priority: 'high'
|
234
|
+
});
|
235
|
+
};
|
236
|
+
}
|
237
|
+
|
238
|
+
|
239
|
+
export function upcastImageMapAttribute() {
|
240
|
+
return dispatcher => {
|
241
|
+
dispatcher.on(`element:${HtmlElements.IMAGE}`, (evt, data, conversionApi) => {
|
242
|
+
const {consumable, writer} = conversionApi;
|
243
|
+
const viewImage = data.viewItem;
|
244
|
+
|
245
|
+
// Do not convert if the `usemap` attribute was already converted.
|
246
|
+
if (!consumable.consume(viewImage, {attributes: [HtmlAttributes.USE_MAP]})) {
|
247
|
+
return;
|
248
|
+
}
|
249
|
+
|
250
|
+
const usemap = viewImage.getAttribute(HtmlAttributes.USE_MAP);
|
251
|
+
// Do not convert if image element is missing `usemap` attribute
|
252
|
+
if (!usemap) {
|
253
|
+
return;
|
254
|
+
}
|
255
|
+
|
256
|
+
const modelImage = first(data.modelRange.getItems());
|
257
|
+
// When image wasn't successfully converted then finish conversion.
|
258
|
+
if (!modelImage) {
|
259
|
+
return;
|
260
|
+
}
|
261
|
+
|
262
|
+
if (modelImage.is('element', ImageMapElements.IMAGE)) {
|
263
|
+
const mapName = trimStart(usemap, '#');
|
264
|
+
writer.setAttribute(ImageMapAttributes.IMAGE_USE_MAP, '#' + mapName, modelImage);
|
265
|
+
}
|
266
|
+
},
|
267
|
+
{
|
268
|
+
priority: 'low'
|
269
|
+
});
|
270
|
+
};
|
271
|
+
}
|
272
|
+
|
273
|
+
|
274
|
+
export function upcastImageSavedSrcAttribute() {
|
275
|
+
return dispatcher => {
|
276
|
+
dispatcher.on(`element:${HtmlElements.IMAGE}`, (evt, data, conversionApi) => {
|
277
|
+
const {consumable, writer} = conversionApi;
|
278
|
+
const viewImage = data.viewItem;
|
279
|
+
|
280
|
+
// Do not convert if the `usemap` attribute was already converted.
|
281
|
+
if (!consumable.consume(viewImage, {attributes: [HtmlAttributes.SAVED_SRC]})) {
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
|
285
|
+
const originalSrc = viewImage.getAttribute(HtmlAttributes.SAVED_SRC);
|
286
|
+
|
287
|
+
// Do not convert if image element is missing `usemap` attribute
|
288
|
+
if (!originalSrc) {
|
289
|
+
return;
|
290
|
+
}
|
291
|
+
|
292
|
+
const modelImage = first(data.modelRange.getItems());
|
293
|
+
// When image wasn't successfully converted then finish conversion.
|
294
|
+
if (!modelImage) {
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
|
298
|
+
if (modelImage.is('element', ImageMapElements.IMAGE)) {
|
299
|
+
writer.setAttribute(ImageMapAttributes.IMAGE_SAVED_SRC, originalSrc || '', modelImage);
|
300
|
+
}
|
301
|
+
|
302
|
+
},
|
303
|
+
{
|
304
|
+
priority: 'low'
|
305
|
+
});
|
306
|
+
};
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
export function upcastImageWidthAttribute() {
|
311
|
+
return dispatcher => {
|
312
|
+
dispatcher.on(`element:${HtmlElements.IMAGE}`, (evt, data, conversionApi) => {
|
313
|
+
const {consumable, writer} = conversionApi;
|
314
|
+
const viewImage = data.viewItem;
|
315
|
+
|
316
|
+
// Do not convert if the `usemap` attribute was already converted.
|
317
|
+
if (!consumable.consume(viewImage, {attributes: [HtmlAttributes.WIDTH]})) {
|
318
|
+
return;
|
319
|
+
}
|
320
|
+
|
321
|
+
const width = viewImage.getAttribute(HtmlAttributes.WIDTH);
|
322
|
+
|
323
|
+
// Do not convert if image element is missing `usemap` attribute
|
324
|
+
if (!width) {
|
325
|
+
return;
|
326
|
+
}
|
327
|
+
|
328
|
+
const modelImage = first(data.modelRange.getItems());
|
329
|
+
// When image wasn't successfully converted then finish conversion.
|
330
|
+
if (!modelImage) {
|
331
|
+
return;
|
332
|
+
}
|
333
|
+
|
334
|
+
if (modelImage.is('element', ImageMapElements.IMAGE)) {
|
335
|
+
writer.setAttribute(ImageMapAttributes.IMAGE_WIDTH, width, modelImage);
|
336
|
+
}
|
337
|
+
},
|
338
|
+
{
|
339
|
+
priority: 'low'
|
340
|
+
});
|
341
|
+
};
|
342
|
+
}
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
export function upcastImageHeightAttribute() {
|
347
|
+
return dispatcher => {
|
348
|
+
dispatcher.on(`element:${HtmlElements.IMAGE}`, (evt, data, conversionApi) => {
|
349
|
+
const {consumable, writer} = conversionApi;
|
350
|
+
const viewImage = data.viewItem;
|
351
|
+
|
352
|
+
// Do not convert if the `usemap` attribute was already converted.
|
353
|
+
if (!consumable.consume(viewImage, {attributes: [HtmlAttributes.HEIGHT]})) {
|
354
|
+
return;
|
355
|
+
}
|
356
|
+
|
357
|
+
const height = viewImage.getAttribute(HtmlAttributes.HEIGHT);
|
358
|
+
|
359
|
+
// Do not convert if image element is missing `usemap` attribute
|
360
|
+
if (!height) {
|
361
|
+
return;
|
362
|
+
}
|
363
|
+
|
364
|
+
const modelImage = first(data.modelRange.getItems());
|
365
|
+
// When image wasn't successfully converted then finish conversion.
|
366
|
+
if (!modelImage) {
|
367
|
+
return;
|
368
|
+
}
|
369
|
+
|
370
|
+
if (modelImage.is('element', ImageMapElements.IMAGE)) {
|
371
|
+
writer.setAttribute(ImageMapAttributes.IMAGE_HEIGHT, height, modelImage);
|
372
|
+
}
|
373
|
+
},
|
374
|
+
{
|
375
|
+
priority: 'low'
|
376
|
+
});
|
377
|
+
};
|
378
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
2
|
+
import ImageMapEditing from './imagemapediting';
|
3
|
+
import ImageMapUI from './imagemapui';
|
4
|
+
|
5
|
+
export default class ImageMap extends Plugin {
|
6
|
+
|
7
|
+
static get requires() {
|
8
|
+
return [ ImageMapEditing, ImageMapUI ];
|
9
|
+
}
|
10
|
+
|
11
|
+
static pluginName() {
|
12
|
+
return 'ImageMap';
|
13
|
+
}
|
14
|
+
}
|