qms-angular 1.0.71 → 1.0.75
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 +960 -583
- package/bundles/qms-angular.umd.js.map +1 -1
- package/esm2015/lib/components/button/button.js +1 -1
- package/esm2015/lib/components/comment/comment.js +2 -2
- package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.js +7 -6
- package/esm2015/lib/components/qms-navigation-drawer/qms-navigation-drawer.module.js +4 -4
- package/esm2015/lib/components/qms-paginator/qms-paginator.component.js +3 -3
- package/esm2015/lib/components/qms-stepper/qms-stepper.component.js +1 -1
- package/esm2015/lib/components/range-slider/directives/range-slider-lockup.directive.js +20 -0
- package/esm2015/lib/components/range-slider/directives/range-slider.directive.js +34 -0
- package/esm2015/lib/components/range-slider/index.js +2 -0
- package/esm2015/lib/components/range-slider/public-api.js +4 -0
- package/esm2015/lib/components/range-slider/range-slider.module.js +22 -0
- package/esm2015/lib/components/related/popup/related-popup.component.js +1 -1
- package/esm2015/lib/components/select-include-children/select-include-children.component.js +112 -45
- package/esm2015/lib/components/select-one/select-one.component.js +50 -3
- package/esm2015/lib/components/select-process-document/select-process-document.component.js +64 -143
- package/esm2015/lib/components/side-sheet/directives/drawer-content.directive.js +20 -0
- package/esm2015/lib/components/side-sheet/directives/drawer-header-action.directive.js +20 -0
- package/esm2015/lib/components/side-sheet/directives/drawer-header.directive.js +20 -0
- package/esm2015/lib/components/side-sheet/directives/drawer.directive.js +20 -0
- package/esm2015/lib/components/side-sheet/index.js +2 -0
- package/esm2015/lib/components/side-sheet/public-api.js +6 -0
- package/esm2015/lib/components/side-sheet/side-sheet.module.js +28 -0
- package/esm2015/lib/components/tree/tree.component.js +15 -19
- package/esm2015/lib/components/treeNew/tree.component.js +6 -3
- package/esm2015/lib/directives/table/table-row.directive.js +50 -0
- package/esm2015/lib/directives/table/table.directive.js +18 -61
- package/esm2015/lib/model/en.js +19 -2
- package/esm2015/lib/model/no.js +19 -2
- package/esm2015/lib/qms-angular.module.js +5 -24
- package/esm2015/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.js +89 -0
- package/esm2015/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.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-video-tree.model.js +4 -0
- package/esm2015/lib/qms-ckeditor-components/common/models/wproofreader-config.model.js +6 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.js +38 -0
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.js +22 -3
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-fullscreen/qms-ckeditor-fullscreen.component.js +1 -46
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.js +9 -8
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-link/qms-ckeditor-link.component.js +4 -1
- package/esm2015/lib/qms-ckeditor-components/components/qms-ckeditor-tooltip/qms-ckeditor-tooltip.component.js +3 -4
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +178 -28
- package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.module.js +7 -3
- package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.js +4 -1
- package/esm2015/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.js +20 -0
- package/esm2015/public-api.js +6 -7
- package/esm2015/qms-angular.js +6 -4
- package/fesm2015/qms-angular.js +862 -524
- package/fesm2015/qms-angular.js.map +1 -1
- package/lib/components/button/button.d.ts +1 -1
- package/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.d.ts +1 -1
- package/lib/{directives/range-slider → components/range-slider/directives}/range-slider-lockup.directive.d.ts +0 -0
- package/lib/{directives/range-slider → components/range-slider/directives}/range-slider.directive.d.ts +0 -0
- package/lib/components/range-slider/index.d.ts +1 -0
- package/lib/components/range-slider/public-api.d.ts +3 -0
- package/lib/components/range-slider/range-slider.module.d.ts +2 -0
- package/lib/components/select-include-children/select-include-children.component.d.ts +2 -1
- package/lib/components/select-one/select-one.component.d.ts +4 -0
- package/lib/components/select-process-document/select-process-document.component.d.ts +3 -0
- package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer-content.directive.d.ts +0 -0
- package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer-header-action.directive.d.ts +0 -0
- package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer-header.directive.d.ts +0 -0
- package/lib/{directives/side-sheet → components/side-sheet/directives}/drawer.directive.d.ts +0 -0
- package/lib/components/side-sheet/index.d.ts +1 -0
- package/lib/components/side-sheet/public-api.d.ts +5 -0
- package/lib/components/side-sheet/side-sheet.module.d.ts +2 -0
- package/lib/directives/table/table-row.directive.d.ts +13 -0
- package/lib/directives/table/table.directive.d.ts +2 -11
- package/lib/model/en.d.ts +17 -0
- package/lib/model/no.d.ts +17 -0
- package/lib/qms-ckeditor-components/common/classes/qmsUploadAdapter.d.ts +18 -0
- package/lib/qms-ckeditor-components/common/constants/ckeditorEvent.constant.d.ts +2 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-data.model.d.ts +5 -0
- package/lib/qms-ckeditor-components/common/models/qms-ckeditor-video-tree.model.d.ts +5 -0
- package/lib/qms-ckeditor-components/common/models/wproofreader-config.model.d.ts +25 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.d.ts +15 -0
- package/lib/qms-ckeditor-components/components/qms-ckeditor-bpmn/qms-ckeditor-bpmn.component.d.ts +4 -1
- package/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.d.ts +2 -1
- package/lib/qms-ckeditor-components/qms-ckeditor.component.d.ts +17 -5
- package/lib/qms-ckeditor-components/services/qms-ckeditor-tree.service.d.ts +2 -0
- package/lib/qms-ckeditor-components/services/qms-ckeditor-upload.service.d.ts +5 -0
- package/lib.theme.scss +1 -0
- package/package.json +1 -1
- package/public-api.d.ts +3 -6
- package/qms-angular.d.ts +5 -3
- package/qms-angular.metadata.json +1 -1
- package/src/assets/images/ckeditor5.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/az.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/cs.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/da.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/de-ch.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/de.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/en-au.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/es.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/et.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/fa.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/fr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/gl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/he.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hi.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/hu.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/id.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/it.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ja.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ko.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ku.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/lv.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/nl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/no.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/pl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/pt-br.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/ru.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sl.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sr-latn.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/sr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/th.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/tk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/tr.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/uk.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/vi.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/zh-cn.js +1 -1
- package/src/assets/qms-ckeditor-plugin/build/translations/zh.js +1 -1
- package/src/assets/qms-ckeditor-plugin/package-lock.json +23 -0
- package/src/assets/qms-ckeditor-plugin/package.json +2 -0
- package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +18 -4
- package/src/assets/qms-ckeditor-plugin/src/plugins/aboutckeditor/aboutckeditor.js +28 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/bpmn/bpmndialogcommand.js +74 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/bpmn/qmsCKEditorBpmnPlugin.js +5 -68
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/contexts.json +3 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/de.po +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/en.po +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/gl.po +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/hu.po +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/it.po +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/ru.po +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/lang/translations/zh.po +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/src/index.js +10 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/src/sourceediting.js +386 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/src/utils/formathtml.js +142 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/theme/icons/source-editing.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-source-editing/theme/sourceediting.css +48 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorConstant.js +4 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/common/qmsCKEditorService.js +21 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/fullscreen/qmsCKEditorFullscreenPlugin.js +22 -15
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/imagemapcommand.js +1 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/imagemap/utils.js +1 -1
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkcommand.js +131 -176
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkdialogcommand.js +88 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkediting.js +2 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/link/linkui.js +41 -32
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontents.js +14 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentscommand.js +87 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsediting.js +59 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsui.js +35 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/utils.js +62 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/loadtemplatedialogcommand.js +14 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/qmsCKEditorLoadTemplatePlugin.js +10 -12
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/qmsCKEdtiorTemplatePlugin.js +10 -7
- package/src/assets/qms-ckeditor-plugin/src/plugins/template/templatedialogcommand.js +9 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/timestamp/timestamp.js +15 -18
- package/src/assets/qms-ckeditor-plugin/src/plugins/timestamp/timestampcommand.js +17 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/removetooltipcommand.js +42 -26
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltip.js +3 -3
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipcommand.js +75 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipdialogcommand.js +68 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipediting.js +206 -131
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/tooltipui.js +424 -136
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/ui/actionsview.js +67 -12
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/utils.js +17 -55
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/autovideo.js +1 -5
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/video/videoediting.js +5 -2
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/browsevideodialogcommand.js +25 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/uploadvideocommand.js +3 -16
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/videouploadediting.js +4 -0
- package/src/assets/qms-ckeditor-plugin/src/plugins/video/videoupload/videouploadui.js +12 -23
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/fullscreen_exit.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/information.svg +1 -50
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/table-excel.svg +44 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/timestamp.svg +1 -1
- package/src/assets/qms-ckeditor-plugin/src/themes/icons/tooltip.svg +1 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/styles/heading.css +54 -0
- package/src/assets/qms-ckeditor-plugin/src/themes/styles/tooltip.css +11 -53
- package/src/lib/components/qms-navigation-drawer/qms-navigation-drawer.component.scss +37 -20
- package/src/lib/components/qms-paginator/qms-paginator.component.scss +15 -0
- package/src/lib/components/qms-stepper/qms-stepper.component.scss +2 -1
- package/src/lib/components/select-process-document/select-process-document.component.scss +2 -2
- package/src/lib/qms-ckeditor-components/components/qms-ckeditor-about/qms-ckeditor-about.component.scss +16 -0
- package/src/lib/qms-ckeditor-components/components/qms-ckeditor-imagemap/qms-ckeditor-imagemap.component.scss +25 -23
- package/src/lib/qms-ckeditor-components/qms-ckeditor.component.scss +24 -0
- package/src/themes/core/_range-slider.scss +61 -42
- package/src/themes/core/_side-sheet.scss +2 -2
- package/src/themes/core/_table.scss +176 -37
- package/esm2015/lib/directives/range-slider/range-slider-lockup.directive.js +0 -20
- package/esm2015/lib/directives/range-slider/range-slider.directive.js +0 -36
- package/esm2015/lib/directives/side-sheet/drawer-content.directive.js +0 -20
- package/esm2015/lib/directives/side-sheet/drawer-header-action.directive.js +0 -20
- package/esm2015/lib/directives/side-sheet/drawer-header.directive.js +0 -20
- package/esm2015/lib/directives/side-sheet/drawer.directive.js +0 -20
- package/esm2015/lib/qms-ckeditor-components/common/classes/uploadAdapter.js +0 -26
- package/lib/qms-ckeditor-components/common/classes/uploadAdapter.d.ts +0 -5
- package/src/assets/qms-ckeditor-plugin/src/plugins/tooltip/inserttooltipcommand.js +0 -88
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
3
|
+
import { Collection, first } from '@ckeditor/ckeditor5-utils';
|
4
|
+
import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
|
5
|
+
import * as QMSCKEditorEnum from '../common/qmsCKEditorEnum';
|
6
|
+
import * as QMSCKEditorService from '../common/qmsCKEditorService';
|
7
|
+
import { isImageAllowed } from './utils';
|
8
|
+
import AutomaticDecorators from './utils/automaticdecorators';
|
9
|
+
|
10
|
+
export default class LinkDialogCommand extends Command {
|
11
|
+
constructor( editor ) {
|
12
|
+
super( editor );
|
13
|
+
this.manualDecorators = new Collection();
|
14
|
+
this.automaticDecorators = new AutomaticDecorators();
|
15
|
+
}
|
16
|
+
|
17
|
+
restoreManualDecoratorStates() {
|
18
|
+
for ( const manualDecorator of this.manualDecorators ) {
|
19
|
+
manualDecorator.value = this._getDecoratorStateFromModel( manualDecorator.id );
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
refresh() {
|
24
|
+
const model = this.editor.model;
|
25
|
+
const doc = model.document;
|
26
|
+
|
27
|
+
const selectedElement = first( doc.selection.getSelectedBlocks() );
|
28
|
+
|
29
|
+
// A check for the `LinkImage` plugin. If the selection contains an element, get values from the element.
|
30
|
+
// Currently the selection reads attributes from text nodes only. See #7429 and #7465.
|
31
|
+
if ( isImageAllowed( selectedElement, model.schema ) ) {
|
32
|
+
this.value = selectedElement.getAttribute( 'linkHref' );
|
33
|
+
this.isEnabled = model.schema.checkAttribute( selectedElement, 'linkHref' );
|
34
|
+
} else {
|
35
|
+
this.value = doc.selection.getAttribute( 'linkHref' );
|
36
|
+
this.isEnabled = model.schema.checkAttributeInSelection( doc.selection, 'linkHref' );
|
37
|
+
}
|
38
|
+
|
39
|
+
for ( const manualDecorator of this.manualDecorators ) {
|
40
|
+
manualDecorator.value = this._getDecoratorStateFromModel( manualDecorator.id );
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
execute() {
|
45
|
+
const editor = this.editor;
|
46
|
+
const model = editor.model;
|
47
|
+
const selection = model.document.selection;
|
48
|
+
const ranges = selection.getFirstRange();
|
49
|
+
|
50
|
+
let link = QMSCKEditorEnum.hyperLink;
|
51
|
+
link.typeId = 0;
|
52
|
+
link.targetId = 0;
|
53
|
+
link.protocolId = 0;
|
54
|
+
link.url = '';
|
55
|
+
link.title = '';
|
56
|
+
link.editorContent = '';
|
57
|
+
for (const item of ranges.getItems()) {
|
58
|
+
if (item.data) {
|
59
|
+
link.title = item.data;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
QMSCKEditorService.linkNotify(link);
|
63
|
+
window[QMSCKEditorConstant.QMSCK_LINKED] = false;
|
64
|
+
window.addEventListener(QMSCKEditorConstant.QMSCK_LINK_PLUGIN_RESP, function(evt) {
|
65
|
+
if (window[QMSCKEditorConstant.QMSCK_LINKED]){
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
window[QMSCKEditorConstant.QMSCK_LINKED] = true;
|
69
|
+
const options = evt.detail;
|
70
|
+
editor.commands.get('link').execute(options);
|
71
|
+
}, { once: true });
|
72
|
+
}
|
73
|
+
|
74
|
+
_getDecoratorStateFromModel( decoratorName ) {
|
75
|
+
const model = this.editor.model;
|
76
|
+
const doc = model.document;
|
77
|
+
const selectedElement = first( doc.selection.getSelectedBlocks() );
|
78
|
+
|
79
|
+
// A check for the `LinkImage` plugin. If the selection contains an element, get values from the element.
|
80
|
+
// Currently the selection reads attributes from text nodes only. See #7429 and #7465.
|
81
|
+
if ( isImageAllowed( selectedElement, model.schema ) ) {
|
82
|
+
return selectedElement.getAttribute( decoratorName );
|
83
|
+
}
|
84
|
+
|
85
|
+
return doc.selection.getAttribute( decoratorName );
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
@@ -20,6 +20,7 @@ import { createLinkElement, ensureSafeUrl, getLocalizedDecorators, normalizeDeco
|
|
20
20
|
import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
|
21
21
|
import '../../themes/styles/link.css';
|
22
22
|
import { isLinkElement } from './utils';
|
23
|
+
import LinkDialogCommand from './linkdialogcommand';
|
23
24
|
|
24
25
|
const HIGHLIGHT_CLASS = 'ck-link_selected';
|
25
26
|
const DECORATOR_AUTOMATIC = 'automatic';
|
@@ -94,6 +95,7 @@ export default class LinkEditing extends Plugin {
|
|
94
95
|
|
95
96
|
// Create linking commands.
|
96
97
|
editor.commands.add( 'link', new LinkCommand( editor ) );
|
98
|
+
editor.commands.add( 'linkdialog', new LinkDialogCommand( editor ) );
|
97
99
|
editor.commands.add( 'unlink', new UnlinkCommand( editor ) );
|
98
100
|
|
99
101
|
const linkDecorators = getLocalizedDecorators( editor.t, normalizeDecorators( editor.config.get( 'link.decorators' ) ) );
|
@@ -130,31 +130,40 @@ export default class LinkUI extends Plugin {
|
|
130
130
|
// Execute unlink command after clicking on the "Edit" button.
|
131
131
|
this.listenTo( actionsView, 'edit', () => {
|
132
132
|
//this._addFormView();
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
133
|
+
let link = QMSCKEditorEnum.hyperLink;
|
134
|
+
const href = this.actionsView.href;
|
135
|
+
const hasLink = this.isImageLinked( editor.editing.view.document.selection.getSelectedElement(), editor.plugins.get('Image') );
|
136
|
+
let parentLink;
|
137
|
+
if (hasLink) {
|
138
|
+
parentLink = editor.editing.view.document.selection.getSelectedElement().getChild(0);
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
parentLink = this._getSelectedLinkElement();
|
142
|
+
}
|
143
|
+
|
144
|
+
const linkOption = parentLink.getAttribute('url');
|
145
|
+
link.typeId = QMSCKEditorUtil.getLinkType(linkOption);
|
146
|
+
link.targetId = parentLink.getAttribute('target') ? QMSCKEditorEnum.targetEnum[parentLink.getAttribute('target')] : 0;
|
147
|
+
if (parentLink._children.length > 0) {
|
148
|
+
link.title = parentLink._children[0]._textData ? parentLink._children[0]._textData.trim() : '';
|
149
|
+
}
|
150
|
+
else {
|
151
|
+
link.title = '';
|
152
|
+
}
|
153
|
+
link.protocolId = QMSCKEditorUtil.getProtocolId(linkOption);
|
154
|
+
link.url = href;
|
155
|
+
link.edit = true;
|
156
|
+
QMSCKEditorService.linkNotify(link);
|
157
|
+
window[QMSCKEditorConstant.QMSCK_LINKED] = false;
|
158
|
+
window.addEventListener(QMSCKEditorConstant.QMSCK_LINK_PLUGIN_RESP, function(evt) {
|
159
|
+
if (window[QMSCKEditorConstant.QMSCK_LINKED]){
|
160
|
+
return;
|
161
|
+
}
|
162
|
+
window[QMSCKEditorConstant.QMSCK_LINKED] = true;
|
163
|
+
const options = evt.detail;
|
164
|
+
editor.commands.get('link').execute(options);
|
165
|
+
}, { once: true });
|
166
|
+
this._hideUI();
|
158
167
|
} );
|
159
168
|
|
160
169
|
// Execute unlink command after clicking on the "Unlink" button.
|
@@ -240,7 +249,7 @@ export default class LinkUI extends Plugin {
|
|
240
249
|
*/
|
241
250
|
_createToolbarLinkButton() {
|
242
251
|
const editor = this.editor;
|
243
|
-
const
|
252
|
+
const linkDialogCommand = editor.commands.get( 'linkdialog' );
|
244
253
|
const t = editor.t;
|
245
254
|
|
246
255
|
// Handle the `Ctrl+K` keystroke and show the panel.
|
@@ -248,9 +257,9 @@ export default class LinkUI extends Plugin {
|
|
248
257
|
// Prevent focusing the search bar in FF, Chrome and Edge. See https://github.com/ckeditor/ckeditor5/issues/4811.
|
249
258
|
cancel();
|
250
259
|
|
251
|
-
if (
|
260
|
+
if ( linkDialogCommand.isEnabled ) {
|
252
261
|
// this._showUI( true );
|
253
|
-
|
262
|
+
this.editor.execute('linkdialog');
|
254
263
|
}
|
255
264
|
} );
|
256
265
|
|
@@ -265,14 +274,14 @@ export default class LinkUI extends Plugin {
|
|
265
274
|
button.isToggleable = true;
|
266
275
|
|
267
276
|
// Bind button to the command.
|
268
|
-
const
|
269
|
-
button.bind( 'isEnabled' ).to(
|
270
|
-
button.bind( 'isOn' ).to(
|
277
|
+
const linkDialogCommand = editor.commands.get( 'linkdialog' );
|
278
|
+
button.bind( 'isEnabled' ).to( linkDialogCommand, 'isEnabled' );
|
279
|
+
button.bind( 'isOn' ).to( linkDialogCommand, 'value', value => !!value );
|
271
280
|
|
272
281
|
// Show the panel on button click.
|
273
282
|
//this.listenTo( button, 'execute', () => this._showUI( true ) );
|
274
283
|
this.listenTo(button, 'execute', () => {
|
275
|
-
this.editor.execute('
|
284
|
+
this.editor.execute('linkdialog');
|
276
285
|
});
|
277
286
|
|
278
287
|
return button;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Plugin } from '@ckeditor/ckeditor5-core';
|
2
|
+
import TableOfContentsEditing from './tableofcontentsediting';
|
3
|
+
import TableOfContentsUI from './tableofcontentsui';
|
4
|
+
|
5
|
+
export default class TableOfContents extends Plugin {
|
6
|
+
static get requires() {
|
7
|
+
return [TableOfContentsEditing, TableOfContentsUI];
|
8
|
+
}
|
9
|
+
|
10
|
+
static get pluginName() {
|
11
|
+
return 'TableOfContents';
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
2
|
+
import { rangeToText, getAttributeValueOn, setAttributeOn, TOC_ELEMENTS, TOC_ATTRIBUTES} from './utils';
|
3
|
+
import { findOptimalInsertionPosition } from '@ckeditor/ckeditor5-widget/src/utils';
|
4
|
+
import { trimStart } from '../common/qmsCKEditorUtil';
|
5
|
+
|
6
|
+
export default class TableOfContentsCommand extends Command {
|
7
|
+
|
8
|
+
execute( options = {} ) {
|
9
|
+
const editor = this.editor;
|
10
|
+
const model = editor.model;
|
11
|
+
model.change(writer => {
|
12
|
+
const headingObject = this._findHeadingElements(options.headings);
|
13
|
+
if(Object.keys(headingObject).length > 0){
|
14
|
+
const tocObject = this._buildTOCElements(headingObject);
|
15
|
+
this._setAnchorIdAttribute(headingObject, tocObject, writer);
|
16
|
+
this._insertTOCElements(tocObject, writer);
|
17
|
+
}
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
_insertTOCElements(tocObject, writer){
|
22
|
+
let position;
|
23
|
+
Object.keys(tocObject).forEach((key) => {
|
24
|
+
const section = tocObject[key];
|
25
|
+
const paragraphElement = writer.createElement(TOC_ELEMENTS.PARAGRAPH, { ...section.attributes });
|
26
|
+
const textElement = writer.createText(section.text, { [TOC_ATTRIBUTES.LINK_HREF]: '#' + section.id });
|
27
|
+
writer.insert(textElement, writer.createPositionAt(paragraphElement, 0));
|
28
|
+
if(!position){
|
29
|
+
position = findOptimalInsertionPosition(this.editor.model.document.selection, this.editor.model);
|
30
|
+
}
|
31
|
+
const { end: positionAfter } = this.editor.model.insertContent(paragraphElement, position);
|
32
|
+
position = positionAfter;
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
_setAnchorIdAttribute(headingObject, tocObject, writer){
|
37
|
+
Object.keys(tocObject).forEach((key) =>{
|
38
|
+
const node = headingObject[key];
|
39
|
+
const sectionOject = tocObject[key];
|
40
|
+
if(!sectionOject.hasAnchorId){
|
41
|
+
const range = this.editor.model.createRangeIn(node);
|
42
|
+
const attribute = { key: TOC_ATTRIBUTES.ANCHOR_ID, value: sectionOject.id }
|
43
|
+
const hasAnchorId = setAttributeOn(range, this.editor.model.schema, writer, attribute);
|
44
|
+
if(!hasAnchorId){
|
45
|
+
let childNode = writer.createText('\u00A0', { [TOC_ATTRIBUTES.ANCHOR_ID]: sectionOject.id });//insert non-breaking space
|
46
|
+
writer.insert(childNode, writer.createPositionAt(node, 0));
|
47
|
+
}
|
48
|
+
}
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
_buildTOCElements(headingObject){
|
53
|
+
const tocObject = {};
|
54
|
+
let index = 1;
|
55
|
+
Object.keys(headingObject).forEach(key =>{
|
56
|
+
const node = headingObject[key];
|
57
|
+
const range = this.editor.model.createRangeIn(node);
|
58
|
+
const attributes = Object.fromEntries(node.getAttributes());
|
59
|
+
const name = node.name.toLowerCase();
|
60
|
+
attributes[TOC_ATTRIBUTES.HEADING_CLASS] = name;
|
61
|
+
const text = rangeToText(range) || '';
|
62
|
+
let id = trimStart(text, '#').replace(/[^a-z0-9\+]/gi, '').toLowerCase() + index;
|
63
|
+
let hasAnchorId = false;
|
64
|
+
const anchorId = getAttributeValueOn(range, TOC_ATTRIBUTES.ANCHOR_ID);
|
65
|
+
if(!!anchorId){
|
66
|
+
id = trimStart(anchorId, '#');
|
67
|
+
hasAnchorId = true;
|
68
|
+
}
|
69
|
+
tocObject[key] = { id, name, text, hasAnchorId, attributes };
|
70
|
+
index++;
|
71
|
+
});
|
72
|
+
return tocObject;
|
73
|
+
}
|
74
|
+
|
75
|
+
_findHeadingElements(supportedHeadings){
|
76
|
+
const headingObject = {};
|
77
|
+
const range = this.editor.model.createRangeIn(this.editor.model.document.getRoot());
|
78
|
+
for (const value of range.getWalker()) {
|
79
|
+
const node = value.item;
|
80
|
+
if (node.is('element') && supportedHeadings.indexOf(node.name) > -1) {
|
81
|
+
let path = node.getPath();
|
82
|
+
headingObject[path] = node;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
return headingObject;
|
86
|
+
}
|
87
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
2
|
+
import { TOC_ATTRIBUTES, TOC_COMMAND, normalizeHeadingOptions } from './utils';
|
3
|
+
import TableOfContentsCommand from './tableofcontentscommand';
|
4
|
+
import '../../themes/styles/heading.css';
|
5
|
+
|
6
|
+
export default class TableOfContentsEditing extends Plugin {
|
7
|
+
static get pluginName() {
|
8
|
+
return 'TableOfContentsEditing';
|
9
|
+
}
|
10
|
+
|
11
|
+
init() {
|
12
|
+
const editor = this.editor;
|
13
|
+
const model = editor.model;
|
14
|
+
const supportedHeadings = normalizeHeadingOptions(editor.config.get('tableOfContents.supportedHeadings'));
|
15
|
+
model.schema.extend('$block', { allowAttributes: TOC_ATTRIBUTES.HEADING_CLASS } );
|
16
|
+
model.schema.setAttributeProperties(TOC_ATTRIBUTES.HEADING_CLASS, { isFormatting: true } );
|
17
|
+
editor.conversion.attributeToAttribute(buildClassDefinition(supportedHeadings));
|
18
|
+
editor.commands.add(TOC_COMMAND, new TableOfContentsCommand(editor));
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
function buildClassDefinition( supportedHeadings ) {
|
23
|
+
const options = [];
|
24
|
+
supportedHeadings.forEach((name) =>{
|
25
|
+
try{
|
26
|
+
/* Reference to the default config of the heading plugin
|
27
|
+
editor.config.define( 'heading', {
|
28
|
+
options: [
|
29
|
+
{ model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
|
30
|
+
{ model: 'heading1', view: 'h2', title: 'Heading 1', class: 'ck-heading_heading1' },
|
31
|
+
{ model: 'heading2', view: 'h3', title: 'Heading 2', class: 'ck-heading_heading2' },
|
32
|
+
{ model: 'heading3', view: 'h4', title: 'Heading 3', class: 'ck-heading_heading3' }
|
33
|
+
]
|
34
|
+
}); */
|
35
|
+
const level = parseInt(name.replace('heading', '')) + 1;
|
36
|
+
const className = 'h' + level;
|
37
|
+
options.push({ name, className });
|
38
|
+
}
|
39
|
+
catch{
|
40
|
+
|
41
|
+
}
|
42
|
+
});
|
43
|
+
|
44
|
+
const definition = {
|
45
|
+
model: {
|
46
|
+
key: TOC_ATTRIBUTES.HEADING_CLASS,
|
47
|
+
values: options.map(option => option.name)
|
48
|
+
},
|
49
|
+
view: {}
|
50
|
+
};
|
51
|
+
|
52
|
+
for (const option of options) {
|
53
|
+
definition.view[option.name] = {
|
54
|
+
key: 'class',
|
55
|
+
value: option.className
|
56
|
+
};
|
57
|
+
}
|
58
|
+
return definition;
|
59
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
2
|
+
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
3
|
+
import tableIcon from '../../themes/icons/table-excel.svg';
|
4
|
+
import { TOC_COMMAND, normalizeHeadingOptions } from './utils';
|
5
|
+
|
6
|
+
export default class TableOfContentsUI extends Plugin {
|
7
|
+
static get pluginName() {
|
8
|
+
return 'TableOfContentsUI';
|
9
|
+
}
|
10
|
+
|
11
|
+
init() {
|
12
|
+
const editor = this.editor;
|
13
|
+
const t = editor.t;
|
14
|
+
const supportedHeadings = normalizeHeadingOptions(editor.config.get('tableOfContents.supportedHeadings'));
|
15
|
+
editor.ui.componentFactory.add('tableOfContents', locale => {
|
16
|
+
const buttonView = new ButtonView( locale );
|
17
|
+
buttonView.set( {
|
18
|
+
label: t('Create Table of Contents'),
|
19
|
+
icon: tableIcon,
|
20
|
+
withText: false,
|
21
|
+
tooltip: true
|
22
|
+
} );
|
23
|
+
|
24
|
+
// Bind button to the command.
|
25
|
+
const tocCommand = editor.commands.get(TOC_COMMAND);
|
26
|
+
buttonView.bind('isEnabled').to(tocCommand, 'isEnabled' );
|
27
|
+
buttonView.bind('isOn').to(tocCommand, 'value', value => !!value );
|
28
|
+
|
29
|
+
buttonView.on('execute', () => {
|
30
|
+
editor.execute(TOC_COMMAND, { headings: supportedHeadings });
|
31
|
+
});
|
32
|
+
return buttonView;
|
33
|
+
});
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
export const DEFAULT_SUPPORTED_HEADINGS = ['heading1', 'heading2', 'heading3'];//It is already defined by the heading plugin
|
3
|
+
export const TOC_CUSTOM_PROPERTY = 'toc';
|
4
|
+
export const TOC_COMMAND = 'inserttoc';
|
5
|
+
export const TOC_ATTRIBUTES = {
|
6
|
+
HEADING_CLASS: 'headingClass',
|
7
|
+
ANCHOR_ID: 'anchorId', //It is already defined by the anchor plugin,
|
8
|
+
LINK_HREF: 'linkHref'//It is already defined by the link plugin
|
9
|
+
}
|
10
|
+
|
11
|
+
export const TOC_ELEMENTS = {
|
12
|
+
TOC: 'toc',
|
13
|
+
PARAGRAPH: 'paragraph' //It is already defined by the paragraph plugin
|
14
|
+
}
|
15
|
+
|
16
|
+
export function normalizeHeadingOptions(headingOptions) {
|
17
|
+
let headings = headingOptions || [];
|
18
|
+
headings = headings.map(value => value.toLowerCase()).filter(value => value.startsWith('heading'));
|
19
|
+
if(headings.length == 0){
|
20
|
+
headings = DEFAULT_SUPPORTED_HEADINGS;
|
21
|
+
}
|
22
|
+
return headings;
|
23
|
+
}
|
24
|
+
|
25
|
+
export function rangeToText(range) {
|
26
|
+
return Array.from(range.getItems()).reduce((rangeText, node) => {
|
27
|
+
if (!(node.is('text') || node.is('textProxy'))) {
|
28
|
+
return rangeText;
|
29
|
+
}
|
30
|
+
return rangeText + node.data;
|
31
|
+
}, '');
|
32
|
+
}
|
33
|
+
|
34
|
+
export function getAttributeValueOn(range, attributeName) {
|
35
|
+
for (const item of range.getItems()) {
|
36
|
+
for (const [ key, value ] of item.getAttributes()) {
|
37
|
+
if (key.toLowerCase() == attributeName.toLowerCase()) {
|
38
|
+
return value;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
return null;
|
43
|
+
}
|
44
|
+
|
45
|
+
export function setAttributeOn(range, schema, writer, attribute) {
|
46
|
+
for (const node of Array.from(range.getItems())) {
|
47
|
+
if (schema.checkAttribute(node, attribute.key)) {
|
48
|
+
writer.setAttribute(attribute.key, attribute.value, node);
|
49
|
+
return true;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
|
55
|
+
export function getTextNodeOn(range) {
|
56
|
+
for (const node of Array.from(range.getItems())) {
|
57
|
+
if (node.is('text') || node.is('textProxy')) {
|
58
|
+
return node;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return null;
|
62
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
2
|
+
import * as QMSCKEditorConstant from '../common/qmsCKEditorConstant';
|
3
|
+
import * as QMSCKEditorService from '../common/qmsCKEditorService';
|
4
|
+
|
5
|
+
export default class LoadTemplateDialogCommand extends Command {
|
6
|
+
|
7
|
+
execute() {
|
8
|
+
QMSCKEditorService.loadTemplateNotify(null);
|
9
|
+
window.addEventListener(QMSCKEditorConstant.QMSCK_LOAD_TEMPLATE_PLUGIN_RESP, function (evt) {
|
10
|
+
editor.setData(evt.detail);
|
11
|
+
}, { once: true });
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
package/src/assets/qms-ckeditor-plugin/src/plugins/template/qmsCKEditorLoadTemplatePlugin.js
CHANGED
@@ -1,32 +1,30 @@
|
|
1
1
|
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
2
2
|
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
3
3
|
import TemplateIcon from '../../themes/icons/load_template.svg';
|
4
|
-
import
|
5
|
-
import * as QMSCKEditorService from '../common/qmsCKEditorService';
|
6
|
-
|
4
|
+
import LoadTemplateDialogCommand from './loadtemplatedialogcommand';
|
7
5
|
export default class QMSCKEditorLoadTemplatePlugin extends Plugin {
|
8
6
|
init() {
|
9
7
|
const editor = this.editor;
|
8
|
+
const t = editor.t;
|
10
9
|
|
11
10
|
editor.ui.componentFactory.add('qmsLoadTemplate', locale => {
|
12
11
|
const view = new ButtonView(locale);
|
13
|
-
|
12
|
+
const command = editor.commands.get('loadtemplateDialog');
|
14
13
|
view.set({
|
15
|
-
label: 'Templates',
|
14
|
+
label: t('Templates'),
|
16
15
|
icon: TemplateIcon,
|
17
16
|
tooltip: true
|
18
17
|
});
|
19
18
|
|
20
|
-
view.
|
21
|
-
QMSCKEditorService.loadTemplateNotify(null);
|
19
|
+
view.bind('isEnabled').to(command);
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
},
|
26
|
-
{ once: true });
|
21
|
+
view.on('execute', () => {
|
22
|
+
command.execute();
|
27
23
|
});
|
28
24
|
|
29
25
|
return view;
|
30
|
-
})
|
26
|
+
});
|
27
|
+
|
28
|
+
editor.commands.add('loadtemplateDialog', new LoadTemplateDialogCommand(editor));
|
31
29
|
}
|
32
30
|
}
|
@@ -1,26 +1,29 @@
|
|
1
1
|
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
2
2
|
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
3
3
|
import TemplateIcon from '../../themes/icons/template.svg';
|
4
|
-
import
|
5
|
-
|
4
|
+
import TemplateDialogCommand from './templatedialogcommand';
|
6
5
|
export default class QMSCKEditorTemplatePlugin extends Plugin {
|
7
6
|
init() {
|
8
7
|
const editor = this.editor;
|
9
|
-
|
8
|
+
const t = editor.t;
|
10
9
|
editor.ui.componentFactory.add('qmsTemplate', locale => {
|
11
10
|
const view = new ButtonView(locale);
|
12
|
-
|
11
|
+
const command = editor.commands.get('templateDialog');
|
13
12
|
view.set({
|
14
|
-
label: 'Add Template',
|
13
|
+
label: t('Add Template'),
|
15
14
|
icon: TemplateIcon,
|
16
15
|
tooltip: true
|
17
16
|
});
|
18
17
|
|
18
|
+
view.bind('isEnabled').to(command);
|
19
|
+
|
19
20
|
view.on('execute', () => {
|
20
|
-
|
21
|
+
command.execute();
|
21
22
|
});
|
22
23
|
|
23
24
|
return view;
|
24
|
-
})
|
25
|
+
});
|
26
|
+
|
27
|
+
editor.commands.add('templateDialog', new TemplateDialogCommand(editor));
|
25
28
|
}
|
26
29
|
}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
|
2
2
|
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
|
3
3
|
import timestampIcon from '../../themes/icons/timestamp.svg';
|
4
|
-
import
|
5
|
-
import { toMap } from '@ckeditor/ckeditor5-utils';
|
4
|
+
import TimestampCommand from './timestampcommand';
|
6
5
|
|
7
6
|
/**
|
8
7
|
* Users can format the DateTime output based on a DateTime pattern
|
@@ -10,19 +9,19 @@ import { toMap } from '@ckeditor/ckeditor5-utils';
|
|
10
9
|
* The default DateTime pattern is dd/MM/yyyy hh:mm:ss aaa
|
11
10
|
*
|
12
11
|
* DateTime Patterns:
|
13
|
-
*
|
12
|
+
*
|
14
13
|
* yy = 2-digit year; yyyy = full year
|
15
|
-
*
|
14
|
+
*
|
16
15
|
* M = digit month; MM = 2-digit month
|
17
|
-
*
|
16
|
+
*
|
18
17
|
* d = digit day; dd = 2-digit day
|
19
|
-
*
|
18
|
+
*
|
20
19
|
* h = hours am/pm; hh = 2-digit hours am/pm; H = hours; HH = 2-digit hours
|
21
|
-
*
|
20
|
+
*
|
22
21
|
* m = minutes; mm = 2-digit minutes; aaa = AM/PM
|
23
|
-
*
|
22
|
+
*
|
24
23
|
* s = seconds; ss = 2-digit seconds
|
25
|
-
*
|
24
|
+
*
|
26
25
|
* S = miliseconds
|
27
26
|
*/
|
28
27
|
export default class Timestamp extends Plugin {
|
@@ -33,23 +32,21 @@ export default class Timestamp extends Plugin {
|
|
33
32
|
|
34
33
|
editor.ui.componentFactory.add('timestamp', locale => {
|
35
34
|
const buttonView = new ButtonView( locale );
|
36
|
-
|
35
|
+
const command = editor.commands.get('timestamp');
|
37
36
|
buttonView.set( {
|
38
37
|
label: t('Timestamp'),
|
39
38
|
icon: timestampIcon,
|
40
|
-
withText:
|
39
|
+
withText: false,
|
41
40
|
tooltip: true
|
42
|
-
}
|
41
|
+
});
|
42
|
+
buttonView.bind('isEnabled').to( command);
|
43
43
|
|
44
44
|
buttonView.on('execute', () => {
|
45
|
-
|
46
|
-
const attributes = toMap( editor.model.document.selection.getAttributes() );
|
47
|
-
const timestamp = writer.createText(formatDate(new Date(), datetimeformat), attributes);
|
48
|
-
editor.model.insertContent(timestamp, editor.model.document.selection );
|
49
|
-
} );
|
45
|
+
command.execute({ datetimeformat: datetimeformat })
|
50
46
|
} );
|
51
|
-
|
52
47
|
return buttonView;
|
53
48
|
} );
|
49
|
+
|
50
|
+
editor.commands.add('timestamp', new TimestampCommand(editor));
|
54
51
|
}
|
55
52
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Command } from '@ckeditor/ckeditor5-core';
|
2
|
+
import { formatDate } from '../common/qmsCKEditorUtil';
|
3
|
+
import { toMap } from '@ckeditor/ckeditor5-utils';
|
4
|
+
|
5
|
+
export default class TimestampCommand extends Command {
|
6
|
+
|
7
|
+
execute(options) {
|
8
|
+
const editor = this.editor;
|
9
|
+
const model = editor.model;
|
10
|
+
model.change( writer => {
|
11
|
+
const attributes = toMap(editor.model.document.selection.getAttributes());
|
12
|
+
const timestamp = writer.createText(formatDate(new Date(), options.datetimeformat), attributes);
|
13
|
+
model.insertContent(timestamp, editor.model.document.selection );
|
14
|
+
});
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|