@progress/kendo-editor-common 1.12.2-develop.5 → 1.12.2-develop.7
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/js/kendo-editor-common.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/DOMSerializer.js +6 -7
- package/dist/es/align.js +3 -6
- package/dist/es/blockNode.js +11 -14
- package/dist/es/blockquote.js +2 -5
- package/dist/es/cleanFormatting.js +3 -6
- package/dist/es/config/align-rules.js +5 -7
- package/dist/es/config/commands.js +13 -9
- package/dist/es/config/constants.js +7 -9
- package/dist/es/config/indent-rules.js +3 -6
- package/dist/es/config/keymap.js +7 -10
- package/dist/es/config/list-settings.js +3 -5
- package/dist/es/config/schema.js +4 -6
- package/dist/es/find-replace.js +8 -10
- package/dist/es/flatten-spans.js +2 -5
- package/dist/es/image.js +2 -5
- package/dist/es/indent.js +11 -14
- package/dist/es/inline-style.js +10 -12
- package/dist/es/link.js +5 -8
- package/dist/es/listConvert.js +8 -9
- package/dist/es/lists.js +12 -15
- package/dist/es/main.js +34 -33
- package/dist/es/mark.js +16 -17
- package/dist/es/paste.js +10 -13
- package/dist/es/plugins/caret-color.js +5 -8
- package/dist/es/plugins/csp-fix.js +2 -5
- package/dist/es/plugins/highlight.js +3 -6
- package/dist/es/plugins/image-resize.js +8 -11
- package/dist/es/plugins/list-markers-styles.js +2 -5
- package/dist/es/plugins/placeholder.js +2 -5
- package/dist/es/plugins/resize-utils.js +2 -4
- package/dist/es/plugins/spaces-fix.js +1 -4
- package/dist/es/plugins/table-resize/column-resize.js +21 -24
- package/dist/es/plugins/table-resize/index.js +6 -9
- package/dist/es/plugins/table-resize/row-resize.js +23 -24
- package/dist/es/plugins/table-resize/table-resize.js +17 -20
- package/dist/es/plugins/table-resize/table-view.js +6 -9
- package/dist/es/plugins/table-resize/utils.js +10 -13
- package/dist/es/source.js +15 -18
- package/dist/es/table.js +15 -18
- package/dist/es/text.js +1 -3
- package/dist/es/types/active-marks.js +1 -0
- package/dist/es/types/command.js +1 -0
- package/dist/es/types/dispatchFn.js +1 -0
- package/dist/es/types/paste-cleanup-settings.js +1 -0
- package/dist/es/types/predicate.js +1 -0
- package/dist/es/utils.js +18 -21
- package/dist/npm/DOMSerializer.d.ts +35 -0
- package/dist/npm/DOMSerializer.js +10 -9
- package/dist/npm/align.d.ts +4 -7
- package/dist/npm/align.js +9 -10
- package/dist/npm/blockNode.d.ts +15 -12
- package/dist/npm/blockNode.js +28 -29
- package/dist/npm/blockquote.d.ts +2 -5
- package/dist/npm/blockquote.js +6 -7
- package/dist/npm/cleanFormatting.d.ts +3 -6
- package/dist/npm/cleanFormatting.js +7 -8
- package/dist/npm/config/align-rules.d.ts +6 -8
- package/dist/npm/config/align-rules.js +8 -13
- package/dist/npm/config/commands.d.ts +19 -11
- package/dist/npm/config/commands.js +16 -17
- package/dist/npm/config/constants.d.ts +7 -0
- package/dist/npm/config/constants.js +10 -17
- package/dist/npm/config/indent-rules.d.ts +4 -6
- package/dist/npm/config/indent-rules.js +8 -11
- package/dist/npm/config/keymap.d.ts +2 -5
- package/dist/npm/config/keymap.js +21 -22
- package/dist/npm/config/list-settings.d.ts +30 -0
- package/dist/npm/config/list-settings.js +10 -13
- package/dist/npm/config/schema.d.ts +2 -3
- package/dist/npm/config/schema.js +19 -20
- package/dist/npm/find-replace.d.ts +7 -10
- package/dist/npm/find-replace.js +20 -20
- package/dist/npm/flatten-spans.d.ts +1 -3
- package/dist/npm/flatten-spans.js +6 -7
- package/dist/npm/image.d.ts +3 -6
- package/dist/npm/image.js +5 -6
- package/dist/npm/indent.d.ts +9 -12
- package/dist/npm/indent.js +37 -38
- package/dist/npm/inline-style.d.ts +4 -7
- package/dist/npm/inline-style.js +28 -28
- package/dist/npm/link.d.ts +2 -4
- package/dist/npm/link.js +21 -22
- package/dist/npm/listConvert.d.ts +1 -3
- package/dist/npm/listConvert.js +13 -12
- package/dist/npm/lists.d.ts +8 -8
- package/dist/npm/lists.js +26 -27
- package/dist/npm/main.d.ts +34 -35
- package/dist/npm/main.js +214 -391
- package/dist/npm/mark.d.ts +17 -12
- package/dist/npm/mark.js +30 -29
- package/dist/npm/paste.d.ts +8 -11
- package/dist/npm/paste.js +19 -20
- package/dist/npm/plugins/caret-color.d.ts +2 -5
- package/dist/npm/plugins/caret-color.js +15 -17
- package/dist/npm/plugins/csp-fix.d.ts +1 -4
- package/dist/npm/plugins/csp-fix.js +8 -9
- package/dist/npm/plugins/highlight.d.ts +4 -7
- package/dist/npm/plugins/highlight.js +11 -13
- package/dist/npm/plugins/image-resize.d.ts +5 -7
- package/dist/npm/plugins/image-resize.js +35 -37
- package/dist/npm/plugins/list-markers-styles.d.ts +2 -5
- package/dist/npm/plugins/list-markers-styles.js +14 -16
- package/dist/npm/plugins/placeholder.d.ts +1 -4
- package/dist/npm/plugins/placeholder.js +10 -12
- package/dist/npm/plugins/resize-utils.d.ts +35 -0
- package/dist/npm/plugins/resize-utils.js +5 -7
- package/dist/npm/plugins/spaces-fix.d.ts +1 -4
- package/dist/npm/plugins/spaces-fix.js +9 -10
- package/dist/npm/plugins/table-resize/column-resize.d.ts +2 -0
- package/dist/npm/plugins/table-resize/column-resize.js +44 -46
- package/dist/npm/plugins/table-resize/index.d.ts +2 -5
- package/dist/npm/plugins/table-resize/index.js +13 -14
- package/dist/npm/plugins/table-resize/row-resize.d.ts +2 -0
- package/dist/npm/plugins/table-resize/row-resize.js +40 -40
- package/dist/npm/plugins/table-resize/table-resize.d.ts +18 -0
- package/dist/npm/plugins/table-resize/table-resize.js +51 -52
- package/dist/npm/plugins/table-resize/table-view.d.ts +28 -0
- package/dist/npm/plugins/table-resize/table-view.js +23 -24
- package/dist/npm/plugins/table-resize/utils.d.ts +17 -7
- package/dist/npm/plugins/table-resize/utils.js +24 -28
- package/dist/npm/source.d.ts +13 -16
- package/dist/npm/source.js +35 -36
- package/dist/npm/table.d.ts +9 -10
- package/dist/npm/table.js +33 -49
- package/dist/npm/text.d.ts +3 -6
- package/dist/npm/text.js +3 -3
- package/dist/npm/types/active-marks.d.ts +1 -4
- package/dist/npm/types/active-marks.js +2 -0
- package/dist/npm/types/command.d.ts +2 -5
- package/dist/npm/types/command.js +2 -0
- package/dist/npm/types/dispatchFn.d.ts +1 -4
- package/dist/npm/types/dispatchFn.js +2 -0
- package/dist/npm/types/paste-cleanup-settings.d.ts +1 -3
- package/dist/npm/types/paste-cleanup-settings.js +2 -0
- package/dist/npm/types/predicate.d.ts +1 -0
- package/dist/npm/types/predicate.js +2 -0
- package/dist/npm/utils.d.ts +33 -14
- package/dist/npm/utils.js +38 -39
- package/package.json +4 -51
- package/dist/es2015/DOMSerializer.js +0 -184
- package/dist/es2015/align.js +0 -43
- package/dist/es2015/blockNode.js +0 -180
- package/dist/es2015/blockquote.js +0 -26
- package/dist/es2015/cleanFormatting.js +0 -20
- package/dist/es2015/config/align-rules.js +0 -30
- package/dist/es2015/config/commands.js +0 -50
- package/dist/es2015/config/constants.js +0 -9
- package/dist/es2015/config/indent-rules.js +0 -42
- package/dist/es2015/config/keymap.js +0 -51
- package/dist/es2015/config/list-settings.js +0 -21
- package/dist/es2015/config/schema.js +0 -314
- package/dist/es2015/find-replace.js +0 -122
- package/dist/es2015/flatten-spans.js +0 -112
- package/dist/es2015/image.js +0 -10
- package/dist/es2015/indent.js +0 -105
- package/dist/es2015/inline-style.js +0 -177
- package/dist/es2015/link.js +0 -105
- package/dist/es2015/listConvert.js +0 -184
- package/dist/es2015/lists.js +0 -266
- package/dist/es2015/main.js +0 -44
- package/dist/es2015/mark.js +0 -239
- package/dist/es2015/node_modules/tslib/tslib.es6.js +0 -35
- package/dist/es2015/paste.js +0 -162
- package/dist/es2015/plugins/caret-color.js +0 -34
- package/dist/es2015/plugins/csp-fix.js +0 -51
- package/dist/es2015/plugins/highlight.js +0 -23
- package/dist/es2015/plugins/image-resize.js +0 -225
- package/dist/es2015/plugins/list-markers-styles.js +0 -104
- package/dist/es2015/plugins/placeholder.js +0 -27
- package/dist/es2015/plugins/resize-utils.js +0 -13
- package/dist/es2015/plugins/spaces-fix.js +0 -46
- package/dist/es2015/plugins/table-resize/column-resize.js +0 -267
- package/dist/es2015/plugins/table-resize/index.js +0 -12
- package/dist/es2015/plugins/table-resize/row-resize.js +0 -234
- package/dist/es2015/plugins/table-resize/table-resize.js +0 -278
- package/dist/es2015/plugins/table-resize/table-view.js +0 -128
- package/dist/es2015/plugins/table-resize/utils.js +0 -93
- package/dist/es2015/source.js +0 -251
- package/dist/es2015/table.js +0 -132
- package/dist/es2015/text.js +0 -5
- package/dist/es2015/utils.js +0 -289
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextSelection, Selection, Transaction, EditorState } from 'prosemirror-state';
|
|
2
2
|
import { Node } from 'prosemirror-model';
|
|
3
|
-
|
|
4
|
-
interface SearchOptions {
|
|
3
|
+
export interface SearchOptions {
|
|
5
4
|
text: string;
|
|
6
5
|
backward?: boolean;
|
|
7
6
|
matchCyclic?: boolean;
|
|
@@ -9,16 +8,14 @@ interface SearchOptions {
|
|
|
9
8
|
matchWord?: boolean | ((exec: RegExpExecArray) => boolean);
|
|
10
9
|
useRegExp?: boolean;
|
|
11
10
|
}
|
|
12
|
-
declare const findAt: (doc: Node, searchOptions: SearchOptions, start: number, end: number, exit: (result: TextSelection[]) => boolean) => TextSelection[];
|
|
13
|
-
declare const find: (state: EditorState | {
|
|
11
|
+
export declare const findAt: (doc: Node, searchOptions: SearchOptions, start: number, end: number, exit: (result: TextSelection[]) => boolean) => TextSelection[];
|
|
12
|
+
export declare const find: (state: EditorState | {
|
|
14
13
|
doc: Node;
|
|
15
14
|
selection: Selection;
|
|
16
15
|
}, searchOptions: SearchOptions) => TextSelection | null;
|
|
17
|
-
declare const findAll: (doc: Node, searchOptions: SearchOptions) => TextSelection[];
|
|
18
|
-
declare const replace: (selection: Selection | {
|
|
16
|
+
export declare const findAll: (doc: Node, searchOptions: SearchOptions) => TextSelection[];
|
|
17
|
+
export declare const replace: (selection: Selection | {
|
|
19
18
|
from: number;
|
|
20
19
|
to: number;
|
|
21
20
|
}, text: string, transaction: Transaction) => Transaction;
|
|
22
|
-
declare const replaceAll: (state: EditorState, replaceText: string, searchOptions: SearchOptions) => Transaction | null;
|
|
23
|
-
|
|
24
|
-
export { type SearchOptions, find, findAll, findAt, replace, replaceAll };
|
|
21
|
+
export declare const replaceAll: (state: EditorState, replaceText: string, searchOptions: SearchOptions) => Transaction | null;
|
package/dist/npm/find-replace.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceAll = exports.replace = exports.findAll = exports.find = exports.findAt = void 0;
|
|
4
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
5
5
|
const findAt = (doc, searchOptions, start, end, exit) => {
|
|
6
|
-
|
|
6
|
+
const result = [];
|
|
7
|
+
let exec, text, from, to, childText, nextSibling;
|
|
7
8
|
const nodes = [];
|
|
8
9
|
const { matchCase, matchWord, useRegExp } = searchOptions;
|
|
9
10
|
let searchText = searchOptions.text;
|
|
@@ -42,7 +43,7 @@ const findAt = (doc, searchOptions, start, end, exit) => {
|
|
|
42
43
|
from = nodes[0].start + exec.index;
|
|
43
44
|
to = from + exec[0].length;
|
|
44
45
|
if (start <= from && end >= to && shouldMatchWord(exec, matchWord)) {
|
|
45
|
-
result.push(
|
|
46
|
+
result.push(prosemirror_state_1.TextSelection.create(doc, from, to));
|
|
46
47
|
}
|
|
47
48
|
if (exit(result)) {
|
|
48
49
|
break;
|
|
@@ -58,36 +59,40 @@ const findAt = (doc, searchOptions, start, end, exit) => {
|
|
|
58
59
|
});
|
|
59
60
|
return result;
|
|
60
61
|
};
|
|
62
|
+
exports.findAt = findAt;
|
|
61
63
|
const find = (state, searchOptions) => {
|
|
62
64
|
const { backward, matchCyclic, ...options } = searchOptions;
|
|
63
65
|
const exit = backward ? () => false : r => r.length > 0;
|
|
64
66
|
const { doc, selection } = state;
|
|
65
67
|
let result = [];
|
|
66
68
|
if (backward) {
|
|
67
|
-
result = findAt(doc, options, 0, selection.from, exit);
|
|
69
|
+
result = (0, exports.findAt)(doc, options, 0, selection.from, exit);
|
|
68
70
|
if (!result.length && matchCyclic) {
|
|
69
|
-
result = findAt(doc, options, selection.from, doc.content.size, exit);
|
|
71
|
+
result = (0, exports.findAt)(doc, options, selection.from, doc.content.size, exit);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
else {
|
|
73
|
-
result = findAt(doc, options, selection.to, doc.content.size, exit);
|
|
75
|
+
result = (0, exports.findAt)(doc, options, selection.to, doc.content.size, exit);
|
|
74
76
|
if (!result.length && matchCyclic) {
|
|
75
|
-
result = findAt(doc, options, 0, selection.to, exit);
|
|
77
|
+
result = (0, exports.findAt)(doc, options, 0, selection.to, exit);
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
return result.length ? result[result.length - 1] : null;
|
|
79
81
|
};
|
|
82
|
+
exports.find = find;
|
|
80
83
|
const findAll = (doc, searchOptions) => {
|
|
81
|
-
return findAt(doc, searchOptions, 0, doc.content.size, () => false);
|
|
84
|
+
return (0, exports.findAt)(doc, searchOptions, 0, doc.content.size, () => false);
|
|
82
85
|
};
|
|
86
|
+
exports.findAll = findAll;
|
|
83
87
|
const replace = (selection, text, transaction) => {
|
|
84
88
|
const { from, to } = selection;
|
|
85
89
|
transaction.insertText(text, from, to)
|
|
86
|
-
.setSelection(
|
|
90
|
+
.setSelection(prosemirror_state_1.TextSelection.create(transaction.doc, from, from + text.length));
|
|
87
91
|
return transaction;
|
|
88
92
|
};
|
|
93
|
+
exports.replace = replace;
|
|
89
94
|
const replaceAll = (state, replaceText, searchOptions) => {
|
|
90
|
-
const result = findAll(state.doc, searchOptions);
|
|
95
|
+
const result = (0, exports.findAll)(state.doc, searchOptions);
|
|
91
96
|
if (result.length === 0) {
|
|
92
97
|
return null;
|
|
93
98
|
}
|
|
@@ -97,7 +102,8 @@ const replaceAll = (state, replaceText, searchOptions) => {
|
|
|
97
102
|
}
|
|
98
103
|
return transaction;
|
|
99
104
|
};
|
|
100
|
-
|
|
105
|
+
exports.replaceAll = replaceAll;
|
|
106
|
+
const notLetter = /^[\s0-9~`!@#$%^&*()_\-=+\\|[\]{};:'"?/.,<>]?$/;
|
|
101
107
|
const shouldMatchWord = (exec, matchWord) => {
|
|
102
108
|
if (!matchWord) {
|
|
103
109
|
return true;
|
|
@@ -119,9 +125,3 @@ const createRegExp = (inputString, flags) => {
|
|
|
119
125
|
.replace(/\s/g, '\\s');
|
|
120
126
|
return new RegExp(escaped, flags);
|
|
121
127
|
};
|
|
122
|
-
|
|
123
|
-
exports.find = find;
|
|
124
|
-
exports.findAll = findAll;
|
|
125
|
-
exports.findAt = findAt;
|
|
126
|
-
exports.replace = replace;
|
|
127
|
-
exports.replaceAll = replaceAll;
|
|
@@ -5,6 +5,4 @@
|
|
|
5
5
|
* @param content - The HTML content to normalize.
|
|
6
6
|
* @returns The normalized HTML content with flattened <span> elements.
|
|
7
7
|
*/
|
|
8
|
-
declare const flattenNestedSpans: (content: string) => string;
|
|
9
|
-
|
|
10
|
-
export { flattenNestedSpans };
|
|
8
|
+
export declare const flattenNestedSpans: (content: string) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenNestedSpans = void 0;
|
|
4
|
+
const source_1 = require("./source");
|
|
5
5
|
class DomTreeExtractor {
|
|
6
6
|
constructor(top) {
|
|
7
7
|
this.extractBefore = (edgeNode) => {
|
|
@@ -64,7 +64,7 @@ const isEmptySpan = (fragment) => {
|
|
|
64
64
|
* @returns The normalized HTML content with flattened <span> elements.
|
|
65
65
|
*/
|
|
66
66
|
const flattenNestedSpans = (content) => {
|
|
67
|
-
const dom =
|
|
67
|
+
const dom = (0, source_1.htmlToFragment)(content);
|
|
68
68
|
let innerSpan = getInnerSpan(dom);
|
|
69
69
|
while (innerSpan) {
|
|
70
70
|
const parentSpan = innerSpan.parentNode.closest('span');
|
|
@@ -108,7 +108,6 @@ const flattenNestedSpans = (content) => {
|
|
|
108
108
|
}
|
|
109
109
|
innerSpan = getInnerSpan(dom);
|
|
110
110
|
}
|
|
111
|
-
return
|
|
111
|
+
return (0, source_1.fragmentToHtml)(dom);
|
|
112
112
|
};
|
|
113
|
-
|
|
114
113
|
exports.flattenNestedSpans = flattenNestedSpans;
|
package/dist/npm/image.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { Command } from './types/command
|
|
2
|
-
|
|
3
|
-
interface ImageData {
|
|
1
|
+
import { Command } from './types/command';
|
|
2
|
+
export interface ImageData {
|
|
4
3
|
src: string;
|
|
5
4
|
alt?: string;
|
|
6
5
|
width?: string;
|
|
7
6
|
height?: string;
|
|
8
7
|
}
|
|
9
|
-
declare const insertImage: (attrs: ImageData) => Command;
|
|
10
|
-
|
|
11
|
-
export { type ImageData, insertImage };
|
|
8
|
+
export declare const insertImage: (attrs: ImageData) => Command;
|
package/dist/npm/image.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertImage = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
5
|
const insertImage = (attrs) => (state, dispatch) => {
|
|
6
6
|
const { image } = state.schema.nodes;
|
|
7
7
|
const commandName = 'insertImage';
|
|
8
8
|
const newImage = image.createAndFill(attrs);
|
|
9
|
-
|
|
9
|
+
(0, utils_1.insertNode)(newImage)(state, tr => dispatch(tr.setMeta('commandName', commandName).setMeta('args', attrs)));
|
|
10
10
|
};
|
|
11
|
-
|
|
12
11
|
exports.insertImage = insertImage;
|
package/dist/npm/indent.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { EditorState } from 'prosemirror-state';
|
|
2
2
|
import { NodeType } from 'prosemirror-model';
|
|
3
|
-
import {
|
|
4
|
-
import { Command } from './types/command
|
|
5
|
-
|
|
3
|
+
import { IndentRule, IndentationRules } from './config/indent-rules';
|
|
4
|
+
import { Command } from './types/command';
|
|
6
5
|
/**
|
|
7
6
|
* Indenting block elements in the selection.
|
|
8
7
|
*
|
|
9
8
|
* @returns {boolean} - Returns true if any indentation is applied.
|
|
10
9
|
*/
|
|
11
|
-
declare const indentBlocks: (actions: Array<IndentRule>, command?: string, dir?: string) => Command;
|
|
12
|
-
declare const isIndented: (state: EditorState, rules: Array<IndentRule>, dir?: string) => boolean;
|
|
13
|
-
declare const canIndentAsListItem: (state: EditorState, nodeType: NodeType) => boolean;
|
|
14
|
-
declare const canOutdentAsListItem: (state: EditorState, rules: IndentationRules) => boolean;
|
|
15
|
-
declare const canBeIndented: (state: EditorState, rules: IndentationRules) => boolean;
|
|
16
|
-
declare const indent: Command;
|
|
17
|
-
declare const outdent: Command;
|
|
18
|
-
|
|
19
|
-
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent };
|
|
10
|
+
export declare const indentBlocks: (actions: Array<IndentRule>, command?: string, dir?: string) => Command;
|
|
11
|
+
export declare const isIndented: (state: EditorState, rules: Array<IndentRule>, dir?: string) => boolean;
|
|
12
|
+
export declare const canIndentAsListItem: (state: EditorState, nodeType: NodeType) => boolean;
|
|
13
|
+
export declare const canOutdentAsListItem: (state: EditorState, rules: IndentationRules) => boolean;
|
|
14
|
+
export declare const canBeIndented: (state: EditorState, rules: IndentationRules) => boolean;
|
|
15
|
+
export declare const indent: Command;
|
|
16
|
+
export declare const outdent: Command;
|
package/dist/npm/indent.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.outdent = exports.indent = exports.canBeIndented = exports.canOutdentAsListItem = exports.canIndentAsListItem = exports.isIndented = exports.indentBlocks = void 0;
|
|
4
|
+
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
5
|
+
const indent_rules_1 = require("./config/indent-rules");
|
|
6
|
+
const blockNode_1 = require("./blockNode");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
const blockquote_1 = require("./blockquote");
|
|
9
9
|
/**
|
|
10
10
|
* Indenting block elements in the selection.
|
|
11
11
|
*
|
|
12
12
|
* @returns {boolean} - Returns true if any indentation is applied.
|
|
13
13
|
*/
|
|
14
14
|
const indentBlocks = (actions, command, dir) => (state, dispatch) => {
|
|
15
|
-
const blocks =
|
|
15
|
+
const blocks = (0, blockNode_1.blockNodes)(state);
|
|
16
16
|
const tr = state.tr;
|
|
17
17
|
tr.setMeta('commandName', command);
|
|
18
18
|
blocks.forEach(node => {
|
|
@@ -34,10 +34,10 @@ const indentBlocks = (actions, command, dir) => (state, dispatch) => {
|
|
|
34
34
|
newStyle.value = `${newMargin}${newMargin ? action.unit : ''}`;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
newAttrs =
|
|
37
|
+
newAttrs = (0, blockNode_1.addStyles)(node, [newStyle]);
|
|
38
38
|
}
|
|
39
39
|
if (newAttrs) {
|
|
40
|
-
|
|
40
|
+
(0, blockNode_1.changeTextBlock)(tr, node, node.type, newAttrs);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
});
|
|
@@ -47,8 +47,9 @@ const indentBlocks = (actions, command, dir) => (state, dispatch) => {
|
|
|
47
47
|
}
|
|
48
48
|
return result;
|
|
49
49
|
};
|
|
50
|
+
exports.indentBlocks = indentBlocks;
|
|
50
51
|
const isIndented = (state, rules, dir) => {
|
|
51
|
-
const blocks =
|
|
52
|
+
const blocks = (0, blockNode_1.blockNodes)(state);
|
|
52
53
|
let result = false;
|
|
53
54
|
blocks.forEach(node => {
|
|
54
55
|
if (!result && node.type.isTextblock && node.attrs.style) {
|
|
@@ -62,52 +63,50 @@ const isIndented = (state, rules, dir) => {
|
|
|
62
63
|
});
|
|
63
64
|
return result;
|
|
64
65
|
};
|
|
66
|
+
exports.isIndented = isIndented;
|
|
65
67
|
const canIndentAsListItem = (state, nodeType) => {
|
|
66
|
-
return
|
|
68
|
+
return (0, prosemirror_schema_list_1.sinkListItem)(nodeType)(state);
|
|
67
69
|
};
|
|
70
|
+
exports.canIndentAsListItem = canIndentAsListItem;
|
|
68
71
|
const canOutdentAsListItem = (state, rules) => {
|
|
69
72
|
const listItem = state.schema.nodes[rules.listsTypes.listItem];
|
|
70
73
|
const orderedList = state.schema.nodes[rules.listsTypes.orderedList];
|
|
71
74
|
const bulletList = state.schema.nodes[rules.listsTypes.bulletList];
|
|
72
|
-
const isNestedInOL = !!
|
|
73
|
-
const isNestedInUL = !!
|
|
74
|
-
return (isNestedInOL || isNestedInUL) &&
|
|
75
|
+
const isNestedInOL = !!(0, utils_1.findNthParentNodeOfType)(orderedList, 2)(state.selection);
|
|
76
|
+
const isNestedInUL = !!(0, utils_1.findNthParentNodeOfType)(bulletList, 2)(state.selection);
|
|
77
|
+
return (isNestedInOL || isNestedInUL) && (0, prosemirror_schema_list_1.liftListItem)(listItem)(state);
|
|
75
78
|
};
|
|
79
|
+
exports.canOutdentAsListItem = canOutdentAsListItem;
|
|
76
80
|
const canBeIndented = (state, rules) => {
|
|
77
81
|
const nodes = state.schema.nodes;
|
|
78
|
-
const listItem = nodes[
|
|
79
|
-
return ((isIndented(state, rules.nodes) ||
|
|
80
|
-
!
|
|
82
|
+
const listItem = nodes[indent_rules_1.indentRules.listsTypes.listItem];
|
|
83
|
+
return (((0, exports.isIndented)(state, rules.nodes) || indent_rules_1.indentRules.nodes.some(rule => nodes[rule.node] && (0, blockNode_1.hasNode)(state, nodes[rule.node]))) &&
|
|
84
|
+
!(0, blockNode_1.hasNode)(state, listItem));
|
|
81
85
|
};
|
|
86
|
+
exports.canBeIndented = canBeIndented;
|
|
82
87
|
const indent = (state, dispatch) => {
|
|
83
|
-
const listItem = state.schema.nodes[
|
|
84
|
-
const isIndentableBlock = canBeIndented(state,
|
|
85
|
-
if (canIndentAsListItem(state, listItem)) {
|
|
86
|
-
|
|
88
|
+
const listItem = state.schema.nodes[indent_rules_1.indentRules.listsTypes.listItem];
|
|
89
|
+
const isIndentableBlock = (0, exports.canBeIndented)(state, indent_rules_1.indentRules);
|
|
90
|
+
if ((0, exports.canIndentAsListItem)(state, listItem)) {
|
|
91
|
+
(0, prosemirror_schema_list_1.sinkListItem)(listItem)(state, dispatch);
|
|
87
92
|
}
|
|
88
93
|
else if (isIndentableBlock) {
|
|
89
|
-
indentBlocks(
|
|
94
|
+
(0, exports.indentBlocks)(indent_rules_1.indentRules.nodes)(state, dispatch);
|
|
90
95
|
}
|
|
91
96
|
};
|
|
97
|
+
exports.indent = indent;
|
|
92
98
|
const outdent = (state, dispatch) => {
|
|
93
99
|
const nodes = state.schema.nodes;
|
|
94
|
-
const listItem = nodes[
|
|
95
|
-
const isIndentableBlock = canBeIndented(state,
|
|
96
|
-
if (
|
|
97
|
-
|
|
100
|
+
const listItem = nodes[indent_rules_1.outdentRules.listsTypes.listItem];
|
|
101
|
+
const isIndentableBlock = (0, exports.canBeIndented)(state, indent_rules_1.outdentRules);
|
|
102
|
+
if ((0, blockNode_1.hasNode)(state, nodes.blockquote)) {
|
|
103
|
+
(0, blockquote_1.liftBlockquote)(state, dispatch);
|
|
98
104
|
}
|
|
99
|
-
else if (canOutdentAsListItem(state,
|
|
100
|
-
|
|
105
|
+
else if ((0, exports.canOutdentAsListItem)(state, indent_rules_1.outdentRules)) {
|
|
106
|
+
(0, prosemirror_schema_list_1.liftListItem)(listItem)(state, dispatch);
|
|
101
107
|
}
|
|
102
108
|
else if (isIndentableBlock) {
|
|
103
|
-
indentBlocks(
|
|
109
|
+
(0, exports.indentBlocks)(indent_rules_1.outdentRules.nodes)(state, dispatch);
|
|
104
110
|
}
|
|
105
111
|
};
|
|
106
|
-
|
|
107
|
-
exports.canBeIndented = canBeIndented;
|
|
108
|
-
exports.canIndentAsListItem = canIndentAsListItem;
|
|
109
|
-
exports.canOutdentAsListItem = canOutdentAsListItem;
|
|
110
|
-
exports.indent = indent;
|
|
111
|
-
exports.indentBlocks = indentBlocks;
|
|
112
|
-
exports.isIndented = isIndented;
|
|
113
112
|
exports.outdent = outdent;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { InlineFormatOptions } from './config/commands
|
|
3
|
-
|
|
2
|
+
import { InlineFormatOptions } from './config/commands';
|
|
4
3
|
/**
|
|
5
4
|
* Used by FontSize and FontName tools for getting their state.
|
|
6
5
|
*/
|
|
7
|
-
declare const getInlineStyles: (state: EditorState, style: {
|
|
6
|
+
export declare const getInlineStyles: (state: EditorState, style: {
|
|
8
7
|
name: string;
|
|
9
8
|
value: RegExp;
|
|
10
9
|
}) => Array<string>;
|
|
11
10
|
/**
|
|
12
11
|
* Used by bold, italic, ... and link commands.
|
|
13
12
|
*/
|
|
14
|
-
declare const toggleInlineFormat: (options: InlineFormatOptions, tr?: Transaction, markAttrs?: any) => (state: any, dispatch: any) => boolean;
|
|
13
|
+
export declare const toggleInlineFormat: (options: InlineFormatOptions, tr?: Transaction, markAttrs?: any) => (state: any, dispatch: any) => boolean;
|
|
15
14
|
/**
|
|
16
15
|
* Used by FontSize, FontName, Color and BackColor commands.
|
|
17
16
|
*/
|
|
18
|
-
declare const applyInlineStyle: (options: {
|
|
17
|
+
export declare const applyInlineStyle: (options: {
|
|
19
18
|
style: string;
|
|
20
19
|
value: string;
|
|
21
20
|
}, command?: string) => (state: any, dispatch: any) => boolean;
|
|
22
|
-
|
|
23
|
-
export { applyInlineStyle, getInlineStyles, toggleInlineFormat };
|
package/dist/npm/inline-style.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyInlineStyle = exports.toggleInlineFormat = exports.getInlineStyles = void 0;
|
|
4
|
+
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
5
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const mark_1 = require("./mark");
|
|
8
8
|
const changeStyleFromMark = (marks, toChange) => {
|
|
9
9
|
const styleMark = marks.find(m => m.type.name === 'style');
|
|
10
10
|
const elementStyle = styleMark && styleMark.attrs.style;
|
|
11
|
-
return
|
|
11
|
+
return (0, utils_1.changeStylesString)(elementStyle, toChange);
|
|
12
12
|
};
|
|
13
13
|
const changeStyleMark = (tr, from, to, attrs, markType) => {
|
|
14
14
|
const mark = markType.create({ style: attrs.style });
|
|
15
|
-
|
|
15
|
+
const removed = [], added = [];
|
|
16
|
+
let removing = null, adding = null;
|
|
16
17
|
tr.doc.nodesBetween(from, to, (node, pos, parent) => {
|
|
17
18
|
if (!node.isInline) {
|
|
18
19
|
return;
|
|
@@ -23,7 +24,7 @@ const changeStyleMark = (tr, from, to, attrs, markType) => {
|
|
|
23
24
|
const newStyle = changeStyleFromMark(marks, attrs);
|
|
24
25
|
if (newStyle.changed || attrs.newValue) {
|
|
25
26
|
const style = newStyle.changed ?
|
|
26
|
-
{ style: newStyle.style || null } : { style: `${
|
|
27
|
+
{ style: newStyle.style || null } : { style: `${attrs.style}: ${attrs.newValue};` };
|
|
27
28
|
const currentMark = markType.isInSet(marks) ? marks.find(m => m.type.name === 'style') : null;
|
|
28
29
|
const newMarkAttrs = currentMark ? { ...currentMark.attrs, ...style } : style;
|
|
29
30
|
const newStyleMark = markType.create(newMarkAttrs);
|
|
@@ -34,7 +35,7 @@ const changeStyleMark = (tr, from, to, attrs, markType) => {
|
|
|
34
35
|
removing.to = end;
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
|
-
removing = new
|
|
38
|
+
removing = new prosemirror_transform_1.RemoveMarkStep(start, end, marks[i]);
|
|
38
39
|
removed.push(removing);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -45,7 +46,7 @@ const changeStyleMark = (tr, from, to, attrs, markType) => {
|
|
|
45
46
|
adding.to = end;
|
|
46
47
|
}
|
|
47
48
|
else if (Object.keys(newMarkAttrs).some(attrName => newMarkAttrs[attrName] !== null)) {
|
|
48
|
-
adding = new
|
|
49
|
+
adding = new prosemirror_transform_1.AddMarkStep(start, end, newStyleMark);
|
|
49
50
|
added.push(adding);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -60,14 +61,15 @@ const changeStyleMark = (tr, from, to, attrs, markType) => {
|
|
|
60
61
|
*/
|
|
61
62
|
const getInlineStyles = (state, style) => {
|
|
62
63
|
const styleMark = state.schema.marks.style;
|
|
63
|
-
const marks = styleMark ?
|
|
64
|
-
return marks.map(mark
|
|
64
|
+
const marks = styleMark ? (0, mark_1.selectionMarks)(state, styleMark) : [];
|
|
65
|
+
return marks.map(mark => (0, mark_1.styleValue)(mark, style)).filter(m => m !== null);
|
|
65
66
|
};
|
|
67
|
+
exports.getInlineStyles = getInlineStyles;
|
|
66
68
|
const changeStyle = (markType, attrs) => {
|
|
67
69
|
return function (state, dispatch, tr) {
|
|
68
70
|
const { empty, ranges } = state.selection;
|
|
69
|
-
const $cursor = state.selection instanceof
|
|
70
|
-
if ((empty && !$cursor) || !
|
|
71
|
+
const $cursor = state.selection instanceof prosemirror_state_1.TextSelection && state.selection.$cursor;
|
|
72
|
+
if ((empty && !$cursor) || !(0, mark_1.markApplies)(state.doc, ranges, markType)) {
|
|
71
73
|
return false;
|
|
72
74
|
}
|
|
73
75
|
let result = false;
|
|
@@ -79,7 +81,7 @@ const changeStyle = (markType, attrs) => {
|
|
|
79
81
|
const newStyle = changeStyleFromMark(currentMarks, attrs);
|
|
80
82
|
const styleMark = currentMarks.find(m => m.type.name === 'style');
|
|
81
83
|
const newAttrs = { ...(styleMark ? styleMark.attrs : {}), style: newStyle.style || null };
|
|
82
|
-
if (
|
|
84
|
+
if ((0, utils_1.shallowEqual)(styleMark.attrs, newAttrs)) {
|
|
83
85
|
return false;
|
|
84
86
|
}
|
|
85
87
|
dispatch(transaction.removeStoredMark(markType));
|
|
@@ -108,7 +110,7 @@ const changeStyle = (markType, attrs) => {
|
|
|
108
110
|
*/
|
|
109
111
|
const toggleInlineFormat = (options, tr, markAttrs) => (state, dispatch) => {
|
|
110
112
|
const marks = state.schema.marks;
|
|
111
|
-
const { altStyle, altMarks = [], mark
|
|
113
|
+
const { altStyle, altMarks = [], mark } = options;
|
|
112
114
|
const transaction = tr || state.tr;
|
|
113
115
|
let styleRemoved = false;
|
|
114
116
|
let dispatched = false;
|
|
@@ -117,14 +119,14 @@ const toggleInlineFormat = (options, tr, markAttrs) => (state, dispatch) => {
|
|
|
117
119
|
const cmd = changeStyle(marks.style, { style: altStyle.name, value: altStyle.value });
|
|
118
120
|
styleRemoved = cmd(state, markDispatched, transaction);
|
|
119
121
|
}
|
|
120
|
-
const allMarks = [mark
|
|
121
|
-
const toRemove = allMarks.map(m =>
|
|
122
|
+
const allMarks = [mark, ...altMarks].filter(m => marks[m]);
|
|
123
|
+
const toRemove = allMarks.map(m => (0, mark_1.hasMark)(state, { mark: m }) && marks[m]).filter(m => m);
|
|
122
124
|
if (toRemove.length) {
|
|
123
|
-
|
|
125
|
+
(0, mark_1.removeMarks)(toRemove, state, markDispatched, transaction);
|
|
124
126
|
}
|
|
125
127
|
else {
|
|
126
128
|
if (!styleRemoved) {
|
|
127
|
-
|
|
129
|
+
(0, mark_1.toggleMark)(marks[mark], markAttrs, transaction)(state, markDispatched);
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
if (dispatched) {
|
|
@@ -132,6 +134,7 @@ const toggleInlineFormat = (options, tr, markAttrs) => (state, dispatch) => {
|
|
|
132
134
|
}
|
|
133
135
|
return dispatched;
|
|
134
136
|
};
|
|
137
|
+
exports.toggleInlineFormat = toggleInlineFormat;
|
|
135
138
|
/**
|
|
136
139
|
* Used by FontSize, FontName, Color and BackColor commands.
|
|
137
140
|
*/
|
|
@@ -147,7 +150,7 @@ const applyInlineStyle = (options, command) => (state, dispatch) => {
|
|
|
147
150
|
}
|
|
148
151
|
tr.setMeta('args', options);
|
|
149
152
|
const { empty, $cursor, ranges } = state.selection;
|
|
150
|
-
if ((empty && !$cursor) || !markType || !
|
|
153
|
+
if ((empty && !$cursor) || !markType || !(0, mark_1.markApplies)(state.doc, ranges, markType)) {
|
|
151
154
|
return false;
|
|
152
155
|
}
|
|
153
156
|
// Empty selection
|
|
@@ -156,13 +159,13 @@ const applyInlineStyle = (options, command) => (state, dispatch) => {
|
|
|
156
159
|
const currentMark = markType.isInSet(marksFromSelection) ? marksFromSelection.find(m => m.type.name === 'style') : null;
|
|
157
160
|
const newStyles = { style: null };
|
|
158
161
|
if (currentMark && currentMark.attrs.style) {
|
|
159
|
-
const resultStyles =
|
|
162
|
+
const resultStyles = (0, utils_1.changeStylesString)(currentMark.attrs.style, attrs);
|
|
160
163
|
if (resultStyles.changed && resultStyles.style) {
|
|
161
164
|
newStyles.style = resultStyles.style;
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
else if (attrs.newValue) {
|
|
165
|
-
newStyles.style = `${
|
|
168
|
+
newStyles.style = `${attrs.style}: ${attrs.newValue};`;
|
|
166
169
|
}
|
|
167
170
|
const newMarkAttrs = currentMark ? { ...currentMark.attrs, ...newStyles } : newStyles;
|
|
168
171
|
if (Object.keys(newMarkAttrs).some(attrName => newMarkAttrs[attrName] !== null)) {
|
|
@@ -175,7 +178,4 @@ const applyInlineStyle = (options, command) => (state, dispatch) => {
|
|
|
175
178
|
}
|
|
176
179
|
return changeStyle(markType, attrs)(state, dispatch, tr);
|
|
177
180
|
};
|
|
178
|
-
|
|
179
181
|
exports.applyInlineStyle = applyInlineStyle;
|
|
180
|
-
exports.getInlineStyles = getInlineStyles;
|
|
181
|
-
exports.toggleInlineFormat = toggleInlineFormat;
|
package/dist/npm/link.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
declare const removeLink: (options: any, tr?: any) => (state: any, dispatch: any) => void;
|
|
2
|
-
declare const applyLink: ({ mark, attrs }: {
|
|
1
|
+
export declare const removeLink: (options: any, tr?: any) => (state: any, dispatch: any) => void;
|
|
2
|
+
export declare const applyLink: ({ mark, attrs }: {
|
|
3
3
|
mark: any;
|
|
4
4
|
attrs: any;
|
|
5
5
|
}, commandName?: string) => (state: any, dispatch: any) => boolean;
|
|
6
|
-
|
|
7
|
-
export { applyLink, removeLink };
|
package/dist/npm/link.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyLink = exports.removeLink = void 0;
|
|
4
|
+
const inline_style_1 = require("./inline-style");
|
|
5
|
+
const mark_1 = require("./mark");
|
|
6
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
7
7
|
const modifyLink = (options, tr) => (state, dispatch) => {
|
|
8
8
|
const { $cursor, from, to } = state.selection;
|
|
9
9
|
const markType = state.schema.marks[options.mark];
|
|
@@ -42,38 +42,39 @@ const modifyLink = (options, tr) => (state, dispatch) => {
|
|
|
42
42
|
const removeLink = (options, tr) => (state, dispatch) => {
|
|
43
43
|
const { $cursor } = state.selection;
|
|
44
44
|
if (!$cursor) {
|
|
45
|
-
|
|
45
|
+
(0, inline_style_1.toggleInlineFormat)(options, tr)(state, dispatch);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
const parentNode = $cursor.parent;
|
|
49
49
|
const cursorNodeIndex = $cursor.index();
|
|
50
50
|
const toolMark = state.schema.marks[options.mark];
|
|
51
|
-
const mark
|
|
51
|
+
const mark = parentNode.child(cursorNodeIndex).marks.find(m => m.type === toolMark);
|
|
52
52
|
const childCount = parentNode.childCount;
|
|
53
53
|
let linkStart = $cursor.pos - $cursor.textOffset, linkSize = parentNode.child(cursorNodeIndex).nodeSize, index, nodeSize;
|
|
54
54
|
index = cursorNodeIndex - 1;
|
|
55
|
-
while (index >= 0 && mark
|
|
55
|
+
while (index >= 0 && mark.isInSet(parentNode.child(index).marks)) {
|
|
56
56
|
nodeSize = parentNode.child(index).nodeSize;
|
|
57
57
|
linkSize += nodeSize;
|
|
58
58
|
linkStart -= nodeSize;
|
|
59
59
|
index -= 1;
|
|
60
60
|
}
|
|
61
61
|
index = cursorNodeIndex + 1;
|
|
62
|
-
while (index < childCount && mark
|
|
62
|
+
while (index < childCount && mark.isInSet(parentNode.child(index).marks)) {
|
|
63
63
|
linkSize += parentNode.child(index).nodeSize;
|
|
64
64
|
index += 1;
|
|
65
65
|
}
|
|
66
|
-
dispatch(
|
|
66
|
+
dispatch((0, mark_1.removeMark)(tr || state.tr, linkStart, linkStart + linkSize, mark));
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
+
exports.removeLink = removeLink;
|
|
69
70
|
/**
|
|
70
71
|
* Returns a mark which wraps the selection.
|
|
71
72
|
*/
|
|
72
73
|
const getParentMark = (state, markType) => {
|
|
73
|
-
const marks =
|
|
74
|
+
const marks = (0, mark_1.selectionMarks)(state, markType);
|
|
74
75
|
return marks.length === 1 && marks[0] ? marks[0] : null;
|
|
75
76
|
};
|
|
76
|
-
const applyLink = ({ mark
|
|
77
|
+
const applyLink = ({ mark, attrs }, commandName = 'link') => (state, dispatch) => {
|
|
77
78
|
const marks = state.schema.marks;
|
|
78
79
|
const tr = state.tr;
|
|
79
80
|
if (commandName) {
|
|
@@ -82,20 +83,20 @@ const applyLink = ({ mark: mark$1, attrs }, commandName = 'link') => (state, dis
|
|
|
82
83
|
}
|
|
83
84
|
let dispatched = false;
|
|
84
85
|
const markDispatched = () => dispatched = true;
|
|
85
|
-
if (getParentMark(state, marks[mark
|
|
86
|
-
modifyLink({ mark
|
|
86
|
+
if (getParentMark(state, marks[mark])) {
|
|
87
|
+
modifyLink({ mark, attrs }, tr)(state, markDispatched);
|
|
87
88
|
}
|
|
88
89
|
else {
|
|
89
90
|
let nextState = state;
|
|
90
|
-
if (
|
|
91
|
-
removeLink({ mark
|
|
92
|
-
nextState =
|
|
91
|
+
if ((0, mark_1.hasMark)(state, { mark })) {
|
|
92
|
+
(0, exports.removeLink)({ mark, attrs }, tr)(state, markDispatched);
|
|
93
|
+
nextState = prosemirror_state_1.EditorState.create({ doc: tr.doc, selection: tr.selection });
|
|
93
94
|
}
|
|
94
95
|
if (dispatched) {
|
|
95
|
-
|
|
96
|
+
(0, mark_1.toggleMark)(marks[mark], attrs, tr)(nextState, markDispatched);
|
|
96
97
|
}
|
|
97
98
|
else {
|
|
98
|
-
|
|
99
|
+
(0, inline_style_1.toggleInlineFormat)({ mark: mark }, tr, attrs)(nextState, markDispatched);
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
if (dispatched) {
|
|
@@ -103,6 +104,4 @@ const applyLink = ({ mark: mark$1, attrs }, commandName = 'link') => (state, dis
|
|
|
103
104
|
}
|
|
104
105
|
return dispatched;
|
|
105
106
|
};
|
|
106
|
-
|
|
107
107
|
exports.applyLink = applyLink;
|
|
108
|
-
exports.removeLink = removeLink;
|