jodit 4.18.12 → 4.19.4
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/CHANGELOG.md +46 -0
- package/es2015/jodit.css +10 -1
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +18 -12
- package/es2015/jodit.js +2464 -300
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +18 -12
- package/es2015/plugins/debug/debug.css +1 -1
- package/es2015/plugins/debug/debug.js +1 -1
- package/es2015/plugins/debug/debug.min.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2018/jodit.fat.min.css +1 -1
- package/es2018/jodit.fat.min.js +18 -12
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +18 -12
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +10 -1
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +26 -19
- package/es2021/jodit.js +2426 -297
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +26 -19
- package/es2021/plugins/debug/debug.css +1 -1
- package/es2021/plugins/debug/debug.js +1 -1
- package/es2021/plugins/debug/debug.min.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021.en/jodit.css +10 -1
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +29 -22
- package/es2021.en/jodit.js +2400 -271
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +29 -22
- package/es2021.en/plugins/debug/debug.css +1 -1
- package/es2021.en/plugins/debug/debug.js +1 -1
- package/es2021.en/plugins/debug/debug.min.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es5/jodit.css +11 -2
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +2823 -360
- package/es5/jodit.min.css +3 -3
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/debug/debug.css +1 -1
- package/es5/plugins/debug/debug.js +1 -1
- package/es5/plugins/debug/debug.min.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es5/polyfills.fat.min.js +1 -1
- package/es5/polyfills.js +1 -1
- package/es5/polyfills.min.js +1 -1
- package/esm/config.d.ts +44 -1
- package/esm/config.js +2 -1
- package/esm/core/constants.js +1 -1
- package/esm/core/dom/dom.js +4 -2
- package/esm/core/event-emitter/event-emitter.js +1 -0
- package/esm/core/helpers/utils/align.d.ts +6 -1
- package/esm/core/helpers/utils/align.js +22 -12
- package/esm/core/helpers/utils/image-caption.d.ts +24 -0
- package/esm/core/helpers/utils/image-caption.js +43 -0
- package/esm/core/helpers/utils/index.d.ts +1 -0
- package/esm/core/helpers/utils/index.js +1 -0
- package/esm/core/selection/selection.d.ts +3 -0
- package/esm/core/selection/selection.js +20 -5
- package/esm/core/ui/helpers/focus-form-field.d.ts +12 -0
- package/esm/core/ui/helpers/focus-form-field.js +21 -0
- package/esm/jodit.js +18 -2
- package/esm/langs/ar.d.ts +2 -0
- package/esm/langs/ar.js +2 -0
- package/esm/langs/az.d.ts +2 -0
- package/esm/langs/az.js +2 -0
- package/esm/langs/cs_cz.d.ts +2 -0
- package/esm/langs/cs_cz.js +2 -0
- package/esm/langs/de.d.ts +2 -0
- package/esm/langs/de.js +2 -0
- package/esm/langs/es.d.ts +2 -0
- package/esm/langs/es.js +2 -0
- package/esm/langs/fa.d.ts +2 -0
- package/esm/langs/fa.js +2 -0
- package/esm/langs/fi.d.ts +2 -0
- package/esm/langs/fi.js +2 -0
- package/esm/langs/fr.d.ts +2 -0
- package/esm/langs/fr.js +2 -0
- package/esm/langs/he.d.ts +2 -0
- package/esm/langs/he.js +2 -0
- package/esm/langs/hu.d.ts +2 -0
- package/esm/langs/hu.js +2 -0
- package/esm/langs/id.d.ts +2 -0
- package/esm/langs/id.js +2 -0
- package/esm/langs/it.d.ts +2 -0
- package/esm/langs/it.js +2 -0
- package/esm/langs/ja.d.ts +2 -0
- package/esm/langs/ja.js +2 -0
- package/esm/langs/ko.d.ts +2 -0
- package/esm/langs/ko.js +2 -0
- package/esm/langs/mn.d.ts +2 -0
- package/esm/langs/mn.js +2 -0
- package/esm/langs/nl.d.ts +2 -0
- package/esm/langs/nl.js +2 -0
- package/esm/langs/no.d.ts +2 -0
- package/esm/langs/no.js +2 -0
- package/esm/langs/pl.d.ts +2 -0
- package/esm/langs/pl.js +2 -0
- package/esm/langs/pt_br.d.ts +2 -0
- package/esm/langs/pt_br.js +2 -0
- package/esm/langs/ru.d.ts +2 -0
- package/esm/langs/ru.js +2 -0
- package/esm/langs/sk.d.ts +2 -0
- package/esm/langs/sk.js +2 -0
- package/esm/langs/sv.d.ts +2 -0
- package/esm/langs/sv.js +2 -0
- package/esm/langs/tr.d.ts +2 -0
- package/esm/langs/tr.js +2 -0
- package/esm/langs/ua.d.ts +2 -0
- package/esm/langs/ua.js +2 -0
- package/esm/langs/zh_cn.d.ts +2 -0
- package/esm/langs/zh_cn.js +2 -0
- package/esm/langs/zh_tw.d.ts +2 -0
- package/esm/langs/zh_tw.js +2 -0
- package/esm/modules/table/table.d.ts +27 -0
- package/esm/modules/table/table.js +110 -2
- package/esm/modules/toolbar/button/button.js +11 -3
- package/esm/modules/uploader/helpers/send-files.js +3 -1
- package/esm/modules/widget/tabs/tabs.js +2 -0
- package/esm/plugins/all.d.ts +1 -0
- package/esm/plugins/all.js +1 -0
- package/esm/plugins/backspace/backspace.js +17 -1
- package/esm/plugins/backspace/cases/check-remove-char.js +1 -11
- package/esm/plugins/backspace/helpers.d.ts +5 -0
- package/esm/plugins/backspace/helpers.js +11 -0
- package/esm/plugins/clean-html/clean-html.js +2 -2
- package/esm/plugins/clean-html/helpers/index.d.ts +1 -0
- package/esm/plugins/clean-html/helpers/index.js +1 -0
- package/esm/plugins/clean-html/helpers/remove-format/remove-format-for-word.d.ts +16 -0
- package/esm/plugins/clean-html/helpers/remove-format/remove-format-for-word.js +109 -0
- package/esm/plugins/drag-and-drop-element/drag-and-drop-element.js +4 -2
- package/esm/plugins/format-block/config.d.ts +13 -0
- package/esm/plugins/format-block/config.js +38 -1
- package/esm/plugins/format-block/content-fonts.d.ts +17 -0
- package/esm/plugins/format-block/content-fonts.js +156 -0
- package/esm/plugins/image-caption/config.d.ts +31 -0
- package/esm/plugins/image-caption/config.js +11 -0
- package/esm/plugins/image-caption/image-caption.d.ts +140 -0
- package/esm/plugins/image-caption/image-caption.js +799 -0
- package/esm/plugins/image-processor/image-processor.d.ts +2 -1
- package/esm/plugins/image-processor/image-processor.js +9 -4
- package/esm/plugins/image-properties/config.js +1 -0
- package/esm/plugins/image-properties/image-properties.js +19 -5
- package/esm/plugins/image-properties/interface.d.ts +6 -0
- package/esm/plugins/image-properties/readers/align.d.ts +1 -1
- package/esm/plugins/image-properties/readers/index.js +9 -3
- package/esm/plugins/image-properties/readers/margin.d.ts +1 -1
- package/esm/plugins/image-properties/readers/size.d.ts +5 -1
- package/esm/plugins/image-properties/readers/size.js +4 -5
- package/esm/plugins/image-properties/ui/ui-image-main-tab.d.ts +2 -0
- package/esm/plugins/image-properties/ui/ui-image-main-tab.js +20 -0
- package/esm/plugins/image-properties/writers/caption.d.ts +15 -0
- package/esm/plugins/image-properties/writers/caption.js +18 -0
- package/esm/plugins/image-properties/writers/index.js +15 -10
- package/esm/plugins/image-properties/writers/link.js +7 -2
- package/esm/plugins/image-properties/writers/margin.d.ts +1 -1
- package/esm/plugins/image-properties/writers/size.d.ts +5 -2
- package/esm/plugins/image-properties/writers/size.js +16 -2
- package/esm/plugins/indent/helpers.d.ts +9 -0
- package/esm/plugins/indent/helpers.js +23 -3
- package/esm/plugins/indent/indent.js +2 -20
- package/esm/plugins/index.d.ts +1 -0
- package/esm/plugins/inline-popup/config/config.js +4 -0
- package/esm/plugins/inline-popup/config/items/cells.js +29 -0
- package/esm/plugins/inline-popup/config/items/img.js +35 -5
- package/esm/plugins/inline-popup/icons/caption.svg.js +1 -0
- package/esm/plugins/inline-popup/icons/headerrow.svg.js +1 -0
- package/esm/plugins/inline-popup/inline-popup.js +3 -2
- package/esm/plugins/placeholder/placeholder.js +7 -1
- package/esm/plugins/resize-cells/resize-cells.d.ts +49 -0
- package/esm/plugins/resize-cells/resize-cells.js +247 -13
- package/esm/plugins/resizer/resizer.js +13 -2
- package/esm/plugins/select-cells/select-cells.d.ts +5 -0
- package/esm/plugins/select-cells/select-cells.js +29 -11
- package/esm/plugins/tab/cases/index.d.ts +1 -0
- package/esm/plugins/tab/cases/index.js +1 -0
- package/esm/plugins/tab/cases/on-tab-inside-li.js +3 -1
- package/esm/plugins/tab/cases/tab-spaces.d.ts +32 -0
- package/esm/plugins/tab/cases/tab-spaces.js +263 -0
- package/esm/plugins/tab/config.d.ts +10 -0
- package/esm/plugins/tab/config.js +2 -1
- package/esm/plugins/tab/tab.js +61 -6
- package/esm/types/types.d.ts +16 -0
- package/esm/types/uploader.d.ts +6 -0
- package/package.json +1 -1
- package/types/config.d.ts +44 -1
- package/types/core/helpers/utils/align.d.ts +6 -1
- package/types/core/helpers/utils/image-caption.d.ts +24 -0
- package/types/core/helpers/utils/index.d.ts +1 -0
- package/types/core/selection/selection.d.ts +3 -0
- package/types/core/ui/helpers/focus-form-field.d.ts +12 -0
- package/types/langs/ar.d.ts +2 -0
- package/types/langs/az.d.ts +2 -0
- package/types/langs/cs_cz.d.ts +2 -0
- package/types/langs/de.d.ts +2 -0
- package/types/langs/es.d.ts +2 -0
- package/types/langs/fa.d.ts +2 -0
- package/types/langs/fi.d.ts +2 -0
- package/types/langs/fr.d.ts +2 -0
- package/types/langs/he.d.ts +2 -0
- package/types/langs/hu.d.ts +2 -0
- package/types/langs/id.d.ts +2 -0
- package/types/langs/it.d.ts +2 -0
- package/types/langs/ja.d.ts +2 -0
- package/types/langs/ko.d.ts +2 -0
- package/types/langs/mn.d.ts +2 -0
- package/types/langs/nl.d.ts +2 -0
- package/types/langs/no.d.ts +2 -0
- package/types/langs/pl.d.ts +2 -0
- package/types/langs/pt_br.d.ts +2 -0
- package/types/langs/ru.d.ts +2 -0
- package/types/langs/sk.d.ts +2 -0
- package/types/langs/sv.d.ts +2 -0
- package/types/langs/tr.d.ts +2 -0
- package/types/langs/ua.d.ts +2 -0
- package/types/langs/zh_cn.d.ts +2 -0
- package/types/langs/zh_tw.d.ts +2 -0
- package/types/modules/table/table.d.ts +27 -0
- package/types/plugins/backspace/helpers.d.ts +5 -0
- package/types/plugins/clean-html/helpers/index.d.ts +1 -0
- package/types/plugins/clean-html/helpers/remove-format/remove-format-for-word.d.ts +16 -0
- package/types/plugins/format-block/config.d.ts +13 -0
- package/types/plugins/format-block/content-fonts.d.ts +17 -0
- package/types/plugins/image-caption/config.d.ts +31 -0
- package/types/plugins/image-caption/image-caption.d.ts +140 -0
- package/types/plugins/image-processor/image-processor.d.ts +2 -1
- package/types/plugins/image-properties/interface.d.ts +6 -0
- package/types/plugins/image-properties/readers/align.d.ts +1 -1
- package/types/plugins/image-properties/readers/margin.d.ts +1 -1
- package/types/plugins/image-properties/readers/size.d.ts +5 -1
- package/types/plugins/image-properties/ui/ui-image-main-tab.d.ts +2 -0
- package/types/plugins/image-properties/writers/caption.d.ts +15 -0
- package/types/plugins/image-properties/writers/margin.d.ts +1 -1
- package/types/plugins/image-properties/writers/size.d.ts +5 -2
- package/types/plugins/indent/helpers.d.ts +9 -0
- package/types/plugins/index.d.ts +1 -0
- package/types/plugins/resize-cells/resize-cells.d.ts +49 -0
- package/types/plugins/select-cells/select-cells.d.ts +5 -0
- package/types/plugins/tab/cases/index.d.ts +1 -0
- package/types/plugins/tab/cases/tab-spaces.d.ts +32 -0
- package/types/plugins/tab/config.d.ts +10 -0
- package/types/types/types.d.ts +16 -0
- package/types/types/uploader.d.ts +6 -0
package/esm/langs/ua.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ declare const _exports: {
|
|
|
60
60
|
Src: string;
|
|
61
61
|
Title: string;
|
|
62
62
|
Alternative: string;
|
|
63
|
+
Caption: string;
|
|
63
64
|
Link: string;
|
|
64
65
|
'Open link in new tab': string;
|
|
65
66
|
file: string;
|
|
@@ -98,6 +99,7 @@ declare const _exports: {
|
|
|
98
99
|
'Insert column after': string;
|
|
99
100
|
'Insert row above': string;
|
|
100
101
|
'Insert row below': string;
|
|
102
|
+
'Header row': string;
|
|
101
103
|
'Delete table': string;
|
|
102
104
|
'Delete row': string;
|
|
103
105
|
'Delete column': string;
|
package/esm/langs/ua.js
CHANGED
|
@@ -70,6 +70,7 @@ export default {
|
|
|
70
70
|
Src: 'src',
|
|
71
71
|
Title: 'Заголовок',
|
|
72
72
|
Alternative: 'Альтернативний текст (alt)',
|
|
73
|
+
Caption: 'Підпис',
|
|
73
74
|
Link: 'Посилання',
|
|
74
75
|
'Open link in new tab': 'Відкрити посилання в новій вкладці',
|
|
75
76
|
file: 'Файл',
|
|
@@ -110,6 +111,7 @@ export default {
|
|
|
110
111
|
'Insert column after': 'Вставити стовпець після',
|
|
111
112
|
'Insert row above': 'Вставити рядок вище',
|
|
112
113
|
'Insert row below': 'Вставити рядок нижче',
|
|
114
|
+
'Header row': 'Рядок заголовка',
|
|
113
115
|
'Delete table': 'Видалити таблицю',
|
|
114
116
|
'Delete row': 'Видалити рядок',
|
|
115
117
|
'Delete column': 'Видалити стовпчик',
|
package/esm/langs/zh_cn.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ declare const _exports: {
|
|
|
62
62
|
Src: string;
|
|
63
63
|
Title: string;
|
|
64
64
|
Alternative: string;
|
|
65
|
+
Caption: string;
|
|
65
66
|
Link: string;
|
|
66
67
|
'Open link in new tab': string;
|
|
67
68
|
Image: string;
|
|
@@ -100,6 +101,7 @@ declare const _exports: {
|
|
|
100
101
|
'Insert column after': string;
|
|
101
102
|
'Insert row above': string;
|
|
102
103
|
'Insert row below': string;
|
|
104
|
+
'Header row': string;
|
|
103
105
|
'Delete table': string;
|
|
104
106
|
'Delete row': string;
|
|
105
107
|
'Delete column': string;
|
package/esm/langs/zh_cn.js
CHANGED
|
@@ -71,6 +71,7 @@ export default {
|
|
|
71
71
|
Src: 'Src',
|
|
72
72
|
Title: 'Title',
|
|
73
73
|
Alternative: 'Alternative',
|
|
74
|
+
Caption: '题注',
|
|
74
75
|
Link: 'Link',
|
|
75
76
|
'Open link in new tab': '在新窗口打开链接',
|
|
76
77
|
Image: '图片',
|
|
@@ -111,6 +112,7 @@ export default {
|
|
|
111
112
|
'Insert column after': '在之后插入列',
|
|
112
113
|
'Insert row above': '在之前插入行',
|
|
113
114
|
'Insert row below': '在之后插入行',
|
|
115
|
+
'Header row': '标题行',
|
|
114
116
|
'Delete table': '删除表格',
|
|
115
117
|
'Delete row': '删除行',
|
|
116
118
|
'Delete column': '删除列',
|
package/esm/langs/zh_tw.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ declare const _exports: {
|
|
|
61
61
|
Src: string;
|
|
62
62
|
Title: string;
|
|
63
63
|
Alternative: string;
|
|
64
|
+
Caption: string;
|
|
64
65
|
Link: string;
|
|
65
66
|
'Open link in new tab': string;
|
|
66
67
|
Image: string;
|
|
@@ -99,6 +100,7 @@ declare const _exports: {
|
|
|
99
100
|
'Insert column after': string;
|
|
100
101
|
'Insert row above': string;
|
|
101
102
|
'Insert row below': string;
|
|
103
|
+
'Header row': string;
|
|
102
104
|
'Delete table': string;
|
|
103
105
|
'Delete row': string;
|
|
104
106
|
'Delete column': string;
|
package/esm/langs/zh_tw.js
CHANGED
|
@@ -70,6 +70,7 @@ export default {
|
|
|
70
70
|
Src: 'Src',
|
|
71
71
|
Title: 'Title',
|
|
72
72
|
Alternative: '替代',
|
|
73
|
+
Caption: '標號',
|
|
73
74
|
Link: 'Link',
|
|
74
75
|
'Open link in new tab': '在新分頁開啟連結',
|
|
75
76
|
Image: '圖片',
|
|
@@ -110,6 +111,7 @@ export default {
|
|
|
110
111
|
'Insert column after': '插入右方欄',
|
|
111
112
|
'Insert row above': '插入上方列',
|
|
112
113
|
'Insert row below': '插入下方列',
|
|
114
|
+
'Header row': '標題列',
|
|
113
115
|
'Delete table': '刪除表格',
|
|
114
116
|
'Delete row': '刪除整列',
|
|
115
117
|
'Delete column': '刪除整欄',
|
|
@@ -54,6 +54,33 @@ export declare class Table extends ViewComponent<IJodit> {
|
|
|
54
54
|
*/
|
|
55
55
|
formalCoordinate(table: HTMLTableElement, cell: HTMLTableCellElement, max?: boolean): number[];
|
|
56
56
|
private static __appendRow;
|
|
57
|
+
/**
|
|
58
|
+
* The table's first `<tbody>`, made after `head` when there's none
|
|
59
|
+
*/
|
|
60
|
+
private static __bodyOf;
|
|
61
|
+
/**
|
|
62
|
+
* Makes the row's cells `<td>`, or `<th>` with a column scope unless they
|
|
63
|
+
* have one, keeping their content and attributes. The cells it replaces
|
|
64
|
+
* go in `replaced`, with their replacements
|
|
65
|
+
*/
|
|
66
|
+
private static __setCellsTag;
|
|
67
|
+
/**
|
|
68
|
+
* The table has a header row: a `<thead>` with a row in it
|
|
69
|
+
*/
|
|
70
|
+
hasHeaderRow(table: HTMLTableElement): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Header rows can always go back into the body. The first row can become
|
|
73
|
+
* one unless a cell in it spans into the next, as a span can't cross from
|
|
74
|
+
* the `<thead>` into the `<tbody>`
|
|
75
|
+
*/
|
|
76
|
+
canToggleHeaderRow(table: HTMLTableElement): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Moves the first row into a `<thead>`, its cells becoming
|
|
79
|
+
* `<th scope="col">`, or the header rows back to the start of the
|
|
80
|
+
* `<tbody>` as `<td>`. Their content, attributes and spans stay. Returns
|
|
81
|
+
* the cells it replaced, with their replacements
|
|
82
|
+
*/
|
|
83
|
+
toggleHeaderRow(table: HTMLTableElement): Map<HTMLTableCellElement, HTMLTableCellElement>;
|
|
57
84
|
/**
|
|
58
85
|
* Inserts a new line after row what contains the selected cell
|
|
59
86
|
*
|
|
@@ -9,6 +9,7 @@ import { Dom } from "../../core/dom/index.js";
|
|
|
9
9
|
import { getContainer } from "../../core/global.js";
|
|
10
10
|
import { attr, css, cssPath, isNumber, toArray, trim } from "../../core/helpers/index.js";
|
|
11
11
|
import { cssInline } from "../../core/helpers/utils/css.js";
|
|
12
|
+
const SECTIONS = new Set(['thead', 'tbody', 'tfoot']);
|
|
12
13
|
const markedValue = new WeakMap();
|
|
13
14
|
export class Table extends ViewComponent {
|
|
14
15
|
constructor() {
|
|
@@ -27,9 +28,17 @@ export class Table extends ViewComponent {
|
|
|
27
28
|
const selector = cssPath(td);
|
|
28
29
|
selector && selectors.push(selector);
|
|
29
30
|
});
|
|
31
|
+
// Across cells, the browser's own text selection, which a drag makes
|
|
32
|
+
// as well, isn't shown
|
|
33
|
+
const hidden = selectors.length > 1
|
|
34
|
+
? selectors
|
|
35
|
+
.map(selector => `${selector}::selection,${selector} ::selection`)
|
|
36
|
+
.join(',') + '{background:transparent}'
|
|
37
|
+
: '';
|
|
30
38
|
style.innerHTML = selectors.length
|
|
31
39
|
? selectors.join(',') +
|
|
32
|
-
`{${this.jodit.options.table.selectionCellStyle}}`
|
|
40
|
+
`{${this.jodit.options.table.selectionCellStyle}}` +
|
|
41
|
+
hidden
|
|
33
42
|
: '';
|
|
34
43
|
});
|
|
35
44
|
}
|
|
@@ -191,7 +200,17 @@ export class Table extends ViewComponent {
|
|
|
191
200
|
}
|
|
192
201
|
});
|
|
193
202
|
}
|
|
194
|
-
|
|
203
|
+
const section = line && line.parentElement;
|
|
204
|
+
// Below the header rows, a row is a body row
|
|
205
|
+
if (after &&
|
|
206
|
+
line &&
|
|
207
|
+
!line.nextElementSibling &&
|
|
208
|
+
Dom.isTag(section, 'thead')) {
|
|
209
|
+
const body = Table.__bodyOf(table, section, create);
|
|
210
|
+
body.insertBefore(row, body.firstChild);
|
|
211
|
+
Table.__setCellsTag(row, 'td', create);
|
|
212
|
+
}
|
|
213
|
+
else if (after && line && line.nextSibling) {
|
|
195
214
|
Dom.after(line, row);
|
|
196
215
|
}
|
|
197
216
|
else if (!after && line) {
|
|
@@ -201,6 +220,89 @@ export class Table extends ViewComponent {
|
|
|
201
220
|
Dom.append(Dom.first(table, node => Dom.isTag(node, 'tbody')) || table, row);
|
|
202
221
|
}
|
|
203
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* The table's first `<tbody>`, made after `head` when there's none
|
|
225
|
+
*/
|
|
226
|
+
static __bodyOf(table, head, create) {
|
|
227
|
+
let body = table.tBodies[0];
|
|
228
|
+
if (!body) {
|
|
229
|
+
body = create.element('tbody');
|
|
230
|
+
Dom.after(head, body);
|
|
231
|
+
}
|
|
232
|
+
return body;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Makes the row's cells `<td>`, or `<th>` with a column scope unless they
|
|
236
|
+
* have one, keeping their content and attributes. The cells it replaces
|
|
237
|
+
* go in `replaced`, with their replacements
|
|
238
|
+
*/
|
|
239
|
+
static __setCellsTag(row, tag, create, replaced) {
|
|
240
|
+
toArray(row.cells).forEach(cell => {
|
|
241
|
+
const next = Dom.isTag(cell, tag)
|
|
242
|
+
? cell
|
|
243
|
+
: Dom.replace(cell, tag, create, true);
|
|
244
|
+
if (next !== cell) {
|
|
245
|
+
replaced === null || replaced === void 0 ? void 0 : replaced.set(cell, next);
|
|
246
|
+
}
|
|
247
|
+
if (tag === 'td') {
|
|
248
|
+
attr(next, 'scope', null);
|
|
249
|
+
}
|
|
250
|
+
else if (!next.hasAttribute('scope')) {
|
|
251
|
+
attr(next, 'scope', 'col');
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The table has a header row: a `<thead>` with a row in it
|
|
257
|
+
*/
|
|
258
|
+
hasHeaderRow(table) {
|
|
259
|
+
var _a;
|
|
260
|
+
return Boolean((_a = table.tHead) === null || _a === void 0 ? void 0 : _a.rows.length);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Header rows can always go back into the body. The first row can become
|
|
264
|
+
* one unless a cell in it spans into the next, as a span can't cross from
|
|
265
|
+
* the `<thead>` into the `<tbody>`
|
|
266
|
+
*/
|
|
267
|
+
canToggleHeaderRow(table) {
|
|
268
|
+
const [row] = toArray(table.rows);
|
|
269
|
+
return (this.hasHeaderRow(table) ||
|
|
270
|
+
Boolean(row && toArray(row.cells).every(cell => cell.rowSpan < 2)));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Moves the first row into a `<thead>`, its cells becoming
|
|
274
|
+
* `<th scope="col">`, or the header rows back to the start of the
|
|
275
|
+
* `<tbody>` as `<td>`. Their content, attributes and spans stay. Returns
|
|
276
|
+
* the cells it replaced, with their replacements
|
|
277
|
+
*/
|
|
278
|
+
toggleHeaderRow(table) {
|
|
279
|
+
const replaced = new Map();
|
|
280
|
+
const create = this.j.createInside;
|
|
281
|
+
const head = table.tHead;
|
|
282
|
+
if (!this.canToggleHeaderRow(table)) {
|
|
283
|
+
return replaced;
|
|
284
|
+
}
|
|
285
|
+
if (head && this.hasHeaderRow(table)) {
|
|
286
|
+
const body = Table.__bodyOf(table, head, create);
|
|
287
|
+
const first = body.firstChild;
|
|
288
|
+
toArray(head.rows).forEach(row => {
|
|
289
|
+
body.insertBefore(row, first);
|
|
290
|
+
Table.__setCellsTag(row, 'td', create, replaced);
|
|
291
|
+
});
|
|
292
|
+
Dom.safeRemove(head);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
const [row] = toArray(table.rows);
|
|
296
|
+
const thead = head || create.element('thead');
|
|
297
|
+
if (!head) {
|
|
298
|
+
// Setting it puts it after a caption and column groups
|
|
299
|
+
table.tHead = thead;
|
|
300
|
+
}
|
|
301
|
+
Dom.append(thead, row);
|
|
302
|
+
Table.__setCellsTag(row, 'th', create, replaced);
|
|
303
|
+
}
|
|
304
|
+
return replaced;
|
|
305
|
+
}
|
|
204
306
|
/**
|
|
205
307
|
* Inserts a new line after row what contains the selected cell
|
|
206
308
|
*
|
|
@@ -262,7 +364,13 @@ export class Table extends ViewComponent {
|
|
|
262
364
|
attr(cell, 'rowspan', rowSpan - 1 > 1 ? rowSpan - 1 : null);
|
|
263
365
|
}
|
|
264
366
|
});
|
|
367
|
+
const section = row.parentElement;
|
|
265
368
|
Dom.safeRemove(row);
|
|
369
|
+
// A section left without rows goes too, so a table whose header row
|
|
370
|
+
// was deleted has no `<thead>`
|
|
371
|
+
if (Dom.isTag(section, SECTIONS) && !section.rows.length) {
|
|
372
|
+
Dom.safeRemove(section);
|
|
373
|
+
}
|
|
266
374
|
}
|
|
267
375
|
/**
|
|
268
376
|
* Remove row
|
|
@@ -31,6 +31,7 @@ import { assert } from "../../../core/helpers/utils/assert.js";
|
|
|
31
31
|
import { attr } from "../../../core/helpers/utils/attr.js";
|
|
32
32
|
import { call, keys } from "../../../core/helpers/utils/utils.js";
|
|
33
33
|
import { UIButton, UIButtonState } from "../../../core/ui/button/index.js";
|
|
34
|
+
import { focusFormField } from "../../../core/ui/helpers/focus-form-field.js";
|
|
34
35
|
import { findControlType } from "../../../core/ui/helpers/get-control-type.js";
|
|
35
36
|
import { Icon } from "../../../core/ui/icon.js";
|
|
36
37
|
import { Popup } from "../../../core/ui/popup/popup.js";
|
|
@@ -283,6 +284,9 @@ let ToolbarButton = class ToolbarButton extends UIButton {
|
|
|
283
284
|
.open(() => position(this.container), false, this.j.o.allowTabNavigation
|
|
284
285
|
? this.container
|
|
285
286
|
: undefined);
|
|
287
|
+
// The focus stays in the content for a list, which
|
|
288
|
+
// typing searches, but goes to a form, as in a dialog
|
|
289
|
+
focusFormField(popup.container);
|
|
286
290
|
}
|
|
287
291
|
else {
|
|
288
292
|
this.__closePopup();
|
|
@@ -548,16 +552,20 @@ let ToolbarButton = class ToolbarButton extends UIButton {
|
|
|
548
552
|
.off('escape closeAllPopups', this.onOutsideClick)
|
|
549
553
|
.off('keydown', this.__onEditorKeyDown);
|
|
550
554
|
// The keyboard brought the focus into the dropdown: give it back to
|
|
551
|
-
// the button, otherwise it would fall out to the document
|
|
555
|
+
// the button, otherwise it would fall out to the document. A form
|
|
556
|
+
// gives it back to the content, with the selection it was opened for
|
|
552
557
|
const { activeElement } = this.od, hadFocus = activeElement &&
|
|
553
|
-
Dom.isOrContains(popup.container, activeElement);
|
|
558
|
+
Dom.isOrContains(popup.container, activeElement), inForm = hadFocus && Dom.closest(activeElement, 'form', popup.container);
|
|
554
559
|
this.state.activated = false;
|
|
555
560
|
popup.close();
|
|
556
561
|
popup.destruct();
|
|
557
562
|
if (this.trigger) {
|
|
558
563
|
attr(this.trigger, 'aria-expanded', false);
|
|
559
564
|
}
|
|
560
|
-
if (
|
|
565
|
+
if (inForm && isJoditObject(this.j)) {
|
|
566
|
+
this.j.s.focus();
|
|
567
|
+
}
|
|
568
|
+
else if (hadFocus) {
|
|
561
569
|
this.focus();
|
|
562
570
|
}
|
|
563
571
|
}
|
|
@@ -100,13 +100,15 @@ function readImagesWithReader(fileList, imagesExtensions, promises, uploader, ha
|
|
|
100
100
|
continue;
|
|
101
101
|
}
|
|
102
102
|
const reader = new FileReader();
|
|
103
|
+
const { name } = file;
|
|
103
104
|
const readerPromise = uploader.j.async.promise((resolve, reject) => {
|
|
104
105
|
reader.onerror = reject;
|
|
105
106
|
reader.onloadend = () => {
|
|
106
107
|
const resp = {
|
|
107
108
|
baseurl: '',
|
|
108
109
|
files: [reader.result],
|
|
109
|
-
isImages: [true]
|
|
110
|
+
isImages: [true],
|
|
111
|
+
fileNames: [name]
|
|
110
112
|
};
|
|
111
113
|
const handler = isFunction(handlerSuccess)
|
|
112
114
|
? handlerSuccess
|
|
@@ -8,6 +8,7 @@ import { Dom } from "../../../core/dom/dom.js";
|
|
|
8
8
|
import { isFunction } from "../../../core/helpers/checker/is-function.js";
|
|
9
9
|
import { attr } from "../../../core/helpers/utils/attr.js";
|
|
10
10
|
import { Button, UIElement } from "../../../core/ui/index.js";
|
|
11
|
+
import { focusFormField } from "../../../core/ui/helpers/focus-form-field.js";
|
|
11
12
|
/**
|
|
12
13
|
* Build tabs system
|
|
13
14
|
*
|
|
@@ -92,6 +93,7 @@ export const TabsWidget = (jodit, tabs, state) => {
|
|
|
92
93
|
if (state) {
|
|
93
94
|
state.activeTab = name;
|
|
94
95
|
}
|
|
96
|
+
focusFormField(tab);
|
|
95
97
|
return false;
|
|
96
98
|
});
|
|
97
99
|
nameToTab[name] = {
|
package/esm/plugins/all.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ import "./hotkeys/hotkeys";
|
|
|
30
30
|
import "./hr/hr";
|
|
31
31
|
import "./iframe/iframe";
|
|
32
32
|
import "./image/image";
|
|
33
|
+
import "./image-caption/image-caption";
|
|
33
34
|
import "./image-processor/image-processor";
|
|
34
35
|
import "./image-properties/image-properties";
|
|
35
36
|
import "./indent/indent";
|
package/esm/plugins/all.js
CHANGED
|
@@ -31,6 +31,7 @@ import "./hotkeys/hotkeys.js";
|
|
|
31
31
|
import "./hr/hr.js";
|
|
32
32
|
import "./iframe/iframe.js";
|
|
33
33
|
import "./image/image.js";
|
|
34
|
+
import "./image-caption/image-caption.js";
|
|
34
35
|
import "./image-processor/image-processor.js";
|
|
35
36
|
import "./image-properties/image-properties.js";
|
|
36
37
|
import "./indent/indent.js";
|
|
@@ -72,6 +72,14 @@ export class backspace extends Plugin {
|
|
|
72
72
|
if (!Dom.isOrContains(jodit.editor, fakeNode)) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
+
// An editable element inside non-editable content, as an image's
|
|
76
|
+
// caption is, keeps the caret, so nothing past its edge goes
|
|
77
|
+
const host = Dom.closest(fakeNode, elm => Dom.isElement(elm) &&
|
|
78
|
+
elm.hasAttribute('contenteditable') &&
|
|
79
|
+
!Dom.isContentEditable(elm.parentNode, jodit.editor), jodit.editor);
|
|
80
|
+
if (host && sel.cursorInTheEdge(backspace, host, fakeNode)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
75
83
|
if (jodit.e.fire('backSpaceBeforeCases', backspace, fakeNode)) {
|
|
76
84
|
return false;
|
|
77
85
|
}
|
|
@@ -125,7 +133,15 @@ export class backspace extends Plugin {
|
|
|
125
133
|
!around.isPointInRange(range.startContainer, range.startOffset)) {
|
|
126
134
|
return;
|
|
127
135
|
}
|
|
128
|
-
|
|
136
|
+
// The search for text skips text of only non-breaking spaces, but the
|
|
137
|
+
// browser types after it
|
|
138
|
+
let before = fakeNode.previousSibling;
|
|
139
|
+
while (Dom.isText(before) && !/\S|\u00A0/.test(before.data)) {
|
|
140
|
+
before = before.previousSibling;
|
|
141
|
+
}
|
|
142
|
+
const text = Dom.isText(before)
|
|
143
|
+
? before
|
|
144
|
+
: findMostNestedNeighbor(fakeNode, false, jodit.editor, true);
|
|
129
145
|
const link = Dom.closest(text, 'a', jodit.editor);
|
|
130
146
|
if (!Dom.isText(text) ||
|
|
131
147
|
!Dom.isContentEditable(text, jodit.editor) ||
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { INVISIBLE_SPACE, NBSP_SPACE } from "../../../core/constants.js";
|
|
7
7
|
import { Dom } from "../../../core/dom/index.js";
|
|
8
8
|
import { call, isVoid, toArray, trimInv } from "../../../core/helpers/index.js";
|
|
9
|
-
import { findMostNestedNeighbor } from "../helpers.js";
|
|
9
|
+
import { addBRInsideEmptyBlock, findMostNestedNeighbor } from "../helpers.js";
|
|
10
10
|
/**
|
|
11
11
|
* Check possibility the char can be removed
|
|
12
12
|
*
|
|
@@ -112,16 +112,6 @@ function removeEmptyForParent(node, tags) {
|
|
|
112
112
|
parent = p;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Helper add BR element inside empty block element
|
|
117
|
-
*/
|
|
118
|
-
function addBRInsideEmptyBlock(jodit, node) {
|
|
119
|
-
if (node.parentElement !== jodit.editor &&
|
|
120
|
-
Dom.isBlock(node.parentElement) &&
|
|
121
|
-
Dom.each(node.parentElement, Dom.isEmptyTextNode)) {
|
|
122
|
-
Dom.after(node, jodit.createInside.element('br'));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
115
|
function tryRemoveChar(sibling, backspace, step, anotherSibling) {
|
|
126
116
|
// For Unicode escapes
|
|
127
117
|
let value = toArray(sibling.nodeValue);
|
|
@@ -17,3 +17,8 @@ export declare function findMostNestedNeighbor(node: Node, right: boolean, root:
|
|
|
17
17
|
* @private
|
|
18
18
|
*/
|
|
19
19
|
export declare function getMoveFilter(jodit: IJodit): (node: Node) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Helper add BR element inside empty block element
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
export declare function addBRInsideEmptyBlock(jodit: IJodit, node: Node): void;
|
|
@@ -33,3 +33,14 @@ export function findMostNestedNeighbor(node, right, root, onlyInlide = false) {
|
|
|
33
33
|
export function getMoveFilter(jodit) {
|
|
34
34
|
return (node) => jodit.e.fire('backSpaceIsMovedIgnore', node) !== true;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Helper add BR element inside empty block element
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
export function addBRInsideEmptyBlock(jodit, node) {
|
|
41
|
+
if (node.parentElement !== jodit.editor &&
|
|
42
|
+
Dom.isBlock(node.parentElement) &&
|
|
43
|
+
Dom.each(node.parentElement, Dom.isEmptyTextNode)) {
|
|
44
|
+
Dom.after(node, jodit.createInside.element('br'));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -21,7 +21,7 @@ import { safeHTML } from "../../core/helpers/html/safe-html.js";
|
|
|
21
21
|
import { Plugin } from "../../core/plugin/plugin.js";
|
|
22
22
|
import "./config.js";
|
|
23
23
|
import { replaceOldTags } from "./helpers/visitor/filters/replace-old-tags.js";
|
|
24
|
-
import { getHash,
|
|
24
|
+
import { getHash, removeFormatForSelection, removeFormatForWord, removePlaceholderBr, visitNodeWalker } from "./helpers/index.js";
|
|
25
25
|
/**
|
|
26
26
|
* Clean HTML after removeFormat and insertHorizontalRule command
|
|
27
27
|
*/
|
|
@@ -104,7 +104,7 @@ export class cleanHtml extends Plugin {
|
|
|
104
104
|
beforeCommand(command) {
|
|
105
105
|
if (command.toLowerCase() === 'removeformat') {
|
|
106
106
|
if (this.j.s.isCollapsed()) {
|
|
107
|
-
|
|
107
|
+
removeFormatForWord(this.j);
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
110
|
removeFormatForSelection(this.j);
|
|
@@ -10,5 +10,6 @@ export * from "./get-hash";
|
|
|
10
10
|
export * from "./is-allowed-media-embed";
|
|
11
11
|
export * from "./remove-format/remove-format-for-collapsed-selection";
|
|
12
12
|
export * from "./remove-format/remove-format-for-selection";
|
|
13
|
+
export * from "./remove-format/remove-format-for-word";
|
|
13
14
|
export * from "./remove-placeholder-br";
|
|
14
15
|
export * from "./visitor/visit-node-walker";
|
|
@@ -10,5 +10,6 @@ export * from "./get-hash.js";
|
|
|
10
10
|
export * from "./is-allowed-media-embed.js";
|
|
11
11
|
export * from "./remove-format/remove-format-for-collapsed-selection.js";
|
|
12
12
|
export * from "./remove-format/remove-format-for-selection.js";
|
|
13
|
+
export * from "./remove-format/remove-format-for-word.js";
|
|
13
14
|
export * from "./remove-placeholder-br.js";
|
|
14
15
|
export * from "./visitor/visit-node-walker.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
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-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @module plugins/clean-html
|
|
8
|
+
*/
|
|
9
|
+
import type { IJodit } from "../../../../types/index";
|
|
10
|
+
/**
|
|
11
|
+
* With just a caret, Word clears the formatting of the word the caret is
|
|
12
|
+
* inside, and does nothing at a word's start or end. This selects the word,
|
|
13
|
+
* clears it as a selection, and puts the caret back where it was.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
export declare function removeFormatForWord(jodit: IJodit): void;
|
|
@@ -0,0 +1,109 @@
|
|
|
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-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
import { INSEPARABLE_TAGS, INVISIBLE_SPACE } from "../../../../core/constants.js";
|
|
7
|
+
import { Dom } from "../../../../core/dom/dom.js";
|
|
8
|
+
import { removeFormatForSelection } from "./remove-format-for-selection.js";
|
|
9
|
+
/**
|
|
10
|
+
* With just a caret, Word clears the formatting of the word the caret is
|
|
11
|
+
* inside, and does nothing at a word's start or end. This selects the word,
|
|
12
|
+
* clears it as a selection, and puts the caret back where it was.
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
export function removeFormatForWord(jodit) {
|
|
16
|
+
const { range } = jodit.s;
|
|
17
|
+
const block = Dom.closest(range.startContainer, Dom.isBlock, jodit.editor);
|
|
18
|
+
if (!block) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const texts = textsOf(block);
|
|
22
|
+
const text = texts
|
|
23
|
+
.map(node => (Dom.isText(node) ? node.nodeValue : ' '))
|
|
24
|
+
.join('');
|
|
25
|
+
const at = textOffset(texts, range);
|
|
26
|
+
if (!isWordChar(text[at - 1]) || !isWordChar(text[at])) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
let start = at, end = at;
|
|
30
|
+
while (isWordChar(text[start - 1])) {
|
|
31
|
+
start -= 1;
|
|
32
|
+
}
|
|
33
|
+
while (isWordChar(text[end])) {
|
|
34
|
+
end += 1;
|
|
35
|
+
}
|
|
36
|
+
const word = jodit.s.createRange();
|
|
37
|
+
word.setStart(...positionAt(texts, start, true));
|
|
38
|
+
word.setEnd(...positionAt(texts, end, false));
|
|
39
|
+
jodit.s.selectRange(word);
|
|
40
|
+
removeFormatForSelection(jodit);
|
|
41
|
+
// The text is the same, so the caret goes back to the same character
|
|
42
|
+
const caret = jodit.s.createRange();
|
|
43
|
+
caret.setStart(...positionAt(textsOf(block), at, false));
|
|
44
|
+
jodit.s.selectRange(caret);
|
|
45
|
+
}
|
|
46
|
+
function isWordChar(char) {
|
|
47
|
+
return Boolean(char && char !== INVISIBLE_SPACE && /\S/.test(char));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The block's own text nodes, in order, leaving out those of blocks inside
|
|
51
|
+
* it. A line break, an image or another inseparable element ends a word, so
|
|
52
|
+
* it is kept as a one-character piece
|
|
53
|
+
*/
|
|
54
|
+
function textsOf(block) {
|
|
55
|
+
const texts = [];
|
|
56
|
+
Dom.each(block, node => {
|
|
57
|
+
if (Dom.closest(node, Dom.isBlock, block)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (Dom.isText(node) || Dom.isTag(node, INSEPARABLE_TAGS)) {
|
|
61
|
+
texts.push(node);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return texts;
|
|
65
|
+
}
|
|
66
|
+
function lengthOf(piece) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
return Dom.isText(piece) ? ((_b = (_a = piece.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) : 1;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* How many characters of `texts` come before the caret, which can be in a
|
|
72
|
+
* text node or between nodes
|
|
73
|
+
*/
|
|
74
|
+
function textOffset(texts, caret) {
|
|
75
|
+
let at = 0;
|
|
76
|
+
for (const piece of texts) {
|
|
77
|
+
if (piece === caret.startContainer) {
|
|
78
|
+
return at + caret.startOffset;
|
|
79
|
+
}
|
|
80
|
+
const length = lengthOf(piece);
|
|
81
|
+
// This piece ends after the caret, so the caret is before it
|
|
82
|
+
if (caret.comparePoint(piece, Dom.isText(piece) ? length : 0) > 0) {
|
|
83
|
+
return at;
|
|
84
|
+
}
|
|
85
|
+
at += length;
|
|
86
|
+
}
|
|
87
|
+
return at;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The text node and offset of the `at`th character. Where two text nodes
|
|
91
|
+
* meet, `later` picks the start of the second over the end of the first
|
|
92
|
+
*/
|
|
93
|
+
function positionAt(texts, at, later) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
let before = 0;
|
|
96
|
+
let last = null;
|
|
97
|
+
for (const piece of texts) {
|
|
98
|
+
const length = lengthOf(piece);
|
|
99
|
+
if (Dom.isText(piece) &&
|
|
100
|
+
(at < before + length || (!later && at === before + length))) {
|
|
101
|
+
return [piece, at - before];
|
|
102
|
+
}
|
|
103
|
+
if (Dom.isText(piece)) {
|
|
104
|
+
last = piece;
|
|
105
|
+
}
|
|
106
|
+
before += length;
|
|
107
|
+
}
|
|
108
|
+
return [last, (_b = (_a = last === null || last === void 0 ? void 0 : last.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0];
|
|
109
|
+
}
|
|
@@ -16,7 +16,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
16
16
|
import { autobind, throttle } from "../../core/decorators/index.js";
|
|
17
17
|
import { Dom } from "../../core/dom/index.js";
|
|
18
18
|
import { getContainer, pluginSystem } from "../../core/global.js";
|
|
19
|
-
import { css, ctrlKey, dataBind, splitArray } from "../../core/helpers/index.js";
|
|
19
|
+
import { css, ctrlKey, dataBind, getCaptionWrapper, splitArray } from "../../core/helpers/index.js";
|
|
20
20
|
import { Plugin } from "../../core/plugin/index.js";
|
|
21
21
|
import "./config.js";
|
|
22
22
|
var DragState;
|
|
@@ -81,6 +81,7 @@ export class dragAndDropElement extends Plugin {
|
|
|
81
81
|
* Drag start handler
|
|
82
82
|
*/
|
|
83
83
|
onDragStart(event) {
|
|
84
|
+
var _a;
|
|
84
85
|
if (event.type === 'dragstart' && this.draggable) {
|
|
85
86
|
return false;
|
|
86
87
|
}
|
|
@@ -102,7 +103,8 @@ export class dragAndDropElement extends Plugin {
|
|
|
102
103
|
lastTarget.parentElement.lastChild === lastTarget) {
|
|
103
104
|
lastTarget = lastTarget.parentElement;
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
// A captioned image goes with its caption
|
|
107
|
+
this.startDragging((_a = getCaptionWrapper(this.j, lastTarget)) !== null && _a !== void 0 ? _a : lastTarget, event);
|
|
106
108
|
}
|
|
107
109
|
/**
|
|
108
110
|
* Prepare the ghost element and switch to the waiting state.
|