jodit 4.2.14 → 4.2.17

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.
Files changed (133) hide show
  1. package/CHANGELOG.md +64 -5
  2. package/es2015/jodit.css +115 -115
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +2 -2
  5. package/es2015/jodit.js +928 -823
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +2 -2
  8. package/es2015/plugins/debug/debug.js +1 -1
  9. package/es2015/plugins/debug/debug.min.js +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.js +11 -11
  12. package/es2015/plugins/speech-recognize/speech-recognize.min.js +2 -2
  13. package/es2018/jodit.css +115 -115
  14. package/es2018/jodit.fat.min.css +1 -1
  15. package/es2018/jodit.fat.min.js +2 -2
  16. package/es2018/jodit.js +928 -825
  17. package/es2018/jodit.min.css +1 -1
  18. package/es2018/jodit.min.js +2 -2
  19. package/es2018/plugins/debug/debug.js +1 -1
  20. package/es2018/plugins/debug/debug.min.js +1 -1
  21. package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
  22. package/es2018/plugins/speech-recognize/speech-recognize.js +11 -11
  23. package/es2018/plugins/speech-recognize/speech-recognize.min.js +2 -2
  24. package/es2021/jodit.css +115 -115
  25. package/es2021/jodit.fat.min.css +1 -1
  26. package/es2021/jodit.fat.min.js +2 -2
  27. package/es2021/jodit.js +922 -819
  28. package/es2021/jodit.min.css +1 -1
  29. package/es2021/jodit.min.js +2 -2
  30. package/es2021/plugins/debug/debug.js +1 -1
  31. package/es2021/plugins/debug/debug.min.js +1 -1
  32. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  33. package/es2021/plugins/speech-recognize/speech-recognize.js +11 -11
  34. package/es2021/plugins/speech-recognize/speech-recognize.min.js +2 -2
  35. package/es2021.en/jodit.css +115 -115
  36. package/es2021.en/jodit.fat.min.css +1 -1
  37. package/es2021.en/jodit.fat.min.js +2 -2
  38. package/es2021.en/jodit.js +922 -819
  39. package/es2021.en/jodit.min.css +1 -1
  40. package/es2021.en/jodit.min.js +2 -2
  41. package/es2021.en/plugins/debug/debug.js +1 -1
  42. package/es2021.en/plugins/debug/debug.min.js +1 -1
  43. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  44. package/es2021.en/plugins/speech-recognize/speech-recognize.js +11 -11
  45. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +2 -2
  46. package/es5/jodit.css +129 -129
  47. package/es5/jodit.fat.min.css +1 -1
  48. package/es5/jodit.fat.min.js +2 -2
  49. package/es5/jodit.js +950 -844
  50. package/es5/jodit.min.css +3 -3
  51. package/es5/jodit.min.js +2 -2
  52. package/es5/plugins/debug/debug.js +1 -1
  53. package/es5/plugins/debug/debug.min.js +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.js +11 -11
  56. package/es5/plugins/speech-recognize/speech-recognize.min.js +2 -2
  57. package/esm/core/constants.js +1 -1
  58. package/esm/core/helpers/utils/config-proto.js +1 -1
  59. package/esm/core/request/ajax.js +1 -1
  60. package/esm/core/selection/helpers/index.d.ts +9 -3
  61. package/esm/core/selection/helpers/index.js +48 -0
  62. package/esm/core/selection/selection.d.ts +6 -1
  63. package/esm/core/selection/selection.js +95 -117
  64. package/esm/core/ui/helpers/get-control-type.js +15 -9
  65. package/esm/core/ui/helpers/get-strong-control-types.js +1 -1
  66. package/esm/index.d.ts +6 -1
  67. package/esm/index.js +3 -2
  68. package/esm/jodit.d.ts +1 -1
  69. package/esm/jodit.js +1 -1
  70. package/esm/modules/file-browser/file-browser.js +1 -1
  71. package/esm/modules/history/history.js +1 -1
  72. package/esm/modules/image-editor/config.js +1 -1
  73. package/esm/modules/image-editor/image-editor.js +1 -1
  74. package/esm/modules/table/table.d.ts +3 -1
  75. package/esm/modules/table/table.js +38 -33
  76. package/esm/modules/toolbar/button/button.js +2 -1
  77. package/esm/modules/toolbar/button/select/select.js +2 -1
  78. package/esm/modules/uploader/helpers/send-files.js +33 -29
  79. package/esm/modules/uploader/uploader.js +1 -1
  80. package/esm/plugins/about/about.js +1 -1
  81. package/esm/plugins/add-new-line/config.js +1 -1
  82. package/esm/plugins/ai-assistant/config.js +1 -1
  83. package/esm/plugins/backspace/cases/check-remove-char.js +68 -54
  84. package/esm/plugins/bold/bold.js +1 -1
  85. package/esm/plugins/class-span/class-span.js +1 -1
  86. package/esm/plugins/clean-html/config.js +1 -1
  87. package/esm/plugins/clipboard/config.js +1 -1
  88. package/esm/plugins/color/config.js +1 -1
  89. package/esm/plugins/copy-format/copy-format.js +1 -1
  90. package/esm/plugins/drag-and-drop/drag-and-drop.d.ts +2 -0
  91. package/esm/plugins/drag-and-drop/drag-and-drop.js +43 -36
  92. package/esm/plugins/file/file.js +1 -1
  93. package/esm/plugins/font/config.js +1 -1
  94. package/esm/plugins/format-block/config.js +6 -4
  95. package/esm/plugins/fullsize/config.js +1 -1
  96. package/esm/plugins/hr/hr.js +1 -1
  97. package/esm/plugins/image/image.js +1 -1
  98. package/esm/plugins/image-properties/config.d.ts +0 -3
  99. package/esm/plugins/image-properties/config.js +3 -0
  100. package/esm/plugins/image-properties/interface.d.ts +121 -0
  101. package/esm/plugins/indent/config.js +1 -1
  102. package/esm/plugins/inline-popup/config/config.js +1 -1
  103. package/esm/plugins/justify/justify.js +10 -6
  104. package/esm/plugins/line-height/config.js +1 -1
  105. package/esm/plugins/link/config.js +1 -1
  106. package/esm/plugins/link/link.js +71 -64
  107. package/esm/plugins/mobile/config.js +1 -1
  108. package/esm/plugins/ordered-list/config.js +1 -1
  109. package/esm/plugins/paste/config.js +1 -1
  110. package/esm/plugins/print/print.js +1 -1
  111. package/esm/plugins/redo-undo/redo-undo.js +1 -1
  112. package/esm/plugins/search/config.js +1 -1
  113. package/esm/plugins/search/helpers/highlight-text-ranges.d.ts +0 -4
  114. package/esm/plugins/search/helpers/highlight-text-ranges.js +58 -49
  115. package/esm/plugins/source/config.js +1 -1
  116. package/esm/plugins/speech-recognize/config.js +1 -1
  117. package/esm/plugins/spellcheck/config.js +1 -1
  118. package/esm/plugins/symbols/config.js +1 -1
  119. package/esm/plugins/table/config.js +1 -1
  120. package/esm/plugins/table-keyboard-navigation/table-keyboard-navigation.js +35 -29
  121. package/esm/plugins/video/config.js +1 -1
  122. package/esm/types/toolbar.d.ts +1 -2
  123. package/package.json +1 -1
  124. package/types/core/selection/helpers/index.d.ts +9 -3
  125. package/types/core/selection/selection.d.ts +6 -1
  126. package/types/index.d.ts +6 -1
  127. package/types/jodit.d.ts +1 -1
  128. package/types/modules/table/table.d.ts +3 -1
  129. package/types/plugins/drag-and-drop/drag-and-drop.d.ts +2 -0
  130. package/types/plugins/image-properties/config.d.ts +0 -3
  131. package/types/plugins/image-properties/interface.d.ts +121 -0
  132. package/types/plugins/search/helpers/highlight-text-ranges.d.ts +0 -4
  133. package/types/types/toolbar.d.ts +1 -2
@@ -4,11 +4,11 @@
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
6
  import { Icon } from "../../core/ui/icon.js";
7
+ import { Config } from "../../config.js";
7
8
  import copyIcon from "./icons/copy.svg.js";
8
9
  import cutIcon from "./icons/cut.svg.js";
9
10
  import pasteIcon from "./icons/paste.svg.js";
10
11
  import selectAllIcon from "./icons/select-all.svg.js";
11
- import { Config } from "../../config.js";
12
12
  Config.prototype.controls.cut = {
13
13
  command: 'cut',
14
14
  isDisabled: (editor) => editor.s.isCollapsed(),
@@ -6,9 +6,9 @@
6
6
  import { Dom } from "../../core/dom/dom.js";
7
7
  import { css, dataBind, isJoditObject } from "../../core/helpers/index.js";
8
8
  import { Icon } from "../../core/ui/icon.js";
9
+ import { Config } from "../../config.js";
9
10
  import { ColorPickerWidget, TabsWidget } from "../../modules/widget/index.js";
10
11
  import brushIcon from "./brush.svg.js";
11
- import { Config } from "../../config.js";
12
12
  Icon.set('brush', brushIcon);
13
13
  Config.prototype.controls.brushCell = {
14
14
  isVisible: (editor) => {
@@ -7,9 +7,9 @@ import { Dom } from "../../core/dom/dom.js";
7
7
  import { extendLang, pluginSystem } from "../../core/global.js";
8
8
  import { css } from "../../core/helpers/utils/css.js";
9
9
  import { Icon } from "../../core/ui/icon.js";
10
+ import { Config } from "../../config.js";
10
11
  import copyFormatIcon from "./copy-format.svg.js";
11
12
  import * as langs from "./langs/index.js";
12
- import { Config } from "../../config.js";
13
13
  const pluginKey = 'copy-format';
14
14
  /**
15
15
  * Plug-in copy and paste formatting from one element to another
@@ -21,6 +21,8 @@ export declare class dragAndDrop extends Plugin {
21
21
  private onDrag;
22
22
  private onDragEnd;
23
23
  private onDrop;
24
+ private __getWorkFragment;
25
+ private __insertFragment;
24
26
  private getText;
25
27
  /** @override */
26
28
  beforeDestruct(): void;
@@ -107,45 +107,11 @@ export class dragAndDrop extends Plugin {
107
107
  const sel = this.j.s.sel;
108
108
  const range = this.bufferRange ||
109
109
  (sel && sel.rangeCount ? sel.getRangeAt(0) : null);
110
- let fragment = null;
111
- if (!this.draggable && range) {
112
- fragment = this.isCopyMode
113
- ? range.cloneContents()
114
- : range.extractContents();
115
- }
116
- else if (this.draggable) {
117
- if (this.isCopyMode) {
118
- const [tagName, field] = attr(this.draggable, '-is-file') === '1'
119
- ? ['a', 'href']
120
- : ['img', 'src'];
121
- fragment = this.j.createInside.element(tagName);
122
- fragment.setAttribute(field, attr(this.draggable, 'data-src') ||
123
- attr(this.draggable, 'src') ||
124
- '');
125
- if (tagName === 'a') {
126
- fragment.textContent = attr(fragment, field) || '';
127
- }
128
- }
129
- else {
130
- fragment = dataBind(this.draggable, 'target');
131
- }
132
- }
133
- else if (this.getText(event)) {
134
- fragment = this.j.createInside.fromHTML(this.getText(event));
135
- }
110
+ const fragment = this.__getWorkFragment(range, event);
136
111
  sel && sel.removeAllRanges();
137
112
  this.j.s.insertCursorAtPoint(event.clientX, event.clientY);
138
113
  if (fragment) {
139
- this.j.s.insertNode(fragment, false, false);
140
- if (range && fragment.firstChild && fragment.lastChild) {
141
- range.setStartBefore(fragment.firstChild);
142
- range.setEndAfter(fragment.lastChild);
143
- this.j.s.selectRange(range);
144
- this.j.e.fire('synchro');
145
- }
146
- if (Dom.isTag(fragment, 'img') && this.j.events) {
147
- this.j.e.fire('afterInsertImage', fragment);
148
- }
114
+ this.__insertFragment.call(this, fragment, range);
149
115
  }
150
116
  event.preventDefault();
151
117
  event.stopPropagation();
@@ -153,6 +119,47 @@ export class dragAndDrop extends Plugin {
153
119
  this.isFragmentFromEditor = false;
154
120
  this.removeDragListeners();
155
121
  }
122
+ __getWorkFragment(range, event) {
123
+ let fragment = null;
124
+ if (!this.draggable && range) {
125
+ fragment = this.isCopyMode
126
+ ? range.cloneContents()
127
+ : range.extractContents();
128
+ }
129
+ else if (this.draggable) {
130
+ if (this.isCopyMode) {
131
+ const [tagName, field] = attr(this.draggable, '-is-file') === '1'
132
+ ? ['a', 'href']
133
+ : ['img', 'src'];
134
+ fragment = this.j.createInside.element(tagName);
135
+ fragment.setAttribute(field, attr(this.draggable, 'data-src') ||
136
+ attr(this.draggable, 'src') ||
137
+ '');
138
+ if (tagName === 'a') {
139
+ fragment.textContent = attr(fragment, field) || '';
140
+ }
141
+ }
142
+ else {
143
+ fragment = dataBind(this.draggable, 'target');
144
+ }
145
+ }
146
+ else if (this.getText(event)) {
147
+ fragment = this.j.createInside.fromHTML(this.getText(event));
148
+ }
149
+ return fragment;
150
+ }
151
+ __insertFragment(fragment, range) {
152
+ this.j.s.insertNode(fragment, false, false);
153
+ if (range && fragment.firstChild && fragment.lastChild) {
154
+ range.setStartBefore(fragment.firstChild);
155
+ range.setEndAfter(fragment.lastChild);
156
+ this.j.s.selectRange(range);
157
+ this.j.e.fire('synchro');
158
+ }
159
+ if (Dom.isTag(fragment, 'img') && this.j.events) {
160
+ this.j.e.fire('afterInsertImage', fragment);
161
+ }
162
+ }
156
163
  /** @override */
157
164
  beforeDestruct() {
158
165
  this.onDragEnd();
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { Dom } from "../../core/dom/dom.js";
7
7
  import { pluginSystem } from "../../core/global.js";
8
- import { FileSelectorWidget } from "../../modules/widget/index.js";
9
8
  import { Config } from "../../config.js";
9
+ import { FileSelectorWidget } from "../../modules/widget/index.js";
10
10
  Config.prototype.controls.file = {
11
11
  popup: (editor, current, close) => {
12
12
  const insert = (url, title = '') => {
@@ -7,9 +7,9 @@ import { Dom } from "../../core/dom/index.js";
7
7
  import { trimChars } from "../../core/helpers/string/trim.js";
8
8
  import { css } from "../../core/helpers/utils/css.js";
9
9
  import { Icon } from "../../core/ui/icon.js";
10
+ import { Config } from "../../config.js";
10
11
  import fontIcon from "./icons/font.svg.js";
11
12
  import fontsizeIcon from "./icons/fontsize.svg.js";
12
- import { Config } from "../../config.js";
13
13
  /**
14
14
  * Default font-size points
15
15
  */
@@ -3,10 +3,11 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- import { Dom } from "../../core/dom/index.js";
6
+ import { Dom } from "../../core/dom/dom.js";
7
+ import { isPlainObject } from "../../core/helpers/checker/is-plain-object.js";
7
8
  import { Icon } from "../../core/ui/icon.js";
8
- import paragraphIcon from "./paragraph.svg.js";
9
9
  import { Config } from "../../config.js";
10
+ import paragraphIcon from "./paragraph.svg.js";
10
11
  Icon.set('paragraph', paragraphIcon);
11
12
  Config.prototype.controls.paragraph = {
12
13
  command: 'formatBlock',
@@ -21,7 +22,7 @@ Config.prototype.controls.paragraph = {
21
22
  return false;
22
23
  }
23
24
  const currentValue = button.state.value, list = control.list;
24
- if (list && list[currentValue.toString()]) {
25
+ if (isPlainObject(list) && list[currentValue.toString()]) {
25
26
  if (editor.o.textIcons) {
26
27
  button.state.text = list[currentValue.toString()].toString();
27
28
  }
@@ -45,7 +46,8 @@ Config.prototype.controls.paragraph = {
45
46
  },
46
47
  isActive: (editor, button) => {
47
48
  return (button.state.value !== editor.o.enter &&
48
- Boolean(button.control.list?.[button.state.value]));
49
+ isPlainObject(button.control.list) &&
50
+ Boolean(button.control.list[button.state.value]));
49
51
  },
50
52
  childTemplate: (e, key, value) => `<${key} style="margin:0;padding:0"><span>${e.i18n(value)}</span></${key}>`,
51
53
  tooltip: 'Insert format block'
@@ -5,9 +5,9 @@
5
5
  */
6
6
  import * as consts from "../../core/constants.js";
7
7
  import { Icon } from "../../core/ui/icon.js";
8
+ import { Config } from "../../config.js";
8
9
  import fullsizeIcon from "./icons/fullsize.svg.js";
9
10
  import shrinkIcon from "./icons/shrink.svg.js";
10
- import { Config } from "../../config.js";
11
11
  Config.prototype.fullsize = false;
12
12
  Config.prototype.globalFullSize = true;
13
13
  Icon.set('fullsize', fullsizeIcon).set('shrink', shrinkIcon);
@@ -6,8 +6,8 @@
6
6
  import { Dom } from "../../core/dom/index.js";
7
7
  import { pluginSystem } from "../../core/global.js";
8
8
  import { Icon } from "../../core/ui/icon.js";
9
- import hrIcon from "./hr.svg.js";
10
9
  import { Config } from "../../config.js";
10
+ import hrIcon from "./hr.svg.js";
11
11
  Icon.set('hr', hrIcon);
12
12
  Config.prototype.controls.hr = {
13
13
  command: 'insertHorizontalRule',
@@ -7,9 +7,9 @@ import { Dom } from "../../core/dom/index.js";
7
7
  import { pluginSystem } from "../../core/global.js";
8
8
  import { $$ } from "../../core/helpers/index.js";
9
9
  import { Icon } from "../../core/ui/icon.js";
10
+ import { Config } from "../../config.js";
10
11
  import { FileSelectorWidget } from "../../modules/widget/index.js";
11
12
  import imageIcon from "./image.svg.js";
12
- import { Config } from "../../config.js";
13
13
  Icon.set('image', imageIcon);
14
14
  Config.prototype.controls.image = {
15
15
  popup: (editor, current, close) => {
@@ -3,9 +3,6 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- /**
7
- * @module plugins/image-properties
8
- */
9
6
  import type { ImagePropertiesOptions } from "./interface";
10
7
  declare module 'jodit/config' {
11
8
  interface Config {
@@ -3,6 +3,9 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
+ /**
7
+ * @module plugins/image-properties
8
+ */
6
9
  import { Config } from "../../config.js";
7
10
  Config.prototype.image = {
8
11
  dialogWidth: 600,
@@ -0,0 +1,121 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * @module plugins/image-properties
8
+ */
9
+ import type { ImageHAlign } from "../../types";
10
+ export type EditValues = {
11
+ style: string;
12
+ imageSrc: string;
13
+ borderRadius: number;
14
+ imageTitle: string;
15
+ imageAlt: string;
16
+ imageLink: string;
17
+ imageLinkOpenInNewTab: boolean;
18
+ imageWidth: number | string;
19
+ imageHeight: number | string;
20
+ marginTop: number | string;
21
+ marginRight: number | string;
22
+ marginBottom: number | string;
23
+ marginLeft: number | string;
24
+ classes: string;
25
+ id: string;
26
+ align: ImageHAlign;
27
+ };
28
+ export interface ImagePropertiesState {
29
+ image: HTMLImageElement;
30
+ sourceImage: HTMLImageElement;
31
+ ratio: number;
32
+ sizeIsLocked: boolean;
33
+ marginIsLocked: boolean;
34
+ values: EditValues;
35
+ }
36
+ export interface ImagePropertiesAPI {
37
+ openImageEditor: () => void;
38
+ openImagePopup: (target: HTMLElement) => void;
39
+ }
40
+ export interface ImagePropertiesOptions {
41
+ dialogWidth: number;
42
+ /**
43
+ * Open editing dialog after double click on image
44
+ */
45
+ openOnDblClick: boolean;
46
+ /**
47
+ * Show edit 'src' input
48
+ */
49
+ editSrc: boolean;
50
+ /**
51
+ * Show crop/resize btn
52
+ */
53
+ useImageEditor: boolean;
54
+ /**
55
+ * Show edit 'title' input
56
+ */
57
+ editTitle: boolean;
58
+ /**
59
+ * Show edit 'alt' input
60
+ */
61
+ editAlt: boolean;
62
+ /**
63
+ * Show edit image link's options
64
+ */
65
+ editLink: boolean;
66
+ /**
67
+ * Show edit image size's inputs
68
+ */
69
+ editSize: boolean;
70
+ /**
71
+ * Show edit margin inputs
72
+ */
73
+ editMargins: boolean;
74
+ editBorderRadius: boolean;
75
+ /**
76
+ * Show edit classNames input
77
+ */
78
+ editClass: boolean;
79
+ /**
80
+ * Pre-define available classes to select from
81
+ *
82
+ * Classes can be provided as list of strings or as list of tuples
83
+ * `["classname", "human label"]`.
84
+ *
85
+ * @example
86
+ * ```javascript
87
+ * new Jodit('#editor', {
88
+ * image: {
89
+ * availableClasses: [
90
+ * "rte-image-width-50",
91
+ * ["rte-image-width-75", "75 % width"]
92
+ * ]
93
+ * }
94
+ * })
95
+ * ```
96
+ */
97
+ availableClasses: [
98
+ string,
99
+ string
100
+ ][] | string[];
101
+ /**
102
+ * Show style edit input
103
+ */
104
+ editStyle: boolean;
105
+ /**
106
+ * Show edit ID input
107
+ */
108
+ editId: boolean;
109
+ /**
110
+ * Show Alignment selector
111
+ */
112
+ editAlign: boolean;
113
+ /**
114
+ * Show preview image
115
+ */
116
+ showPreview: boolean;
117
+ /**
118
+ * Select image after close dialog
119
+ */
120
+ selectImageAfterClose: boolean;
121
+ }
@@ -5,10 +5,10 @@
5
5
  */
6
6
  import { Dom } from "../../core/dom/index.js";
7
7
  import { Icon } from "../../core/ui/icon.js";
8
+ import { Config } from "../../config.js";
8
9
  import indentIcon from "./icons/indent.svg.js";
9
10
  import outdentIcon from "./icons/outdent.svg.js";
10
11
  import { getKey } from "./helpers.js";
11
- import { Config } from "../../config.js";
12
12
  Icon.set('indent', indentIcon).set('outdent', outdentIcon);
13
13
  Config.prototype.controls.indent = {
14
14
  tooltip: 'Increase Indent'
@@ -4,12 +4,12 @@
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
6
  import { Icon } from "../../../core/ui/icon.js";
7
+ import { Config } from "../../../config.js";
7
8
  import a from "./items/a.js";
8
9
  import cells from "./items/cells.js";
9
10
  import jodit from "./items/iframe.js";
10
11
  import img from "./items/img.js";
11
12
  import toolbar from "./items/toolbar.js";
12
- import { Config } from "../../../config.js";
13
13
  import * as addcolumn from "../icons/addcolumn.svg.js";
14
14
  import * as addrow from "../icons/addrow.svg.js";
15
15
  import * as merge from "../icons/merge.svg.js";
@@ -5,11 +5,12 @@
5
5
  */
6
6
  import { Dom } from "../../core/dom/dom.js";
7
7
  import { pluginSystem } from "../../core/global.js";
8
+ import { isPlainObject } from "../../core/helpers/index.js";
8
9
  import { alignElement } from "../../core/helpers/utils/align.js";
9
10
  import { css } from "../../core/helpers/utils/css.js";
10
11
  import { Icon } from "../../core/ui/icon.js";
11
- import justifyIcon from "./justify.svg.js";
12
12
  import { Config } from "../../config.js";
13
+ import justifyIcon from "./justify.svg.js";
13
14
  Icon.set('justify', justifyIcon);
14
15
  Config.prototype.controls.align = {
15
16
  name: 'left',
@@ -24,17 +25,20 @@ Config.prototype.controls.align = {
24
25
  control.defaultValue.indexOf(currentValue) !== -1) {
25
26
  currentValue = 'left';
26
27
  }
27
- if (control.data &&
28
- control.data.currentValue !== currentValue &&
29
- control.list &&
30
- control.list[currentValue]) {
28
+ const { list, data } = control;
29
+ if (data &&
30
+ data.currentValue !== currentValue &&
31
+ list &&
32
+ (isPlainObject(list)
33
+ ? list[currentValue]
34
+ : list.includes(currentValue))) {
31
35
  if (editor.o.textIcons || control.component === 'select') {
32
36
  button.state.text = currentValue;
33
37
  }
34
38
  else {
35
39
  button.state.icon.name = currentValue;
36
40
  }
37
- control.data.currentValue = currentValue;
41
+ data.currentValue = currentValue;
38
42
  }
39
43
  }
40
44
  },
@@ -5,8 +5,8 @@
5
5
  */
6
6
  import { memorizeExec } from "../../core/helpers/index.js";
7
7
  import { Icon } from "../../core/ui/icon.js";
8
- import lineHeightIcon from "./line-height.svg.js";
9
8
  import { Config } from "../../config.js";
9
+ import lineHeightIcon from "./line-height.svg.js";
10
10
  Config.prototype.defaultLineHeight = null;
11
11
  Icon.set('line-height', lineHeightIcon);
12
12
  Config.prototype.controls.lineHeight = {
@@ -5,10 +5,10 @@
5
5
  */
6
6
  import { Dom } from "../../core/dom/dom.js";
7
7
  import { Icon } from "../../core/ui/icon.js";
8
+ import { Config } from "../../config.js";
8
9
  import linkIcon from "./icons/link.svg.js";
9
10
  import unlinkIcon from "./icons/unlink.svg.js";
10
11
  import { formTemplate } from "./template.js";
11
- import { Config } from "../../config.js";
12
12
  Config.prototype.link = {
13
13
  formTemplate,
14
14
  followOnDblClick: false,
@@ -138,35 +138,7 @@ export class link extends Plugin {
138
138
  if (link) {
139
139
  url_input.value = attr(link, 'href') || '';
140
140
  if (modeClassName) {
141
- switch (modeClassName) {
142
- case 'input':
143
- if (className_input) {
144
- className_input.value = attr(link, 'class') || '';
145
- }
146
- break;
147
- case 'select':
148
- if (className_select) {
149
- for (let i = 0; i < className_select.selectedOptions.length; i++) {
150
- const option = className_select.options.item(i);
151
- if (option) {
152
- option.selected = false;
153
- }
154
- }
155
- const classNames = attr(link, 'class') || '';
156
- classNames.split(' ').forEach(className => {
157
- if (className) {
158
- for (let i = 0; i < className_select.options.length; i++) {
159
- const option = className_select.options.item(i);
160
- if (option?.value &&
161
- option.value === className) {
162
- option.selected = true;
163
- }
164
- }
165
- }
166
- });
167
- }
168
- break;
169
- }
141
+ readClassnames(modeClassName, className_input, link, className_select);
170
142
  }
171
143
  if (openInNewTabCheckbox && target_checkbox) {
172
144
  target_checkbox.checked = attr(link, 'target') === '_blank';
@@ -228,42 +200,9 @@ export class link extends Plugin {
228
200
  }
229
201
  links.forEach(a => {
230
202
  attr(a, 'href', url_input.value);
231
- if (modeClassName && (className_input ?? className_select)) {
232
- if (modeClassName === 'input') {
233
- if (className_input.value === '' &&
234
- a.hasAttribute('class')) {
235
- attr(a, 'class', null);
236
- }
237
- if (className_input.value !== '') {
238
- attr(a, 'class', className_input.value);
239
- }
240
- }
241
- else if (modeClassName === 'select') {
242
- if (a.hasAttribute('class')) {
243
- attr(a, 'class', null);
244
- }
245
- for (let i = 0; i < className_select.selectedOptions.length; i++) {
246
- const className = className_select.selectedOptions.item(i)?.value;
247
- if (className) {
248
- a.classList.add(className);
249
- }
250
- }
251
- }
252
- }
203
+ writeClasses(modeClassName, className_input, className_select, a);
253
204
  if (!isImageContent) {
254
- let newContent = a.textContent;
255
- if (content_input.value.trim().length) {
256
- if (textWasChanged) {
257
- newContent = content_input.value;
258
- }
259
- }
260
- else {
261
- newContent = url_input.value;
262
- }
263
- const content = a.textContent;
264
- if (newContent !== content) {
265
- a.textContent = newContent;
266
- }
205
+ writeImage(a, content_input, textWasChanged, url_input);
267
206
  }
268
207
  if (openInNewTabCheckbox && target_checkbox) {
269
208
  attr(a, 'target', target_checkbox.checked ? '_blank' : null);
@@ -308,3 +247,71 @@ __decorate([
308
247
  autobind
309
248
  ], link.prototype, "__generateForm", null);
310
249
  pluginSystem.add('link', link);
250
+ function writeClasses(modeClassName, className_input, className_select, a) {
251
+ if (modeClassName && (className_input ?? className_select)) {
252
+ if (modeClassName === 'input') {
253
+ if (className_input.value === '' && a.hasAttribute('class')) {
254
+ attr(a, 'class', null);
255
+ }
256
+ if (className_input.value !== '') {
257
+ attr(a, 'class', className_input.value);
258
+ }
259
+ }
260
+ else if (modeClassName === 'select') {
261
+ if (a.hasAttribute('class')) {
262
+ attr(a, 'class', null);
263
+ }
264
+ for (let i = 0; i < className_select.selectedOptions.length; i++) {
265
+ const className = className_select.selectedOptions.item(i)?.value;
266
+ if (className) {
267
+ a.classList.add(className);
268
+ }
269
+ }
270
+ }
271
+ }
272
+ }
273
+ function readClassnames(modeClassName, className_input, link, className_select) {
274
+ switch (modeClassName) {
275
+ case 'input':
276
+ if (className_input) {
277
+ className_input.value = attr(link, 'class') || '';
278
+ }
279
+ break;
280
+ case 'select':
281
+ if (className_select) {
282
+ for (let i = 0; i < className_select.selectedOptions.length; i++) {
283
+ const option = className_select.options.item(i);
284
+ if (option) {
285
+ option.selected = false;
286
+ }
287
+ }
288
+ const classNames = attr(link, 'class') || '';
289
+ classNames.split(' ').forEach(className => {
290
+ if (className) {
291
+ for (let i = 0; i < className_select.options.length; i++) {
292
+ const option = className_select.options.item(i);
293
+ if (option?.value && option.value === className) {
294
+ option.selected = true;
295
+ }
296
+ }
297
+ }
298
+ });
299
+ }
300
+ break;
301
+ }
302
+ }
303
+ function writeImage(a, content_input, textWasChanged, url_input) {
304
+ let newContent = a.textContent;
305
+ if (content_input.value.trim().length) {
306
+ if (textWasChanged) {
307
+ newContent = content_input.value;
308
+ }
309
+ }
310
+ else {
311
+ newContent = url_input.value;
312
+ }
313
+ const content = a.textContent;
314
+ if (newContent !== content) {
315
+ a.textContent = newContent;
316
+ }
317
+ }
@@ -5,9 +5,9 @@
5
5
  */
6
6
  import * as consts from "../../core/constants.js";
7
7
  import { splitArray } from "../../core/helpers/index.js";
8
+ import { Config } from "../../config.js";
8
9
  import { ToolbarCollection } from "../../modules/toolbar/collection/collection.js";
9
10
  import { makeCollection } from "../../modules/toolbar/factory.js";
10
- import { Config } from "../../config.js";
11
11
  Config.prototype.mobileTapTimeout = 300;
12
12
  Config.prototype.toolbarAdaptive = true;
13
13
  Config.prototype.buttonsMD = [
@@ -5,9 +5,9 @@
5
5
  */
6
6
  import { dataBind } from "../../core/helpers/utils/data-bind.js";
7
7
  import { Icon } from "../../core/ui/icon.js";
8
+ import { Config } from "../../config.js";
8
9
  import olIcon from "./icons/ol.svg.js";
9
10
  import ulIcon from "./icons/ul.svg.js";
10
- import { Config } from "../../config.js";
11
11
  const memoExec = (jodit, _, { control }) => {
12
12
  const key = `button${control.command}`;
13
13
  const value = (control.args && control.args[0]) ?? dataBind(jodit, key);
@@ -4,8 +4,8 @@
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
6
  import { CLIPBOARD_ID, INSERT_AS_HTML, INSERT_AS_TEXT, INSERT_ONLY_TEXT, IS_PROD, TEXT_PLAIN } from "../../core/constants.js";
7
- import { pasteInsertHtml } from "./helpers.js";
8
7
  import { Config } from "../../config.js";
8
+ import { pasteInsertHtml } from "./helpers.js";
9
9
  Config.prototype.askBeforePasteHTML = true;
10
10
  Config.prototype.processPasteHTML = true;
11
11
  Config.prototype.scrollToPastedContent = true;