@zzish/math-rich-input 0.1.12 → 0.1.15

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