@progress/kendo-editor-common 1.11.9-dev.202412020819 → 1.11.9-develop.1
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/dist/cdn/main.js +1 -1
- package/dist/es/DOMSerializer.js +71 -75
- package/dist/es/align.js +19 -16
- package/dist/es/blockNode.js +76 -78
- package/dist/es/blockquote.js +12 -9
- package/dist/es/cleanFormatting.js +16 -16
- package/dist/es/config/align-rules.js +8 -6
- package/dist/es/config/commands.js +9 -13
- package/dist/es/config/constants.js +9 -7
- package/dist/es/config/indent-rules.js +8 -6
- package/dist/es/config/keymap.js +20 -18
- package/dist/es/config/list-settings.js +7 -6
- package/dist/es/config/schema.js +184 -126
- package/dist/es/find-replace.js +34 -32
- package/dist/es/image.js +10 -7
- package/dist/es/indent.js +47 -44
- package/dist/es/inline-style.js +72 -70
- package/dist/es/link.js +51 -52
- package/dist/es/listConvert.js +37 -34
- package/dist/es/lists.js +83 -82
- package/dist/es/main.js +32 -33
- package/dist/es/mark.js +87 -92
- package/dist/es/paste.js +48 -46
- package/dist/es/plugins/caret-color.js +14 -11
- package/dist/es/plugins/csp-fix.js +23 -23
- package/dist/es/plugins/highlight.js +12 -10
- package/dist/es/plugins/image-resize.js +81 -81
- package/dist/es/plugins/list-markers-styles.js +43 -39
- package/dist/es/plugins/placeholder.js +12 -9
- package/dist/es/plugins/resize-utils.js +11 -9
- package/dist/es/plugins/spaces-fix.js +13 -10
- package/dist/es/plugins/table-resize/column-resize.js +104 -102
- package/dist/es/plugins/table-resize/index.js +10 -7
- package/dist/es/plugins/table-resize/row-resize.js +88 -89
- package/dist/es/plugins/table-resize/table-resize.js +129 -122
- package/dist/es/plugins/table-resize/table-view.js +46 -48
- package/dist/es/plugins/table-resize/utils.js +39 -41
- package/dist/es/source.js +78 -74
- package/dist/es/table.js +64 -66
- package/dist/es/text.js +4 -2
- package/dist/es/utils.js +107 -116
- package/dist/es2015/DOMSerializer.js +20 -17
- package/dist/es2015/align.js +6 -3
- package/dist/es2015/blockNode.js +15 -12
- package/dist/es2015/blockquote.js +5 -2
- package/dist/es2015/cleanFormatting.js +6 -3
- package/dist/es2015/config/align-rules.js +7 -5
- package/dist/es2015/config/commands.js +9 -13
- package/dist/es2015/config/constants.js +9 -7
- package/dist/es2015/config/indent-rules.js +6 -3
- package/dist/es2015/config/keymap.js +10 -7
- package/dist/es2015/config/list-settings.js +5 -3
- package/dist/es2015/config/schema.js +8 -6
- package/dist/es2015/find-replace.js +9 -6
- package/dist/es2015/image.js +5 -2
- package/dist/es2015/indent.js +14 -11
- package/dist/es2015/inline-style.js +9 -6
- package/dist/es2015/link.js +7 -4
- package/dist/es2015/listConvert.js +5 -2
- package/dist/es2015/lists.js +14 -11
- package/dist/es2015/main.js +32 -33
- package/dist/es2015/mark.js +15 -12
- package/dist/es2015/node_modules/tslib/tslib.es6.js +35 -0
- package/dist/es2015/paste.js +14 -11
- package/dist/es2015/plugins/caret-color.js +8 -5
- package/dist/es2015/plugins/csp-fix.js +5 -2
- package/dist/es2015/plugins/highlight.js +6 -3
- package/dist/es2015/plugins/image-resize.js +10 -7
- package/dist/es2015/plugins/list-markers-styles.js +6 -3
- package/dist/es2015/plugins/placeholder.js +5 -2
- package/dist/es2015/plugins/resize-utils.js +11 -9
- package/dist/es2015/plugins/spaces-fix.js +4 -1
- package/dist/es2015/plugins/table-resize/column-resize.js +24 -21
- package/dist/es2015/plugins/table-resize/index.js +9 -6
- package/dist/es2015/plugins/table-resize/row-resize.js +23 -20
- package/dist/es2015/plugins/table-resize/table-resize.js +20 -17
- package/dist/es2015/plugins/table-resize/table-view.js +9 -6
- package/dist/es2015/plugins/table-resize/utils.js +13 -10
- package/dist/es2015/source.js +24 -13
- package/dist/es2015/table.js +18 -15
- package/dist/es2015/text.js +3 -1
- package/dist/es2015/utils.js +22 -25
- package/dist/npm/DOMSerializer.js +73 -78
- package/dist/npm/align.d.ts +7 -4
- package/dist/npm/align.js +22 -21
- package/dist/npm/blockNode.d.ts +14 -15
- package/dist/npm/blockNode.js +91 -95
- package/dist/npm/blockquote.d.ts +5 -2
- package/dist/npm/blockquote.js +16 -15
- package/dist/npm/cleanFormatting.d.ts +6 -3
- package/dist/npm/cleanFormatting.js +17 -19
- package/dist/npm/config/align-rules.d.ts +8 -6
- package/dist/npm/config/align-rules.js +14 -9
- package/dist/npm/config/commands.d.ts +11 -19
- package/dist/npm/config/commands.js +17 -16
- package/dist/npm/config/constants.js +17 -10
- package/dist/npm/config/indent-rules.d.ts +6 -4
- package/dist/npm/config/indent-rules.js +11 -9
- package/dist/npm/config/keymap.d.ts +5 -2
- package/dist/npm/config/keymap.js +30 -30
- package/dist/npm/config/list-settings.js +13 -11
- package/dist/npm/config/schema.d.ts +4 -3
- package/dist/npm/config/schema.js +191 -134
- package/dist/npm/find-replace.d.ts +10 -7
- package/dist/npm/find-replace.js +47 -47
- package/dist/npm/image.d.ts +6 -3
- package/dist/npm/image.js +11 -10
- package/dist/npm/indent.d.ts +12 -9
- package/dist/npm/indent.js +68 -67
- package/dist/npm/inline-style.d.ts +7 -4
- package/dist/npm/inline-style.js +83 -83
- package/dist/npm/link.d.ts +4 -2
- package/dist/npm/link.js +58 -61
- package/dist/npm/listConvert.d.ts +3 -1
- package/dist/npm/listConvert.js +40 -39
- package/dist/npm/lists.d.ts +9 -9
- package/dist/npm/lists.js +94 -95
- package/dist/npm/main.d.ts +34 -33
- package/dist/npm/main.js +388 -198
- package/dist/npm/mark.d.ts +13 -18
- package/dist/npm/mark.js +104 -111
- package/dist/npm/paste.d.ts +12 -9
- package/dist/npm/paste.js +61 -61
- package/dist/npm/plugins/caret-color.d.ts +6 -3
- package/dist/npm/plugins/caret-color.js +21 -19
- package/dist/npm/plugins/csp-fix.d.ts +4 -1
- package/dist/npm/plugins/csp-fix.js +28 -30
- package/dist/npm/plugins/highlight.d.ts +7 -4
- package/dist/npm/plugins/highlight.js +17 -16
- package/dist/npm/plugins/image-resize.d.ts +7 -5
- package/dist/npm/plugins/image-resize.js +96 -97
- package/dist/npm/plugins/list-markers-styles.d.ts +5 -2
- package/dist/npm/plugins/list-markers-styles.js +49 -47
- package/dist/npm/plugins/placeholder.d.ts +4 -1
- package/dist/npm/plugins/placeholder.js +18 -17
- package/dist/npm/plugins/resize-utils.js +14 -12
- package/dist/npm/plugins/spaces-fix.d.ts +4 -1
- package/dist/npm/plugins/spaces-fix.js +19 -18
- package/dist/npm/plugins/table-resize/column-resize.js +117 -117
- package/dist/npm/plugins/table-resize/index.d.ts +5 -2
- package/dist/npm/plugins/table-resize/index.js +16 -15
- package/dist/npm/plugins/table-resize/row-resize.js +98 -101
- package/dist/npm/plugins/table-resize/table-resize.js +144 -139
- package/dist/npm/plugins/table-resize/table-view.js +59 -61
- package/dist/npm/plugins/table-resize/utils.d.ts +7 -17
- package/dist/npm/plugins/table-resize/utils.js +51 -52
- package/dist/npm/source.d.ts +18 -11
- package/dist/npm/source.js +94 -91
- package/dist/npm/table.d.ts +10 -9
- package/dist/npm/table.js +93 -82
- package/dist/npm/text.d.ts +6 -3
- package/dist/npm/text.js +5 -5
- package/dist/npm/types/active-marks.d.ts +4 -1
- package/dist/npm/types/command.d.ts +5 -2
- package/dist/npm/types/dispatchFn.d.ts +4 -1
- package/dist/npm/types/paste-cleanup-settings.d.ts +3 -1
- package/dist/npm/utils.d.ts +13 -32
- package/dist/npm/utils.js +133 -145
- package/package.json +34 -52
- package/dist/cdn/js/kendo-editor-common.js +0 -1
- package/dist/es/types/active-marks.js +0 -1
- package/dist/es/types/command.js +0 -1
- package/dist/es/types/dispatchFn.js +0 -1
- package/dist/es/types/paste-cleanup-settings.js +0 -1
- package/dist/es/types/predicate.js +0 -1
- package/dist/es2015/types/active-marks.js +0 -1
- package/dist/es2015/types/command.js +0 -1
- package/dist/es2015/types/dispatchFn.js +0 -1
- package/dist/es2015/types/paste-cleanup-settings.js +0 -1
- package/dist/es2015/types/predicate.js +0 -1
- package/dist/npm/DOMSerializer.d.ts +0 -35
- package/dist/npm/config/constants.d.ts +0 -7
- package/dist/npm/config/list-settings.d.ts +0 -30
- package/dist/npm/plugins/resize-utils.d.ts +0 -35
- package/dist/npm/plugins/table-resize/column-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/row-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/table-resize.d.ts +0 -18
- package/dist/npm/plugins/table-resize/table-view.d.ts +0 -28
- package/dist/npm/types/active-marks.js +0 -2
- package/dist/npm/types/command.js +0 -2
- package/dist/npm/types/dispatchFn.js +0 -2
- package/dist/npm/types/paste-cleanup-settings.js +0 -2
- package/dist/npm/types/predicate.d.ts +0 -1
- package/dist/npm/types/predicate.js +0 -2
- package/dist/systemjs/kendo-editor-common.js +0 -1
package/dist/npm/mark.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { MarkType, Mark } from 'prosemirror-model';
|
|
2
|
-
import {
|
|
3
|
-
import { InlineFormatOptions } from './config/commands';
|
|
4
|
-
import { Command } from './types/command';
|
|
5
|
-
import { ActiveMarks } from './types/active-marks';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const removeMark: (tr: any, from: any, to: any, mark: any) => any;
|
|
9
|
-
export declare const removeMarks: (marks: any, state: any, dispatch: any, tr: any) => boolean;
|
|
10
|
-
export declare const removeAllMarks: ({ except }?: {
|
|
2
|
+
import { Transaction, EditorState } from 'prosemirror-state';
|
|
3
|
+
import { InlineFormatOptions } from './config/commands.js';
|
|
4
|
+
import { Command } from './types/command.js';
|
|
5
|
+
import { ActiveMarks } from './types/active-marks.js';
|
|
6
|
+
|
|
7
|
+
declare const removeAllMarks: ({ except }?: {
|
|
11
8
|
except?: MarkType | MarkType[];
|
|
12
9
|
}) => Command;
|
|
13
10
|
/**
|
|
@@ -17,28 +14,26 @@ export declare const removeAllMarks: ({ except }?: {
|
|
|
17
14
|
* @example
|
|
18
15
|
* See `removeAllMarks` or `cleanFormatting` function.
|
|
19
16
|
*/
|
|
20
|
-
|
|
17
|
+
declare const cleanMarks: (tr: Transaction, { except }: {
|
|
21
18
|
except?: MarkType[];
|
|
22
19
|
}) => void;
|
|
23
20
|
/**
|
|
24
21
|
* Checks if a mark exists in the selection.
|
|
25
22
|
* Used for checking the state of bold, italic, ... and unlink tools.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
export declare const styleValue: (mark: Mark | undefined, style: {
|
|
29
|
-
name: string;
|
|
30
|
-
value: RegExp;
|
|
31
|
-
}) => string | null;
|
|
24
|
+
declare const hasMark: (state: EditorState, options: InlineFormatOptions) => boolean;
|
|
32
25
|
/**
|
|
33
26
|
* Returns the marks of a specific type for every inline node in the selection.
|
|
34
27
|
*/
|
|
35
|
-
|
|
28
|
+
declare const selectionMarks: (state: EditorState, markType: MarkType) => Array<Mark | undefined>;
|
|
36
29
|
/**
|
|
37
30
|
* Returns the specified mark which wraps the selection.
|
|
38
31
|
* Used by link tools.
|
|
39
32
|
*/
|
|
40
|
-
|
|
33
|
+
declare const getMark: (state: EditorState, markType: MarkType) => Mark | undefined;
|
|
41
34
|
/**
|
|
42
35
|
* **Deprecated.** Use `selectionMarks` function instead.
|
|
43
36
|
*/
|
|
44
|
-
|
|
37
|
+
declare const getActiveMarks: (state: EditorState, markType: MarkType) => ActiveMarks;
|
|
38
|
+
|
|
39
|
+
export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selectionMarks };
|
package/dist/npm/mark.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
doc.nodesBetween($from.pos, $to.pos,
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorTransform = require('prosemirror-transform');
|
|
4
|
+
var prosemirrorModel = require('prosemirror-model');
|
|
5
|
+
var utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
const markApplies = (doc, ranges, type) => {
|
|
8
|
+
const loop = i => {
|
|
9
|
+
const ref = ranges[i];
|
|
10
|
+
const $from = ref.$from;
|
|
11
|
+
const $to = ref.$to;
|
|
12
|
+
let can = $from.depth === 0 ? doc.type.allowsMarkType(type) : false;
|
|
13
|
+
doc.nodesBetween($from.pos, $to.pos, node => {
|
|
14
14
|
if (can) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -20,18 +20,17 @@ var markApplies = function (doc, ranges, type) {
|
|
|
20
20
|
return { v: true };
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
for (
|
|
24
|
-
|
|
23
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
24
|
+
const returned = loop(i);
|
|
25
25
|
if (returned) {
|
|
26
26
|
return returned.v;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
return false;
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if ((empty && !$cursor) || !(0, exports.markApplies)(state.doc, ranges, markType)) {
|
|
31
|
+
const toggleMark = (markType, attrs, tr) => (state, dispatch) => {
|
|
32
|
+
const { empty, $cursor, ranges } = state.selection;
|
|
33
|
+
if ((empty && !$cursor) || !markApplies(state.doc, ranges, markType)) {
|
|
35
34
|
return false;
|
|
36
35
|
}
|
|
37
36
|
if (dispatch) {
|
|
@@ -44,13 +43,13 @@ var toggleMark = function (markType, attrs, tr) { return function (state, dispat
|
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
else {
|
|
47
|
-
|
|
48
|
-
for (
|
|
49
|
-
|
|
46
|
+
let has = false;
|
|
47
|
+
for (let i = 0; !has && i < ranges.length; i++) {
|
|
48
|
+
const { $from, $to } = ranges[i];
|
|
50
49
|
has = state.doc.rangeHasMark($from.pos, $to.pos, markType);
|
|
51
50
|
}
|
|
52
|
-
for (
|
|
53
|
-
|
|
51
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
52
|
+
const { $from, $to } = ranges[i];
|
|
54
53
|
if (has) {
|
|
55
54
|
tr.removeMark($from.pos, $to.pos, markType);
|
|
56
55
|
}
|
|
@@ -62,21 +61,20 @@ var toggleMark = function (markType, attrs, tr) { return function (state, dispat
|
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
return true;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
var removeMark = function (tr, from, to, mark) {
|
|
64
|
+
};
|
|
65
|
+
const removeMark = (tr, from, to, mark) => {
|
|
68
66
|
if (mark === void 0) {
|
|
69
67
|
mark = null;
|
|
70
68
|
}
|
|
71
|
-
|
|
72
|
-
tr.doc.nodesBetween(from, to,
|
|
69
|
+
let matched = [], step = 0;
|
|
70
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
73
71
|
if (!node.isInline) {
|
|
74
72
|
return;
|
|
75
73
|
}
|
|
76
74
|
step++;
|
|
77
|
-
|
|
78
|
-
if (mark instanceof
|
|
79
|
-
|
|
75
|
+
let toRemove = null;
|
|
76
|
+
if (mark instanceof prosemirrorModel.MarkType) {
|
|
77
|
+
const found = mark.isInSet(node.marks);
|
|
80
78
|
if (found) {
|
|
81
79
|
toRemove = [found];
|
|
82
80
|
}
|
|
@@ -90,11 +88,11 @@ var removeMark = function (tr, from, to, mark) {
|
|
|
90
88
|
toRemove = node.marks;
|
|
91
89
|
}
|
|
92
90
|
if (toRemove && toRemove.length) {
|
|
93
|
-
|
|
94
|
-
for (
|
|
95
|
-
|
|
96
|
-
for (
|
|
97
|
-
|
|
91
|
+
const end = Math.min(pos + node.nodeSize, to);
|
|
92
|
+
for (let i = 0; i < toRemove.length; i++) {
|
|
93
|
+
let style = toRemove[i], found$1 = (void 0);
|
|
94
|
+
for (let j = 0; j < matched.length; j++) {
|
|
95
|
+
const m = matched[j];
|
|
98
96
|
if (m.step === step - 1 && style.eq(m.style)) {
|
|
99
97
|
found$1 = m;
|
|
100
98
|
}
|
|
@@ -109,47 +107,38 @@ var removeMark = function (tr, from, to, mark) {
|
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
109
|
});
|
|
112
|
-
matched.forEach(
|
|
110
|
+
matched.forEach((m) => { return tr.step(new prosemirrorTransform.RemoveMarkStep(m.from, m.to, m.style)); });
|
|
113
111
|
return tr;
|
|
114
112
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
var _a = state.selection, $cursor = _a.$cursor, ranges = _a.ranges;
|
|
113
|
+
const removeMarks = (marks, state, dispatch, tr) => {
|
|
114
|
+
const { $cursor, ranges } = state.selection;
|
|
118
115
|
tr = tr || state.tr;
|
|
119
116
|
if ($cursor) {
|
|
120
|
-
marks.forEach(
|
|
117
|
+
marks.forEach(m => {
|
|
121
118
|
if (m.isInSet(state.storedMarks || $cursor.marks())) {
|
|
122
119
|
dispatch(tr.removeStoredMark(m));
|
|
123
120
|
}
|
|
124
121
|
});
|
|
125
122
|
}
|
|
126
123
|
else {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
marks.forEach(
|
|
130
|
-
|
|
124
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
125
|
+
const { $from, $to } = ranges[i];
|
|
126
|
+
marks.forEach(m => {
|
|
127
|
+
removeMark(tr, $from.pos, $to.pos, m);
|
|
131
128
|
});
|
|
132
|
-
};
|
|
133
|
-
for (var i = 0; i < ranges.length; i++) {
|
|
134
|
-
_loop_1(i);
|
|
135
129
|
}
|
|
136
130
|
dispatch(tr.scrollIntoView());
|
|
137
131
|
}
|
|
138
132
|
return true;
|
|
139
133
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (tr.docChanged) {
|
|
148
|
-
dispatch(tr);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
134
|
+
const toArray = (x) => x instanceof Array ? x : [x];
|
|
135
|
+
const removeAllMarks = ({ except = [] } = {}) => (state, dispatch) => {
|
|
136
|
+
const tr = state.tr;
|
|
137
|
+
cleanMarks(tr, { except: toArray(except) });
|
|
138
|
+
if (tr.docChanged) {
|
|
139
|
+
dispatch(tr);
|
|
140
|
+
}
|
|
151
141
|
};
|
|
152
|
-
exports.removeAllMarks = removeAllMarks;
|
|
153
142
|
/**
|
|
154
143
|
* Removes the marks from the selection base on the passed parameter.
|
|
155
144
|
* Requires to dispatch the transaction.
|
|
@@ -157,74 +146,69 @@ exports.removeAllMarks = removeAllMarks;
|
|
|
157
146
|
* @example
|
|
158
147
|
* See `removeAllMarks` or `cleanFormatting` function.
|
|
159
148
|
*/
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var excludedMarkTypes = (except || []).map(function (mt) { return mt.name; });
|
|
149
|
+
const cleanMarks = (tr, { except }) => {
|
|
150
|
+
const { doc, selection } = tr;
|
|
151
|
+
const schema = doc.type.schema;
|
|
152
|
+
const { empty, ranges } = selection;
|
|
153
|
+
const excludedMarkTypes = (except || []).map(mt => mt.name);
|
|
166
154
|
if (!empty) {
|
|
167
|
-
|
|
168
|
-
.map(
|
|
169
|
-
.filter(
|
|
170
|
-
ranges.forEach(
|
|
171
|
-
|
|
172
|
-
marks_1.forEach(function (mark) { return tr.removeMark($from.pos, $to.pos, mark); });
|
|
155
|
+
const marks = Object.keys(schema.marks)
|
|
156
|
+
.map(m => schema.marks[m])
|
|
157
|
+
.filter(mt => excludedMarkTypes.indexOf(mt.name) === -1);
|
|
158
|
+
ranges.forEach(({ $from, $to }) => {
|
|
159
|
+
marks.forEach(mark => tr.removeMark($from.pos, $to.pos, mark));
|
|
173
160
|
});
|
|
174
161
|
}
|
|
175
162
|
};
|
|
176
|
-
exports.cleanMarks = cleanMarks;
|
|
177
163
|
/**
|
|
178
164
|
* Checks if a mark exists in the selection.
|
|
179
165
|
* Used for checking the state of bold, italic, ... and unlink tools.
|
|
180
166
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
167
|
+
const hasMark = (state, options) => {
|
|
168
|
+
const marks = state.schema.marks;
|
|
169
|
+
const altMarks = (options.altMarks || []).filter(m => marks[m]);
|
|
170
|
+
const altStyle = options.altStyle;
|
|
171
|
+
const { from, $from, to, empty } = state.selection;
|
|
172
|
+
const type = marks[options.mark];
|
|
173
|
+
const doc = state.doc;
|
|
174
|
+
let result = false;
|
|
175
|
+
let currMarks;
|
|
190
176
|
if (empty) {
|
|
191
177
|
currMarks = state.storedMarks || $from.marks();
|
|
192
|
-
result = (type && type.isInSet(currMarks)) || altMarks.some(
|
|
178
|
+
result = (type && type.isInSet(currMarks)) || altMarks.some(m => marks[m].isInSet(currMarks));
|
|
193
179
|
}
|
|
194
180
|
else {
|
|
195
|
-
result = (type && doc.rangeHasMark(from, to, type)) || altMarks.some(
|
|
181
|
+
result = (type && doc.rangeHasMark(from, to, type)) || altMarks.some(m => doc.rangeHasMark(from, to, marks[m]));
|
|
196
182
|
}
|
|
197
183
|
if (!result && altStyle && marks.style) {
|
|
198
|
-
return
|
|
199
|
-
.some(
|
|
184
|
+
return selectionMarks(state, marks.style)
|
|
185
|
+
.some(mark => styleValue(mark, altStyle) !== null);
|
|
200
186
|
}
|
|
201
187
|
return Boolean(result);
|
|
202
188
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return styles[name_1];
|
|
189
|
+
const styleValue = (mark, style) => {
|
|
190
|
+
const styleText = (mark && mark.attrs.style) || '';
|
|
191
|
+
const styles = utils.parseStyle(styleText);
|
|
192
|
+
const styleNames = Object.keys(styles);
|
|
193
|
+
for (let i = 0; i < styleNames.length; i++) {
|
|
194
|
+
const name = styleNames[i];
|
|
195
|
+
if (name.toLowerCase() === style.name && style.value.test(styles[name])) {
|
|
196
|
+
return styles[name];
|
|
212
197
|
}
|
|
213
198
|
}
|
|
214
199
|
return null;
|
|
215
200
|
};
|
|
216
|
-
exports.styleValue = styleValue;
|
|
217
201
|
/**
|
|
218
202
|
* Returns the marks of a specific type for every inline node in the selection.
|
|
219
203
|
*/
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
204
|
+
const selectionMarks = (state, markType) => {
|
|
205
|
+
const { from, $from, to, empty } = state.selection;
|
|
206
|
+
const marks = [];
|
|
223
207
|
if (empty) {
|
|
224
208
|
marks.push(markType.isInSet(state.storedMarks || $from.marks()));
|
|
225
209
|
}
|
|
226
210
|
else {
|
|
227
|
-
state.doc.nodesBetween(from, to,
|
|
211
|
+
state.doc.nodesBetween(from, to, node => {
|
|
228
212
|
if (node.isInline) {
|
|
229
213
|
marks.push(markType.isInSet(node.marks));
|
|
230
214
|
}
|
|
@@ -232,27 +216,36 @@ var selectionMarks = function (state, markType) {
|
|
|
232
216
|
}
|
|
233
217
|
return marks;
|
|
234
218
|
};
|
|
235
|
-
exports.selectionMarks = selectionMarks;
|
|
236
219
|
/**
|
|
237
220
|
* Returns the specified mark which wraps the selection.
|
|
238
221
|
* Used by link tools.
|
|
239
222
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
223
|
+
const getMark = (state, markType) => {
|
|
224
|
+
const marks = selectionMarks(state, markType);
|
|
225
|
+
const filtered = marks.filter(m => Boolean(m));
|
|
243
226
|
return marks.length === filtered.length ? marks[0] : undefined;
|
|
244
227
|
};
|
|
245
|
-
exports.getMark = getMark;
|
|
246
228
|
/**
|
|
247
229
|
* **Deprecated.** Use `selectionMarks` function instead.
|
|
248
230
|
*/
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
231
|
+
const getActiveMarks = (state, markType) => {
|
|
232
|
+
const marks = selectionMarks(state, markType);
|
|
233
|
+
const filtered = marks.filter(m => Boolean(m));
|
|
234
|
+
const hasNodesWithoutMarks = marks.length !== filtered.length;
|
|
253
235
|
return {
|
|
254
|
-
hasNodesWithoutMarks
|
|
236
|
+
hasNodesWithoutMarks,
|
|
255
237
|
marks: filtered
|
|
256
238
|
};
|
|
257
239
|
};
|
|
240
|
+
|
|
241
|
+
exports.cleanMarks = cleanMarks;
|
|
258
242
|
exports.getActiveMarks = getActiveMarks;
|
|
243
|
+
exports.getMark = getMark;
|
|
244
|
+
exports.hasMark = hasMark;
|
|
245
|
+
exports.markApplies = markApplies;
|
|
246
|
+
exports.removeAllMarks = removeAllMarks;
|
|
247
|
+
exports.removeMark = removeMark;
|
|
248
|
+
exports.removeMarks = removeMarks;
|
|
249
|
+
exports.selectionMarks = selectionMarks;
|
|
250
|
+
exports.styleValue = styleValue;
|
|
251
|
+
exports.toggleMark = toggleMark;
|
package/dist/npm/paste.d.ts
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { PasteCleanupSettings } from './types/paste-cleanup-settings';
|
|
1
|
+
import { PasteCleanupSettings } from './types/paste-cleanup-settings.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
declare const sanitize: (html: string) => string;
|
|
6
7
|
/**
|
|
7
8
|
* Removes comments in HTML.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
declare const removeComments: (html: string) => string;
|
|
10
11
|
/**
|
|
11
12
|
* Removes the specified tag(s).
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare const removeTag: (html: string, tagPattern: string) => string;
|
|
14
15
|
/**
|
|
15
16
|
* Removes the passed attribute.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
declare const removeAttribute: (attr: Attr) => void;
|
|
18
19
|
/**
|
|
19
20
|
* Remove the attribute if its value matches /^Mso/ regex.
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
declare const sanitizeClassAttr: (attr: Attr) => void;
|
|
22
23
|
/**
|
|
23
24
|
* Removes invalid HTML styles.
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
declare const sanitizeStyleAttr: (attr: Attr) => void;
|
|
26
27
|
/**
|
|
27
28
|
* Cleans the HTML based on passed settings.
|
|
28
29
|
* Before using it, clean the HTML with the `sanitize` function.
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
declare const pasteCleanup: (html: string, settings: PasteCleanupSettings) => string;
|
|
31
32
|
/**
|
|
32
33
|
* If the input HTML contains images with 'src' pointing to local file system (it happens when pasting images and text from MS Word),
|
|
33
34
|
* the function will extract the image sources form the RTF and replace the image 'src' with extracted base64 format data in `html` string.
|
|
@@ -36,4 +37,6 @@ export declare const pasteCleanup: (html: string, settings: PasteCleanupSettings
|
|
|
36
37
|
* @param clipboardData - The paste event clipboardData object (event.clipboardData).
|
|
37
38
|
* @returns - The html with the replaced images sources.
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
declare const replaceImageSourcesFromRtf: (html: string, clipboardData: DataTransfer) => string;
|
|
41
|
+
|
|
42
|
+
export { pasteCleanup, removeAttribute, removeComments, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr };
|