@voplus/morpho-document 6.0.146 → 6.0.147

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.
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ /** 用于 Propertie 的 Document Header */
3
+ declare const DocumentPropertieHeader: (props: {
4
+ id: string;
5
+ className?: string;
6
+ }) => React.JSX.Element;
7
+ export default DocumentPropertieHeader;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { observe } from "@voplus/morpho-ui";
3
+ import { faEllipsisVertical } from "@fortawesome/pro-light-svg-icons";
4
+ import { FontAwesomeIcon as FAIcon } from "@fortawesome/react-fontawesome";
5
+ import ToolBar from "../../controls/ToolBar/ToolBar2";
6
+ import DocumentHeader from "../DocumentHeader";
7
+ import classnames from "classnames";
8
+ /** 用于 Propertie 的 Document Header */
9
+ const DocumentPropertieHeader = (props) => {
10
+ const { id } = props;
11
+ return observe(() => (React.createElement(DocumentHeader, { id: id, className: classnames("document-propertie-header", props.className), quickVisible: false, tagsVisible: false, descriptionVisible: false, quickDataBarVisible: false, flagVisible: false, autoSaveName: true, quickDataBarAlign: "left", clickNameEffect: "edit", tools: React.createElement(ToolBar, { id: id, moreProps: { icon: React.createElement(FAIcon, { icon: faEllipsisVertical }) } }) })));
12
+ };
13
+ export default DocumentPropertieHeader;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/DocumentPropertieHeader/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,eAAe,IAAI,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,OAAO,MAAM,iCAAiC,CAAC;AACtD,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,qCAAqC;AACrC,MAAM,uBAAuB,GAAG,CAAC,KAAyC,EAAE,EAAE;IAC7E,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAErB,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,CACpB,oBAAC,cAAc,IACd,EAAE,EAAE,EAAE,EACN,SAAS,EAAE,UAAU,CAAC,2BAA2B,EAAE,KAAK,CAAC,SAAS,CAAC,EACnE,YAAY,EAAE,KAAK,EACnB,WAAW,EAAE,KAAK,EAClB,kBAAkB,EAAE,KAAK,EACzB,mBAAmB,EAAE,KAAK,EAC1B,WAAW,EAAE,KAAK,EAClB,YAAY,EAAE,IAAI,EAClB,iBAAiB,EAAC,MAAM,EACxB,eAAe,EAAC,MAAM,EACtB,KAAK,EAAE,oBAAC,OAAO,IAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,oBAAC,MAAM,IAAC,IAAI,EAAE,kBAAkB,GAAI,EAAE,GAAI,GACpF,CACF,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import "./index.less";
2
+ import { DescriptionEditorProps } from "./state";
3
+ import React from "react";
4
+ declare const DescriptionEditor: {
5
+ (props: DescriptionEditorProps): React.JSX.Element;
6
+ defaultProps: {
7
+ collapsible: boolean;
8
+ collapseAll: boolean;
9
+ };
10
+ };
11
+ export default DescriptionEditor;
@@ -0,0 +1,80 @@
1
+ import "./index.less";
2
+ import { Scrollbars } from "react-custom-scrollbars-2";
3
+ import { Button, Space, Tooltip } from "antd";
4
+ import { State } from "./state";
5
+ import React, { useEffect, useState, useRef } from "react";
6
+ import { faPenToSquare, faChevronDoubleDown, faChevronDoubleUp, } from "@fortawesome/pro-solid-svg-icons";
7
+ import ProseMirrorViewer from "@voplus/morpho-text/es/controls/ProseMirror/Viewer";
8
+ import LiteProseMirror from "@voplus/morpho-text/es/components/LiteProseMirror";
9
+ import { FontAwesomeIcon as FAIcon } from "@fortawesome/react-fontawesome";
10
+ import { observe } from "@voplus/morpho-ui";
11
+ import { runInAction } from "mobx";
12
+ import { useDocumentStore } from "@voplus/morpho-document-core";
13
+ const DescriptionEditor = (props) => {
14
+ var _a;
15
+ const { id, description, readonly, collapsible, onSave } = props;
16
+ const ref = useRef(null);
17
+ const [state] = useState(new State());
18
+ const documentStore = useDocumentStore();
19
+ useEffect(() => {
20
+ runInAction(() => {
21
+ state.description = description || "";
22
+ });
23
+ }, [description]);
24
+ /** init */
25
+ useEffect(() => {
26
+ getDescEditorHeight();
27
+ }, [id, (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getElementsByClassName("ProseMirror-container")[0]]);
28
+ return observe(() => (React.createElement("div", { className: "description-editor_2", ref: ref },
29
+ React.createElement("div", { className: "description-editor-header" },
30
+ React.createElement("div", null, "Description"),
31
+ React.createElement(Button, { className: "edit-icon", type: "link", disabled: readonly, onClick: () => runInAction(() => (state.editable = true)) },
32
+ React.createElement(FAIcon, { icon: faPenToSquare }))),
33
+ state.editable ? (React.createElement("div", null,
34
+ React.createElement(LiteProseMirror, { scroll: true, toolbarType: "simple", defaultHtml: description || "", onChange: (opt) => (state.description =
35
+ opt.editor.dom.innerHTML === "<p><br></p>"
36
+ ? ""
37
+ : opt.editor.dom.innerHTML) }),
38
+ React.createElement("div", { className: "description-editor-footer" },
39
+ React.createElement(Space, null,
40
+ React.createElement(Button, { type: "default", onClick: () => runInAction(() => (state.editable = false)) }, "Cancel"),
41
+ React.createElement(Button, { type: "primary", loading: state.loading, onClick: save }, "Save"))))) : (React.createElement("div", null,
42
+ React.createElement(Scrollbars, { autoHide: true, autoHeight: true, autoHeightMax: state.collapse ? "100%" : "20vh" },
43
+ React.createElement(ProseMirrorViewer, { html: description !== null && description !== void 0 ? description : "<div class='no-description'>No Description</div>" })),
44
+ state.hasMore && (React.createElement(Tooltip, { title: state.collapse
45
+ ? "Collapse Description"
46
+ : "Expand all Description" },
47
+ React.createElement("div", { className: "more-description-btn", onClick: () => runInAction(() => (state.collapse = !state.collapse)) },
48
+ React.createElement(FAIcon, { icon: state.collapse ? faChevronDoubleUp : faChevronDoubleDown })))))))));
49
+ async function save() {
50
+ runInAction(() => (state.loading = true));
51
+ onSave
52
+ ? await onSave(state.description)
53
+ : await documentStore.edit(id, {
54
+ data: { Description: state.description },
55
+ error: "message",
56
+ });
57
+ runInAction(() => {
58
+ state.loading = false;
59
+ state.editable = false;
60
+ });
61
+ }
62
+ function getDescEditorHeight() {
63
+ runInAction(() => {
64
+ var _a;
65
+ const ele = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getElementsByClassName("ProseMirror-container")[0];
66
+ state.hasMore = !!(ele && (ele === null || ele === void 0 ? void 0 : ele.clientHeight) > 170) && !!collapsible;
67
+ console.log(ele, ele === null || ele === void 0 ? void 0 : ele.clientHeight, state.hasMore, "*----hasmore");
68
+ return () => {
69
+ state.hasMore = false;
70
+ state.collapse = false;
71
+ };
72
+ });
73
+ }
74
+ };
75
+ DescriptionEditor.defaultProps = {
76
+ collapsible: true,
77
+ collapseAll: false,
78
+ };
79
+ export default DescriptionEditor;
80
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/controls/DescriptionEditor2/index.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAA0B,KAAK,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,kCAAk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O,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YACnE,OAAO,GAAG,EAAE;gBACV,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;gBACtB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;YACzB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,iBAAiB,CAAC,YAAY,GAAG;IAC/B,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,KAAK;CACnB,CAAC;AACF,eAAe,iBAAiB,CAAC"}
@@ -0,0 +1,39 @@
1
+ :global {
2
+ .description-editor_2 {
3
+ .no-description {
4
+ color: #868686;
5
+ font-size: 14px;
6
+ }
7
+ .description-editor-header {
8
+ font-size: 14px;
9
+ font-weight: bold;
10
+ display: flex;
11
+ justify-content: space-between;
12
+ align-items: center;
13
+ margin: 0 0 0.45rem;
14
+ .edit-icon {
15
+ height: 20px;
16
+ color: #cbcbcb;
17
+ padding: 0 8px;
18
+ }
19
+ }
20
+ .more-description-btn {
21
+ width: 44px;
22
+ line-height: 14px;
23
+ margin: auto;
24
+ color: #868686;
25
+ text-align: center;
26
+ cursor: pointer;
27
+ .svg-inline--fa {
28
+ font-size: 13px;
29
+ }
30
+ }
31
+ .description-editor-footer {
32
+ padding-top: 0.75rem;
33
+ text-align: right;
34
+ .ant-btn {
35
+ margin-left: 10px;
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,28 @@
1
+ export type DescriptionEditorProps = {
2
+ /** id of document */
3
+ id: string;
4
+ /** description of document */
5
+ description?: string;
6
+ /** readonly */
7
+ readonly?: boolean;
8
+ /** 是否可折叠 */
9
+ collapsible?: boolean;
10
+ /** 是否全部折叠 (高度0), 预设false */
11
+ collapseAll?: boolean;
12
+ /** save function */
13
+ onSave?: (description?: string) => Promise<void> | void;
14
+ };
15
+ export declare class State {
16
+ props: DescriptionEditorProps;
17
+ /** description of document */
18
+ description: string;
19
+ /** editable of ProseMirror */
20
+ editable: boolean;
21
+ /** loading of save */
22
+ loading: boolean;
23
+ /** collapse description */
24
+ collapse: boolean;
25
+ /** proseMirror.height > 110 显示折叠按钮 */
26
+ hasMore: boolean;
27
+ constructor();
28
+ }
@@ -0,0 +1,64 @@
1
+ import { __decorate } from "tslib";
2
+ import { makeObservable, observable } from "mobx";
3
+ export class State {
4
+ constructor() {
5
+ Object.defineProperty(this, "props", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: void 0
10
+ });
11
+ /** description of document */
12
+ Object.defineProperty(this, "description", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: ""
17
+ });
18
+ /** editable of ProseMirror */
19
+ Object.defineProperty(this, "editable", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: false
24
+ });
25
+ /** loading of save */
26
+ Object.defineProperty(this, "loading", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: false
31
+ });
32
+ /** collapse description */
33
+ Object.defineProperty(this, "collapse", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: false
38
+ });
39
+ /** proseMirror.height > 110 显示折叠按钮 */
40
+ Object.defineProperty(this, "hasMore", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: false
45
+ });
46
+ makeObservable(this);
47
+ }
48
+ }
49
+ __decorate([
50
+ observable
51
+ ], State.prototype, "description", void 0);
52
+ __decorate([
53
+ observable
54
+ ], State.prototype, "editable", void 0);
55
+ __decorate([
56
+ observable
57
+ ], State.prototype, "loading", void 0);
58
+ __decorate([
59
+ observable
60
+ ], State.prototype, "collapse", void 0);
61
+ __decorate([
62
+ observable
63
+ ], State.prototype, "hasMore", void 0);
64
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/controls/DescriptionEditor2/state.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAsBlD,MAAM,OAAO,KAAK;IAajB;QAZO;;;;;WAA8B;QACrC,8BAA8B;QACX;;;;mBAAc,EAAE;WAAC;QACpC,8BAA8B;QACX;;;;mBAAW,KAAK;WAAC;QACpC,sBAAsB;QACH;;;;mBAAU,KAAK;WAAC;QACnC,2BAA2B;QACR;;;;mBAAW,KAAK;WAAC;QACpC,sCAAsC;QACnB;;;;mBAAU,KAAK;WAAC;QAGlC,cAAc,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;CACD;AAbmB;IAAlB,UAAU;0CAAyB;AAEjB;IAAlB,UAAU;uCAAyB;AAEjB;IAAlB,UAAU;sCAAwB;AAEhB;IAAlB,UAAU;uCAAyB;AAEjB;IAAlB,UAAU;sCAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voplus/morpho-document",
3
- "version": "6.0.146",
3
+ "version": "6.0.147",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://voplus.visualstudio.com/morpho-document/_git/morpho-document"