@difizen/libro-markdown-cell 0.1.2
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/LICENSE +21 -0
- package/README.md +1 -0
- package/es/index.d.ts +7 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +6 -0
- package/es/index.less +116 -0
- package/es/markdown-cell-contribution.d.ts +12 -0
- package/es/markdown-cell-contribution.d.ts.map +1 -0
- package/es/markdown-cell-contribution.js +50 -0
- package/es/markdown-cell-model.d.ts +11 -0
- package/es/markdown-cell-model.d.ts.map +1 -0
- package/es/markdown-cell-model.js +77 -0
- package/es/markdown-cell-module.d.ts +3 -0
- package/es/markdown-cell-module.d.ts.map +1 -0
- package/es/markdown-cell-module.js +21 -0
- package/es/markdown-cell-protocol.d.ts +5 -0
- package/es/markdown-cell-protocol.d.ts.map +1 -0
- package/es/markdown-cell-protocol.js +1 -0
- package/es/markdown-cell-view.d.ts +40 -0
- package/es/markdown-cell-view.d.ts.map +1 -0
- package/es/markdown-cell-view.js +293 -0
- package/es/markdown-preview.d.ts +7 -0
- package/es/markdown-preview.d.ts.map +1 -0
- package/es/markdown-preview.js +31 -0
- package/package.json +64 -0
- package/src/index.less +116 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +6 -0
- package/src/markdown-cell-contribution.ts +33 -0
- package/src/markdown-cell-model.ts +40 -0
- package/src/markdown-cell-module.ts +26 -0
- package/src/markdown-cell-protocol.ts +6 -0
- package/src/markdown-cell-view.tsx +217 -0
- package/src/markdown-preview.tsx +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Difizen Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# libro shared model
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './markdown-cell-contribution.js';
|
|
2
|
+
export * from './markdown-cell-model.js';
|
|
3
|
+
export * from './markdown-cell-module.js';
|
|
4
|
+
export * from './markdown-cell-protocol.js';
|
|
5
|
+
export * from './markdown-cell-view.js';
|
|
6
|
+
export * from './markdown-preview.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
|
package/es/index.js
ADDED
package/es/index.less
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
.libro-dnd-cell-container {
|
|
2
|
+
.markdown-cell-preview.libro-dnd-cell {
|
|
3
|
+
border: 1px solid transparent;
|
|
4
|
+
box-shadow: unset;
|
|
5
|
+
|
|
6
|
+
&.active.command-mode {
|
|
7
|
+
border: 1px solid rgb(55, 147, 239);
|
|
8
|
+
box-shadow: unset;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.libro-dnd-cell-preview {
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.libro-markdown-warpper-container {
|
|
16
|
+
.libro-markdown-preview {
|
|
17
|
+
min-height: 50px;
|
|
18
|
+
padding: 0 4px;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
|
|
21
|
+
img {
|
|
22
|
+
max-width: 100%;
|
|
23
|
+
max-height: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
a {
|
|
27
|
+
text-decoration: none;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
a:hover {
|
|
31
|
+
text-decoration: underline;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
a:focus,
|
|
35
|
+
input:focus,
|
|
36
|
+
select:focus,
|
|
37
|
+
textarea:focus {
|
|
38
|
+
outline: 1px solid -webkit-focus-ring-color;
|
|
39
|
+
outline-offset: -1px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
hr {
|
|
43
|
+
height: 2px;
|
|
44
|
+
border: 0;
|
|
45
|
+
border-bottom: 2px solid;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
div {
|
|
49
|
+
width: 100%;
|
|
50
|
+
min-height: 20px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Adjust margin of first item in markdown cell */
|
|
54
|
+
*:first-child {
|
|
55
|
+
margin-top: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* h1 tags don't need top margin */
|
|
59
|
+
h1:first-child {
|
|
60
|
+
margin-top: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Removes bottom margin when only one item exists in markdown cell */
|
|
64
|
+
#preview > *:only-child,
|
|
65
|
+
#preview > *:last-child {
|
|
66
|
+
margin-bottom: 0;
|
|
67
|
+
padding-bottom: 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
table {
|
|
71
|
+
border-collapse: collapse;
|
|
72
|
+
border-spacing: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
table th,
|
|
76
|
+
table td {
|
|
77
|
+
border: 1px solid;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
table > thead > tr > th {
|
|
81
|
+
text-align: left;
|
|
82
|
+
border-bottom: 1px solid;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
table > thead > tr > th,
|
|
86
|
+
table > thead > tr > td,
|
|
87
|
+
table > tbody > tr > th,
|
|
88
|
+
table > tbody > tr > td {
|
|
89
|
+
padding: 5px 10px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
table > tbody > tr + tr > td {
|
|
93
|
+
border-top: 1px solid;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
blockquote {
|
|
97
|
+
margin: 0 7px 0 5px;
|
|
98
|
+
padding: 0 16px 0 10px;
|
|
99
|
+
border-left-width: 5px;
|
|
100
|
+
border-left-style: solid;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
code {
|
|
104
|
+
font-size: 1em;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
pre code {
|
|
108
|
+
color: var(--mana-libro-text-default-color);
|
|
109
|
+
font-family: 12px;
|
|
110
|
+
line-height: 1.357em;
|
|
111
|
+
white-space: pre-wrap;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CellMeta, CellOptions, CellModel } from '@difizen/libro-core';
|
|
2
|
+
import { CellModelContribution, CellViewContribution } from '@difizen/libro-core';
|
|
3
|
+
import { MarkdownCellModelFactory } from './markdown-cell-protocol.js';
|
|
4
|
+
import { MarkdownCellView } from './markdown-cell-view.js';
|
|
5
|
+
export declare class MarkdownCellContribution implements CellModelContribution, CellViewContribution {
|
|
6
|
+
markdownCellModelFactory: MarkdownCellModelFactory;
|
|
7
|
+
cellMeta: CellMeta;
|
|
8
|
+
canHandle(options: CellOptions): number;
|
|
9
|
+
createModel(options: CellOptions): CellModel;
|
|
10
|
+
view: typeof MarkdownCellView;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=markdown-cell-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-cell-contribution.d.ts","sourceRoot":"","sources":["../src/markdown-cell-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGlF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qBACa,wBACX,YAAW,qBAAqB,EAAE,oBAAoB;IAEpB,wBAAwB,EAAE,wBAAwB,CAAC;IAErF,QAAQ,EAAE,QAAQ,CAIhB;IAEF,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM;IAOvC,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS;IAK5C,IAAI,0BAAoB;CACzB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _class, _class2, _descriptor;
|
|
3
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); }
|
|
9
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
10
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
11
|
+
import { CellModelContribution, CellViewContribution } from '@difizen/libro-core';
|
|
12
|
+
import { singleton, inject } from '@difizen/mana-app';
|
|
13
|
+
import { MarkdownCellModelFactory } from "./markdown-cell-protocol.js";
|
|
14
|
+
import { MarkdownCellView } from "./markdown-cell-view.js";
|
|
15
|
+
export var MarkdownCellContribution = (_dec = singleton({
|
|
16
|
+
contrib: [CellModelContribution, CellViewContribution]
|
|
17
|
+
}), _dec2 = inject(MarkdownCellModelFactory), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
18
|
+
function MarkdownCellContribution() {
|
|
19
|
+
_classCallCheck(this, MarkdownCellContribution);
|
|
20
|
+
_initializerDefineProperty(this, "markdownCellModelFactory", _descriptor, this);
|
|
21
|
+
this.cellMeta = {
|
|
22
|
+
type: 'markdown',
|
|
23
|
+
name: 'Markdown',
|
|
24
|
+
order: 'c'
|
|
25
|
+
};
|
|
26
|
+
this.view = MarkdownCellView;
|
|
27
|
+
}
|
|
28
|
+
_createClass(MarkdownCellContribution, [{
|
|
29
|
+
key: "canHandle",
|
|
30
|
+
value: function canHandle(options) {
|
|
31
|
+
var _options$cell;
|
|
32
|
+
if ((options === null || options === void 0 || (_options$cell = options.cell) === null || _options$cell === void 0 ? void 0 : _options$cell.cell_type) === this.cellMeta.type) {
|
|
33
|
+
return 999;
|
|
34
|
+
}
|
|
35
|
+
return -1;
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
key: "createModel",
|
|
39
|
+
value: function createModel(options) {
|
|
40
|
+
var model = this.markdownCellModelFactory(options);
|
|
41
|
+
return model;
|
|
42
|
+
}
|
|
43
|
+
}]);
|
|
44
|
+
return MarkdownCellContribution;
|
|
45
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "markdownCellModelFactory", [_dec2], {
|
|
46
|
+
configurable: true,
|
|
47
|
+
enumerable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
initializer: null
|
|
50
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IMarkdownCell } from '@difizen/libro-common';
|
|
2
|
+
import type { LibroMarkdownCellModel } from '@difizen/libro-core';
|
|
3
|
+
import { CellOptions, LibroCellModel } from '@difizen/libro-core';
|
|
4
|
+
export declare class MarkdownCellModel extends LibroCellModel implements LibroMarkdownCellModel {
|
|
5
|
+
mimeType: string;
|
|
6
|
+
constructor(options: CellOptions);
|
|
7
|
+
isEdit: boolean;
|
|
8
|
+
preview: string;
|
|
9
|
+
toJSON(): IMarkdownCell;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=markdown-cell-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-cell-model.d.ts","sourceRoot":"","sources":["../src/markdown-cell-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIlE,qBACa,iBACX,SAAQ,cACR,YAAW,sBAAsB;IAGxB,QAAQ,SAAqB;gBAEL,OAAO,EAAE,WAAW;IAWrD,MAAM,UAAS;IAGf,OAAO,SAAM;IAEJ,MAAM,IAAI,aAAa;CAQjC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _class, _class2, _descriptor, _descriptor2, _descriptor3;
|
|
3
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
8
|
+
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); }
|
|
9
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
11
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
13
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
14
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
15
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
17
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
18
|
+
import { concatMultilineString } from '@difizen/libro-common';
|
|
19
|
+
import { CellOptions, LibroCellModel } from '@difizen/libro-core';
|
|
20
|
+
import { prop } from '@difizen/mana-app';
|
|
21
|
+
import { inject, transient } from '@difizen/mana-app';
|
|
22
|
+
export var MarkdownCellModel = (_dec = transient(), _dec2 = prop(), _dec3 = prop(), _dec4 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function (_LibroCellModel) {
|
|
23
|
+
_inherits(MarkdownCellModel, _LibroCellModel);
|
|
24
|
+
var _super = _createSuper(MarkdownCellModel);
|
|
25
|
+
function MarkdownCellModel(options) {
|
|
26
|
+
var _options$cell, _options$cell3;
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, MarkdownCellModel);
|
|
29
|
+
_this = _super.call(this, options);
|
|
30
|
+
_initializerDefineProperty(_this, "mimeType", _descriptor, _assertThisInitialized(_this));
|
|
31
|
+
_initializerDefineProperty(_this, "isEdit", _descriptor2, _assertThisInitialized(_this));
|
|
32
|
+
_initializerDefineProperty(_this, "preview", _descriptor3, _assertThisInitialized(_this));
|
|
33
|
+
if ((_options$cell = options.cell) !== null && _options$cell !== void 0 && _options$cell.id) {
|
|
34
|
+
var _options$cell2;
|
|
35
|
+
_this.id = (_options$cell2 = options.cell) === null || _options$cell2 === void 0 ? void 0 : _options$cell2.id;
|
|
36
|
+
}
|
|
37
|
+
if ((_options$cell3 = options.cell) !== null && _options$cell3 !== void 0 && _options$cell3.source) {
|
|
38
|
+
var _options$cell4;
|
|
39
|
+
_this.value = concatMultilineString((_options$cell4 = options.cell) === null || _options$cell4 === void 0 ? void 0 : _options$cell4.source);
|
|
40
|
+
}
|
|
41
|
+
return _this;
|
|
42
|
+
}
|
|
43
|
+
MarkdownCellModel = inject(CellOptions)(MarkdownCellModel, undefined, 0) || MarkdownCellModel;
|
|
44
|
+
_createClass(MarkdownCellModel, [{
|
|
45
|
+
key: "toJSON",
|
|
46
|
+
value: function toJSON() {
|
|
47
|
+
return {
|
|
48
|
+
id: this.id,
|
|
49
|
+
cell_type: 'markdown',
|
|
50
|
+
source: this.source,
|
|
51
|
+
metadata: this.metadata
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}]);
|
|
55
|
+
return MarkdownCellModel;
|
|
56
|
+
}(LibroCellModel), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "mimeType", [_dec2], {
|
|
57
|
+
configurable: true,
|
|
58
|
+
enumerable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
initializer: function initializer() {
|
|
61
|
+
return 'text/x-markdown';
|
|
62
|
+
}
|
|
63
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "isEdit", [_dec3], {
|
|
64
|
+
configurable: true,
|
|
65
|
+
enumerable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
initializer: function initializer() {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "preview", [_dec4], {
|
|
71
|
+
configurable: true,
|
|
72
|
+
enumerable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
initializer: function initializer() {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-cell-module.d.ts","sourceRoot":"","sources":["../src/markdown-cell-module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAO/C,eAAO,MAAM,kBAAkB,YAgBJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CellOptions } from '@difizen/libro-core';
|
|
2
|
+
import { MarkdownModule } from '@difizen/libro-markdown';
|
|
3
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
4
|
+
import { MarkdownCellContribution } from "./markdown-cell-contribution.js";
|
|
5
|
+
import { MarkdownCellModel } from "./markdown-cell-model.js";
|
|
6
|
+
import { MarkdownCellModelFactory } from "./markdown-cell-protocol.js";
|
|
7
|
+
import { MarkdownCellView } from "./markdown-cell-view.js";
|
|
8
|
+
export var MarkdownCellModule = ManaModule.create().register(MarkdownCellContribution, MarkdownCellView, MarkdownCellModel).register({
|
|
9
|
+
token: MarkdownCellModelFactory,
|
|
10
|
+
useFactory: function useFactory(ctx) {
|
|
11
|
+
return function (options) {
|
|
12
|
+
var child = ctx.container.createChild();
|
|
13
|
+
child.register({
|
|
14
|
+
token: CellOptions,
|
|
15
|
+
useValue: options
|
|
16
|
+
});
|
|
17
|
+
var model = child.get(MarkdownCellModel);
|
|
18
|
+
return model;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}).dependOn(MarkdownModule);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CellOptions } from '@difizen/libro-core';
|
|
2
|
+
import type { MarkdownCellModel } from './markdown-cell-model.js';
|
|
3
|
+
export type MarkdownCellModelFactory = (options: CellOptions) => MarkdownCellModel;
|
|
4
|
+
export declare const MarkdownCellModelFactory: unique symbol;
|
|
5
|
+
//# sourceMappingURL=markdown-cell-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-cell-protocol.d.ts","sourceRoot":"","sources":["../src/markdown-cell-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,iBAAiB,CAAC;AACnF,eAAO,MAAM,wBAAwB,eAAqC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var MarkdownCellModelFactory = Symbol('MarkdownCellModelFactory');
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { CodeEditorViewOptions, IEditor, CodeEditorView } from '@difizen/libro-code-editor';
|
|
3
|
+
import { CodeEditorManager } from '@difizen/libro-code-editor';
|
|
4
|
+
import type { CellCollapsible, CellViewOptions } from '@difizen/libro-core';
|
|
5
|
+
import { CellService, EditorStatus, LibroEditorCellView } from '@difizen/libro-core';
|
|
6
|
+
import { MarkdownParser } from '@difizen/libro-markdown';
|
|
7
|
+
import type { ViewSize } from '@difizen/mana-app';
|
|
8
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
9
|
+
import './index.less';
|
|
10
|
+
import type { MarkdownCellModel } from './markdown-cell-model.js';
|
|
11
|
+
export declare const MarkdownCell: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
+
export declare class MarkdownCellView extends LibroEditorCellView implements CellCollapsible {
|
|
13
|
+
get wrapperCls(): "" | "markdown-cell-preview";
|
|
14
|
+
view: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
viewManager: ViewManager;
|
|
16
|
+
codeEditorManager: CodeEditorManager;
|
|
17
|
+
editorView?: CodeEditorView;
|
|
18
|
+
editorAreaHeight: number;
|
|
19
|
+
noEditorAreaHeight: number;
|
|
20
|
+
editor: IEditor | undefined;
|
|
21
|
+
headingCollapsed: boolean;
|
|
22
|
+
collapsibleChildNumber: number;
|
|
23
|
+
editorStatus: EditorStatus;
|
|
24
|
+
get isEdit(): boolean | undefined;
|
|
25
|
+
get cellmodel(): MarkdownCellModel;
|
|
26
|
+
markdownParser: MarkdownParser;
|
|
27
|
+
constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, codeEditorManager: CodeEditorManager, markdownParser: MarkdownParser);
|
|
28
|
+
onViewMount(): void;
|
|
29
|
+
onViewResize(size: ViewSize): void;
|
|
30
|
+
calcEditorAreaHeight(): number;
|
|
31
|
+
protected getEditorOption(): CodeEditorViewOptions;
|
|
32
|
+
createEditor(): Promise<void>;
|
|
33
|
+
protected afterEditorReady(): Promise<void>;
|
|
34
|
+
shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
|
|
35
|
+
focus(toEdit: boolean): void;
|
|
36
|
+
blur(): void;
|
|
37
|
+
redo(): void;
|
|
38
|
+
undo(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=markdown-cell-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-cell-view.d.ts","sourceRoot":"","sources":["../src/markdown-cell-view.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,OAAO,EACP,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAGL,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAI3B,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,eAAO,MAAM,YAAY,0FAmCxB,CAAC;AAEF,qBAEa,gBAAiB,SAAQ,mBAAoB,YAAW,eAAe;IAClF,IAAa,UAAU,iCAKtB;IACQ,IAAI,2FAAgB;IAE7B,WAAW,EAAE,WAAW,CAAC;IAEzB,iBAAiB,EAAE,iBAAiB,CAAC;IAGrC,UAAU,CAAC,EAAE,cAAc,CAAC;IAG5B,gBAAgB,SAAK;IAGZ,kBAAkB,SAAK;IAExB,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAGpC,gBAAgB,UAAS;IAGzB,sBAAsB,SAAK;IAGlB,YAAY,EAAE,YAAY,CAA0B;IAE7D,IAAI,MAAM,wBAIT;IAED,IAAI,SAAS,sBAEZ;IAED,cAAc,EAAE,cAAc,CAAC;gBAGT,OAAO,EAAE,eAAe,EACvB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,WAAW,EAClB,iBAAiB,EAAE,iBAAiB,EACvC,cAAc,EAAE,cAAc;IAS/C,WAAW;IAWX,YAAY,CAAC,IAAI,EAAE,QAAQ;IAMpC,oBAAoB;IAIpB,SAAS,CAAC,eAAe,IAAI,qBAAqB;IAe5C,YAAY;cAqBF,gBAAgB;IAKvB,qBAAqB,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;IAOtD,KAAK,CAAC,MAAM,EAAE,OAAO;IAWrB,IAAI;IAIJ,IAAI,IAAI,IAAI;IAKZ,IAAI,IAAI,IAAI;CAItB"}
|