jodit 3.23.3 → 3.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +4 -4
  2. package/build/jodit.css +8 -3
  3. package/build/jodit.es2018.css +7 -2
  4. package/build/jodit.es2018.en.css +7 -2
  5. package/build/jodit.es2018.en.js +8384 -7869
  6. package/build/jodit.es2018.en.min.css +1 -1
  7. package/build/jodit.es2018.en.min.js +1 -1
  8. package/build/jodit.es2018.js +8384 -7869
  9. package/build/jodit.es2018.min.css +1 -1
  10. package/build/jodit.es2018.min.js +1 -1
  11. package/build/jodit.js +2954 -2414
  12. package/build/jodit.min.css +2 -2
  13. package/build/jodit.min.js +1 -1
  14. package/build/plugins/debug/debug.es2018.en.js +8 -8
  15. package/build/plugins/debug/debug.es2018.en.min.js +1 -1
  16. package/build/plugins/debug/debug.es2018.js +8 -8
  17. package/build/plugins/debug/debug.es2018.min.js +1 -1
  18. package/build/plugins/debug/debug.js +8 -8
  19. package/build/plugins/debug/debug.min.js +1 -1
  20. package/build/plugins/speech-recognize/speech-recognize.css +1 -1
  21. package/build/plugins/speech-recognize/speech-recognize.es2018.css +1 -1
  22. package/build/plugins/speech-recognize/speech-recognize.es2018.en.css +1 -1
  23. package/build/plugins/speech-recognize/speech-recognize.es2018.en.js +38 -38
  24. package/build/plugins/speech-recognize/speech-recognize.es2018.en.min.js +1 -1
  25. package/build/plugins/speech-recognize/speech-recognize.es2018.js +38 -38
  26. package/build/plugins/speech-recognize/speech-recognize.es2018.min.js +1 -1
  27. package/build/plugins/speech-recognize/speech-recognize.js +30 -30
  28. package/build/plugins/speech-recognize/speech-recognize.min.js +1 -1
  29. package/build/vdom.css +12 -1
  30. package/build/vdom.js +1445 -41
  31. package/package.json +23 -23
  32. package/src/core/constants.ts +10 -8
  33. package/src/core/dom/dom.test.js +25 -0
  34. package/src/core/dom/dom.ts +90 -41
  35. package/src/core/helpers/checker/has-browser-color-picker.ts +2 -2
  36. package/src/core/helpers/checker/index.ts +1 -0
  37. package/src/core/helpers/checker/is-boolean.ts +1 -1
  38. package/src/core/helpers/checker/is-marker.ts +20 -0
  39. package/src/core/helpers/normalize/normalize-css-value.ts +19 -0
  40. package/src/core/helpers/normalize/normalize-node.ts +2 -2
  41. package/src/core/helpers/size/position.test.js +198 -187
  42. package/src/core/helpers/utils/css.ts +7 -14
  43. package/src/core/plugin/plugin.ts +1 -1
  44. package/src/core/selection/interface.ts +24 -0
  45. package/src/core/selection/select.ts +69 -29
  46. package/src/core/selection/selection.test.js +5 -17
  47. package/src/core/selection/style/api/extract.ts +6 -7
  48. package/src/core/selection/style/api/finite-state-machine.ts +40 -35
  49. package/src/core/selection/style/api/get-suit-child.ts +3 -4
  50. package/src/core/selection/style/api/get-suit-parent.ts +3 -4
  51. package/src/core/selection/style/api/{element-has-same-style.ts → has-same-style.ts} +25 -6
  52. package/src/core/selection/style/api/index.ts +6 -6
  53. package/src/core/selection/style/api/is-inside-invisible-element.ts +1 -1
  54. package/src/core/selection/style/api/is-normal-node.ts +3 -3
  55. package/src/core/selection/style/api/is-same-attributes.ts +56 -0
  56. package/src/core/selection/style/api/is-suit-element.ts +22 -12
  57. package/src/core/selection/style/api/list/toggle-ordered-list.ts +100 -0
  58. package/src/core/selection/style/api/list/wrap-list.ts +71 -0
  59. package/src/core/selection/style/api/toggle-attributes.ts +251 -0
  60. package/src/core/selection/style/api/unwrap-children.ts +10 -8
  61. package/src/core/selection/style/api/wrap-unwrapped-text.ts +7 -8
  62. package/src/core/selection/style/api/{wrap-and-commit-style.ts → wrap.ts} +8 -11
  63. package/src/core/selection/style/apply-style.ts +32 -181
  64. package/src/core/selection/style/commit-style.ts +79 -4
  65. package/src/core/selection/style/style.test.js +457 -128
  66. package/src/core/selection/style/transactions.ts +256 -0
  67. package/src/core/ui/button/tooltip/tooltip.test.js +95 -76
  68. package/src/core/ui/popup/popup.test.js +158 -153
  69. package/src/{plugins/backspace/interface.d.ts → core/vdom/on-demand.ts} +7 -5
  70. package/src/core/vdom/render/index.ts +2 -4
  71. package/src/core/vdom/render/patcher.ts +14 -0
  72. package/src/core/vdom/v-dom-jodit.less +17 -0
  73. package/src/core/vdom/v-dom-jodit.ts +102 -3
  74. package/src/core/view/view.ts +2 -2
  75. package/src/index.ts +2 -0
  76. package/src/jodit.ts +5 -1
  77. package/src/langs/i18n.test.js +221 -216
  78. package/src/modules/dialog/dialog.less +9 -1
  79. package/src/modules/dialog/dialog.ts +25 -16
  80. package/src/modules/file-browser/data-provider.ts +44 -12
  81. package/src/modules/file-browser/file-browser.test.js +1019 -958
  82. package/src/modules/file-browser/file-browser.ts +0 -1
  83. package/src/modules/messages/messages.ts +3 -8
  84. package/src/plugins/backspace/backspace.test.js +2 -9
  85. package/src/plugins/backspace/backspace.ts +5 -0
  86. package/src/plugins/backspace/cases/check-join-neighbors.ts +7 -1
  87. package/src/plugins/backspace/cases/check-join-two-lists.ts +2 -1
  88. package/src/plugins/backspace/helpers.ts +9 -1
  89. package/src/plugins/backspace/interface.ts +31 -0
  90. package/src/plugins/clean-html/helpers/visitor/filters/fill-empty-paragraph.ts +2 -1
  91. package/src/plugins/color/color.test.js +122 -119
  92. package/src/plugins/enter/enter.test.js +18 -5
  93. package/src/plugins/enter/enter.ts +9 -5
  94. package/src/plugins/enter/interface.ts +41 -0
  95. package/src/plugins/font/config.ts +8 -8
  96. package/src/plugins/font/font.test.js +18 -23
  97. package/src/plugins/hotkeys/hotkeys.test.js +35 -47
  98. package/src/plugins/iframe/iframe.test.js +206 -195
  99. package/src/plugins/image/image.ts +1 -1
  100. package/src/plugins/image-properties/config.ts +22 -0
  101. package/src/plugins/image-properties/image-properties.test.js +174 -93
  102. package/src/plugins/image-properties/templates/position-tab.ts +22 -1
  103. package/src/plugins/indent/indent.test.js +2 -8
  104. package/src/plugins/link/link.test.js +19 -0
  105. package/src/plugins/link/link.ts +25 -15
  106. package/src/plugins/placeholder/placeholder.ts +8 -7
  107. package/src/plugins/size/size.test.js +239 -225
  108. package/src/plugins/tab/cases/on-tab-inside-li.ts +131 -22
  109. package/src/plugins/tab/tab.test.js +95 -11
  110. package/src/plugins/tab/tab.ts +22 -2
  111. package/src/plugins/wrap-nodes/config.ts +11 -0
  112. package/src/plugins/wrap-nodes/wrap-nodes.ts +0 -1
  113. package/src/types/events.d.ts +4 -0
  114. package/src/types/file-browser.d.ts +17 -10
  115. package/src/types/select.d.ts +6 -1
  116. package/src/types/style.d.ts +72 -5
  117. package/src/types/uploader.d.ts +14 -0
  118. package/src/types/view.d.ts +2 -2
  119. package/types/core/async/async.d.ts +1 -1
  120. package/types/core/constants.d.ts +3 -3
  121. package/types/core/dom/dom.d.ts +6 -3
  122. package/types/core/helpers/checker/index.d.ts +1 -0
  123. package/types/core/helpers/checker/is-boolean.d.ts +1 -1
  124. package/types/core/helpers/checker/is-marker.d.ts +10 -0
  125. package/types/core/helpers/html/safe-html.d.ts +1 -1
  126. package/types/core/helpers/normalize/normalize-css-value.d.ts +2 -0
  127. package/types/core/helpers/normalize/normalize-node.d.ts +1 -1
  128. package/types/core/helpers/utils/append-script.d.ts +1 -1
  129. package/types/core/selection/interface.d.ts +19 -0
  130. package/types/core/selection/select.d.ts +22 -5
  131. package/types/core/selection/style/api/finite-state-machine.d.ts +10 -9
  132. package/types/core/selection/style/api/get-suit-child.d.ts +2 -3
  133. package/types/core/selection/style/api/get-suit-parent.d.ts +2 -3
  134. package/types/core/selection/style/api/{element-has-same-style.d.ts → has-same-style.d.ts} +2 -2
  135. package/types/core/selection/style/api/index.d.ts +6 -6
  136. package/types/core/selection/style/api/is-same-attributes.d.ts +12 -0
  137. package/types/core/selection/style/api/is-suit-element.d.ts +4 -4
  138. package/types/core/selection/style/api/{toggle → list}/toggle-ordered-list.d.ts +2 -3
  139. package/types/core/selection/style/api/{wrap-ordered-list.d.ts → list/wrap-list.d.ts} +2 -3
  140. package/types/core/selection/style/api/toggle-attributes.d.ts +11 -0
  141. package/types/core/selection/style/api/unwrap-children.d.ts +2 -2
  142. package/types/core/selection/style/api/wrap-unwrapped-text.d.ts +2 -3
  143. package/types/core/selection/style/api/{wrap-and-commit-style.d.ts → wrap.d.ts} +2 -3
  144. package/types/core/selection/style/apply-style.d.ts +3 -3
  145. package/types/core/selection/style/commit-style.d.ts +6 -2
  146. package/types/core/selection/style/transactions.d.ts +29 -0
  147. package/types/core/ui/popup/popup.d.ts +1 -1
  148. package/types/core/view/view.d.ts +1 -1
  149. package/types/index.d.ts +2 -0
  150. package/types/modules/file-browser/builders/elements-map.d.ts +1 -1
  151. package/types/modules/file-browser/data-provider.d.ts +5 -0
  152. package/types/modules/messages/messages.d.ts +2 -1
  153. package/types/plugins/backspace/helpers.d.ts +5 -1
  154. package/types/plugins/backspace/interface.d.ts +21 -0
  155. package/types/plugins/enter/enter.d.ts +2 -0
  156. package/types/plugins/enter/interface.d.ts +32 -0
  157. package/types/plugins/image-properties/config.d.ts +19 -0
  158. package/types/plugins/link/link.d.ts +1 -1
  159. package/types/plugins/paste/interface.d.ts +2 -2
  160. package/types/plugins/tab/cases/on-tab-inside-li.d.ts +1 -1
  161. package/types/plugins/wrap-nodes/config.d.ts +10 -0
  162. package/types/types/events.d.ts +4 -0
  163. package/types/types/file-browser.d.ts +17 -10
  164. package/types/types/select.d.ts +6 -1
  165. package/types/types/storage.d.ts +1 -1
  166. package/types/types/style.d.ts +72 -5
  167. package/types/types/uploader.d.ts +14 -0
  168. package/types/types/view.d.ts +2 -2
  169. package/vdom.html +20 -0
  170. package/src/core/selection/style/api/toggle/toggle-css.ts +0 -136
  171. package/src/core/selection/style/api/toggle/toggle-ordered-list.ts +0 -54
  172. package/src/core/selection/style/api/toggle-commit-styles.ts +0 -35
  173. package/src/core/selection/style/api/wrap-ordered-list.ts +0 -42
  174. package/types/core/selection/style/api/toggle/toggle-css.d.ts +0 -12
  175. package/types/core/selection/style/api/toggle-commit-styles.d.ts +0 -13
@@ -11,6 +11,16 @@ declare module '../../config' {
11
11
  interface Config {
12
12
  wrapNodes: {
13
13
  exclude: HTMLTagNames[];
14
+ /**
15
+ * If the editor is empty then insert an empty paragraph into it
16
+ * @example
17
+ * ```javascript
18
+ * Jodit.make('#editor', {
19
+ * wrapNodes: {
20
+ * emptyBlockAfterInit: true
21
+ * }
22
+ * });
23
+ */
14
24
  emptyBlockAfterInit: boolean;
15
25
  };
16
26
  }
@@ -174,3 +174,7 @@ interface IEventEmitter extends IDestructible {
174
174
  export interface IObservable {
175
175
  on(event: string | string[], callback: CallbackFunction): this;
176
176
  }
177
+
178
+ interface IEventEmitter {
179
+ on(object: Document, event: 'selectionchange', callback: CallbackFunction): this;
180
+ }
@@ -27,7 +27,7 @@ import type { IDlgs } from './traits';
27
27
  * The module creates a web browser dialog box. In a Web browser ,you can select an image, remove, drag it. Upload new
28
28
  */
29
29
  export interface ISourceFile {
30
- type: 'folder' | 'image' | 'file';
30
+ type: 'image' | 'file' | 'folder';
31
31
  file?: string;
32
32
  fileIsAbsolute?: boolean;
33
33
  name?: string;
@@ -210,6 +210,15 @@ export interface IFileBrowserDataProvider extends IDestructible {
210
210
  mods?: IFileBrowserDataProviderItemsMods
211
211
  ): Promise<IFileBrowserItem[]>;
212
212
 
213
+ itemsEx(
214
+ path: string,
215
+ source: string,
216
+ mods?: IFileBrowserDataProviderItemsMods
217
+ ): Promise<{
218
+ items: IFileBrowserItem[];
219
+ loadedTotal: number;
220
+ }>;
221
+
213
222
  tree(path: string, source: string): Promise<ISourcesFiles>;
214
223
 
215
224
  createFolder(name: string, path: string, source: string): Promise<boolean>;
@@ -286,11 +295,6 @@ export interface IFileBrowser<
286
295
  status(message: string | Error, success?: boolean): void;
287
296
  }
288
297
 
289
- export interface IFileBrowserMessage {
290
- message: string;
291
- type: 'success' | 'error';
292
- }
293
-
294
298
  export interface IFileBrowserState {
295
299
  currentPath: string;
296
300
  currentSource: string;
@@ -304,8 +308,6 @@ export interface IFileBrowserState {
304
308
  elements: IFileBrowserItem[];
305
309
  activeElements: IFileBrowserItem[];
306
310
  sources: ISourcesFiles;
307
-
308
- messages: IFileBrowserMessage[];
309
311
  }
310
312
 
311
313
  export interface IFileBrowserFolder {
@@ -319,12 +321,17 @@ export interface IFileBrowserItemElement extends ISourceFile {
319
321
  sourceName: string;
320
322
  }
321
323
 
322
- export interface IFileBrowserItemWrapper extends IFileBrowserItemElement {
324
+ export interface IUniqueHash {
325
+ uniqueHashKey: string;
326
+ }
327
+
328
+ export interface IFileBrowserItemWrapper
329
+ extends IFileBrowserItemElement,
330
+ IUniqueHash {
323
331
  path: string;
324
332
  fileURL: string;
325
333
  imageURL: string;
326
334
  time: string;
327
- uniqueHashKey: string;
328
335
  }
329
336
 
330
337
  export type IFileBrowserItem = IFileBrowserItemWrapper &
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import type { CanUndef, HTMLTagNames, IDictionary, Nullable } from './types';
12
- import type { IStyle } from './style';
12
+ import type { IStyle, IStyleOptions } from './style';
13
13
 
14
14
  export interface MarkerInfo {
15
15
  startId: string;
@@ -80,15 +80,20 @@ export interface ISelect {
80
80
  tagOrCallback: HTMLTagNames | ((font: HTMLElement) => any)
81
81
  ): HTMLElement[];
82
82
 
83
+ /** @deprecated Instead use commitStyle */
83
84
  applyStyle(
84
85
  style: CanUndef<IStyle>,
85
86
  options?: {
86
87
  element?: HTMLTagNames;
88
+ /** @deprecated Instead use attributes.class*/
87
89
  className?: string;
90
+ attributes?: IDictionary<string | number>;
88
91
  defaultTag?: HTMLTagNames;
89
92
  }
90
93
  ): void;
91
94
 
95
+ commitStyle(options: IStyleOptions): void;
96
+
92
97
  eachSelection(callback: (current: Node) => void): void;
93
98
  splitSelection(currentBox: HTMLElement): Nullable<Element>;
94
99
  }
@@ -6,7 +6,7 @@
6
6
  /**
7
7
  * @module types
8
8
  */
9
- export declare type StorageValueType = string | number | boolean | object | StorageValueType[];
9
+ export type StorageValueType = string | number | boolean | object | StorageValueType[];
10
10
  export interface IStorage<T = StorageValueType> {
11
11
  set(key: string, value: T): IStorage<T>;
12
12
  delete(key: string): IStorage<T>;
@@ -8,17 +8,84 @@
8
8
  * @module types
9
9
  */
10
10
 
11
- import type { CanUndef, HTMLTagNames, IDictionary } from './types';
11
+ import type { HTMLTagNames, IDictionary } from './types';
12
+ import { IJodit } from './jodit';
12
13
 
13
14
  export type StyleValue = number | string | null | undefined;
14
15
 
15
16
  export type IStyle = IDictionary<StyleValue>;
17
+ export type IAttributes = {
18
+ [K in string]: IStyle | string | number | boolean | null;
19
+ };
16
20
 
17
21
  export interface IStyleOptions {
18
- style: CanUndef<IStyle>;
19
- element: CanUndef<HTMLTagNames>;
20
- className: CanUndef<string>;
21
- defaultTag: CanUndef<HTMLTagNames>;
22
+ element?: HTMLTagNames;
23
+ attributes?: IAttributes;
24
+ defaultTag?: HTMLTagNames;
25
+ hooks?: {
26
+ beforeWrapList?(
27
+ mode: CommitMode,
28
+ li: HTMLElement,
29
+ style: ICommitStyle
30
+ ): void;
31
+ afterWrapList?(
32
+ mode: CommitMode,
33
+ li: HTMLElement,
34
+ style: ICommitStyle
35
+ ): void;
36
+ beforeToggleList?(
37
+ mode: CommitMode,
38
+ list: HTMLElement,
39
+ style: ICommitStyle
40
+ ): void | CommitMode;
41
+ beforeUnwrapList?(
42
+ mode: 'unwrap',
43
+ list: HTMLElement,
44
+ style: ICommitStyle
45
+ ): void | CommitMode;
46
+ afterToggleList?(
47
+ mode: CommitMode,
48
+ list: HTMLElement,
49
+ style: ICommitStyle
50
+ ): void;
51
+ afterToggleAttribute?(
52
+ mode: CommitMode,
53
+ elm: HTMLElement,
54
+ key: string,
55
+ value?: string | number | null | boolean
56
+ ): void;
57
+ };
58
+ /** @deprecated */
59
+ style?: IStyle;
60
+ /** @deprecated */
61
+ className?: string;
62
+ }
63
+
64
+ export interface ICommitStyle {
65
+ isApplied(elm: HTMLElement, key: string): boolean;
66
+
67
+ setApplied(elm: HTMLElement, key: string): void;
68
+
69
+ readonly elementIsList: boolean;
70
+
71
+ readonly element: HTMLTagNames;
72
+
73
+ /**
74
+ * New element is block
75
+ */
76
+ readonly elementIsBlock: boolean;
77
+
78
+ /**
79
+ * The commit applies the tag change
80
+ */
81
+ readonly isElementCommit: boolean;
82
+
83
+ readonly defaultTag: HTMLTagNames;
84
+
85
+ readonly elementIsDefault: Boolean;
86
+ readonly options: IStyleOptions;
87
+
88
+ apply(jodit: IJodit): void;
22
89
  }
23
90
 
24
91
  export type CommitMode =
@@ -40,6 +40,20 @@ export interface IUploaderOptions<T> {
40
40
  | string
41
41
  | ((request: FormData | IDictionary<string> | string) => string);
42
42
  insertImageAsBase64URI: boolean;
43
+
44
+ /**
45
+ * List of extensions for images
46
+ * @default ['jpg', 'png', 'jpeg', 'gif']
47
+ * @example
48
+ * ```javascript
49
+ * Jodit.make('#editor', {
50
+ * uploader: {
51
+ * insertImageAsBase64URI: true,
52
+ * imagesExtensions: ['jpg', 'png', 'jpeg', 'gif', 'svg', 'webp']
53
+ * }
54
+ * });
55
+ * ```
56
+ */
43
57
  imagesExtensions: string[];
44
58
  headers?:
45
59
  | IDictionary<string>
@@ -70,7 +70,7 @@ interface IViewOptions extends ILanguageOptions, IToolbarOptions {
70
70
 
71
71
  allowTabNavigation?: boolean;
72
72
 
73
- zIndex?: number;
73
+ zIndex?: number | string;
74
74
  fullsize?: boolean;
75
75
  globalFullSize?: boolean;
76
76
 
@@ -135,7 +135,7 @@ interface IViewBased<T = IViewOptions>
135
135
  readonly components: Set<IComponent>;
136
136
  getInstance<T extends IComponent>(moduleName: string, options?: object): T;
137
137
 
138
- readonly message: IMessages;
138
+ message: IMessages;
139
139
  }
140
140
 
141
141
  interface IViewWithToolbar<T = IViewOptions> extends IViewBased<T> {
package/vdom.html ADDED
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta
6
+ name="viewport"
7
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
8
+ />
9
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
10
+ <title>Document</title>
11
+ <script src="build/vdom.js"></script>
12
+ <link rel="stylesheet" href="build/vdom.css" />
13
+ </head>
14
+ <body>
15
+ <textarea id="editor">test</textarea>
16
+ <script>
17
+ VDomJodit.make(editor);
18
+ </script>
19
+ </body>
20
+ </html>
@@ -1,136 +0,0 @@
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- import type { CommitMode, IJodit } from 'jodit/types';
8
- import type { CommitStyle } from 'jodit/core/selection/style/commit-style';
9
- import { attr } from 'jodit/core/helpers/utils';
10
- import { css } from 'jodit/core/helpers/utils/css';
11
- import { dataBind } from 'jodit/core/helpers/utils/data-bind';
12
- import { kebabCase } from 'jodit/core/helpers/string/kebab-case';
13
- import { normalizeCssValue } from 'jodit/core/helpers/normalize/normalize-css-value';
14
- import { size } from 'jodit/core/helpers/size/object-size';
15
- import { Dom } from 'jodit/core/dom';
16
- import { CHANGE, UNSET, UNWRAP } from 'jodit/core/selection/style/commit-style';
17
- import { getContainer } from 'jodit/core/global';
18
-
19
- /**
20
- * Toggles css and classname
21
- * @private
22
- */
23
- export function toggleCSS(
24
- commitStyle: CommitStyle,
25
- elm: HTMLElement,
26
- jodit: IJodit,
27
- mode: CommitMode,
28
- dry: boolean = false
29
- ): CommitMode {
30
- const { style, className } = commitStyle.options;
31
-
32
- if (style && size(style) > 0) {
33
- Object.keys(style).forEach((rule: string) => {
34
- const inlineValue = elm.style.getPropertyValue(kebabCase(rule));
35
-
36
- if (inlineValue === '' && style[rule] == null) {
37
- return;
38
- }
39
-
40
- if (
41
- getNativeCSSValue(jodit, elm, rule) ===
42
- normalizeCssValue(rule, style[rule] as string)
43
- ) {
44
- !dry && css(elm, rule, null);
45
- mode = UNSET;
46
- mode = removeExtraStyleAttribute(commitStyle, elm, mode);
47
- return;
48
- }
49
-
50
- mode = CHANGE;
51
- !dry && css(elm, rule, style[rule]);
52
- if (!dry) {
53
- mode = removeExtraStyleAttribute(commitStyle, elm, mode);
54
- }
55
- });
56
- }
57
-
58
- if (className) {
59
- if (elm.classList.contains(className)) {
60
- elm.classList.remove(className);
61
- mode = UNSET;
62
- } else {
63
- elm.classList.add(className);
64
- mode = CHANGE;
65
- }
66
- }
67
-
68
- return mode;
69
- }
70
-
71
- /**
72
- * If the element has an empty style attribute, it removes the attribute,
73
- * and if it is default, it removes the element itself
74
- */
75
- function removeExtraStyleAttribute(
76
- commitStyle: CommitStyle,
77
- elm: HTMLElement,
78
- mode: CommitMode
79
- ): CommitMode {
80
- if (!attr(elm, 'style')) {
81
- attr(elm, 'style', null);
82
-
83
- if (elm.tagName.toLowerCase() === commitStyle.defaultTag) {
84
- Dom.unwrap(elm);
85
- mode = UNWRAP;
86
- }
87
- }
88
-
89
- return mode;
90
- }
91
-
92
- /**
93
- * Creates an iframe into which elements will be inserted to test their default styles in the browser
94
- */
95
- function getShadowRoot(jodit: IJodit): HTMLElement {
96
- if (dataBind(jodit, 'shadowRoot') !== undefined) {
97
- return dataBind(jodit, 'shadowRoot');
98
- }
99
-
100
- const container = getContainer(jodit);
101
-
102
- const iframe = document.createElement('iframe');
103
- css(iframe, {
104
- width: 0,
105
- height: 0,
106
- position: 'absolute',
107
- border: 0
108
- });
109
-
110
- iframe.src = 'about:blank';
111
- container.appendChild(iframe);
112
-
113
- const doc = iframe.contentWindow?.document;
114
-
115
- const shadowRoot = !doc ? jodit.od.body : doc.body;
116
- dataBind(jodit, 'shadowRoot', shadowRoot);
117
-
118
- return shadowRoot;
119
- }
120
-
121
- /**
122
- * `strong -> fontWeight 700`
123
- */
124
- function getNativeCSSValue(
125
- jodit: IJodit,
126
- elm: HTMLElement,
127
- key: string
128
- ): ReturnType<typeof css> {
129
- const newElm = jodit.create.element(elm.tagName.toLowerCase());
130
- newElm.style.cssText = elm.style.cssText;
131
- const root = getShadowRoot(jodit);
132
- root.appendChild(newElm);
133
- const result = css(newElm, key);
134
- Dom.safeRemove(newElm);
135
- return result;
136
- }
@@ -1,54 +0,0 @@
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- import type { IJodit, CommitMode } from 'jodit/types';
8
- import type { CommitStyle } from '../../commit-style';
9
- import { Dom } from 'jodit/core/dom';
10
- import { extractSelectedPart } from '../extract';
11
- import { CHANGE, INITIAL, REPLACE } from '../../commit-style';
12
- import { toggleCSS } from './toggle-css';
13
-
14
- /**
15
- * Replaces `ul->ol` or `ol->ul`, apply styles to the list, or remove a list item from it
16
- * @private
17
- */
18
- export function toggleOrderedList(
19
- style: CommitStyle,
20
- li: HTMLElement,
21
- jodit: IJodit,
22
- mode: CommitMode
23
- ): CommitMode {
24
- if (!li) {
25
- return mode;
26
- }
27
-
28
- const list = li.parentElement;
29
-
30
- if (!list) {
31
- return mode;
32
- }
33
-
34
- // ul => ol, ol => ul
35
- if (list.tagName.toLowerCase() !== style.element) {
36
- const newList = Dom.replace<HTMLElement>(
37
- list,
38
- style.element,
39
- jodit.createInside
40
- );
41
- toggleCSS(style, newList, jodit, mode);
42
- return REPLACE;
43
- }
44
-
45
- if (toggleCSS(style, li.parentElement, jodit, INITIAL, true) === CHANGE) {
46
- return toggleCSS(style, li.parentElement, jodit, mode);
47
- }
48
-
49
- extractSelectedPart(list, li, jodit);
50
- Dom.unwrap(li.parentElement);
51
- Dom.replace(li, jodit.o.enter, jodit.createInside);
52
-
53
- return mode;
54
- }
@@ -1,35 +0,0 @@
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- import type { IJodit } from 'jodit/types';
8
- import type { CommitStyle } from '../commit-style';
9
- import { Dom } from 'jodit/core/dom';
10
-
11
- /**
12
- * Add or remove styles to element
13
- * @param elm - The element to switch styles
14
- * @private
15
- */
16
- export function toggleCommitStyles(
17
- commitStyle: CommitStyle,
18
- elm: HTMLElement,
19
- jodit: IJodit
20
- ): boolean {
21
- if (
22
- commitStyle.elementIsBlock ||
23
- (Dom.isTag(elm, commitStyle.element) && !commitStyle.elementIsDefault)
24
- ) {
25
- if (elm.getAttribute('style')) {
26
- Dom.replace(elm, commitStyle.defaultTag, jodit.createInside, true);
27
- } else {
28
- Dom.unwrap(elm);
29
- }
30
-
31
- return true;
32
- }
33
-
34
- return false;
35
- }
@@ -1,42 +0,0 @@
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
-
7
- import type { IJodit } from 'jodit/types';
8
- import { Dom } from 'jodit/core/dom';
9
- import type { CommitStyle } from '../commit-style';
10
-
11
- /**
12
- * Replaces non-leaf items with leaf items and either creates a new list or
13
- * adds a new item to the nearest old list
14
- * @private
15
- */
16
- export function wrapOrderedList(
17
- commitStyle: CommitStyle,
18
- wrapper: HTMLElement,
19
- jodit: IJodit
20
- ): HTMLElement {
21
- const newWrapper = Dom.replace<HTMLElement>(
22
- wrapper,
23
- 'li',
24
- jodit.createInside
25
- );
26
-
27
- let list =
28
- newWrapper.previousElementSibling || newWrapper.nextElementSibling;
29
-
30
- if (!Dom.isTag(list, ['ul', 'ol'])) {
31
- list = jodit.createInside.element(commitStyle.element);
32
- Dom.before(newWrapper, list);
33
- }
34
-
35
- if (newWrapper.previousElementSibling === list) {
36
- Dom.append(list, newWrapper);
37
- } else {
38
- Dom.prepend(list, newWrapper);
39
- }
40
-
41
- return <HTMLElement>list;
42
- }
@@ -1,12 +0,0 @@
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
- import type { CommitMode, IJodit } from '../../../../../types';
7
- import type { CommitStyle } from '../../../../../core/selection/style/commit-style';
8
- /**
9
- * Toggles css and classname
10
- * @private
11
- */
12
- export declare function toggleCSS(commitStyle: CommitStyle, elm: HTMLElement, jodit: IJodit, mode: CommitMode, dry?: boolean): CommitMode;
@@ -1,13 +0,0 @@
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-2022 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
- */
6
- import type { IJodit } from '../../../../types';
7
- import type { CommitStyle } from '../commit-style';
8
- /**
9
- * Add or remove styles to element
10
- * @param elm - The element to switch styles
11
- * @private
12
- */
13
- export declare function toggleCommitStyles(commitStyle: CommitStyle, elm: HTMLElement, jodit: IJodit): boolean;