@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,29 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _prosemirrorHistory = require("prosemirror-history");
|
|
9
|
-
|
|
10
8
|
var _prosemirrorState = require("prosemirror-state");
|
|
11
|
-
|
|
12
9
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
|
-
|
|
14
10
|
var _prosemirrorView = require("prosemirror-view");
|
|
15
|
-
|
|
16
11
|
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
+
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); }
|
|
20
15
|
class HistoryUndoCommand extends _licitDocAttrsStep.UICommand {
|
|
21
16
|
constructor() {
|
|
22
17
|
super(...arguments);
|
|
23
|
-
|
|
24
18
|
_defineProperty(this, "execute", (state, dispatch, view) => {
|
|
25
19
|
return (0, _prosemirrorHistory.undo)(state, dispatch);
|
|
26
20
|
});
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
var _default = HistoryUndoCommand;
|
|
32
24
|
exports.default = _default;
|
|
@@ -4,64 +4,47 @@ 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 _prosemirrorView = require("prosemirror-view");
|
|
15
|
-
|
|
16
11
|
var _NodeNames = require("./NodeNames");
|
|
17
|
-
|
|
18
12
|
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
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); }
|
|
22
16
|
function insertHorizontalRule(tr, schema) {
|
|
23
17
|
const {
|
|
24
18
|
selection
|
|
25
19
|
} = tr;
|
|
26
|
-
|
|
27
20
|
if (!selection) {
|
|
28
21
|
return tr;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
const {
|
|
32
24
|
from,
|
|
33
25
|
to
|
|
34
26
|
} = selection;
|
|
35
|
-
|
|
36
27
|
if (from !== to) {
|
|
37
28
|
return tr;
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
const horizontalRule = schema.nodes[_NodeNames.HORIZONTAL_RULE];
|
|
41
|
-
|
|
42
31
|
if (!horizontalRule) {
|
|
43
32
|
return tr;
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
const node = horizontalRule.create({}, null, null);
|
|
47
|
-
|
|
48
35
|
const frag = _prosemirrorModel.Fragment.from(node);
|
|
49
|
-
|
|
50
36
|
tr = tr.insert(from, frag);
|
|
51
37
|
return tr;
|
|
52
38
|
}
|
|
53
|
-
|
|
54
39
|
class HorizontalRuleCommand extends _licitDocAttrsStep.UICommand {
|
|
55
40
|
constructor() {
|
|
56
41
|
super(...arguments);
|
|
57
|
-
|
|
58
42
|
_defineProperty(this, "execute", (state, dispatch, view) => {
|
|
59
43
|
const {
|
|
60
44
|
selection,
|
|
61
45
|
schema
|
|
62
46
|
} = state;
|
|
63
47
|
const tr = insertHorizontalRule(state.tr.setSelection(selection), schema);
|
|
64
|
-
|
|
65
48
|
if (tr.docChanged) {
|
|
66
49
|
dispatch && dispatch(tr);
|
|
67
50
|
return true;
|
|
@@ -70,8 +53,6 @@ class HorizontalRuleCommand extends _licitDocAttrsStep.UICommand {
|
|
|
70
53
|
}
|
|
71
54
|
});
|
|
72
55
|
}
|
|
73
|
-
|
|
74
56
|
}
|
|
75
|
-
|
|
76
57
|
var _default = HorizontalRuleCommand;
|
|
77
58
|
exports.default = _default;
|
|
@@ -4,23 +4,17 @@ 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
|
const DOM_ATTRIBUTE_PAGE_BREAK = 'data-page-break';
|
|
11
|
-
|
|
12
9
|
function getAttrs(dom) {
|
|
13
10
|
const attrs = {};
|
|
14
|
-
|
|
15
11
|
if (dom.getAttribute(DOM_ATTRIBUTE_PAGE_BREAK) || dom.style.pageBreakBefore === 'always') {
|
|
16
12
|
// Google Doc exports page break as HTML:
|
|
17
13
|
// `<hr style="page-break-before:always;display:none; />`.
|
|
18
14
|
attrs.pageBreak = true;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
return attrs;
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
const HorizontalRuleNode = {
|
|
25
19
|
attrs: {
|
|
26
20
|
pageBreak: {
|
|
@@ -32,17 +26,13 @@ const HorizontalRuleNode = {
|
|
|
32
26
|
tag: 'hr',
|
|
33
27
|
getAttrs
|
|
34
28
|
}],
|
|
35
|
-
|
|
36
29
|
toDOM(node) {
|
|
37
30
|
const domAttrs = {};
|
|
38
|
-
|
|
39
31
|
if (node.attrs.pageBreak) {
|
|
40
32
|
domAttrs[DOM_ATTRIBUTE_PAGE_BREAK] = 'true';
|
|
41
33
|
}
|
|
42
|
-
|
|
43
34
|
return ['hr', domAttrs];
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
};
|
|
47
37
|
var _default = HorizontalRuleNode;
|
|
48
38
|
exports.default = _default;
|
|
@@ -4,25 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _ImageSourceCommand = _interopRequireDefault(require("./ImageSourceCommand"));
|
|
11
|
-
|
|
12
9
|
var _ImageURLEditor = _interopRequireDefault(require("./ui/ImageURLEditor"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
13
|
class ImageFromURLCommand extends _ImageSourceCommand.default {
|
|
21
14
|
getEditor() {
|
|
22
15
|
return _ImageURLEditor.default;
|
|
23
16
|
}
|
|
24
|
-
|
|
25
17
|
}
|
|
26
|
-
|
|
27
18
|
var _default = ImageFromURLCommand;
|
|
28
19
|
exports.default = _default;
|
package/dist/ImageNodeSpec.js
CHANGED
|
@@ -4,12 +4,9 @@ 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 CSS_ROTATE_PATTERN = /rotate\(([0-9\.]+)rad\)/i;
|
|
11
9
|
const EMPTY_CSS_VALUE = new Set(['0%', '0pt', '0px']);
|
|
12
|
-
|
|
13
10
|
function getAttrs(dom) {
|
|
14
11
|
const {
|
|
15
12
|
cssFloat,
|
|
@@ -22,7 +19,6 @@ function getAttrs(dom) {
|
|
|
22
19
|
height
|
|
23
20
|
} = dom.style;
|
|
24
21
|
let align = dom.getAttribute('data-align') || dom.getAttribute('align');
|
|
25
|
-
|
|
26
22
|
if (align) {
|
|
27
23
|
align = /(left|right|center)/.test(align) ? align : null;
|
|
28
24
|
} else if (cssFloat === 'left' && !display) {
|
|
@@ -32,7 +28,6 @@ function getAttrs(dom) {
|
|
|
32
28
|
} else if (!cssFloat && display === 'block') {
|
|
33
29
|
align = 'block';
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
width = width || dom.getAttribute('width');
|
|
37
32
|
height = height || dom.getAttribute('height');
|
|
38
33
|
let crop = null;
|
|
@@ -40,11 +35,9 @@ function getAttrs(dom) {
|
|
|
40
35
|
const {
|
|
41
36
|
parentElement
|
|
42
37
|
} = dom;
|
|
43
|
-
|
|
44
38
|
if (parentElement instanceof HTMLElement) {
|
|
45
39
|
// Special case for Google doc's image.
|
|
46
40
|
const ps = parentElement.style;
|
|
47
|
-
|
|
48
41
|
if (ps.display === 'inline-block' && ps.overflow === 'hidden' && ps.width && ps.height && marginLeft && !EMPTY_CSS_VALUE.has(marginLeft) && marginTop && !EMPTY_CSS_VALUE.has(marginTop)) {
|
|
49
42
|
crop = {
|
|
50
43
|
width: parseInt(ps.width, 10) || 0,
|
|
@@ -53,17 +46,14 @@ function getAttrs(dom) {
|
|
|
53
46
|
top: parseInt(marginTop, 10) || 0
|
|
54
47
|
};
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
if (ps.transform) {
|
|
58
50
|
// example: `rotate(1.57rad) translateZ(0px)`;
|
|
59
51
|
const mm = ps.transform.match(CSS_ROTATE_PATTERN);
|
|
60
|
-
|
|
61
52
|
if (mm && mm[1]) {
|
|
62
53
|
rotate = parseFloat(mm[1]) || null;
|
|
63
54
|
}
|
|
64
55
|
}
|
|
65
56
|
}
|
|
66
|
-
|
|
67
57
|
return {
|
|
68
58
|
align,
|
|
69
59
|
alt: dom.getAttribute('alt') || null,
|
|
@@ -74,9 +64,9 @@ function getAttrs(dom) {
|
|
|
74
64
|
title: dom.getAttribute('title') || null,
|
|
75
65
|
width: parseInt(width, 10) || null
|
|
76
66
|
};
|
|
77
|
-
}
|
|
78
|
-
|
|
67
|
+
}
|
|
79
68
|
|
|
69
|
+
// https://github.com/ProseMirror/prosemirror-schema-basic/blob/master/src/schema-basic.js
|
|
80
70
|
const ImageNodeSpec = {
|
|
81
71
|
inline: true,
|
|
82
72
|
attrs: {
|
|
@@ -111,11 +101,9 @@ const ImageNodeSpec = {
|
|
|
111
101
|
tag: 'img[src]',
|
|
112
102
|
getAttrs
|
|
113
103
|
}],
|
|
114
|
-
|
|
115
104
|
toDOM(node) {
|
|
116
105
|
return ['img', node.attrs];
|
|
117
106
|
}
|
|
118
|
-
|
|
119
107
|
};
|
|
120
108
|
var _default = ImageNodeSpec;
|
|
121
109
|
exports.default = _default;
|
|
@@ -4,89 +4,63 @@ 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 _prosemirrorView = require("prosemirror-view");
|
|
15
|
-
|
|
16
11
|
var React = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _CursorPlaceholderPlugin = require("./CursorPlaceholderPlugin");
|
|
19
|
-
|
|
20
13
|
var _NodeNames = require("./NodeNames");
|
|
21
|
-
|
|
22
14
|
var _licitDocAttrsStep = require("@modusoperandi/licit-doc-attrs-step");
|
|
23
|
-
|
|
24
15
|
var _licitUiCommands = require("@modusoperandi/licit-ui-commands");
|
|
25
|
-
|
|
26
16
|
var _Types = require("./Types");
|
|
27
|
-
|
|
28
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
21
|
+
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); }
|
|
34
22
|
function insertImage(tr, schema, src) {
|
|
35
23
|
const {
|
|
36
24
|
selection
|
|
37
25
|
} = tr;
|
|
38
|
-
|
|
39
26
|
if (!selection) {
|
|
40
27
|
return tr;
|
|
41
28
|
}
|
|
42
|
-
|
|
43
29
|
const {
|
|
44
30
|
from,
|
|
45
31
|
to
|
|
46
32
|
} = selection;
|
|
47
|
-
|
|
48
33
|
if (from !== to) {
|
|
49
34
|
return tr;
|
|
50
35
|
}
|
|
51
|
-
|
|
52
36
|
const image = schema.nodes[_NodeNames.IMAGE];
|
|
53
|
-
|
|
54
37
|
if (!image) {
|
|
55
38
|
return tr;
|
|
56
39
|
}
|
|
57
|
-
|
|
58
40
|
const attrs = {
|
|
59
41
|
src: src || '',
|
|
60
42
|
alt: '',
|
|
61
43
|
title: ''
|
|
62
44
|
};
|
|
63
45
|
const node = image.create(attrs, null, null);
|
|
64
|
-
|
|
65
46
|
const frag = _prosemirrorModel.Fragment.from(node);
|
|
66
|
-
|
|
67
47
|
tr = tr.insert(from, frag);
|
|
68
48
|
return tr;
|
|
69
49
|
}
|
|
70
|
-
|
|
71
50
|
class ImageSourceCommand extends _licitDocAttrsStep.UICommand {
|
|
72
51
|
constructor() {
|
|
73
52
|
super(...arguments);
|
|
74
|
-
|
|
75
53
|
_defineProperty(this, "_popUp", null);
|
|
76
|
-
|
|
77
54
|
_defineProperty(this, "isEnabled", (state, view) => {
|
|
78
55
|
return this.__isEnabled(state, view);
|
|
79
56
|
});
|
|
80
|
-
|
|
81
57
|
_defineProperty(this, "waitForUserInput", (state, dispatch, view, event) => {
|
|
82
58
|
if (this._popUp) {
|
|
83
59
|
return Promise.resolve(undefined);
|
|
84
60
|
}
|
|
85
|
-
|
|
86
61
|
if (dispatch) {
|
|
87
62
|
dispatch((0, _CursorPlaceholderPlugin.showCursorPlaceholder)(state));
|
|
88
63
|
}
|
|
89
|
-
|
|
90
64
|
return new Promise(resolve => {
|
|
91
65
|
const props = {
|
|
92
66
|
runtime: view ? view.runtime : null
|
|
@@ -102,7 +76,6 @@ class ImageSourceCommand extends _licitDocAttrsStep.UICommand {
|
|
|
102
76
|
});
|
|
103
77
|
});
|
|
104
78
|
});
|
|
105
|
-
|
|
106
79
|
_defineProperty(this, "executeWithUserInput", (state, dispatch, view, inputs) => {
|
|
107
80
|
if (dispatch) {
|
|
108
81
|
const {
|
|
@@ -114,40 +87,31 @@ class ImageSourceCommand extends _licitDocAttrsStep.UICommand {
|
|
|
114
87
|
} = state;
|
|
115
88
|
tr = view ? (0, _CursorPlaceholderPlugin.hideCursorPlaceholder)(view.state) : tr;
|
|
116
89
|
tr = tr.setSelection(selection);
|
|
117
|
-
|
|
118
90
|
if (inputs) {
|
|
119
91
|
const {
|
|
120
92
|
src
|
|
121
93
|
} = inputs;
|
|
122
94
|
tr = insertImage(tr, schema, src);
|
|
123
95
|
}
|
|
124
|
-
|
|
125
96
|
dispatch(tr);
|
|
126
97
|
view && view.focus();
|
|
127
98
|
}
|
|
128
|
-
|
|
129
99
|
return false;
|
|
130
100
|
});
|
|
131
|
-
|
|
132
101
|
_defineProperty(this, "__isEnabled", (state, view) => {
|
|
133
102
|
const tr = state;
|
|
134
103
|
const {
|
|
135
104
|
selection
|
|
136
105
|
} = tr;
|
|
137
|
-
|
|
138
106
|
if (selection instanceof _prosemirrorState.TextSelection) {
|
|
139
107
|
return selection.from === selection.to;
|
|
140
108
|
}
|
|
141
|
-
|
|
142
109
|
return false;
|
|
143
110
|
});
|
|
144
111
|
}
|
|
145
|
-
|
|
146
112
|
getEditor() {
|
|
147
113
|
throw new Error('Not implemented');
|
|
148
114
|
}
|
|
149
|
-
|
|
150
115
|
}
|
|
151
|
-
|
|
152
116
|
var _default = ImageSourceCommand;
|
|
153
117
|
exports.default = _default;
|
|
@@ -4,64 +4,46 @@ 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 React = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _ImageSourceCommand = _interopRequireDefault(require("./ImageSourceCommand"));
|
|
15
|
-
|
|
16
11
|
var _ImageUploadEditor = _interopRequireDefault(require("./ui/ImageUploadEditor"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
|
+
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); }
|
|
26
18
|
class ImageUploadCommand extends _ImageSourceCommand.default {
|
|
27
19
|
constructor() {
|
|
28
20
|
super(...arguments);
|
|
29
|
-
|
|
30
21
|
_defineProperty(this, "isEnabled", (state, view) => {
|
|
31
22
|
if (!view) {
|
|
32
23
|
return false;
|
|
33
24
|
}
|
|
34
|
-
|
|
35
25
|
const {
|
|
36
26
|
runtime
|
|
37
27
|
} = view;
|
|
38
|
-
|
|
39
28
|
if (!runtime) {
|
|
40
29
|
return false;
|
|
41
30
|
}
|
|
42
|
-
|
|
43
31
|
const {
|
|
44
32
|
canUploadImage,
|
|
45
33
|
uploadImage
|
|
46
34
|
} = runtime;
|
|
47
|
-
|
|
48
35
|
if (!canUploadImage || !uploadImage) {
|
|
49
36
|
return false;
|
|
50
37
|
}
|
|
51
|
-
|
|
52
38
|
if (!canUploadImage()) {
|
|
53
39
|
return false;
|
|
54
40
|
}
|
|
55
|
-
|
|
56
41
|
return this.__isEnabled(state, view);
|
|
57
42
|
});
|
|
58
43
|
}
|
|
59
|
-
|
|
60
44
|
getEditor() {
|
|
61
45
|
return _ImageUploadEditor.default;
|
|
62
46
|
}
|
|
63
|
-
|
|
64
47
|
}
|
|
65
|
-
|
|
66
48
|
var _default = ImageUploadCommand;
|
|
67
49
|
exports.default = _default;
|
|
@@ -5,47 +5,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.uploadImageFiles = uploadImageFiles;
|
|
8
|
-
|
|
9
8
|
var _nullthrows = _interopRequireDefault(require("nullthrows"));
|
|
10
|
-
|
|
11
9
|
var _prosemirrorState = require("prosemirror-state");
|
|
12
|
-
|
|
13
10
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
14
|
-
|
|
15
11
|
var _prosemirrorView = require("prosemirror-view");
|
|
16
|
-
|
|
17
12
|
var _NodeNames = require("./NodeNames");
|
|
18
|
-
|
|
19
13
|
var _uuid = _interopRequireDefault(require("./ui/uuid"));
|
|
20
|
-
|
|
21
14
|
require("./ui/czi-image-upload-placeholder.css");
|
|
22
|
-
|
|
23
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
-
|
|
25
16
|
const IMAGE_FILE_TYLES = new Set(['image/jpeg', 'image/gif', 'image/png', 'image/jpg']);
|
|
26
17
|
const TITLE = 'Uploading...';
|
|
27
18
|
const INNER_HTML = new Array(4).join('<div class="czi-image-upload-placeholder-child"></div>');
|
|
28
|
-
|
|
29
19
|
function isImageUploadPlaceholderPlugin(plugin) {
|
|
30
20
|
return plugin instanceof ImageUploadPlaceholderPlugin;
|
|
31
21
|
}
|
|
32
|
-
|
|
33
22
|
function isImageFileType(file) {
|
|
34
23
|
return file && IMAGE_FILE_TYLES.has(file.type);
|
|
35
24
|
}
|
|
36
|
-
|
|
37
25
|
function findImageUploadPlaceholder(placeholderPlugin, state, id) {
|
|
38
26
|
const decos = placeholderPlugin.getState(state);
|
|
39
27
|
const found = decos.find(null, null, spec => spec.id === id);
|
|
40
28
|
return found.length ? found[0].from : null;
|
|
41
29
|
}
|
|
42
|
-
|
|
43
30
|
function defer(fn) {
|
|
44
31
|
return () => {
|
|
45
32
|
setTimeout(fn, 0);
|
|
46
33
|
};
|
|
47
34
|
}
|
|
48
|
-
|
|
49
35
|
function uploadImageFiles(view, files, coords) {
|
|
50
36
|
const {
|
|
51
37
|
runtime,
|
|
@@ -57,39 +43,30 @@ function uploadImageFiles(view, files, coords) {
|
|
|
57
43
|
schema,
|
|
58
44
|
plugins
|
|
59
45
|
} = state;
|
|
60
|
-
|
|
61
46
|
if (readOnly || disabled || !runtime || !runtime.canUploadImage) {
|
|
62
47
|
return false;
|
|
63
48
|
}
|
|
64
|
-
|
|
65
49
|
const imageType = schema.nodes[_NodeNames.IMAGE];
|
|
66
|
-
|
|
67
50
|
if (!imageType) {
|
|
68
51
|
return false;
|
|
69
52
|
}
|
|
70
|
-
|
|
71
53
|
const {
|
|
72
54
|
uploadImage,
|
|
73
55
|
canUploadImage
|
|
74
56
|
} = runtime;
|
|
75
|
-
|
|
76
57
|
if (!uploadImage || !canUploadImage) {
|
|
77
58
|
return false;
|
|
78
59
|
}
|
|
79
|
-
|
|
80
60
|
const imageFiles = Array.from(files).filter(isImageFileType);
|
|
81
|
-
|
|
82
61
|
if (!imageFiles.length) {
|
|
83
62
|
return false;
|
|
84
63
|
}
|
|
85
|
-
|
|
86
64
|
const placeholderPlugin = plugins.find(isImageUploadPlaceholderPlugin);
|
|
87
|
-
|
|
88
65
|
if (!placeholderPlugin) {
|
|
89
66
|
return false;
|
|
90
|
-
}
|
|
91
|
-
|
|
67
|
+
}
|
|
92
68
|
|
|
69
|
+
// A fresh object to act as the ID for this upload.
|
|
93
70
|
const id = {
|
|
94
71
|
debugId: 'image_upload_' + (0, _uuid.default)()
|
|
95
72
|
};
|
|
@@ -97,7 +74,6 @@ function uploadImageFiles(view, files, coords) {
|
|
|
97
74
|
const done = imageInfo => {
|
|
98
75
|
const pos = findImageUploadPlaceholder(placeholderPlugin, view.state, id);
|
|
99
76
|
let trNext = view.state.tr;
|
|
100
|
-
|
|
101
77
|
if (pos && !view.readOnly && !view.disabled) {
|
|
102
78
|
const imageNode = imageType.create(imageInfo);
|
|
103
79
|
trNext = trNext.replaceWith(pos, pos, imageNode);
|
|
@@ -105,7 +81,6 @@ function uploadImageFiles(view, files, coords) {
|
|
|
105
81
|
// Upload was cancelled.
|
|
106
82
|
imageFiles.length = 0;
|
|
107
83
|
}
|
|
108
|
-
|
|
109
84
|
if (imageFiles.length) {
|
|
110
85
|
uploadNext();
|
|
111
86
|
} else {
|
|
@@ -116,10 +91,8 @@ function uploadImageFiles(view, files, coords) {
|
|
|
116
91
|
}
|
|
117
92
|
});
|
|
118
93
|
}
|
|
119
|
-
|
|
120
94
|
view.dispatch(trNext);
|
|
121
95
|
};
|
|
122
|
-
|
|
123
96
|
const ff = (0, _nullthrows.default)(imageFiles.shift());
|
|
124
97
|
uploadImage(ff).then(done).catch(done.bind(null, {
|
|
125
98
|
src: null
|
|
@@ -128,27 +101,26 @@ function uploadImageFiles(view, files, coords) {
|
|
|
128
101
|
uploadNext();
|
|
129
102
|
let {
|
|
130
103
|
tr
|
|
131
|
-
} = state;
|
|
104
|
+
} = state;
|
|
132
105
|
|
|
133
|
-
|
|
106
|
+
// Replace the selection with a placeholder
|
|
107
|
+
let from = 0;
|
|
134
108
|
|
|
109
|
+
// Adjust the cursor to the dropped position.
|
|
135
110
|
if (coords) {
|
|
136
111
|
const dropPos = view.posAtCoords({
|
|
137
112
|
left: coords.x,
|
|
138
113
|
top: coords.y
|
|
139
114
|
});
|
|
140
|
-
|
|
141
115
|
if (!dropPos) {
|
|
142
116
|
return false;
|
|
143
117
|
}
|
|
144
|
-
|
|
145
118
|
from = dropPos.pos;
|
|
146
119
|
tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, from, from));
|
|
147
120
|
} else {
|
|
148
121
|
from = tr.selection.to;
|
|
149
122
|
tr = tr.setSelection(_prosemirrorState.TextSelection.create(tr.doc, from, from));
|
|
150
123
|
}
|
|
151
|
-
|
|
152
124
|
const meta = {
|
|
153
125
|
add: {
|
|
154
126
|
id,
|
|
@@ -158,9 +130,9 @@ function uploadImageFiles(view, files, coords) {
|
|
|
158
130
|
tr = tr.setMeta(placeholderPlugin, meta);
|
|
159
131
|
view.dispatch(tr);
|
|
160
132
|
return true;
|
|
161
|
-
}
|
|
162
|
-
|
|
133
|
+
}
|
|
163
134
|
|
|
135
|
+
// https://prosemirror.net/examples/upload/
|
|
164
136
|
class ImageUploadPlaceholderPlugin extends _prosemirrorState.Plugin {
|
|
165
137
|
constructor() {
|
|
166
138
|
super({
|
|
@@ -171,44 +143,34 @@ class ImageUploadPlaceholderPlugin extends _prosemirrorState.Plugin {
|
|
|
171
143
|
init() {
|
|
172
144
|
return _prosemirrorView.DecorationSet.empty;
|
|
173
145
|
},
|
|
174
|
-
|
|
175
146
|
apply(tr, set) {
|
|
176
147
|
// Adjust decoration positions to changes made by the transaction
|
|
177
|
-
set = set.map(tr.mapping, tr.doc);
|
|
178
|
-
|
|
148
|
+
set = set.map(tr.mapping, tr.doc);
|
|
149
|
+
// See if the transaction adds or removes any placeholders
|
|
179
150
|
const action = tr.getMeta(this);
|
|
180
|
-
|
|
181
151
|
if (action && action.add) {
|
|
182
152
|
const el = document.createElement('div');
|
|
183
153
|
el.title = TITLE;
|
|
184
154
|
el.className = 'czi-image-upload-placeholder';
|
|
185
155
|
el.innerHTML = INNER_HTML;
|
|
186
|
-
|
|
187
156
|
const deco = _prosemirrorView.Decoration.widget(action.add.pos, el, {
|
|
188
157
|
id: action.add.id
|
|
189
158
|
});
|
|
190
|
-
|
|
191
159
|
set = set.add(tr.doc, [deco]);
|
|
192
160
|
} else if (action && action.remove) {
|
|
193
161
|
const finder = spec => spec.id == action.remove.id;
|
|
194
|
-
|
|
195
162
|
set = set.remove(set.find(null, null, finder));
|
|
196
163
|
}
|
|
197
|
-
|
|
198
164
|
return set;
|
|
199
165
|
}
|
|
200
|
-
|
|
201
166
|
},
|
|
202
167
|
props: {
|
|
203
168
|
decorations(state) {
|
|
204
169
|
return this.getState(state);
|
|
205
170
|
}
|
|
206
|
-
|
|
207
171
|
}
|
|
208
172
|
});
|
|
209
173
|
}
|
|
210
|
-
|
|
211
174
|
}
|
|
212
|
-
|
|
213
175
|
var _default = ImageUploadPlaceholderPlugin;
|
|
214
176
|
exports.default = _default;
|