@standardnotes/simple-task-editor 1.3.10 → 1.6.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,126 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [1.6.0](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.8...@standardnotes/simple-task-editor@1.6.0) (2023-11-18)
7
+
8
+ ### Features
9
+
10
+ * add classic editors ([96a412a](https://github.com/standardnotes/plugins/commit/96a412a9725f689cbd5ca95f7feb5ba19938dd9a))
11
+
12
+ ## [1.5.8](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.7...@standardnotes/simple-task-editor@1.5.8) (2023-09-11)
13
+
14
+ ### Bug Fixes
15
+
16
+ * simple task editor task min-height ([18edfe6](https://github.com/standardnotes/plugins/commit/18edfe61f01e29851b35b692c16879d8aa41a491))
17
+
18
+ ## [1.5.7](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.6...@standardnotes/simple-task-editor@1.5.7) (2022-11-04)
19
+
20
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
21
+
22
+ ## [1.5.6](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.5...@standardnotes/simple-task-editor@1.5.6) (2022-11-04)
23
+
24
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
25
+
26
+ ## [1.5.5](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.4...@standardnotes/simple-task-editor@1.5.5) (2022-11-04)
27
+
28
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
29
+
30
+ ## [1.5.4](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.3...@standardnotes/simple-task-editor@1.5.4) (2022-11-04)
31
+
32
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
33
+
34
+ ## [1.5.3](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.2...@standardnotes/simple-task-editor@1.5.3) (2022-11-04)
35
+
36
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
37
+
38
+ ## [1.5.2](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.1...@standardnotes/simple-task-editor@1.5.2) (2022-11-04)
39
+
40
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
41
+
42
+ ## [1.5.1](https://github.com/standardnotes/plugins/compare/@standardnotes/simple-task-editor@1.5.0...@standardnotes/simple-task-editor@1.5.1) (2022-11-04)
43
+
44
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
45
+
46
+ # 1.5.0 (2022-11-04)
47
+
48
+ ### Features
49
+
50
+ * add core plugins ([b607787](https://github.com/standardnotes/plugins/commit/b60778762306f5647cb715102eab23083b266718))
51
+
52
+ ## [1.4.4](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.4.3...@standardnotes/simple-task-editor@1.4.4) (2022-09-07)
53
+
54
+ ### Bug Fixes
55
+
56
+ * add min-height to task textarea ([#1490](https://github.com/standardnotes/app/issues/1490)) ([0e86b13](https://github.com/standardnotes/app/commit/0e86b13a8f3b11ed99cdc49b3a44665396bfca98))
57
+
58
+ ## [1.4.3](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.4.2...@standardnotes/simple-task-editor@1.4.3) (2022-07-14)
59
+
60
+ ### Bug Fixes
61
+
62
+ * **ste:** revert border radius change ([b174493](https://github.com/standardnotes/app/commit/b174493b4ea3ca164cf5754ab791022b17b612ac))
63
+
64
+ ## [1.4.2](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.4.1...@standardnotes/simple-task-editor@1.4.2) (2022-07-13)
65
+
66
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
67
+
68
+ ## [1.4.1](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.4.0...@standardnotes/simple-task-editor@1.4.1) (2022-07-06)
69
+
70
+ ### Bug Fixes
71
+
72
+ * **advanced checklist:** improve editor styles ([#1221](https://github.com/standardnotes/app/issues/1221)) ([f7ba658](https://github.com/standardnotes/app/commit/f7ba6588a7d062e3ec82e6413042ce5d8cd075f7))
73
+
74
+ # [1.4.0](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.3.15...@standardnotes/simple-task-editor@1.4.0) (2022-06-28)
75
+
76
+ ### Features
77
+
78
+ * deprecated editors ([#1166](https://github.com/standardnotes/app/issues/1166)) ([60ca415](https://github.com/standardnotes/app/commit/60ca4150446f9a14bb6a31416686c6d07a7d0cd9))
79
+
80
+ ## [1.3.15](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.3.15-alpha.0...@standardnotes/simple-task-editor@1.3.15) (2022-06-22)
81
+
82
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
83
+
84
+ ## [1.3.15-alpha.0](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.3.14...@standardnotes/simple-task-editor@1.3.15-alpha.0) (2022-06-22)
85
+
86
+ ### Bug Fixes
87
+
88
+ * components scripts ([#1136](https://github.com/standardnotes/app/issues/1136)) ([e80b4d0](https://github.com/standardnotes/app/commit/e80b4d0ffad495c758b593c30e1c4c754dda9b7e))
89
+
90
+ ## [1.3.14](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.3.14-alpha.0...@standardnotes/simple-task-editor@1.3.14) (2022-06-18)
91
+
92
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
93
+
94
+ ## [1.3.14-alpha.0](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.3.13...@standardnotes/simple-task-editor@1.3.14-alpha.0) (2022-06-18)
95
+
96
+ ### Bug Fixes
97
+
98
+ * plus editor icons ([#1120](https://github.com/standardnotes/app/issues/1120)) ([ba65948](https://github.com/standardnotes/app/commit/ba65948364a3fca7bfa5005c56802102c73ccd99))
99
+
100
+ ## 1.3.13 (2022-06-16)
101
+
102
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
103
+
104
+ ## 1.3.12 (2022-06-16)
105
+
106
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
107
+
108
+ ## [1.3.11](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.3.11-alpha.3...@standardnotes/simple-task-editor@1.3.11) (2022-06-16)
109
+
110
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
111
+
112
+ ## [1.3.11-alpha.3](https://github.com/standardnotes/app/compare/@standardnotes/simple-task-editor@1.3.11-alpha.2...@standardnotes/simple-task-editor@1.3.11-alpha.3) (2022-06-16)
113
+
114
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
115
+
116
+ ## 1.3.11-alpha.2 (2022-06-16)
117
+
118
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
119
+
120
+ ## 1.3.11-alpha.1 (2022-06-16)
121
+
122
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
123
+
124
+ ## 1.3.11-alpha.0 (2022-06-15)
125
+
126
+ **Note:** Version bump only for package @standardnotes/simple-task-editor
package/LICENSE.md ADDED
File without changes
@@ -1,249 +1,254 @@
1
- import Task from '@Models/Task';
2
- import ComponentRelay from '@standardnotes/component-relay';
1
+ import Task from '@Models/Task'
2
+ import ComponentRelay from '@standardnotes/component-relay'
3
3
 
4
- const TaskDelimitter = '\n';
4
+ const TaskDelimitter = '\n'
5
5
 
6
6
  export default class TasksManager {
7
7
  spellcheckEnabled = true
8
8
 
9
9
  /* Singleton */
10
- static instance = null;
10
+ static instance = null
11
11
  static get() {
12
- if (this.instance === null) {
13
- this.instance = new TasksManager();
12
+ if (this.instance === null) {
13
+ this.instance = new TasksManager()
14
14
  }
15
- return this.instance;
15
+ return this.instance
16
16
  }
17
17
 
18
18
  initiateBridge() {
19
- const permissions = [
20
- {
21
- name: 'stream-context-item'
22
- }
23
- ];
24
-
25
19
  this.componentRelay = new ComponentRelay({
26
20
  targetWindow: window,
27
- permissions,
28
21
  onReady: () => {
29
- this.onReady && this.onReady();
30
- }
31
- });
22
+ this.onReady && this.onReady()
23
+ },
24
+ handleRequestForContentHeight: () => {
25
+ const offset = 50
26
+ return document.body.scrollHeight + offset
27
+ },
28
+ })
32
29
 
33
30
  this.componentRelay.streamContextItem((note) => {
34
- this.note = note;
31
+ this.note = note
35
32
 
36
33
  if (note.isMetadataUpdate) {
37
- return;
34
+ return
38
35
  }
39
36
 
40
- this.dataString = note.content.text;
41
- this.unsavedTask = note.content.unsavedTask;
42
- this.reloadData();
43
- this.dataChangeHandler && this.dataChangeHandler(this.tasks);
44
- this.spellcheckEnabled = JSON.stringify(note.content.spellcheck);
45
- });
37
+ this.dataString = note.content.text
38
+ this.unsavedTask = note.content.unsavedTask
39
+ this.reloadData()
40
+ this.dataChangeHandler && this.dataChangeHandler(this.tasks)
41
+ this.spellcheckEnabled = JSON.stringify(note.content.spellcheck)
42
+ })
46
43
  }
47
44
 
48
45
  getPlatform() {
49
- return this.componentRelay.platform;
46
+ return this.componentRelay.platform
50
47
  }
51
48
 
52
49
  isMobile() {
53
- return this.componentRelay && this.componentRelay.isRunningInMobileApplication();
50
+ return this.componentRelay && this.componentRelay.isRunningInMobileApplication()
54
51
  }
55
52
 
56
53
  get showTutorial() {
57
- const showTutorial = this.componentRelay.getComponentDataValueForKey('showTutorial');
58
- return showTutorial === undefined;
54
+ const showTutorial = this.componentRelay.getComponentDataValueForKey('showTutorial')
55
+ return showTutorial === undefined
59
56
  }
60
57
 
61
58
  setOnReady(onReady) {
62
- this.onReady = onReady;
59
+ this.onReady = onReady
63
60
  }
64
61
 
65
62
  setDataChangeHandler(handler) {
66
- this.dataChangeHandler = handler;
63
+ this.dataChangeHandler = handler
67
64
  }
68
65
 
69
66
  parseRawTasksString(string) {
70
- if (!string) {string = '';}
71
- const allTasks = string.split(TaskDelimitter);
72
- return allTasks.filter((s) => {return s.replace(/ /g, '').length > 0;}).map((rawString) => {
73
- return this.createTask(rawString);
74
- });
67
+ if (!string) {
68
+ string = ''
69
+ }
70
+ const allTasks = string.split(TaskDelimitter)
71
+ return allTasks
72
+ .filter((s) => {
73
+ return s.replace(/ /g, '').length > 0
74
+ })
75
+ .map((rawString) => {
76
+ return this.createTask(rawString)
77
+ })
75
78
  }
76
79
 
77
80
  keyForTask(task) {
78
- return this.tasks.indexOf(task) + task.rawString;
81
+ return this.tasks.indexOf(task) + task.rawString
79
82
  }
80
83
 
81
84
  reloadData() {
82
- this.tasks = this.parseRawTasksString(this.dataString);
85
+ this.tasks = this.parseRawTasksString(this.dataString)
83
86
  }
84
87
 
85
88
  getTasks() {
86
89
  if (!this.tasks) {
87
- this.reloadData();
90
+ this.reloadData()
88
91
  }
89
- return this.tasks;
92
+ return this.tasks
90
93
  }
91
94
 
92
95
  createTask(rawString) {
93
- return new Task(rawString);
96
+ return new Task(rawString)
94
97
  }
95
98
 
96
99
  addTask(task) {
97
- this.tasks.unshift(task);
98
- this.save();
99
- this.reloadData();
100
+ this.tasks.unshift(task)
101
+ this.save()
102
+ this.reloadData()
100
103
  }
101
104
 
102
105
  setUnsavedTask(text) {
103
- this.unsavedTask = text;
106
+ this.unsavedTask = text
104
107
  }
105
108
 
106
109
  completedTasks() {
107
- return this.tasks.filter((task) => task.completed == true);
110
+ return this.tasks.filter((task) => task.completed == true)
108
111
  }
109
112
 
110
113
  openTasks(tasks) {
111
- tasks.forEach(task => {
112
- task.markOpen();
113
- });
114
+ tasks.forEach((task) => {
115
+ task.markOpen()
116
+ })
114
117
 
115
- this.tasks = this.categorizedTasks.openTasks.concat(tasks);
118
+ this.tasks = this.categorizedTasks.openTasks.concat(tasks)
116
119
  }
117
120
 
118
121
  removeTasks(tasks) {
119
- this.tasks = this.tasks.filter((task) => !tasks.includes(task));
122
+ this.tasks = this.tasks.filter((task) => !tasks.includes(task))
120
123
  }
121
124
 
122
125
  // Splits into completed and non completed piles, and organizes them into an ordered array
123
126
  splitTasks() {
124
- let tasks = this.getTasks();
125
- const openTasks = [], completedTasks = [];
127
+ let tasks = this.getTasks()
128
+ const openTasks = [],
129
+ completedTasks = []
126
130
  tasks.forEach((task) => {
127
131
  if (task.completed) {
128
- completedTasks.push(task);
132
+ completedTasks.push(task)
129
133
  } else {
130
- openTasks.push(task);
134
+ openTasks.push(task)
131
135
  }
132
- });
136
+ })
133
137
 
134
- this.tasks = openTasks.concat(completedTasks);
138
+ this.tasks = openTasks.concat(completedTasks)
135
139
  this.categorizedTasks = {
136
140
  unsavedTask: this.unsavedTask,
137
141
  openTasks,
138
- completedTasks
139
- };
142
+ completedTasks,
143
+ }
140
144
 
141
- return this.categorizedTasks;
145
+ return this.categorizedTasks
142
146
  }
143
147
 
144
148
  moveTaskToTop(task) {
145
- this.tasks.splice(this.tasks.indexOf(task), 1);
146
- this.tasks.unshift(task);
149
+ this.tasks.splice(this.tasks.indexOf(task), 1)
150
+ this.tasks.unshift(task)
147
151
  }
148
152
 
149
153
  changeTaskPosition(task, taskOccupyingTargetLocation) {
150
- const from = this.tasks.indexOf(task);
151
- const to = this.tasks.indexOf(taskOccupyingTargetLocation);
154
+ const from = this.tasks.indexOf(task)
155
+ const to = this.tasks.indexOf(taskOccupyingTargetLocation)
152
156
 
153
- this.tasks = this.tasks.move(from, to);
157
+ this.tasks = this.tasks.move(from, to)
154
158
  }
155
159
 
156
160
  reopenCompleted() {
157
- this.openTasks(this.completedTasks());
158
- this.save();
161
+ this.openTasks(this.completedTasks())
162
+ this.save()
159
163
  }
160
164
 
161
165
  deleteCompleted() {
162
- this.removeTasks(this.completedTasks());
163
- this.save();
166
+ this.removeTasks(this.completedTasks())
167
+ this.save()
164
168
  }
165
169
 
166
170
  deleteTask(task) {
167
- this.removeTasks([task]);
168
- this.save();
171
+ this.removeTasks([task])
172
+ this.save()
169
173
  }
170
174
 
171
175
  buildHtmlPreview() {
172
- const { openTasks, completedTasks } = this.categorizedTasks;
173
- const totalLength = openTasks.length + completedTasks.length;
176
+ const { openTasks, completedTasks } = this.categorizedTasks
177
+ const totalLength = openTasks.length + completedTasks.length
174
178
 
175
- const taskPreviewLimit = 3;
176
- const tasksToPreview = Math.min(openTasks.length, taskPreviewLimit);
179
+ const taskPreviewLimit = 3
180
+ const tasksToPreview = Math.min(openTasks.length, taskPreviewLimit)
177
181
 
178
- let html = '<div>';
179
- html += `<div style="margin-top: 8px;"><strong>${completedTasks.length}/${totalLength} tasks completed</strong></div>`;
180
- html += `<progress max="100" style="margin-top: 10px; width: 100%;" value="${(completedTasks.length/totalLength) * 100}"></progress>`;
182
+ let html = '<div>'
183
+ html += `<div style="margin-top: 8px;"><strong>${completedTasks.length}/${totalLength} tasks completed</strong></div>`
184
+ html += `<progress max="100" style="margin-top: 10px; width: 100%;" value="${
185
+ (completedTasks.length / totalLength) * 100
186
+ }"></progress>`
181
187
 
182
188
  if (tasksToPreview > 0) {
183
- html += '<ul style=\'padding-left: 19px; margin-top: 10px;\'>';
189
+ html += "<ul style='padding-left: 19px; margin-top: 10px;'>"
184
190
  for (let i = 0; i < tasksToPreview; i++) {
185
- const task = openTasks[i];
186
- html += `<li style='margin-bottom: 6px;'>${task.content}</li>`;
191
+ const task = openTasks[i]
192
+ html += `<li style='margin-bottom: 6px;'>${task.content}</li>`
187
193
  }
188
- html += '</ul>';
194
+ html += '</ul>'
189
195
 
190
196
  if (openTasks.length > tasksToPreview) {
191
- const diff = openTasks.length - tasksToPreview;
192
- const noun = diff == 1 ? 'task' : 'tasks';
193
- html += `<div><strong>And ${diff} other open ${noun}.</strong></div>`;
197
+ const diff = openTasks.length - tasksToPreview
198
+ const noun = diff == 1 ? 'task' : 'tasks'
199
+ html += `<div><strong>And ${diff} other open ${noun}.</strong></div>`
194
200
  }
195
201
  }
196
202
 
197
- html += '</div>';
203
+ html += '</div>'
198
204
 
199
- return html;
205
+ return html
200
206
  }
201
207
 
202
208
  buildPlainPreview() {
203
- const { openTasks, completedTasks } = this.categorizedTasks;
204
- const totalLength = openTasks.length + completedTasks.length;
209
+ const { openTasks, completedTasks } = this.categorizedTasks
210
+ const totalLength = openTasks.length + completedTasks.length
205
211
 
206
- return `${completedTasks.length}/${totalLength} tasks completed.`;
212
+ return `${completedTasks.length}/${totalLength} tasks completed.`
207
213
  }
208
214
 
209
215
  save() {
210
- this.dataString = this.tasks.map((task) => task.rawString).join(TaskDelimitter);
216
+ this.dataString = this.tasks.map((task) => task.rawString).join(TaskDelimitter)
211
217
 
212
218
  if (this.note) {
213
219
  // Be sure to capture this object as a variable, as this.note may be reassigned in `streamContextItem`, so by the time
214
220
  // you modify it in the presave block, it may not be the same object anymore, so the presave values will not be applied to
215
221
  // the right object, and it will save incorrectly.
216
- let note = this.note;
222
+ let note = this.note
217
223
  this.componentRelay.saveItemWithPresave(note, () => {
218
224
  // required to build dynamic previews
219
- this.splitTasks();
220
- note.content.text = this.dataString;
221
- note.content.unsavedTask = this.unsavedTask;
222
- note.content.preview_html = this.buildHtmlPreview();
223
- note.content.preview_plain = this.buildPlainPreview();
224
- });
225
+ this.splitTasks()
226
+ note.content.text = this.dataString
227
+ note.content.unsavedTask = this.unsavedTask
228
+ note.content.preview_html = this.buildHtmlPreview()
229
+ note.content.preview_plain = this.buildPlainPreview()
230
+ })
225
231
 
226
232
  if (this.showTutorial) {
227
- this.componentRelay.setComponentDataValueForKey('showTutorial', false);
233
+ this.componentRelay.setComponentDataValueForKey('showTutorial', false)
228
234
  }
229
235
  }
230
236
  }
231
-
232
237
  }
233
238
 
234
239
  Array.prototype.move = function (old_index, new_index) {
235
240
  while (old_index < 0) {
236
- old_index += this.length;
241
+ old_index += this.length
237
242
  }
238
243
  while (new_index < 0) {
239
- new_index += this.length;
244
+ new_index += this.length
240
245
  }
241
246
  if (new_index >= this.length) {
242
- let k = new_index - this.length;
243
- while ((k--) + 1) {
244
- this.push(undefined);
247
+ let k = new_index - this.length
248
+ while (k-- + 1) {
249
+ this.push(undefined)
245
250
  }
246
251
  }
247
- this.splice(new_index, 0, this.splice(old_index, 1)[0]);
248
- return this; // for testing purposes
249
- };
252
+ this.splice(new_index, 0, this.splice(old_index, 1)[0])
253
+ return this // for testing purposes
254
+ }
@@ -116,6 +116,7 @@ body {
116
116
  resize: none;
117
117
  overflow: hidden;
118
118
  background-color: transparent;
119
+ min-height: 1.375rem;
119
120
  }
120
121
  }
121
122