@zzish/math-rich-input 0.1.16 → 0.1.17

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/dist/index.js CHANGED
@@ -21469,8 +21469,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21469
21469
  rangeParams: rangeParams
21470
21470
  });
21471
21471
 
21472
- if (_this2.undoHistory.length > MAX_HISTORY_LENGTH) _this2.undoHistory.shift();
21473
- _this2.value = value; // Call the parent handler to apply the changes
21472
+ if (_this2.undoHistory.length > MAX_HISTORY_LENGTH) _this2.undoHistory.shift(); // Call the parent handler to apply the changes
21474
21473
 
21475
21474
  _this2.onChangeCallback({
21476
21475
  value: value,
@@ -21481,10 +21480,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
21481
21480
  });
21482
21481
  });
21483
21482
 
21484
- _defineProperty(_assertThisInitialized(_this2), "getValue", function () {
21485
- return _this2.value;
21486
- });
21487
-
21488
21483
  _defineProperty(_assertThisInitialized(_this2), "initialiseHistory", function () {
21489
21484
  if (_this2.initialHistoryState == null) _this2.initialHistoryState = {
21490
21485
  value: _this2.props.value,
@@ -22834,8 +22829,7 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22834
22829
  superscript: false
22835
22830
  },
22836
22831
  keyPressed: ""
22837
- };
22838
- _this2.value = ""; // this.handleInput = this.handleInput.bind(this);
22832
+ }; // this.handleInput = this.handleInput.bind(this);
22839
22833
  // this.handleKeyDown = this.handleKeyDown.bind(this);
22840
22834
  // this.handleKeyUp = this.handleKeyUp.bind(this);
22841
22835
  // Remember the last key pressed
@@ -22970,9 +22964,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22970
22964
  }, {
22971
22965
  key: "componentDidMount",
22972
22966
  value: function componentDidMount() {
22973
- var onRef = this.props.onRef;
22974
- onRef && onRef(this);
22975
-
22976
22967
  try {
22977
22968
  setupKatex();
22978
22969
  this.editableDiv.addEventListener("keydown", this.handleKeyDown);
@@ -22984,9 +22975,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22984
22975
  }, {
22985
22976
  key: "componentWillUnmount",
22986
22977
  value: function componentWillUnmount() {
22987
- var onRef = this.props.onRef;
22988
- onRef && onRef(undefined);
22989
-
22990
22978
  try {
22991
22979
  this.editableDiv.removeEventListener("keydown", this.handleKeyDown);
22992
22980
  this.editableDiv.removeEventListener("keyup", this.handleKeyUp);
@@ -22998,8 +22986,6 @@ var MathRichInput = /*#__PURE__*/function (_React$Component) {
22998
22986
  key: "componentDidUpdate",
22999
22987
  value: function componentDidUpdate() {
23000
22988
  try {
23001
- // console.log("Component updated:")
23002
- // console.log(this.editableDiv.childNodes)
23003
22989
  if (this.rangeParamsToSetAfterComponentUpdate !== null && this.rangeParamsToSetAfterComponentUpdate !== undefined) {
23004
22990
  this._setRangeParams(this.rangeParamsToSetAfterComponentUpdate);
23005
22991
 
@@ -69,6 +69,161 @@
69
69
  padding: 2px;
70
70
  margin: 0px 2px;
71
71
  }
72
+ .EquationEditorModal-background {
73
+ position: fixed;
74
+ top: 0;
75
+ left: 0;
76
+ width: 100%;
77
+ height: 100%;
78
+ background: black;
79
+ z-index: 99;
80
+ animation: 0.3s shade;
81
+ animation-fill-mode: forwards;
82
+ }
83
+
84
+ @keyframes shade {
85
+ 00% {
86
+ opacity: 0;
87
+ }
88
+ 100% {
89
+ opacity: 0.6;
90
+ }
91
+ }
92
+
93
+ .EquationEditorModal {
94
+ background: white;
95
+ border: 1px solid #808080;
96
+ border-radius: 10px;
97
+ box-shadow: 0px 2px 5px 1px #a0a0a0;
98
+ position: fixed;
99
+ max-width: 500px;
100
+ width: 98%;
101
+ top: 50%;
102
+ left: 50%;
103
+ /* transform: translate(-50%,-50%); */
104
+ z-index: 100;
105
+ animation: 0.3s rise;
106
+ animation-fill-mode: forwards;
107
+ }
108
+
109
+ @keyframes rise {
110
+ 00% {
111
+ transform: translate(-50%, 100%);
112
+ opacity: 0;
113
+ }
114
+ 100% {
115
+ transform: translate(-50%, -50%);
116
+ opacity: 1;
117
+ }
118
+ }
119
+
120
+ .EquationEditorModal-mobile {
121
+ background: white;
122
+ border: 1px solid #808080;
123
+ border-radius: 10px;
124
+ box-shadow: 0px 2px 5px 1px #a0a0a0;
125
+ position: fixed;
126
+ max-width: 500px;
127
+ width: 99%;
128
+ top: 0%;
129
+ left: 50%;
130
+ transform: translate(-50%, 1px);
131
+ z-index: 100;
132
+ }
133
+
134
+ .EquationEditorModal .title {
135
+ display: flex;
136
+ justify-content: space-between;
137
+ font-size: 14px;
138
+ color: #404040;
139
+ text-align: left;
140
+ background: #e0e0e0;
141
+ border: 0px;
142
+ border-radius: 5px 5px 0px 0px;
143
+ padding: 15px;
144
+ margin: 0px;
145
+ }
146
+
147
+ .EquationEditorModal-mobile .title {
148
+ display: flex;
149
+ justify-content: space-between;
150
+ font-size: 14px;
151
+ color: #404040;
152
+ text-align: left;
153
+ background: #e0e0e0;
154
+ border: 0px;
155
+ border-radius: 5px 5px 0px 0px;
156
+ height: 30px;
157
+ padding: 15px;
158
+ margin: 0px;
159
+ }
160
+
161
+ .EquationEditorModal .expertModeSwitch .switch {
162
+ margin-left: 10px;
163
+ }
164
+
165
+ /* The switch - the box around the slider */
166
+ .EquationEditorModal .switch {
167
+ position: relative;
168
+ display: inline-block;
169
+ width: 35px;
170
+ height: 22px;
171
+ }
172
+
173
+ /* Hide default HTML checkbox */
174
+ .EquationEditorModal .switch input {
175
+ opacity: 0;
176
+ width: 0;
177
+ height: 0;
178
+ }
179
+
180
+ /* The slider */
181
+ .EquationEditorModal .slider {
182
+ position: absolute;
183
+ cursor: pointer;
184
+ top: 0;
185
+ left: 0;
186
+ right: 0;
187
+ bottom: 0;
188
+ background-color: #ccc;
189
+ -webkit-transition: 0.4s;
190
+ transition: 0.4s;
191
+ }
192
+
193
+ .EquationEditorModal .slider:before {
194
+ position: absolute;
195
+ content: "";
196
+ height: 14px;
197
+ width: 14px;
198
+ left: 4px;
199
+ bottom: 4px;
200
+ background-color: white;
201
+ -webkit-transition: 0.4s;
202
+ transition: 0.4s;
203
+ }
204
+
205
+ .EquationEditorModal input:checked + .slider {
206
+ background-color: #663676;
207
+ }
208
+
209
+ .EquationEditorModal input:focus + .slider {
210
+ box-shadow: 0 0 1px #2196f3;
211
+ }
212
+
213
+ .EquationEditorModal input:checked + .slider:before {
214
+ -webkit-transform: translateX(13px);
215
+ -ms-transform: translateX(13px);
216
+ transform: translateX(13px);
217
+ }
218
+
219
+ /* Rounded sliders */
220
+ .EquationEditorModal .slider.round {
221
+ border-radius: 18px;
222
+ }
223
+
224
+ .EquationEditorModal .slider.round:before {
225
+ border-radius: 50%;
226
+ }
72
227
  /* Note that the top left position of the toolbar is set programatically in componentDidMount */
73
228
 
74
229
  .Toolbar {
@@ -374,161 +529,6 @@
374
529
  animation: 0.4s fadeIn1;
375
530
  animation-fill-mode: forwards;
376
531
  }
377
- .EquationEditorModal-background {
378
- position: fixed;
379
- top: 0;
380
- left: 0;
381
- width: 100%;
382
- height: 100%;
383
- background: black;
384
- z-index: 99;
385
- animation: 0.3s shade;
386
- animation-fill-mode: forwards;
387
- }
388
-
389
- @keyframes shade {
390
- 00% {
391
- opacity: 0;
392
- }
393
- 100% {
394
- opacity: 0.6;
395
- }
396
- }
397
-
398
- .EquationEditorModal {
399
- background: white;
400
- border: 1px solid #808080;
401
- border-radius: 10px;
402
- box-shadow: 0px 2px 5px 1px #a0a0a0;
403
- position: fixed;
404
- max-width: 500px;
405
- width: 98%;
406
- top: 50%;
407
- left: 50%;
408
- /* transform: translate(-50%,-50%); */
409
- z-index: 100;
410
- animation: 0.3s rise;
411
- animation-fill-mode: forwards;
412
- }
413
-
414
- @keyframes rise {
415
- 00% {
416
- transform: translate(-50%, 100%);
417
- opacity: 0;
418
- }
419
- 100% {
420
- transform: translate(-50%, -50%);
421
- opacity: 1;
422
- }
423
- }
424
-
425
- .EquationEditorModal-mobile {
426
- background: white;
427
- border: 1px solid #808080;
428
- border-radius: 10px;
429
- box-shadow: 0px 2px 5px 1px #a0a0a0;
430
- position: fixed;
431
- max-width: 500px;
432
- width: 99%;
433
- top: 0%;
434
- left: 50%;
435
- transform: translate(-50%, 1px);
436
- z-index: 100;
437
- }
438
-
439
- .EquationEditorModal .title {
440
- display: flex;
441
- justify-content: space-between;
442
- font-size: 14px;
443
- color: #404040;
444
- text-align: left;
445
- background: #e0e0e0;
446
- border: 0px;
447
- border-radius: 5px 5px 0px 0px;
448
- padding: 15px;
449
- margin: 0px;
450
- }
451
-
452
- .EquationEditorModal-mobile .title {
453
- display: flex;
454
- justify-content: space-between;
455
- font-size: 14px;
456
- color: #404040;
457
- text-align: left;
458
- background: #e0e0e0;
459
- border: 0px;
460
- border-radius: 5px 5px 0px 0px;
461
- height: 30px;
462
- padding: 15px;
463
- margin: 0px;
464
- }
465
-
466
- .EquationEditorModal .expertModeSwitch .switch {
467
- margin-left: 10px;
468
- }
469
-
470
- /* The switch - the box around the slider */
471
- .EquationEditorModal .switch {
472
- position: relative;
473
- display: inline-block;
474
- width: 35px;
475
- height: 22px;
476
- }
477
-
478
- /* Hide default HTML checkbox */
479
- .EquationEditorModal .switch input {
480
- opacity: 0;
481
- width: 0;
482
- height: 0;
483
- }
484
-
485
- /* The slider */
486
- .EquationEditorModal .slider {
487
- position: absolute;
488
- cursor: pointer;
489
- top: 0;
490
- left: 0;
491
- right: 0;
492
- bottom: 0;
493
- background-color: #ccc;
494
- -webkit-transition: 0.4s;
495
- transition: 0.4s;
496
- }
497
-
498
- .EquationEditorModal .slider:before {
499
- position: absolute;
500
- content: "";
501
- height: 14px;
502
- width: 14px;
503
- left: 4px;
504
- bottom: 4px;
505
- background-color: white;
506
- -webkit-transition: 0.4s;
507
- transition: 0.4s;
508
- }
509
-
510
- .EquationEditorModal input:checked + .slider {
511
- background-color: #663676;
512
- }
513
-
514
- .EquationEditorModal input:focus + .slider {
515
- box-shadow: 0 0 1px #2196f3;
516
- }
517
-
518
- .EquationEditorModal input:checked + .slider:before {
519
- -webkit-transform: translateX(13px);
520
- -ms-transform: translateX(13px);
521
- transform: translateX(13px);
522
- }
523
-
524
- /* Rounded sliders */
525
- .EquationEditorModal .slider.round {
526
- border-radius: 18px;
527
- }
528
-
529
- .EquationEditorModal .slider.round:before {
530
- border-radius: 50%;
531
- }
532
532
  .EquationEditor {
533
533
  height: auto;
534
534
  text-align: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zzish/math-rich-input",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "React component for user to enter rich text with embedded math equations.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -70,7 +70,6 @@ export default class MathRichInput extends React.Component {
70
70
  },
71
71
  keyPressed: "",
72
72
  };
73
- this.value = "";
74
73
 
75
74
  // this.handleInput = this.handleInput.bind(this);
76
75
  // this.handleKeyDown = this.handleKeyDown.bind(this);
@@ -214,15 +213,10 @@ export default class MathRichInput extends React.Component {
214
213
  this.undoHistory.push({ value, mimeType, rangeParams });
215
214
  if (this.undoHistory.length > MAX_HISTORY_LENGTH) this.undoHistory.shift();
216
215
 
217
- this.value = value;
218
216
  // Call the parent handler to apply the changes
219
217
  this.onChangeCallback({ value, mimeType }, { isExpertMode, selectedTab });
220
218
  };
221
219
 
222
- getValue = () => {
223
- return this.value;
224
- };
225
-
226
220
  initialiseHistory = () => {
227
221
  if (this.initialHistoryState == null)
228
222
  this.initialHistoryState = {
@@ -1193,8 +1187,6 @@ export default class MathRichInput extends React.Component {
1193
1187
  };
1194
1188
 
1195
1189
  componentDidMount() {
1196
- const onRef = this.props.onRef;
1197
- onRef && onRef(this);
1198
1190
  try {
1199
1191
  setupKatex();
1200
1192
 
@@ -1206,8 +1198,6 @@ export default class MathRichInput extends React.Component {
1206
1198
  }
1207
1199
 
1208
1200
  componentWillUnmount() {
1209
- const onRef = this.props.onRef;
1210
- onRef && onRef(undefined);
1211
1201
  try {
1212
1202
  this.editableDiv.removeEventListener("keydown", this.handleKeyDown);
1213
1203
  this.editableDiv.removeEventListener("keyup", this.handleKeyUp);
@@ -1218,8 +1208,6 @@ export default class MathRichInput extends React.Component {
1218
1208
 
1219
1209
  componentDidUpdate() {
1220
1210
  try {
1221
- // console.log("Component updated:")
1222
- // console.log(this.editableDiv.childNodes)
1223
1211
  if (
1224
1212
  this.rangeParamsToSetAfterComponentUpdate !== null &&
1225
1213
  this.rangeParamsToSetAfterComponentUpdate !== undefined