@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
|
@@ -4,32 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _TableNodeView = _interopRequireDefault(require("./ui/TableNodeView"));
|
|
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 _prosemirrorView = require("prosemirror-view");
|
|
17
|
-
|
|
18
12
|
var _prosemirrorUtils = require("prosemirror-utils");
|
|
19
|
-
|
|
20
13
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
21
|
-
|
|
22
14
|
var _prosemirrorTables = require("prosemirror-tables");
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
+
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; }
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
|
+
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); }
|
|
21
|
+
const PLUGIN_KEY = new _prosemirrorState.PluginKey('tableColumnResizing');
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const PLUGIN_KEY = new _prosemirrorState.PluginKey('tableColumnResizing'); // [FS] IRAD-949 2020-05-27
|
|
23
|
+
// [FS] IRAD-949 2020-05-27
|
|
33
24
|
// Fix:Cell Resize Handler causes edit diificult to firsrst/last two chars in the cell.
|
|
34
25
|
// Rezie cursor position issue fixed.
|
|
35
26
|
|
|
@@ -37,69 +28,56 @@ const CELL_MIN_WIDTH = 30;
|
|
|
37
28
|
const HANDLE_WIDTH = 5;
|
|
38
29
|
const HANDLE_RIGHT_WIDTH = 20;
|
|
39
30
|
let cancelDrag = null;
|
|
40
|
-
let isEnabled = true;
|
|
31
|
+
let isEnabled = true;
|
|
41
32
|
|
|
33
|
+
// The immutable plugin state that stores the information for resizing.
|
|
42
34
|
class ResizeState {
|
|
43
35
|
constructor(cellPos, forMarginLeft, draggingInfo) {
|
|
44
36
|
_defineProperty(this, "cellPos", void 0);
|
|
45
|
-
|
|
46
37
|
_defineProperty(this, "forMarginLeft", void 0);
|
|
47
|
-
|
|
48
38
|
_defineProperty(this, "draggingInfo", void 0);
|
|
49
|
-
|
|
50
39
|
this.cellPos = cellPos;
|
|
51
40
|
this.draggingInfo = draggingInfo;
|
|
52
41
|
this.forMarginLeft = forMarginLeft;
|
|
53
42
|
}
|
|
54
|
-
|
|
55
43
|
apply(tr) {
|
|
56
44
|
let state = this;
|
|
57
45
|
const action = tr.getMeta(PLUGIN_KEY);
|
|
58
|
-
|
|
59
46
|
if (action && typeof action.setCellPos === 'number') {
|
|
60
47
|
return new ResizeState(action.setCellPos, action.setForMarginLeft, null);
|
|
61
48
|
}
|
|
62
|
-
|
|
63
49
|
if (action && action.setDraggingInfo !== undefined) {
|
|
64
50
|
return new ResizeState(state.cellPos, state.forMarginLeft, action.setDraggingInfo);
|
|
65
51
|
}
|
|
66
|
-
|
|
67
52
|
if (state.cellPos && state.cellPos > -1 && tr.docChanged) {
|
|
68
53
|
let cellPos = tr.mapping.map(state.cellPos, -1);
|
|
69
|
-
|
|
70
54
|
if (!(0, _prosemirrorTables.pointsAtCell)(tr.doc.resolve(cellPos))) {
|
|
71
55
|
cellPos = null;
|
|
72
56
|
}
|
|
73
|
-
|
|
74
57
|
state = new ResizeState(cellPos, cellPos ? state.forMarginLeft : false, state.draggingInfo);
|
|
75
58
|
}
|
|
76
|
-
|
|
77
59
|
return state;
|
|
78
60
|
}
|
|
61
|
+
}
|
|
79
62
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
// Function that handles the mousemove event inside table cell.
|
|
83
64
|
function handleMouseMove(view, event) {
|
|
84
65
|
const resizeState = PLUGIN_KEY.getState(view.state);
|
|
85
|
-
|
|
86
66
|
if (resizeState.draggingInfo) {
|
|
87
67
|
return;
|
|
88
68
|
}
|
|
89
|
-
|
|
90
69
|
const target = domCellAround(event.target);
|
|
91
70
|
let forMarginLeft = false;
|
|
92
71
|
let cell = -1;
|
|
93
|
-
|
|
94
72
|
if (target instanceof HTMLTableCellElement) {
|
|
95
73
|
const {
|
|
96
74
|
left,
|
|
97
75
|
right
|
|
98
76
|
} = target.getBoundingClientRect();
|
|
99
|
-
const offsetLeft = event.clientX - left;
|
|
77
|
+
const offsetLeft = event.clientX - left;
|
|
78
|
+
// [FS] IRAD-949 2020-05-27
|
|
100
79
|
// Fix:Cell Resize Handler causes edit diificult to firsrst/last two chars in the cell.
|
|
101
80
|
// Rezie cursor position issue fixed.
|
|
102
|
-
|
|
103
81
|
if (offsetLeft <= HANDLE_WIDTH) {
|
|
104
82
|
if (target.cellIndex === 0) {
|
|
105
83
|
forMarginLeft = true;
|
|
@@ -111,105 +89,89 @@ function handleMouseMove(view, event) {
|
|
|
111
89
|
cell = edgeCell(view, event, 'right');
|
|
112
90
|
}
|
|
113
91
|
}
|
|
114
|
-
|
|
115
92
|
if (cell === resizeState.cellPos && forMarginLeft === resizeState.forMarginLeft) {
|
|
116
93
|
return;
|
|
117
94
|
}
|
|
118
|
-
|
|
119
95
|
if (cell !== -1) {
|
|
120
96
|
const $cell = view.state.doc.resolve(cell);
|
|
121
|
-
|
|
122
97
|
if (!$cell) {
|
|
123
98
|
return;
|
|
124
99
|
}
|
|
125
100
|
}
|
|
126
|
-
|
|
127
101
|
updateResizeHandle(view, cell, forMarginLeft);
|
|
128
|
-
}
|
|
129
|
-
|
|
102
|
+
}
|
|
130
103
|
|
|
104
|
+
// Function that handles the mouseleave event from the table cell.
|
|
131
105
|
function handleMouseLeave(view) {
|
|
132
106
|
const resizeState = PLUGIN_KEY.getState(view.state);
|
|
133
107
|
const {
|
|
134
108
|
cellPos,
|
|
135
109
|
draggingInfo
|
|
136
110
|
} = resizeState;
|
|
137
|
-
|
|
138
111
|
if (cellPos > -1 && !draggingInfo) {
|
|
139
112
|
updateResizeHandle(view, -1, false);
|
|
140
113
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
114
|
+
}
|
|
143
115
|
|
|
116
|
+
// Function that handles the mousedown event from the table cell.
|
|
144
117
|
function handleMouseDown(view, event) {
|
|
145
118
|
// It's possible that the resize action that happened earlier was inturrupted
|
|
146
119
|
// while its dependent mouse events were stopped or prevented by others.
|
|
147
120
|
// We need to stop the previous resize action if it did not finish.
|
|
148
121
|
cancelDrag && cancelDrag(event);
|
|
149
122
|
const resizeState = PLUGIN_KEY.getState(view.state);
|
|
150
|
-
|
|
151
123
|
if (resizeState.cellPos === -1 || resizeState.draggingInfo) {
|
|
152
124
|
return false;
|
|
153
125
|
}
|
|
154
|
-
|
|
155
126
|
let dragStarted = false;
|
|
156
127
|
let dragMoveHandler = null;
|
|
157
|
-
|
|
158
128
|
const finish = event => {
|
|
159
129
|
window.removeEventListener('mouseup', finish, true);
|
|
160
130
|
window.removeEventListener('mousemove', this.move, true);
|
|
161
131
|
dragStarted && handleDragEnd(view, event);
|
|
162
132
|
cancelDrag = null;
|
|
163
133
|
};
|
|
164
|
-
|
|
165
134
|
const move = event => {
|
|
166
135
|
if (event.which) {
|
|
167
136
|
if (!dragStarted) {
|
|
168
137
|
handleDragStart(view, event);
|
|
169
138
|
dragStarted = true;
|
|
170
|
-
}
|
|
139
|
+
}
|
|
140
|
+
// Move events should be batched to avoid over-handling the mouse
|
|
171
141
|
// event.
|
|
172
|
-
|
|
173
|
-
|
|
174
142
|
dragMoveHandler = dragMoveHandler || batchMouseHandler(handleDragMove);
|
|
175
143
|
dragMoveHandler(view, event);
|
|
176
144
|
} else {
|
|
177
145
|
finish(event);
|
|
178
146
|
}
|
|
179
147
|
};
|
|
180
|
-
|
|
181
148
|
cancelDrag = finish;
|
|
182
149
|
window.addEventListener('mouseup', finish, true);
|
|
183
150
|
window.addEventListener('mousemove', move, true);
|
|
184
151
|
event.preventDefault();
|
|
185
152
|
return true;
|
|
186
153
|
}
|
|
187
|
-
|
|
188
154
|
function handleDragStart(view, event) {
|
|
189
155
|
const resizeState = PLUGIN_KEY.getState(view.state);
|
|
190
|
-
|
|
191
156
|
if (resizeState.cellPos === -1 || resizeState.draggingInfo) {
|
|
192
157
|
return;
|
|
193
158
|
}
|
|
194
|
-
|
|
195
159
|
view.dispatch(view.state.tr.setMeta(PLUGIN_KEY, {
|
|
196
160
|
setDraggingInfo: calculateDraggingInfo(view, event, resizeState)
|
|
197
161
|
}));
|
|
198
|
-
}
|
|
199
|
-
// This will temporarily updates the table's style until the resize ends.
|
|
200
|
-
|
|
162
|
+
}
|
|
201
163
|
|
|
164
|
+
// Function that handles the mouse event while resizing the table cell.
|
|
165
|
+
// This will temporarily updates the table's style until the resize ends.
|
|
202
166
|
function handleDragMove(view, event) {
|
|
203
167
|
const resizeState = PLUGIN_KEY.getState(view.state);
|
|
204
168
|
const {
|
|
205
169
|
draggingInfo,
|
|
206
170
|
forMarginLeft
|
|
207
171
|
} = resizeState;
|
|
208
|
-
|
|
209
172
|
if (!draggingInfo) {
|
|
210
173
|
return;
|
|
211
174
|
}
|
|
212
|
-
|
|
213
175
|
const {
|
|
214
176
|
startX,
|
|
215
177
|
columnWidths,
|
|
@@ -225,12 +187,11 @@ function handleDragMove(view, event) {
|
|
|
225
187
|
const lastIndex = columnWidths.length - 1;
|
|
226
188
|
const widths = columnWidths.map((cw, index) => {
|
|
227
189
|
let ww;
|
|
228
|
-
|
|
229
190
|
if (forMarginLeft) {
|
|
230
191
|
if (index === 0) {
|
|
231
192
|
// Resize the first column.
|
|
232
|
-
ww = Math.min(Math.max(CELL_MIN_WIDTH, cw - dx), cw + tableMarginLeft);
|
|
233
|
-
|
|
193
|
+
ww = Math.min(Math.max(CELL_MIN_WIDTH, cw - dx), cw + tableMarginLeft);
|
|
194
|
+
// Resize table's left margin.
|
|
234
195
|
ml = Math.max(0, tableMarginLeft + cw - ww);
|
|
235
196
|
} else {
|
|
236
197
|
// The rest columns remain the same,
|
|
@@ -249,33 +210,30 @@ function handleDragMove(view, event) {
|
|
|
249
210
|
// This column does not resize.
|
|
250
211
|
ww = cw;
|
|
251
212
|
}
|
|
252
|
-
|
|
253
213
|
totalWidth += ww;
|
|
254
214
|
return ww;
|
|
255
215
|
});
|
|
256
216
|
const tableElementStyle = tableElement.style;
|
|
257
|
-
tableElementStyle.marginLeft = `${ml}px`;
|
|
217
|
+
tableElementStyle.marginLeft = `${ml}px`;
|
|
218
|
+
// [FS] IRAD-993 2020-06-26
|
|
258
219
|
// Fix:Table exceeds the canvas
|
|
259
|
-
|
|
260
220
|
tableElementStyle.width = Math.round(totalWidth - ml) + 'px';
|
|
261
221
|
tableElementStyle.minWidth = '';
|
|
262
222
|
columnElements.forEach((colEl, index) => {
|
|
263
223
|
colEl.style.width = Math.round(widths[index]) + 'px';
|
|
264
224
|
});
|
|
265
|
-
}
|
|
266
|
-
|
|
225
|
+
}
|
|
267
226
|
|
|
227
|
+
// Function that handles the mouse event while stop resizing the table cell.
|
|
268
228
|
function handleDragEnd(view, event) {
|
|
269
229
|
const resizeState = PLUGIN_KEY.getState(view.state);
|
|
270
230
|
const {
|
|
271
231
|
cellPos,
|
|
272
232
|
draggingInfo
|
|
273
233
|
} = resizeState;
|
|
274
|
-
|
|
275
234
|
if (!draggingInfo) {
|
|
276
235
|
return;
|
|
277
236
|
}
|
|
278
|
-
|
|
279
237
|
const {
|
|
280
238
|
columnElements,
|
|
281
239
|
tableElement
|
|
@@ -286,67 +244,53 @@ function handleDragEnd(view, event) {
|
|
|
286
244
|
const $cell = view.state.doc.resolve(cellPos);
|
|
287
245
|
const start = $cell.start(-1);
|
|
288
246
|
const table = $cell.node(-1);
|
|
289
|
-
|
|
290
247
|
const map = _prosemirrorTables.TableMap.get(table);
|
|
291
|
-
|
|
292
248
|
let tr = view.state.tr;
|
|
293
|
-
|
|
294
249
|
for (let row = 0; row < map.height; row++) {
|
|
295
250
|
for (let col = 0; col < widths.length; col++) {
|
|
296
251
|
const mapIndex = row * map.width + col;
|
|
297
|
-
|
|
298
252
|
if (row && map.map[mapIndex] == map.map[mapIndex - map.width]) {
|
|
299
253
|
// Rowspanning cell that has already been handled
|
|
300
254
|
continue;
|
|
301
255
|
}
|
|
302
|
-
|
|
303
256
|
const pos = map.map[mapIndex];
|
|
304
257
|
const {
|
|
305
258
|
attrs
|
|
306
259
|
} = table.nodeAt(pos);
|
|
307
260
|
const colspan = attrs.colspan || 1;
|
|
308
261
|
const colwidth = widths.slice(col, col + colspan);
|
|
309
|
-
|
|
310
262
|
if (colspan > 1) {
|
|
311
263
|
// The current cell spans across multiple columns, this forwards to
|
|
312
264
|
// the next cell for the next iteration.
|
|
313
265
|
col += colspan - 1;
|
|
314
266
|
}
|
|
315
|
-
|
|
316
267
|
if (attrs.colwidth && compareNumbersList(attrs.colwidth, colwidth)) {
|
|
317
268
|
continue;
|
|
318
269
|
}
|
|
319
|
-
|
|
320
270
|
tr = tr.setNodeMarkup(start + pos, null, (0, _prosemirrorTables.setAttr)(attrs, 'colwidth', colwidth));
|
|
321
271
|
}
|
|
322
272
|
}
|
|
323
|
-
|
|
324
273
|
const marginLeft = parseFloat(tableElement.style.marginLeft) || null;
|
|
325
|
-
|
|
326
274
|
if (table.attrs.marginLeft !== marginLeft) {
|
|
327
275
|
const nodeType = table.type;
|
|
328
|
-
|
|
329
276
|
const attrs = _objectSpread(_objectSpread({}, table.attrs), {}, {
|
|
330
277
|
marginLeft
|
|
331
278
|
});
|
|
332
|
-
|
|
333
279
|
const tableLookup = (0, _prosemirrorUtils.findParentNodeOfTypeClosestToPos)($cell, view.state.schema.nodes[nodeType.name]);
|
|
334
280
|
const tablePos = (0, _nullthrows.default)(tableLookup && tableLookup.pos);
|
|
335
281
|
tr = tr.setNodeMarkup(tablePos, nodeType, attrs);
|
|
336
282
|
}
|
|
337
|
-
|
|
338
283
|
if (tr.docChanged) {
|
|
339
284
|
// Let editor know the change.
|
|
340
285
|
view.dispatch(tr);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
286
|
+
}
|
|
287
|
+
// Hides the resize handle bars.
|
|
344
288
|
view.dispatch(view.state.tr.setMeta(PLUGIN_KEY, {
|
|
345
289
|
setDraggingInfo: null
|
|
346
290
|
}));
|
|
347
|
-
}
|
|
348
|
-
|
|
291
|
+
}
|
|
349
292
|
|
|
293
|
+
// Helper that prepares the information needed before the resizing starts.
|
|
350
294
|
function calculateDraggingInfo(view, event, resizeState) {
|
|
351
295
|
const {
|
|
352
296
|
cellPos,
|
|
@@ -366,14 +310,14 @@ function calculateDraggingInfo(view, event, resizeState) {
|
|
|
366
310
|
let taregtColumnIndex = -1;
|
|
367
311
|
const tableMarginLeftStyle = tableEl.style.marginLeft;
|
|
368
312
|
const tableMarginLeft = tableMarginLeftStyle && /\d+px/.test(tableMarginLeftStyle) ? parseFloat(tableMarginLeftStyle) : 0;
|
|
369
|
-
const tableMarginRight = tableWrapperRect.right - tableRect.right;
|
|
313
|
+
const tableMarginRight = tableWrapperRect.right - tableRect.right;
|
|
314
|
+
|
|
315
|
+
// Calculate the inital width of each column.
|
|
370
316
|
// Calculate the inital width of the table.
|
|
371
317
|
// Find out the target column to resize.
|
|
372
|
-
|
|
373
318
|
const columnWidths = Array.from(colEls).map((colEl, ii) => {
|
|
374
319
|
const cssWidth = colEl.style.width;
|
|
375
320
|
let colWidth = Math.max(CELL_MIN_WIDTH, cssWidth && parseFloat(cssWidth) || defaultColumnWidth);
|
|
376
|
-
|
|
377
321
|
if (tableWidth + colWidth > tableWrapperRect.width) {
|
|
378
322
|
// column is too wide, make it fit.
|
|
379
323
|
// colWidth -= tableWrapperRect.width - (tableWidth + colWidth);
|
|
@@ -381,14 +325,13 @@ function calculateDraggingInfo(view, event, resizeState) {
|
|
|
381
325
|
// Fix:Table exceeds the canvas
|
|
382
326
|
const tosub = Math.abs(tableWrapperRect.width - (tableWidth + colWidth));
|
|
383
327
|
colWidth = colWidth - tosub;
|
|
384
|
-
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// The edges of the column's right border.
|
|
385
331
|
// [FS] IRAD-949 2020-05-27
|
|
386
332
|
// Fix:Cell Resize Handler causes edit diificult to firsrst/last two chars in the cell.
|
|
387
|
-
|
|
388
|
-
|
|
389
333
|
const edgeLeft = tableWidth + colWidth - HANDLE_RIGHT_WIDTH / 2;
|
|
390
334
|
const edgeRight = tableWidth + colWidth + HANDLE_RIGHT_WIDTH / 2;
|
|
391
|
-
|
|
392
335
|
if (offsetLeft >= edgeLeft && offsetLeft <= edgeRight) {
|
|
393
336
|
// [FS] IRAD-993 2020-06-24
|
|
394
337
|
// Fix:Table exceeds the canvas
|
|
@@ -397,22 +340,18 @@ function calculateDraggingInfo(view, event, resizeState) {
|
|
|
397
340
|
taregtColumnIndex = ii;
|
|
398
341
|
}
|
|
399
342
|
}
|
|
400
|
-
|
|
401
343
|
tableWidth += colWidth;
|
|
402
344
|
return colWidth;
|
|
403
345
|
});
|
|
404
|
-
|
|
405
346
|
if (forMarginLeft) {
|
|
406
347
|
// Both the first column and the table's left margin should resize.
|
|
407
348
|
taregtColumnIndex = 0;
|
|
408
349
|
}
|
|
409
|
-
|
|
410
350
|
if (taregtColumnIndex < 0) {
|
|
411
351
|
// Nothing to resize. This happens when the mouse isn't nearby any position
|
|
412
352
|
// that is alllowed to resize a column.
|
|
413
353
|
return null;
|
|
414
354
|
}
|
|
415
|
-
|
|
416
355
|
return {
|
|
417
356
|
columnElements: colEls,
|
|
418
357
|
taregtColumnIndex,
|
|
@@ -424,19 +363,18 @@ function calculateDraggingInfo(view, event, resizeState) {
|
|
|
424
363
|
tableWidth,
|
|
425
364
|
tableWrapperWidth: tableWrapperRect.width
|
|
426
365
|
};
|
|
427
|
-
}
|
|
428
|
-
|
|
366
|
+
}
|
|
429
367
|
|
|
368
|
+
// Helper that finds the closest cell element from a given event target.
|
|
430
369
|
function domCellAround(target) {
|
|
431
370
|
while (target && target.nodeName !== 'TD' && target.nodeName !== 'TH') {
|
|
432
371
|
target = target.classList.contains('ProseMirror') ? null : target.parentElement;
|
|
433
372
|
}
|
|
434
|
-
|
|
435
373
|
return target;
|
|
436
|
-
}
|
|
437
|
-
// event target.
|
|
438
|
-
|
|
374
|
+
}
|
|
439
375
|
|
|
376
|
+
// Helper that resolves the prose-mirror node postion of a cell from a given
|
|
377
|
+
// event target.
|
|
440
378
|
function edgeCell(view, event, side) {
|
|
441
379
|
const {
|
|
442
380
|
pos
|
|
@@ -445,82 +383,69 @@ function edgeCell(view, event, side) {
|
|
|
445
383
|
top: event.clientY
|
|
446
384
|
});
|
|
447
385
|
const $cell = (0, _prosemirrorTables.cellAround)(view.state.doc.resolve(pos));
|
|
448
|
-
|
|
449
386
|
if (!$cell) {
|
|
450
387
|
return -1;
|
|
451
388
|
}
|
|
452
|
-
|
|
453
389
|
if (side == 'right') {
|
|
454
390
|
return $cell.pos;
|
|
455
391
|
}
|
|
456
|
-
|
|
457
392
|
const map = _prosemirrorTables.TableMap.get($cell.node(-1));
|
|
458
|
-
|
|
459
393
|
const start = $cell.start(-1);
|
|
460
394
|
const index = map.map.indexOf($cell.pos - start);
|
|
461
395
|
return index % map.width == 0 ? -1 : start + map.map[index - 1];
|
|
462
|
-
}
|
|
463
|
-
|
|
396
|
+
}
|
|
464
397
|
|
|
398
|
+
// Update the resize handler (UI) state.
|
|
465
399
|
function updateResizeHandle(view, cellPos, forMarginLeft) {
|
|
466
400
|
view.dispatch(view.state.tr.setMeta(PLUGIN_KEY, {
|
|
467
401
|
setCellPos: cellPos,
|
|
468
402
|
setForMarginLeft: forMarginLeft
|
|
469
403
|
}));
|
|
470
|
-
}
|
|
471
|
-
|
|
404
|
+
}
|
|
472
405
|
|
|
406
|
+
// Get the decorations that renders the resize handle bars.
|
|
473
407
|
function handleDecorations(state, resizeState) {
|
|
474
408
|
if (!resizeState.cellPos) {
|
|
475
409
|
return _prosemirrorView.DecorationSet.create(state.doc, []);
|
|
476
410
|
}
|
|
477
|
-
|
|
478
411
|
const decorations = [];
|
|
479
412
|
const $cell = state.doc.resolve(resizeState.cellPos);
|
|
480
413
|
const table = $cell.node(-1);
|
|
481
|
-
|
|
482
414
|
const map = _prosemirrorTables.TableMap.get(table);
|
|
483
|
-
|
|
484
415
|
const start = $cell.start(-1);
|
|
485
416
|
const col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan;
|
|
486
|
-
|
|
487
417
|
for (let row = 0; row < map.height; row++) {
|
|
488
|
-
const index = col + row * map.width - 1;
|
|
418
|
+
const index = col + row * map.width - 1;
|
|
419
|
+
// For positions that are have either a different cell or the end
|
|
489
420
|
// of the table to their right, and either the top of the table or
|
|
490
421
|
// a different cell above them, add a decoration
|
|
491
|
-
|
|
492
422
|
if ((col === map.width || map.map[index] !== map.map[index + 1]) && (row === 0 || map.map[index - 1] !== map.map[index - 1 - map.width])) {
|
|
493
423
|
const cellPos = map.map[index];
|
|
494
424
|
const pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;
|
|
495
425
|
const dom = document.createElement('div');
|
|
496
426
|
let className = 'column-resize-handle';
|
|
497
|
-
|
|
498
427
|
if (resizeState.forMarginLeft) {
|
|
499
428
|
className += ' for-margin-left';
|
|
500
429
|
}
|
|
501
|
-
|
|
502
430
|
dom.className = className;
|
|
503
431
|
decorations.push(_prosemirrorView.Decoration.widget(pos, dom));
|
|
504
432
|
}
|
|
505
433
|
}
|
|
506
|
-
|
|
507
434
|
return _prosemirrorView.DecorationSet.create(state.doc, decorations);
|
|
508
|
-
}
|
|
509
|
-
|
|
435
|
+
}
|
|
510
436
|
|
|
437
|
+
// Creates a custom table view that renders the margin-left style.
|
|
511
438
|
function createTableView(node, view) {
|
|
512
439
|
// [FS] IRAD-1008 2020-07-16
|
|
513
440
|
// Does not allow Table cell Resize in disable mode
|
|
514
441
|
isEnabled = view.editable;
|
|
515
442
|
return new _TableNodeView.default(node, CELL_MIN_WIDTH, view);
|
|
516
443
|
}
|
|
517
|
-
|
|
518
444
|
function batchMouseHandler(handler) {
|
|
519
445
|
let target = null;
|
|
520
446
|
let clientX = 0;
|
|
521
447
|
let clientY = 0;
|
|
522
448
|
let view = null;
|
|
523
|
-
|
|
524
449
|
const onMouseEvent = () => {
|
|
525
450
|
if (view && target) {
|
|
526
451
|
const pointerEvent = {
|
|
@@ -531,7 +456,6 @@ function batchMouseHandler(handler) {
|
|
|
531
456
|
handler(view, pointerEvent);
|
|
532
457
|
}
|
|
533
458
|
};
|
|
534
|
-
|
|
535
459
|
return function (ev, me) {
|
|
536
460
|
target = me.target;
|
|
537
461
|
clientX = me.clientX;
|
|
@@ -540,20 +464,19 @@ function batchMouseHandler(handler) {
|
|
|
540
464
|
requestAnimationFrame(onMouseEvent);
|
|
541
465
|
};
|
|
542
466
|
}
|
|
543
|
-
|
|
544
467
|
function compareNumbersList(one, two) {
|
|
545
468
|
if (one.length !== two.length) {
|
|
546
469
|
return false;
|
|
547
470
|
}
|
|
548
|
-
|
|
549
471
|
return !one.some((value, index) => two[index] !== value);
|
|
550
|
-
}
|
|
551
|
-
|
|
472
|
+
}
|
|
552
473
|
|
|
474
|
+
// Plugin that supports table columns resizing.
|
|
553
475
|
class TableResizePlugin extends _prosemirrorState.Plugin {
|
|
554
476
|
// [FS] IRAD-1005 2020-07-07
|
|
555
477
|
// Upgrade outdated packages.
|
|
556
478
|
//spec: Object;
|
|
479
|
+
|
|
557
480
|
constructor() {
|
|
558
481
|
super({
|
|
559
482
|
key: PLUGIN_KEY,
|
|
@@ -562,11 +485,9 @@ class TableResizePlugin extends _prosemirrorState.Plugin {
|
|
|
562
485
|
this.spec.props.nodeViews[(0, _prosemirrorTables.tableNodeTypes)(state.schema).table.name] = createTableView;
|
|
563
486
|
return new ResizeState(-1, null);
|
|
564
487
|
},
|
|
565
|
-
|
|
566
488
|
apply(tr, prev) {
|
|
567
489
|
return prev.apply(tr);
|
|
568
490
|
}
|
|
569
|
-
|
|
570
491
|
},
|
|
571
492
|
props: {
|
|
572
493
|
attributes(state) {
|
|
@@ -575,7 +496,6 @@ class TableResizePlugin extends _prosemirrorState.Plugin {
|
|
|
575
496
|
class: 'resize-cursor'
|
|
576
497
|
} : null;
|
|
577
498
|
},
|
|
578
|
-
|
|
579
499
|
handleDOMEvents: {
|
|
580
500
|
// Move events should be batched to avoid over-handling the mouse
|
|
581
501
|
// event.
|
|
@@ -583,19 +503,15 @@ class TableResizePlugin extends _prosemirrorState.Plugin {
|
|
|
583
503
|
mouseleave: handleMouseLeave,
|
|
584
504
|
mousedown: handleMouseDown
|
|
585
505
|
},
|
|
586
|
-
|
|
587
506
|
decorations(state) {
|
|
588
|
-
const resizeState = PLUGIN_KEY.getState(state);
|
|
507
|
+
const resizeState = PLUGIN_KEY.getState(state);
|
|
508
|
+
// [FS] IRAD-1008 2020-07-16
|
|
589
509
|
// Does not allow Table cell Resize in disable mode
|
|
590
|
-
|
|
591
510
|
return resizeState.cellPos > -1 && isEnabled ? handleDecorations(state, resizeState) : undefined;
|
|
592
511
|
},
|
|
593
|
-
|
|
594
512
|
nodeViews: {}
|
|
595
513
|
}
|
|
596
514
|
});
|
|
597
515
|
}
|
|
598
|
-
|
|
599
516
|
}
|
|
600
|
-
|
|
601
517
|
exports.default = TableResizePlugin;
|
|
@@ -4,15 +4,10 @@ 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 _toCSSColor = _interopRequireDefault(require("./ui/toCSSColor"));
|
|
11
|
-
|
|
12
9
|
var _Types = require("./Types");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
const TextColorMarkSpec = {
|
|
17
12
|
attrs: {
|
|
18
13
|
color: ''
|
|
@@ -27,22 +22,18 @@ const TextColorMarkSpec = {
|
|
|
27
22
|
};
|
|
28
23
|
}
|
|
29
24
|
}],
|
|
30
|
-
|
|
31
25
|
toDOM(node) {
|
|
32
26
|
const {
|
|
33
27
|
color
|
|
34
28
|
} = node.attrs;
|
|
35
29
|
let style = '';
|
|
36
|
-
|
|
37
30
|
if (color) {
|
|
38
31
|
style += `color: ${color};`;
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
return ['span', {
|
|
42
34
|
style
|
|
43
35
|
}, 0];
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
};
|
|
47
38
|
var _default = TextColorMarkSpec;
|
|
48
39
|
exports.default = _default;
|
|
@@ -4,13 +4,9 @@ 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 _toCSSColor = require("./ui/toCSSColor");
|
|
11
|
-
|
|
12
9
|
var _Types = require("./Types");
|
|
13
|
-
|
|
14
10
|
const TextHighlightMarkSpec = {
|
|
15
11
|
attrs: {
|
|
16
12
|
highlightColor: ''
|
|
@@ -29,22 +25,18 @@ const TextHighlightMarkSpec = {
|
|
|
29
25
|
};
|
|
30
26
|
}
|
|
31
27
|
}],
|
|
32
|
-
|
|
33
28
|
toDOM(node) {
|
|
34
29
|
const {
|
|
35
30
|
highlightColor
|
|
36
31
|
} = node.attrs;
|
|
37
32
|
let style = '';
|
|
38
|
-
|
|
39
33
|
if (highlightColor) {
|
|
40
34
|
style += `background-color: ${highlightColor};`;
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
return ['span', {
|
|
44
37
|
style
|
|
45
38
|
}, 0];
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
};
|
|
49
41
|
var _default = TextHighlightMarkSpec;
|
|
50
42
|
exports.default = _default;
|