@modusoperandi/licit 0.13.25 → 0.14.0
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/.eslintrc.js +1 -1
- package/README.md +1 -0
- package/dist/BlockquoteInsertNewLineCommand.js +3 -23
- package/dist/BlockquoteNodeSpec.js +3 -13
- package/dist/BlockquoteToggleCommand.js +3 -16
- package/dist/BookmarkNodeSpec.js +0 -6
- package/dist/BulletListNodeSpec.js +2 -16
- package/dist/CZIProseMirror.js +3 -27
- package/dist/CodeBlockCommand.js +3 -19
- package/dist/CodeBlockNodeSpec.js +3 -4
- package/dist/CodeMarkSpec.js +0 -4
- package/dist/ContentPlaceholderPlugin.js +6 -58
- package/dist/CursorPlaceholderPlugin.js +2 -32
- package/dist/DocLayoutCommand.js +5 -28
- package/dist/DocNodeSpec.js +0 -9
- package/dist/EMMarkSpec.js +0 -4
- package/dist/EditorCommands.js +5 -33
- package/dist/EditorKeyMap.js +4 -18
- package/dist/EditorMarks.js +2 -26
- package/dist/EditorNodes.js +4 -22
- package/dist/EditorPageLayoutPlugin.js +3 -15
- package/dist/EditorPlugins.js +0 -4
- package/dist/EditorSchema.js +0 -5
- package/dist/EditorState.js +0 -2
- package/dist/FontSizeMarkSpec.js +0 -12
- package/dist/FontTypeMarkSpec.js +15 -19
- package/dist/HTMLMutator.js +5 -24
- package/dist/HardBreakNodeSpec.js +0 -2
- package/dist/HeadingNodeSpec.js +6 -15
- package/dist/HistoryRedoCommand.js +3 -11
- package/dist/HistoryUndoCommand.js +3 -11
- package/dist/HorizontalRuleCommand.js +3 -22
- package/dist/HorizontalRuleNodeSpec.js +0 -10
- package/dist/ImageFromURLCommand.js +0 -9
- package/dist/ImageNodeSpec.js +2 -14
- package/dist/ImageSourceCommand.js +3 -39
- package/dist/ImageUploadCommand.js +3 -21
- package/dist/ImageUploadPlaceholderPlugin.js +10 -48
- package/dist/LinkMarkSpec.js +0 -4
- package/dist/LinkSetURLCommand.js +3 -28
- package/dist/LinkTooltipPlugin.js +6 -52
- package/dist/ListItemInsertNewLineCommand.js +3 -23
- package/dist/ListItemMergeCommand.js +15 -66
- package/dist/ListItemNodeSpec.js +0 -11
- package/dist/ListSplitCommand.js +3 -14
- package/dist/ListToggleCommand.js +5 -26
- package/dist/MarksClearCommand.js +6 -17
- package/dist/MathEditCommand.js +3 -38
- package/dist/MathNodeSpec.js +0 -10
- package/dist/OrderedListNodeSpec.js +0 -24
- package/dist/ParagraphNodeSpec.js +5 -26
- package/dist/ParagraphSpacingCommand.js +3 -32
- package/dist/PrintCommand.js +3 -13
- package/dist/SelectionPlaceholderPlugin.js +2 -31
- package/dist/SpacerMarkSpec.js +2 -6
- package/dist/StrikeMarkSpec.js +0 -4
- package/dist/StrongMarkSpec.js +2 -5
- package/dist/StyleView.js +1 -7
- package/dist/TableBackgroundColorCommand.js +3 -24
- package/dist/TableBorderColorCommand.js +3 -24
- package/dist/TableCellColorCommand.js +3 -23
- package/dist/TableCellMenuPlugin.js +9 -45
- package/dist/TableInsertCommand.js +7 -39
- package/dist/TableMergeCellsCommand.js +5 -30
- package/dist/TableNodesSpecs.js +4 -23
- package/dist/TablePlugins.js +0 -5
- package/dist/TableResizePlugin.js +54 -138
- package/dist/TextColorMarkSpec.js +0 -9
- package/dist/TextHighlightMarkSpec.js +0 -8
- package/dist/TextInsertTabSpaceCommand.js +3 -28
- package/dist/TextNoWrapMarkSpec.js +0 -4
- package/dist/TextSelectionMarkSpec.js +0 -5
- package/dist/TextSubMarkSpec.js +0 -4
- package/dist/TextSuperMarkSpec.js +0 -4
- package/dist/TextUnderlineMarkSpec.js +0 -4
- package/dist/Types.js +0 -6
- package/dist/WebFontLoader.js +3 -8
- package/dist/blockQuoteInputRule.js +0 -13
- package/dist/bom.xml +1492 -1645
- package/dist/buildEditorPlugins.js +5 -27
- package/dist/buildInputRules.js +12 -24
- package/dist/client/CollabConnector.js +6 -30
- package/dist/client/EditorConnection.js +23 -69
- package/dist/client/Licit.js +79 -163
- package/dist/client/Licit.js.flow +16 -2
- package/dist/client/Licit.test.js +6 -13
- package/dist/client/Reporter.js +1 -8
- package/dist/client/SimpleConnector.js +6 -26
- package/dist/client/http.js +8 -15
- package/dist/client/throttle.js +0 -2
- package/dist/convertFromDOMElement.js +2 -10
- package/dist/convertFromHTML.js +0 -5
- package/dist/convertFromJSON.js +3 -13
- package/dist/convertToCSSPTValue.js +0 -6
- package/dist/convertToJSON.js +0 -2
- package/dist/createCommand.js +3 -11
- package/dist/createEditorKeyMap.js +0 -13
- package/dist/createEmptyEditorState.js +0 -7
- package/dist/createTableResizingPlugin.js +5 -16
- package/dist/findActionableCell.js +0 -19
- package/dist/findActiveMark.js +0 -11
- package/dist/hyphenize.js +2 -4
- package/dist/index.js +0 -9
- package/dist/insertTable.js +0 -16
- package/dist/isEditorStateEmpty.js +0 -6
- package/dist/isTableNode.js +0 -3
- package/dist/joinDown.js +0 -7
- package/dist/joinListNode.js +0 -15
- package/dist/joinUp.js +0 -9
- package/dist/keymaps.js +0 -15
- package/dist/lookUpElement.js +0 -3
- package/dist/nodeAt.js +0 -3
- package/dist/normalizeHTML.js +9 -25
- package/dist/patchAnchorElements.js +5 -12
- package/dist/patchBreakElements.js +0 -6
- package/dist/patchElementInlineStyles.js +5 -15
- package/dist/patchListElements.js +20 -54
- package/dist/patchMathElements.js +11 -21
- package/dist/patchParagraphElements.js +0 -5
- package/dist/patchStyleElements.js +12 -41
- package/dist/patchTableElements.js +9 -37
- package/dist/rebaseDocWithSteps.js +0 -6
- package/dist/sanitizeURL.js +0 -3
- package/dist/splitListItem.js +12 -43
- package/dist/toClosestFontPtSize.js +1 -5
- package/dist/toSafeHTMLDocument.js +0 -1
- package/dist/toggleBlockquote.js +2 -19
- package/dist/toggleCodeBlock.js +2 -22
- package/dist/ui/AlertInfo.js +6 -22
- package/dist/ui/BookmarkNodeView.js +7 -28
- package/dist/ui/CommandButton.js +3 -19
- package/dist/ui/CommandMenu.js +3 -25
- package/dist/ui/CommandMenuButton.js +3 -36
- package/dist/ui/CustomEditorView.js +3 -16
- package/dist/ui/CustomMenu.js +0 -8
- package/dist/ui/CustomMenuItem.js +4 -18
- package/dist/ui/CustomNodeView.js +21 -67
- package/dist/ui/CustomRadioButton.js +14 -33
- package/dist/ui/DocLayoutEditor.js +5 -27
- package/dist/ui/Editor.js +18 -79
- package/dist/ui/EditorFrameset.js +3 -18
- package/dist/ui/EditorToolbar.js +10 -46
- package/dist/ui/EditorToolbarConfig.js +10 -20
- package/dist/ui/FontSizeCommandMenuButton.js +5 -19
- package/dist/ui/FontTypeCommandMenuButton.js +5 -22
- package/dist/ui/Frag.js +0 -7
- package/dist/ui/Icon.js +5 -25
- package/dist/ui/ImageAlignEditor.js +3 -16
- package/dist/ui/ImageInlineEditor.js +3 -16
- package/dist/ui/ImageNodeView.js +20 -109
- package/dist/ui/ImageResizeBox.js +3 -53
- package/dist/ui/ImageURLEditor.js +3 -28
- package/dist/ui/ImageUploadEditor.js +3 -35
- package/dist/ui/LinkTooltip.js +5 -25
- package/dist/ui/LinkURLEditor.js +3 -29
- package/dist/ui/ListItemNodeView.js +15 -30
- package/dist/ui/ListTypeButton.js +5 -37
- package/dist/ui/ListTypeCommandButton.js +3 -19
- package/dist/ui/ListTypeMenu.js +4 -25
- package/dist/ui/LoadingIndicator.js +0 -7
- package/dist/ui/MathEditor.js +3 -24
- package/dist/ui/MathInlineEditor.js +3 -26
- package/dist/ui/MathNodeView.js +9 -59
- package/dist/ui/PasteMenu.js +4 -20
- package/dist/ui/ResizeObserver.js +0 -18
- package/dist/ui/RichTextEditor.js +5 -27
- package/dist/ui/SelectionObserver.js +3 -29
- package/dist/ui/TableCellMenu.js +3 -18
- package/dist/ui/TableGridSizeEditor.js +5 -51
- package/dist/ui/TableNodeView.js +0 -11
- package/dist/ui/bindScrollHandler.js +2 -9
- package/dist/ui/canUseCSSFont.js +2 -8
- package/dist/ui/czi-icon.css +4 -4
- package/dist/ui/findActiveFontSize.js +2 -18
- package/dist/ui/findActiveFontType.js +0 -12
- package/dist/ui/handleEditorDrop.js +0 -9
- package/dist/ui/handleEditorKeyDown.js +0 -7
- package/dist/ui/handleEditorPaste.js +0 -9
- package/dist/ui/htmlElementToRect.js +0 -4
- package/dist/ui/injectStyleSheet.js +0 -10
- package/dist/ui/isElementFullyVisible.js +2 -8
- package/dist/ui/isOffline.js +0 -2
- package/dist/ui/isReactClass.js +0 -4
- package/dist/ui/mathquill-editor/MathQuillEditor.js +9 -44
- package/dist/ui/mathquill-editor/MathQuillEditorSymbols.js +1 -3
- package/dist/ui/mathquill-editor/MathQuillEditorSymbolsPanel.js +3 -16
- package/dist/ui/mathquill-editor/mathquill-import-kludge.js +5 -7
- package/dist/ui/renderLaTeXAsHTML.js +2 -13
- package/dist/ui/resolveImage.js +7 -32
- package/dist/ui/toCSSColor.js +0 -14
- package/dist/ui/toCSSLineSpacing.js +10 -11
- package/dist/ui/toHexColor.js +0 -8
- package/dist/ui/uuid.js +0 -2
- package/dist/uuid.js +0 -2
- package/package-lock.json.old +32889 -0
- package/package.json +45 -69
- package/src/client/Licit.js +16 -2
- package/src/ui/czi-icon.css +4 -4
- package/utils/build_web_server.js +1 -7
- package/webpack.config.js +3 -3
package/dist/LinkMarkSpec.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _Types = require("./Types");
|
|
9
|
-
|
|
10
8
|
const LinkMarkSpec = {
|
|
11
9
|
attrs: {
|
|
12
10
|
href: {
|
|
@@ -35,11 +33,9 @@ const LinkMarkSpec = {
|
|
|
35
33
|
};
|
|
36
34
|
}
|
|
37
35
|
}],
|
|
38
|
-
|
|
39
36
|
toDOM(node) {
|
|
40
37
|
return ['a', node.attrs, 0];
|
|
41
38
|
}
|
|
42
|
-
|
|
43
39
|
};
|
|
44
40
|
var _default = LinkMarkSpec;
|
|
45
41
|
exports.default = _default;
|
|
@@ -4,72 +4,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
8
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
11
|
-
|
|
12
9
|
var _prosemirrorView = require("prosemirror-view");
|
|
13
|
-
|
|
14
10
|
var _MarkNames = require("./MarkNames");
|
|
15
|
-
|
|
16
11
|
var _SelectionPlaceholderPlugin = require("./SelectionPlaceholderPlugin");
|
|
17
|
-
|
|
18
12
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
19
|
-
|
|
20
13
|
var _LinkURLEditor = _interopRequireDefault(require("./ui/LinkURLEditor"));
|
|
21
|
-
|
|
22
14
|
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
19
|
class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
|
|
29
20
|
constructor() {
|
|
30
21
|
super(...arguments);
|
|
31
|
-
|
|
32
22
|
_defineProperty(this, "_popUp", null);
|
|
33
|
-
|
|
34
23
|
_defineProperty(this, "isEnabled", state => {
|
|
35
24
|
if (!(state.selection instanceof _prosemirrorState.TextSelection)) {
|
|
36
25
|
// Could be a NodeSelection or CellSelection.
|
|
37
26
|
return false;
|
|
38
27
|
}
|
|
39
|
-
|
|
40
28
|
const markType = state.schema.marks[_MarkNames.MARK_LINK];
|
|
41
|
-
|
|
42
29
|
if (!markType) {
|
|
43
30
|
return false;
|
|
44
31
|
}
|
|
45
|
-
|
|
46
32
|
const {
|
|
47
33
|
from,
|
|
48
34
|
to
|
|
49
35
|
} = state.selection;
|
|
50
36
|
return from < to;
|
|
51
37
|
});
|
|
52
|
-
|
|
53
38
|
_defineProperty(this, "waitForUserInput", (state, dispatch, view, event) => {
|
|
54
39
|
if (this._popUp) {
|
|
55
40
|
return Promise.resolve(undefined);
|
|
56
41
|
}
|
|
57
|
-
|
|
58
42
|
if (dispatch) {
|
|
59
43
|
dispatch((0, _SelectionPlaceholderPlugin.showSelectionPlaceholder)(state));
|
|
60
44
|
}
|
|
61
|
-
|
|
62
45
|
const {
|
|
63
46
|
doc,
|
|
64
47
|
schema,
|
|
65
48
|
selection
|
|
66
49
|
} = state;
|
|
67
50
|
const markType = schema.marks[_MarkNames.MARK_LINK];
|
|
68
|
-
|
|
69
51
|
if (!markType) {
|
|
70
52
|
return Promise.resolve(undefined);
|
|
71
53
|
}
|
|
72
|
-
|
|
73
54
|
const {
|
|
74
55
|
from,
|
|
75
56
|
to
|
|
@@ -90,7 +71,6 @@ class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
|
|
|
90
71
|
});
|
|
91
72
|
});
|
|
92
73
|
});
|
|
93
|
-
|
|
94
74
|
_defineProperty(this, "executeWithUserInput", (state, dispatch, view, href) => {
|
|
95
75
|
if (dispatch) {
|
|
96
76
|
const {
|
|
@@ -102,7 +82,6 @@ class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
|
|
|
102
82
|
} = state;
|
|
103
83
|
tr = view ? (0, _SelectionPlaceholderPlugin.hideSelectionPlaceholder)(view.state) : tr;
|
|
104
84
|
tr = tr.setSelection(selection);
|
|
105
|
-
|
|
106
85
|
if (href !== undefined) {
|
|
107
86
|
const markType = schema.marks[_MarkNames.MARK_LINK];
|
|
108
87
|
const attrs = href ? {
|
|
@@ -110,16 +89,12 @@ class LinkSetURLCommand extends _licitDocAttrsStep.UICommand {
|
|
|
110
89
|
} : null;
|
|
111
90
|
tr = (0, _licitUiCommands.applyMark)(tr.setSelection(state.selection), schema, markType, attrs);
|
|
112
91
|
}
|
|
113
|
-
|
|
114
92
|
dispatch(tr);
|
|
115
93
|
}
|
|
116
|
-
|
|
117
94
|
view && view.focus();
|
|
118
95
|
return true;
|
|
119
96
|
});
|
|
120
97
|
}
|
|
121
|
-
|
|
122
98
|
}
|
|
123
|
-
|
|
124
99
|
var _default = LinkSetURLCommand;
|
|
125
100
|
exports.default = _default;
|
|
@@ -4,72 +4,51 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
8
|
var _prosemirrorView = require("prosemirror-view");
|
|
11
|
-
|
|
12
9
|
var _MarkNames = require("./MarkNames");
|
|
13
|
-
|
|
14
10
|
var _SelectionPlaceholderPlugin = require("./SelectionPlaceholderPlugin");
|
|
15
|
-
|
|
16
11
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
17
|
-
|
|
18
12
|
var _lookUpElement = _interopRequireDefault(require("./lookUpElement"));
|
|
19
|
-
|
|
20
13
|
var _LinkTooltip = _interopRequireDefault(require("./ui/LinkTooltip"));
|
|
21
|
-
|
|
22
14
|
var _LinkURLEditor = _interopRequireDefault(require("./ui/LinkURLEditor"));
|
|
23
|
-
|
|
24
15
|
require("@modusoperandi/licit-ui-commands/dist/ui/czi-pop-up.css");
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
20
|
// https://prosemirror.net/examples/tooltip/
|
|
31
21
|
const SPEC = {
|
|
32
22
|
// [FS] IRAD-1005 2020-07-07
|
|
33
23
|
// Upgrade outdated packages.
|
|
34
24
|
key: new _prosemirrorState.PluginKey('LinkTooltipPlugin'),
|
|
35
|
-
|
|
36
25
|
view(editorView) {
|
|
37
26
|
return new LinkTooltipView(editorView);
|
|
38
27
|
}
|
|
39
|
-
|
|
40
28
|
};
|
|
41
|
-
|
|
42
29
|
class LinkTooltipPlugin extends _prosemirrorState.Plugin {
|
|
43
30
|
constructor() {
|
|
44
31
|
super(SPEC);
|
|
45
32
|
}
|
|
46
|
-
|
|
47
33
|
}
|
|
48
|
-
|
|
49
34
|
class LinkTooltipView {
|
|
50
35
|
constructor(editorView) {
|
|
51
36
|
_defineProperty(this, "_anchorEl", null);
|
|
52
|
-
|
|
53
37
|
_defineProperty(this, "_popup", null);
|
|
54
|
-
|
|
55
38
|
_defineProperty(this, "_editor", null);
|
|
56
|
-
|
|
57
39
|
_defineProperty(this, "_onCancel", view => {
|
|
58
40
|
this.destroy();
|
|
59
41
|
view.focus();
|
|
60
42
|
});
|
|
61
|
-
|
|
62
43
|
_defineProperty(this, "_onClose", () => {
|
|
63
44
|
this._anchorEl = null;
|
|
64
45
|
this._editor = null;
|
|
65
46
|
this._popup = null;
|
|
66
47
|
});
|
|
67
|
-
|
|
68
48
|
_defineProperty(this, "_onEdit", view => {
|
|
69
49
|
if (this._editor) {
|
|
70
50
|
return;
|
|
71
51
|
}
|
|
72
|
-
|
|
73
52
|
const {
|
|
74
53
|
state
|
|
75
54
|
} = view;
|
|
@@ -84,74 +63,61 @@ class LinkTooltipView {
|
|
|
84
63
|
} = selection;
|
|
85
64
|
const markType = schema.marks[_MarkNames.MARK_LINK];
|
|
86
65
|
const result = (0, _licitUiCommands.findNodesWithSameMark)(doc, from, to, markType);
|
|
87
|
-
|
|
88
66
|
if (!result) {
|
|
89
67
|
return;
|
|
90
68
|
}
|
|
91
|
-
|
|
92
69
|
const href = result.mark.attrs.href;
|
|
93
70
|
this._editor = (0, _licitUiCommands.createPopUp)(_LinkURLEditor.default, {
|
|
94
71
|
href
|
|
95
72
|
}, {
|
|
96
73
|
onClose: value => {
|
|
97
74
|
this._editor = null;
|
|
98
|
-
|
|
99
75
|
this._onEditEnd(view, selection, value);
|
|
100
76
|
}
|
|
101
77
|
});
|
|
102
78
|
});
|
|
103
|
-
|
|
104
79
|
_defineProperty(this, "_onRemove", view => {
|
|
105
80
|
this._onEditEnd(view, view.state.selection, null);
|
|
106
81
|
});
|
|
107
|
-
|
|
108
82
|
_defineProperty(this, "_onEditEnd", (view, initialSelection, href) => {
|
|
109
83
|
const {
|
|
110
84
|
state,
|
|
111
85
|
dispatch
|
|
112
86
|
} = view;
|
|
113
87
|
let tr = (0, _SelectionPlaceholderPlugin.hideSelectionPlaceholder)(state);
|
|
114
|
-
|
|
115
88
|
if (href !== undefined) {
|
|
116
89
|
const {
|
|
117
90
|
schema
|
|
118
91
|
} = state;
|
|
119
92
|
const markType = schema.marks[_MarkNames.MARK_LINK];
|
|
120
|
-
|
|
121
93
|
if (markType) {
|
|
122
94
|
const result = (0, _licitUiCommands.findNodesWithSameMark)(tr.doc, initialSelection.from, initialSelection.to, markType);
|
|
123
|
-
|
|
124
95
|
if (result) {
|
|
125
96
|
const linkSelection = _prosemirrorState.TextSelection.create(tr.doc, result.from.pos, result.to.pos + 1);
|
|
126
|
-
|
|
127
97
|
tr = tr.setSelection(linkSelection);
|
|
128
98
|
const attrs = href ? {
|
|
129
99
|
href
|
|
130
100
|
} : null;
|
|
131
|
-
tr = (0, _licitUiCommands.applyMark)(tr, schema, markType, attrs);
|
|
101
|
+
tr = (0, _licitUiCommands.applyMark)(tr, schema, markType, attrs);
|
|
102
|
+
|
|
103
|
+
// [FS] IRAD-1005 2020-07-09
|
|
132
104
|
// Upgrade outdated packages.
|
|
133
105
|
// reset selection to original using the latest doc.
|
|
134
|
-
|
|
135
106
|
const origSelection = _prosemirrorState.TextSelection.create(tr.doc, initialSelection.from, initialSelection.to);
|
|
136
|
-
|
|
137
107
|
tr = tr.setSelection(origSelection);
|
|
138
108
|
}
|
|
139
109
|
}
|
|
140
110
|
}
|
|
141
|
-
|
|
142
111
|
dispatch(tr);
|
|
143
112
|
view.focus();
|
|
144
113
|
});
|
|
145
|
-
|
|
146
114
|
this.update(editorView, null);
|
|
147
115
|
}
|
|
148
|
-
|
|
149
116
|
update(view, lastState) {
|
|
150
117
|
if (view.readOnly) {
|
|
151
118
|
this.destroy();
|
|
152
119
|
return;
|
|
153
120
|
}
|
|
154
|
-
|
|
155
121
|
const {
|
|
156
122
|
state
|
|
157
123
|
} = view;
|
|
@@ -161,36 +127,28 @@ class LinkTooltipView {
|
|
|
161
127
|
schema
|
|
162
128
|
} = state;
|
|
163
129
|
const markType = schema.marks[_MarkNames.MARK_LINK];
|
|
164
|
-
|
|
165
130
|
if (!markType) {
|
|
166
131
|
return;
|
|
167
132
|
}
|
|
168
|
-
|
|
169
133
|
const {
|
|
170
134
|
from,
|
|
171
135
|
to
|
|
172
136
|
} = selection;
|
|
173
137
|
const result = (0, _licitUiCommands.findNodesWithSameMark)(doc, from, to, markType);
|
|
174
|
-
|
|
175
138
|
if (!result) {
|
|
176
139
|
this.destroy();
|
|
177
140
|
return;
|
|
178
141
|
}
|
|
179
|
-
|
|
180
142
|
const domFound = view.domAtPos(from);
|
|
181
|
-
|
|
182
143
|
if (!domFound) {
|
|
183
144
|
this.destroy();
|
|
184
145
|
return;
|
|
185
146
|
}
|
|
186
|
-
|
|
187
147
|
const anchorEl = (0, _lookUpElement.default)(domFound.node, el => el.nodeName === 'A');
|
|
188
|
-
|
|
189
148
|
if (!anchorEl) {
|
|
190
149
|
this.destroy();
|
|
191
150
|
return;
|
|
192
151
|
}
|
|
193
|
-
|
|
194
152
|
const popup = this._popup;
|
|
195
153
|
const viewPops = {
|
|
196
154
|
editorState: state,
|
|
@@ -200,7 +158,6 @@ class LinkTooltipView {
|
|
|
200
158
|
onEdit: this._onEdit,
|
|
201
159
|
onRemove: this._onRemove
|
|
202
160
|
};
|
|
203
|
-
|
|
204
161
|
if (popup && anchorEl === this._anchorEl) {
|
|
205
162
|
popup.update(viewPops);
|
|
206
163
|
} else {
|
|
@@ -214,13 +171,10 @@ class LinkTooltipView {
|
|
|
214
171
|
});
|
|
215
172
|
}
|
|
216
173
|
}
|
|
217
|
-
|
|
218
174
|
destroy() {
|
|
219
175
|
this._popup && this._popup.close();
|
|
220
176
|
this._editor && this._editor.close();
|
|
221
177
|
}
|
|
222
|
-
|
|
223
178
|
}
|
|
224
|
-
|
|
225
179
|
var _default = LinkTooltipPlugin;
|
|
226
180
|
exports.default = _default;
|
|
@@ -4,72 +4,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _prosemirrorModel = require("prosemirror-model");
|
|
9
|
-
|
|
10
8
|
var _prosemirrorState = require("prosemirror-state");
|
|
11
|
-
|
|
12
9
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
15
|
-
|
|
16
11
|
var _prosemirrorView = require("prosemirror-view");
|
|
17
|
-
|
|
18
12
|
var _NodeNames = require("./NodeNames");
|
|
19
|
-
|
|
20
13
|
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
24
17
|
// This handles the case when user press SHIFT + ENTER key to insert a new line
|
|
25
18
|
// into list item.
|
|
26
19
|
function insertNewLine(tr, schema) {
|
|
27
20
|
const {
|
|
28
21
|
selection
|
|
29
22
|
} = tr;
|
|
30
|
-
|
|
31
23
|
if (!selection) {
|
|
32
24
|
return tr;
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
const {
|
|
36
27
|
from,
|
|
37
28
|
empty
|
|
38
29
|
} = selection;
|
|
39
|
-
|
|
40
30
|
if (!empty) {
|
|
41
31
|
return tr;
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
const br = schema.nodes[_NodeNames.HARD_BREAK];
|
|
45
|
-
|
|
46
34
|
if (!br) {
|
|
47
35
|
return tr;
|
|
48
36
|
}
|
|
49
|
-
|
|
50
37
|
const blockquote = schema.nodes[_NodeNames.LIST_ITEM];
|
|
51
38
|
const result = (0, _prosemirrorUtils.findParentNodeOfType)(blockquote)(selection);
|
|
52
|
-
|
|
53
39
|
if (!result) {
|
|
54
40
|
return tr;
|
|
55
41
|
}
|
|
56
|
-
|
|
57
42
|
tr = tr.insert(from, _prosemirrorModel.Fragment.from(br.create()));
|
|
58
43
|
tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, from + 1, from + 1));
|
|
59
44
|
return tr;
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
class ListItemInsertNewLineCommand extends _licitDocAttrsStep.UICommand {
|
|
63
47
|
constructor() {
|
|
64
48
|
super(...arguments);
|
|
65
|
-
|
|
66
49
|
_defineProperty(this, "execute", (state, dispatch, view) => {
|
|
67
50
|
const {
|
|
68
51
|
schema,
|
|
69
52
|
selection
|
|
70
53
|
} = state;
|
|
71
54
|
const tr = insertNewLine(state.tr.setSelection(selection), schema);
|
|
72
|
-
|
|
73
55
|
if (tr.docChanged) {
|
|
74
56
|
dispatch && dispatch(tr);
|
|
75
57
|
return true;
|
|
@@ -78,8 +60,6 @@ class ListItemInsertNewLineCommand extends _licitDocAttrsStep.UICommand {
|
|
|
78
60
|
}
|
|
79
61
|
});
|
|
80
62
|
}
|
|
81
|
-
|
|
82
63
|
}
|
|
83
|
-
|
|
84
64
|
var _default = ListItemInsertNewLineCommand;
|
|
85
65
|
exports.default = _default;
|
|
@@ -4,203 +4,157 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
9
|
-
|
|
10
8
|
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
9
|
var _prosemirrorState = require("prosemirror-state");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
15
|
-
|
|
16
11
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
17
|
-
|
|
18
12
|
var _prosemirrorView = require("prosemirror-view");
|
|
19
|
-
|
|
20
13
|
var _NodeNames = require("./NodeNames");
|
|
21
|
-
|
|
22
14
|
var _nodeAt = _interopRequireDefault(require("./nodeAt"));
|
|
23
|
-
|
|
24
15
|
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
20
|
function mergeListItemUp(tr, schema) {
|
|
31
21
|
// This merge a list item to is previous list item of the selection is at the
|
|
32
22
|
// beginning of the list item.
|
|
33
23
|
const {
|
|
34
24
|
selection
|
|
35
25
|
} = tr;
|
|
36
|
-
|
|
37
26
|
if (!selection) {
|
|
38
27
|
return tr;
|
|
39
28
|
}
|
|
40
|
-
|
|
41
29
|
const nodeType = schema.nodes[_NodeNames.LIST_ITEM];
|
|
42
|
-
|
|
43
30
|
if (!nodeType) {
|
|
44
31
|
return tr;
|
|
45
32
|
}
|
|
46
|
-
|
|
47
33
|
const {
|
|
48
34
|
from,
|
|
49
35
|
empty
|
|
50
36
|
} = selection;
|
|
51
|
-
|
|
52
37
|
if (!empty) {
|
|
53
38
|
// Selection is collapsed.
|
|
54
39
|
return tr;
|
|
55
40
|
}
|
|
56
|
-
|
|
57
41
|
const result = (0, _prosemirrorUtils.findParentNodeOfType)(nodeType)(selection);
|
|
58
|
-
|
|
59
42
|
if (!result) {
|
|
60
43
|
return tr;
|
|
61
44
|
}
|
|
62
|
-
|
|
63
45
|
const {
|
|
64
46
|
pos,
|
|
65
47
|
node
|
|
66
48
|
} = result;
|
|
67
|
-
|
|
68
49
|
if (from !== pos + 2) {
|
|
69
50
|
// Selection is not at the begining of the list item.
|
|
70
51
|
return tr;
|
|
71
52
|
}
|
|
72
|
-
|
|
73
53
|
const $pos = tr.doc.resolve(pos);
|
|
74
54
|
const prevNode = $pos.nodeBefore;
|
|
75
|
-
|
|
76
55
|
if (!prevNode || prevNode.type !== nodeType) {
|
|
77
56
|
return tr;
|
|
78
57
|
}
|
|
79
|
-
|
|
80
58
|
if (node.childCount !== 1) {
|
|
81
59
|
// list item should only have one child (paragraph).
|
|
82
60
|
return tr;
|
|
83
61
|
}
|
|
84
|
-
|
|
85
62
|
const paragraphNode = node.firstChild;
|
|
86
|
-
const textNode = schema.text(' ');
|
|
87
|
-
|
|
88
|
-
tr = tr.delete(pos - 2, pos + node.nodeSize); // Append extra space character to its previous list item.
|
|
89
|
-
|
|
90
|
-
tr = tr.insert(pos - 2, _prosemirrorModel.Fragment.from(textNode)); // Move the content to its previous list item.
|
|
63
|
+
const textNode = schema.text(' ');
|
|
91
64
|
|
|
65
|
+
// Delete the list item
|
|
66
|
+
tr = tr.delete(pos - 2, pos + node.nodeSize);
|
|
67
|
+
// Append extra space character to its previous list item.
|
|
68
|
+
tr = tr.insert(pos - 2, _prosemirrorModel.Fragment.from(textNode));
|
|
69
|
+
// Move the content to its previous list item.
|
|
92
70
|
tr = tr.insert(pos - 1, _prosemirrorModel.Fragment.from(paragraphNode.content));
|
|
93
71
|
tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, pos - 1, pos - 1));
|
|
94
72
|
return tr;
|
|
95
73
|
}
|
|
96
|
-
|
|
97
74
|
function mergeListItemDown(tr, schema) {
|
|
98
75
|
// This merge a list item to is next list item of the selection is at the
|
|
99
76
|
// beginning of the list item.
|
|
100
77
|
const {
|
|
101
78
|
selection
|
|
102
79
|
} = tr;
|
|
103
|
-
|
|
104
80
|
if (!selection) {
|
|
105
81
|
return tr;
|
|
106
82
|
}
|
|
107
|
-
|
|
108
83
|
const listItem = schema.nodes[_NodeNames.LIST_ITEM];
|
|
109
|
-
|
|
110
84
|
if (!listItem) {
|
|
111
85
|
return tr;
|
|
112
86
|
}
|
|
113
|
-
|
|
114
87
|
const {
|
|
115
88
|
from,
|
|
116
89
|
empty
|
|
117
90
|
} = selection;
|
|
118
|
-
|
|
119
91
|
if (!empty) {
|
|
120
92
|
// Selection is collapsed.
|
|
121
93
|
return tr;
|
|
122
94
|
}
|
|
123
|
-
|
|
124
95
|
const result = (0, _prosemirrorUtils.findParentNodeOfType)(listItem)(selection);
|
|
125
|
-
|
|
126
96
|
if (!result) {
|
|
127
97
|
return tr;
|
|
128
98
|
}
|
|
129
|
-
|
|
130
99
|
const {
|
|
131
100
|
pos,
|
|
132
101
|
node
|
|
133
102
|
} = result;
|
|
134
|
-
|
|
135
103
|
if (from !== pos + node.content.size) {
|
|
136
104
|
// Selection is not at the begining of the list item.
|
|
137
105
|
return tr;
|
|
138
106
|
}
|
|
139
|
-
|
|
140
107
|
const $pos = tr.doc.resolve(pos);
|
|
141
108
|
const list = $pos.parent.type;
|
|
142
109
|
const listResult = (0, _prosemirrorUtils.findParentNodeOfType)(list)(selection);
|
|
143
|
-
|
|
144
110
|
if (!listResult) {
|
|
145
111
|
return tr;
|
|
146
112
|
}
|
|
147
|
-
|
|
148
113
|
const nextFrom = pos + node.nodeSize;
|
|
149
114
|
let nextNode = (0, _nodeAt.default)(tr.doc, nextFrom);
|
|
150
115
|
let deleteFrom = nextFrom;
|
|
151
|
-
|
|
152
116
|
if (listResult.start + listResult.node.content.size === nextFrom) {
|
|
153
117
|
// It's at the end of the last list item. It shall bring the content of the
|
|
154
118
|
// block after the list.
|
|
155
119
|
nextNode = (0, _nodeAt.default)(tr.doc, nextFrom + 1);
|
|
156
120
|
deleteFrom += 1;
|
|
157
121
|
}
|
|
158
|
-
|
|
159
122
|
if (!nextNode) {
|
|
160
123
|
return tr;
|
|
161
124
|
}
|
|
162
|
-
|
|
163
125
|
let nextContent;
|
|
164
|
-
|
|
165
126
|
switch (nextNode.type) {
|
|
166
127
|
case listItem:
|
|
167
128
|
// List item should only have one child (paragraph).
|
|
168
129
|
const paragraphNode = (0, _nullthrows.default)(nextNode.firstChild);
|
|
169
130
|
nextContent = _prosemirrorModel.Fragment.from(paragraphNode.content);
|
|
170
131
|
break;
|
|
171
|
-
|
|
172
132
|
case schema.nodes[_NodeNames.HEADING]:
|
|
173
133
|
case schema.nodes[_NodeNames.PARAGRAPH]:
|
|
174
134
|
// Will bring in the content of the next block.
|
|
175
135
|
nextContent = _prosemirrorModel.Fragment.from(nextNode.content);
|
|
176
136
|
break;
|
|
177
137
|
}
|
|
178
|
-
|
|
179
138
|
if (!nextContent) {
|
|
180
139
|
return tr;
|
|
181
140
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
141
|
+
const textNode = schema.text(' ');
|
|
142
|
+
// Delete the next node.
|
|
143
|
+
tr = tr.delete(deleteFrom, deleteFrom + nextNode.nodeSize);
|
|
144
|
+
// Append extra space character to its previous list item.
|
|
145
|
+
tr = tr.insert(nextFrom - 2, nextContent);
|
|
146
|
+
// Move the content to the list item.
|
|
189
147
|
tr = tr.insert(nextFrom - 2, _prosemirrorModel.Fragment.from(textNode));
|
|
190
148
|
tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, nextFrom - 2, nextFrom - 2));
|
|
191
149
|
return tr;
|
|
192
150
|
}
|
|
193
|
-
|
|
194
151
|
class ListItemMergeCommand extends _licitDocAttrsStep.UICommand {
|
|
195
152
|
constructor(_direction) {
|
|
196
153
|
super();
|
|
197
|
-
|
|
198
154
|
_defineProperty(this, "_direction", '');
|
|
199
|
-
|
|
200
155
|
_defineProperty(this, "isActive", state => {
|
|
201
156
|
return false;
|
|
202
157
|
});
|
|
203
|
-
|
|
204
158
|
_defineProperty(this, "execute", (state, dispatch, view) => {
|
|
205
159
|
const {
|
|
206
160
|
selection,
|
|
@@ -210,13 +164,11 @@ class ListItemMergeCommand extends _licitDocAttrsStep.UICommand {
|
|
|
210
164
|
tr
|
|
211
165
|
} = state;
|
|
212
166
|
const direction = this._direction;
|
|
213
|
-
|
|
214
167
|
if (direction === 'down') {
|
|
215
168
|
tr = mergeListItemDown(tr.setSelection(selection), schema);
|
|
216
169
|
} else if (direction === 'up') {
|
|
217
170
|
tr = mergeListItemUp(tr.setSelection(selection), schema);
|
|
218
171
|
}
|
|
219
|
-
|
|
220
172
|
if (tr.docChanged) {
|
|
221
173
|
dispatch && dispatch(tr);
|
|
222
174
|
return true;
|
|
@@ -224,11 +176,8 @@ class ListItemMergeCommand extends _licitDocAttrsStep.UICommand {
|
|
|
224
176
|
return false;
|
|
225
177
|
}
|
|
226
178
|
});
|
|
227
|
-
|
|
228
179
|
this._direction = _direction;
|
|
229
180
|
}
|
|
230
|
-
|
|
231
181
|
}
|
|
232
|
-
|
|
233
182
|
var _default = ListItemMergeCommand;
|
|
234
183
|
exports.default = _default;
|