@titaui/pc 1.10.47 → 1.10.50

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.
@@ -98,7 +98,7 @@
98
98
  }
99
99
 
100
100
  .titaui-dialog-confirm__body-title {
101
- display: flex;
101
+ display: inline-flex;
102
102
  align-items: center;
103
103
  }
104
104
 
@@ -25,6 +25,8 @@ var _tools = require("../../../../utils/tools");
25
25
 
26
26
  var _header = _interopRequireDefault(require("../components/header"));
27
27
 
28
+ var _utils = require("./utils");
29
+
28
30
  require("./index.css");
29
31
 
30
32
  var _excluded = ["data"];
@@ -41,47 +43,6 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
41
43
 
42
44
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
43
45
 
44
- var getChartProps = function getChartProps(chartPropsStr) {
45
- var chartQuery = JSON.parse(chartPropsStr);
46
-
47
- if (typeof chartQuery === "number") {
48
- return {
49
- chartId: String(chartQuery)
50
- };
51
- }
52
-
53
- return {
54
- chartId: chartQuery.id,
55
- timeRange: chartQuery.timeRange
56
- };
57
- };
58
-
59
- var systemPublisher = {
60
- avatar: {
61
- big: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_b.png",
62
- color: "#f0c75a",
63
- hasAvatar: true,
64
- large: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_l.png",
65
- medium: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_m.png",
66
- normal: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_n.png",
67
- original: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_o.png",
68
- small: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_s.png"
69
- },
70
- blessingType: 0,
71
- decorationType: 0,
72
- departmentId: 0,
73
- departmentName: null,
74
- jobState: 0,
75
- medalPosition: null,
76
- medalUrl: null,
77
- name: "Tita小助手",
78
- postition: null,
79
- praiseType: 0,
80
- tag: null,
81
- userId: 100000,
82
- userMark: null,
83
- userType: 0
84
- };
85
46
  var prefixCls = "titaui-dynamic-chart";
86
47
 
87
48
  var DynamicChart = function DynamicChart(_ref) {
@@ -93,7 +54,9 @@ var DynamicChart = function DynamicChart(_ref) {
93
54
  var _useContext = (0, _react.useContext)(_context.SearchKeyContext),
94
55
  searchKeyWord = _useContext.searchKeyWord;
95
56
 
96
- var chartQuery = getChartProps(data.biId);
57
+ var chartQuery = (0, _utils.getChartProps)(data.biId); // const chartQuery = getChartProps('{"type":"diaryFeedChart","id":"43","timeRange":"2022/03/01T00:00:00 : 2022/03/05T00:00:00"}');
58
+ // console.log(chartQuery);
59
+
97
60
  (0, _react.useEffect)(function () {
98
61
  (0, _tools.highLightWord)({
99
62
  parentDom: contentRef.current,
@@ -105,7 +68,7 @@ var DynamicChart = function DynamicChart(_ref) {
105
68
  }, /*#__PURE__*/_react["default"].createElement(_header["default"], _extends({
106
69
  data: data
107
70
  }, restProps, {
108
- user: systemPublisher,
71
+ user: _utils.systemPublisher,
109
72
  desc: /*#__PURE__*/_react["default"].createElement("div", {
110
73
  style: {
111
74
  marginLeft: "4px",
@@ -128,11 +91,11 @@ var DynamicChart = function DynamicChart(_ref) {
128
91
  alt: "right"
129
92
  }))), /*#__PURE__*/_react["default"].createElement("div", {
130
93
  className: "".concat(prefixCls, "__charts")
131
- }, /*#__PURE__*/_react["default"].createElement(_supersetCharts["default"], _extends({}, chartQuery, {
132
- layout: "feed-card",
94
+ }, /*#__PURE__*/_react["default"].createElement(_supersetCharts["default"], _extends({
133
95
  width: 800,
134
- height: 400
135
- }))));
96
+ height: 400,
97
+ layout: "feed-card"
98
+ }, chartQuery))));
136
99
  };
137
100
 
138
101
  var _default = DynamicChart;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.systemPublisher = exports.safeParse = exports.getChartProps = void 0;
7
+ var systemPublisher = {
8
+ avatar: {
9
+ big: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_b.png",
10
+ color: "#f0c75a",
11
+ hasAvatar: true,
12
+ large: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_l.png",
13
+ medium: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_m.png",
14
+ normal: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_n.png",
15
+ original: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_o.png",
16
+ small: "https://file.tita.com/TitaImage/352728/d820ed195e204b5aa7d6d1b9bd94f215_s.png"
17
+ },
18
+ blessingType: 0,
19
+ decorationType: 0,
20
+ departmentId: 0,
21
+ departmentName: null,
22
+ jobState: 0,
23
+ medalPosition: null,
24
+ medalUrl: null,
25
+ name: "Tita小助手",
26
+ postition: null,
27
+ praiseType: 0,
28
+ tag: null,
29
+ userId: 100000,
30
+ userMark: null,
31
+ userType: 0
32
+ };
33
+ exports.systemPublisher = systemPublisher;
34
+
35
+ var safeParse = function safeParse(json) {
36
+ var parsed = {};
37
+
38
+ try {
39
+ parsed = JSON.parse(json);
40
+ } catch (e) {
41
+ throw new Error(e);
42
+ }
43
+
44
+ return parsed;
45
+ };
46
+
47
+ exports.safeParse = safeParse;
48
+
49
+ var getChartProps = function getChartProps(json) {
50
+ var parsed = safeParse(json);
51
+
52
+ if (typeof parsed === "number") {
53
+ return {
54
+ id: parsed
55
+ };
56
+ }
57
+
58
+ return parsed;
59
+ };
60
+
61
+ exports.getChartProps = getChartProps;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.PlaceholderPlugin = exports.PlaceholderController = void 0;
9
+
10
+ var _controller = _interopRequireDefault(require("../../../models/controller"));
11
+
12
+ var _prosemirrorState = require("prosemirror-state");
13
+
14
+ var _prosemirrorView = require("prosemirror-view");
15
+
16
+ var _plugin = _interopRequireDefault(require("../../../models/plugin"));
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+
20
+ 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, descriptor.key, descriptor); } }
21
+
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
+
24
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
+
26
+ 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); }
27
+
28
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
+
30
+ 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); }; }
31
+
32
+ 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); }
33
+
34
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
35
+
36
+ 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; } }
37
+
38
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
+
40
+ var PLUGIN_NAME = 'placeholder';
41
+
42
+ var createDecoration = function createDecoration(state) {
43
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '请输入';
44
+ var firstChildType = state.doc.child(0).type;
45
+
46
+ if (state.doc.textContent || firstChildType.name !== 'paragraph' && firstChildType.name !== 'heading' || state.doc.childCount > 1) {
47
+ return _prosemirrorView.DecorationSet.empty;
48
+ }
49
+
50
+ var placeholderDecoration = document.createElement('span');
51
+ var placeholderText = options;
52
+ placeholderDecoration.className = 'tita-rich-editor-placeholder';
53
+ var placeholderNode = document.createElement('span');
54
+ placeholderNode.textContent = placeholderText;
55
+ placeholderDecoration.appendChild(placeholderNode);
56
+ return _prosemirrorView.DecorationSet.create(state.doc, [_prosemirrorView.Decoration.widget(1, placeholderDecoration, {
57
+ side: 1,
58
+ key: 'placeholder'
59
+ })]);
60
+ };
61
+
62
+ var placeHolderPlugin = function placeHolderPlugin(dispatch, options) {
63
+ var plugin = new _prosemirrorState.Plugin({
64
+ state: {
65
+ init: function init(conf, state) {
66
+ return createDecoration(state, options);
67
+ },
68
+ apply: function apply(tr, pluginState, oldState, newState) {
69
+ if (!tr.docChanged) return pluginState.map(tr.mapping, tr.doc);
70
+ return createDecoration(newState, options);
71
+ }
72
+ },
73
+ props: {
74
+ decorations: function decorations(state) {
75
+ return plugin.getState(state);
76
+ }
77
+ }
78
+ });
79
+ return plugin;
80
+ };
81
+
82
+ var PlaceholderController = /*#__PURE__*/function (_BaseController) {
83
+ _inherits(PlaceholderController, _BaseController);
84
+
85
+ var _super = _createSuper(PlaceholderController);
86
+
87
+ function PlaceholderController() {
88
+ var _this;
89
+
90
+ _classCallCheck(this, PlaceholderController);
91
+
92
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
93
+ args[_key] = arguments[_key];
94
+ }
95
+
96
+ return _possibleConstructorReturn(_this, (_this = _super.call.apply(_super, [this].concat(args)), _this.pmPlugins = [placeHolderPlugin], _assertThisInitialized(_this)));
97
+ }
98
+
99
+ return _createClass(PlaceholderController);
100
+ }(_controller["default"]);
101
+
102
+ exports.PlaceholderController = PlaceholderController;
103
+
104
+ var PlaceholderPlugin = /*#__PURE__*/function (_BasePlugin) {
105
+ _inherits(PlaceholderPlugin, _BasePlugin);
106
+
107
+ var _super2 = _createSuper(PlaceholderPlugin);
108
+
109
+ function PlaceholderPlugin() {
110
+ var _this2;
111
+
112
+ _classCallCheck(this, PlaceholderPlugin);
113
+
114
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
115
+ args[_key2] = arguments[_key2];
116
+ }
117
+
118
+ return _possibleConstructorReturn(_this2, (_this2 = _super2.call.apply(_super2, [this].concat(args)), _this2.name = PLUGIN_NAME, _this2.controller = PlaceholderController, _assertThisInitialized(_this2)));
119
+ }
120
+
121
+ return _createClass(PlaceholderPlugin);
122
+ }(_plugin["default"]);
123
+
124
+ exports.PlaceholderPlugin = PlaceholderPlugin;
125
+ var _default = PlaceholderPlugin;
126
+ exports["default"] = _default;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.placeholderStyles = exports.placeHolderClassName = void 0;
7
+
8
+ var _styledComponents = require("styled-components");
9
+
10
+ var _colors = require("@atlaskit/theme/colors");
11
+
12
+ var _templateObject;
13
+
14
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
15
+
16
+ var placeHolderClassName = 'placeholder-decoration';
17
+ exports.placeHolderClassName = placeHolderClassName;
18
+ var placeholderStyles = (0, _styledComponents.css)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror .", " {\n position: relative;\n color: ", ";\n width: 100%;\n\n pointer-events: none;\n display: block;\n user-select: none;\n\n > span {\n position: absolute;\n pointer-events: none;\n }\n\n &.align-end > span {\n right: 0;\n }\n\n &.align-center > span {\n left: 0;\n }\n }\n"])), placeHolderClassName, _colors.N200);
19
+ exports.placeholderStyles = placeholderStyles;
@@ -8,8 +8,8 @@ var FontColor;
8
8
  exports.FontColor = FontColor;
9
9
 
10
10
  (function (FontColor) {
11
- FontColor["default"] = "#3F4755";
12
- FontColor["black1"] = "#141C28";
11
+ FontColor["default"] = "#141C28";
12
+ FontColor["black1"] = "#3F4755";
13
13
  FontColor["black2"] = "#6F7886";
14
14
  FontColor["black3"] = "#A4ACB9";
15
15
  FontColor["red1"] = "#F02673";
@@ -220,14 +220,7 @@ function ColorSelectorPop(_ref2) {
220
220
  (0, _commond.setColor)(editor, editor.state.schema.marks[_index2.BACKGROUND_COLOR_SCHEMA_NAME], activeBackground);
221
221
  editor.view.focus();
222
222
  }, [activeColor, activeBackground]);
223
- return /*#__PURE__*/_react["default"].createElement("div", {
224
- className: preCls + '__icon',
225
- style: {
226
- backgroundColor: activeBackground || _consts.BackgroundColor["default"],
227
- color: activeColor || _consts.FontColor["default"]
228
- },
229
- onClick: handleClickMenu
230
- }, /*#__PURE__*/_react["default"].createElement(_popup["default"], {
223
+ return /*#__PURE__*/_react["default"].createElement(_popup["default"], {
231
224
  action: ["hover"],
232
225
  popupPlacement: "top",
233
226
  popup: /*#__PURE__*/_react["default"].createElement(ColorSelector, {
@@ -237,6 +230,13 @@ function ColorSelectorPop(_ref2) {
237
230
  background: activeBackground,
238
231
  onClickItem: handleClickItem
239
232
  })
233
+ }, /*#__PURE__*/_react["default"].createElement("div", {
234
+ className: preCls + '__icon',
235
+ style: {
236
+ backgroundColor: activeBackground || _consts.BackgroundColor["default"],
237
+ color: activeColor || _consts.FontColor["default"]
238
+ },
239
+ onClick: handleClickMenu
240
240
  }, /*#__PURE__*/_react["default"].createElement("span", {
241
241
  className: config.icon
242
242
  })));
@@ -26,6 +26,10 @@
26
26
  justify-content: flex-end;
27
27
  }
28
28
 
29
+ .tita-rich-editor-link__input .form-field-input__border {
30
+ padding: 3px 12px;
31
+ }
32
+
29
33
  .tita-rich-editor-link__input:first-child {
30
34
  margin-bottom: 16px;
31
35
  }
@@ -53,6 +57,7 @@
53
57
  box-shadow: 0px 4px 12px 0px rgba(127, 145, 180, 0.2);
54
58
  border-radius: 8px;
55
59
  border: 1px solid #f0f2f5;
60
+ color: #3f4755;
56
61
  }
57
62
 
58
63
  .tita-rich-editor-toolbar__text {
@@ -36,6 +36,7 @@ function applyPlugins() {
36
36
  var plugins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
37
37
  var defaultSchema = arguments.length > 1 ? arguments[1] : undefined;
38
38
  var dispatcher = arguments.length > 2 ? arguments[2] : undefined;
39
+ var config = arguments.length > 3 ? arguments[3] : undefined;
39
40
  var nodes = defaultSchema.nodes;
40
41
  var marks = defaultSchema.marks || {};
41
42
  var nativePlugins = [];
@@ -48,9 +49,9 @@ function applyPlugins() {
48
49
  }))) : schemas.push(new p.schema());
49
50
  }
50
51
 
51
- dealPlugin(p, nativePlugins, controllers, dispatcher);
52
+ dealPlugin(p, nativePlugins, controllers, dispatcher, config);
52
53
  });
53
- dealPlugin(new _core.CorePlugin(), nativePlugins, controllers, dispatcher);
54
+ dealPlugin(new _core.CorePlugin(), nativePlugins, controllers, dispatcher, config);
54
55
  schemas.sort(function (s1, s2) {
55
56
  return s2.priority - s1.priority;
56
57
  }).forEach(function (s) {
@@ -69,13 +70,15 @@ function applyPlugins() {
69
70
  }
70
71
 
71
72
  function dealPlugin(plugin, nativePlugins, controllers, dispatcher) {
73
+ var config = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
74
+
72
75
  if (plugin.controller) {
73
76
  var pController = new plugin.controller();
74
77
  controllers.push(pController);
75
78
 
76
79
  if (pController.pmPlugins) {
77
80
  nativePlugins.push.apply(nativePlugins, _toConsumableArray(pController.pmPlugins.map(function (pm) {
78
- return typeof pm == 'function' ? pm((0, _event.createDispatch)(dispatcher)) : pm;
81
+ return typeof pm == 'function' ? pm((0, _event.createDispatch)(dispatcher), config[plugin.name]) : pm;
79
82
  })));
80
83
  }
81
84
 
@@ -19,7 +19,7 @@
19
19
  font-weight: 500;
20
20
  color: #141c28;
21
21
  line-height: 38px;
22
- padding: 36px 0 20px;
22
+ padding: 26px 0 10px;
23
23
  }
24
24
 
25
25
  .tita-rich-editor h2 {
@@ -27,23 +27,31 @@
27
27
  font-weight: 500;
28
28
  color: #141c28;
29
29
  line-height: 32px;
30
- padding: 20px 0 8px;
30
+ padding: 22px 0 8px;
31
31
  }
32
32
 
33
33
  .tita-rich-editor h3 {
34
34
  font-size: 20px;
35
35
  font-weight: 500;
36
- color: #3f4755;
36
+ color: #141c28;
37
37
  line-height: 30px;
38
- padding: 18px 0 8px;
38
+ padding: 20px 0 8px;
39
39
  }
40
40
 
41
41
  .tita-rich-editor p {
42
42
  font-size: 16px;
43
43
  font-weight: 400;
44
- color: #3f4755;
44
+ color: #141c28;
45
45
  line-height: 26px;
46
- padding: 6px 0;
46
+ padding: 3px 0;
47
+ }
48
+
49
+ .tita-rich-editor a {
50
+ color: #2879ff;
51
+ }
52
+
53
+ .tita-rich-editor a:hover {
54
+ color: #5c8eff;
47
55
  }
48
56
 
49
57
  .tita-rich-editor ol,
@@ -128,8 +136,20 @@
128
136
 
129
137
  .tita-rich-editor blockquote {
130
138
  position: relative;
139
+ margin: 3px 0;
131
140
  padding-left: 22px;
132
- margin: 0;
141
+ }
142
+
143
+ .tita-rich-editor blockquote p {
144
+ font-size: 16px !important;
145
+ }
146
+
147
+ .tita-rich-editor blockquote p:first-child {
148
+ padding-top: 0;
149
+ }
150
+
151
+ .tita-rich-editor blockquote p:last-child {
152
+ padding-bottom: 0;
133
153
  }
134
154
 
135
155
  .tita-rich-editor blockquote::before {
@@ -142,3 +162,17 @@
142
162
  background-color: #2879ff;
143
163
  border-radius: 2px;
144
164
  }
165
+
166
+ .tita-rich-editor-placeholder {
167
+ color: #bfc7d5;
168
+ position: relative;
169
+ width: 100%;
170
+ pointer-events: none;
171
+ display: block;
172
+ user-select: none;
173
+ }
174
+
175
+ .tita-rich-editor-placeholder > span {
176
+ position: absolute;
177
+ pointer-events: none;
178
+ }
@@ -31,6 +31,8 @@ require("./index.css");
31
31
 
32
32
  var _classnames = _interopRequireDefault(require("classnames"));
33
33
 
34
+ var _placeholder = _interopRequireDefault(require("../../plugins/extension/placeholder"));
35
+
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
37
 
36
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -40,7 +42,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
40
42
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
41
43
 
42
44
  var preCls = 'tita-rich-editor';
43
- var defaultPlugins = [new _plugins.HeadingPlugin(), new _plugins.StrongPlugin(), new _plugins.ColorPlugin(), new _plugins.UnderLinePlugin(), new _plugins.DeleteLinePlugin(), new _plugins.ListPlugin(), new _plugins.AlignmentPlugin(), new _plugins.BlockquotePlugin(), new _plugins.LinkPlugin()];
45
+ var defaultPlugins = [new _plugins.HeadingPlugin(), new _plugins.StrongPlugin(), new _plugins.ColorPlugin(), new _plugins.UnderLinePlugin(), new _plugins.DeleteLinePlugin(), new _plugins.ListPlugin(), new _plugins.AlignmentPlugin(), new _plugins.BlockquotePlugin(), new _plugins.LinkPlugin(), new _placeholder["default"]()];
44
46
 
45
47
  function RichEditor(_ref, ref) {
46
48
  var _ref$plugins = _ref.plugins,
@@ -49,14 +51,17 @@ function RichEditor(_ref, ref) {
49
51
  _ref$editable = _ref.editable,
50
52
  _editable = _ref$editable === void 0 ? true : _ref$editable,
51
53
  defaultState = _ref.defaultState,
52
- onChange = _ref.onChange;
54
+ onChange = _ref.onChange,
55
+ placeholder = _ref.placeholder;
53
56
 
54
57
  var container = (0, _react.useRef)();
55
58
  var dataRef = (0, _react.useRef)({});
56
59
  (0, _react.useEffect)(function () {
57
60
  var dispatcher = new _event.EventDispatcher();
58
61
 
59
- var _applyPlugins = (0, _util.applyPlugins)(plugins, _schema["default"], dispatcher),
62
+ var _applyPlugins = (0, _util.applyPlugins)(plugins, _schema["default"], dispatcher, {
63
+ placeholder: placeholder
64
+ }),
60
65
  nativePlugins = _applyPlugins.nativePlugins,
61
66
  nodes = _applyPlugins.nodes,
62
67
  marks = _applyPlugins.marks,
@@ -139,7 +144,7 @@ function RichEditor(_ref, ref) {
139
144
  backgroundColor: "#FFF"
140
145
  },
141
146
  spellCheck: false,
142
- onClick: handleClick
147
+ onMouseUp: handleClick
143
148
  });
144
149
  }
145
150
 
@@ -3,12 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.bracketTyped = bracketTyped;
6
7
  exports.findFarthestParentNode = void 0;
7
8
  exports.getNodesCount = getNodesCount;
8
9
  exports.getStepRange = void 0;
10
+ exports.hasDocAsParent = hasDocAsParent;
9
11
  exports.hasVisibleContent = hasVisibleContent;
10
12
  exports.isEmptyDocument = isEmptyDocument;
11
13
  exports.isEmptyParagraph = isEmptyParagraph;
14
+ exports.isInEmptyLine = isInEmptyLine;
12
15
  exports.isNodeEmpty = isNodeEmpty;
13
16
  exports.isSelectionEndOfParagraph = void 0;
14
17
  exports.nodesBetweenChanged = nodesBetweenChanged;
@@ -157,4 +160,52 @@ function getNodesCount(node) {
157
160
  count[node.type.name] = (count[node.type.name] || 0) + 1;
158
161
  });
159
162
  return count;
163
+ } // Checks to see if the parent node is the document, ie not contained within another entity
164
+
165
+
166
+ function hasDocAsParent($anchor) {
167
+ return $anchor.depth === 1;
168
+ }
169
+
170
+ function isInEmptyLine(state) {
171
+ var selection = state.selection;
172
+ var _ref = selection,
173
+ $cursor = _ref.$cursor,
174
+ $anchor = _ref.$anchor;
175
+
176
+ if (!$cursor) {
177
+ return false;
178
+ }
179
+
180
+ var node = $cursor.node();
181
+
182
+ if (!node) {
183
+ return false;
184
+ }
185
+
186
+ return isEmptyParagraph(node) && hasDocAsParent($anchor);
187
+ }
188
+
189
+ function bracketTyped(state) {
190
+ var selection = state.selection;
191
+ var _ref2 = selection,
192
+ $cursor = _ref2.$cursor,
193
+ $anchor = _ref2.$anchor;
194
+
195
+ if (!$cursor) {
196
+ return false;
197
+ }
198
+
199
+ var node = $cursor.nodeBefore;
200
+
201
+ if (!node) {
202
+ return false;
203
+ }
204
+
205
+ if (node.type.name === 'text' && node.text === '{') {
206
+ var paragraphNode = $anchor.node();
207
+ return paragraphNode.marks.length === 0 && hasDocAsParent($anchor);
208
+ }
209
+
210
+ return false;
160
211
  }
@@ -9,16 +9,14 @@ exports["default"] = void 0;
9
9
 
10
10
  var _react = _interopRequireWildcard(require("react"));
11
11
 
12
- var _init = require("../../init");
12
+ var _fetchAssetsAndAppend = _interopRequireDefault(require("../../fetch-assets-and-append"));
13
13
 
14
- var _excluded = ["chartId"];
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
15
 
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
 
18
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; }
19
19
 
20
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
-
22
20
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
21
 
24
22
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -31,33 +29,25 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
31
29
 
32
30
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
31
 
34
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
35
-
36
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
-
38
- var lazyOnce = (0, _init.lazyLoad)();
32
+ var singletonFetchAssetsAndAppend = (0, _fetchAssetsAndAppend["default"])();
39
33
 
40
34
  var Chart = function Chart(props) {
41
35
  var _window, _window$SupersetChart;
42
36
 
43
- var chartId = props.chartId,
44
- restProps = _objectWithoutProperties(props, _excluded);
45
-
46
- var _useState = (0, _react.useState)(true),
37
+ var _useState = (0, _react.useState)(false),
47
38
  _useState2 = _slicedToArray(_useState, 2),
48
- loading = _useState2[0],
49
- setLoading = _useState2[1];
39
+ isInit = _useState2[0],
40
+ setIsInit = _useState2[1];
50
41
 
51
42
  (0, _react.useEffect)(function () {
52
- lazyOnce === null || lazyOnce === void 0 ? void 0 : lazyOnce.then(function () {
53
- setLoading(false);
54
- });
55
- }, []); // @ts-ignore
43
+ var _singletonFetchAssets;
56
44
 
45
+ (_singletonFetchAssets = singletonFetchAssetsAndAppend()) === null || _singletonFetchAssets === void 0 ? void 0 : _singletonFetchAssets.then(function () {
46
+ setIsInit(true);
47
+ });
48
+ }, []);
57
49
  var Chart = (_window = window) === null || _window === void 0 ? void 0 : (_window$SupersetChart = _window.SupersetChart) === null || _window$SupersetChart === void 0 ? void 0 : _window$SupersetChart.SupersetChart;
58
- return /*#__PURE__*/_react["default"].createElement("div", null, Chart && !loading && chartId && /*#__PURE__*/_react["default"].createElement(Chart, _extends({
59
- id: chartId
60
- }, restProps)));
50
+ return /*#__PURE__*/_react["default"].createElement("div", null, Chart && isInit && /*#__PURE__*/_react["default"].createElement(Chart, props));
61
51
  };
62
52
 
63
53
  var _default = Chart;