imdone-core 1.44.0 → 1.44.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/lib/file.js +20 -24
- package/lib/plugins/epic-plugin.js +12 -10
- package/lib/task.js +1 -1
- package/package.json +1 -1
package/lib/file.js
CHANGED
|
@@ -160,35 +160,30 @@ File.addCompleted = function ({ task, content, config }) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
File.parseDueDate = function (config, text) {
|
|
163
|
-
|
|
164
|
-
let dueString
|
|
165
|
-
return text.replace(/(\sdue)\s.*?\./gi, (dueMatch, p1) => {
|
|
166
|
-
if (dueString) return dueMatch
|
|
167
|
-
try {
|
|
168
|
-
const due = chrono.parseDate(dueMatch, new Date(), {forwardDate: true})
|
|
169
|
-
if (!due) return dueMatch
|
|
170
|
-
dueString = getIsoDateWithOffset(due)
|
|
171
|
-
return `${p1.toLowerCase()}${config.getMetaSep()}${dueString}`
|
|
172
|
-
} catch (e) {
|
|
173
|
-
console.log(`Unable to parse due date for ${text}`)
|
|
174
|
-
return dueMatch
|
|
175
|
-
}
|
|
176
|
-
})
|
|
163
|
+
return File.parseDate(config, text, 'due')
|
|
177
164
|
}
|
|
178
165
|
|
|
179
166
|
File.parseRemindDate = function (config, text) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
167
|
+
return File.parseDate(config, text, 'remind')
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
File.parseDeferDate = function (config, text) {
|
|
171
|
+
return File.parseDate(config, text, 'defer')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
File.parseDate = function (config, text, dateType) {
|
|
175
|
+
if (text.includes(`${dateType}${config.getMetaSep()}`)) return text
|
|
176
|
+
let dateString
|
|
177
|
+
return text.replace(new RegExp(`(\\s${dateType})\\s.*?\\.`,'gi'), (match, p1) => {
|
|
178
|
+
if (dateString) return match
|
|
184
179
|
try {
|
|
185
|
-
const
|
|
186
|
-
if (!
|
|
187
|
-
|
|
188
|
-
return `${p1.toLowerCase()}${config.getMetaSep()}${
|
|
180
|
+
const date = chrono.parseDate(match, new Date(), {forwardDate: true})
|
|
181
|
+
if (!date) return match
|
|
182
|
+
dateString = getIsoDateWithOffset(date)
|
|
183
|
+
return `${p1.toLowerCase()}${config.getMetaSep()}${dateString}`
|
|
189
184
|
} catch (e) {
|
|
190
|
-
console.log(`Unable to parse
|
|
191
|
-
return
|
|
185
|
+
console.log(`Unable to parse ${dateType} date for ${text}`)
|
|
186
|
+
return match
|
|
192
187
|
}
|
|
193
188
|
})
|
|
194
189
|
}
|
|
@@ -281,6 +276,7 @@ File.prototype.transformTask = function ({config, modify, task}) {
|
|
|
281
276
|
content = trackListChanges.content
|
|
282
277
|
content = File.parseDueDate(config, content)
|
|
283
278
|
content = File.parseRemindDate(config, content)
|
|
279
|
+
content = File.parseDeferDate(config, content)
|
|
284
280
|
content = File.addCompleted({ task, content, config })
|
|
285
281
|
if (
|
|
286
282
|
content.trim() !== task.content.trim()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const removeMD = require('remove-markdown')
|
|
1
|
+
// const removeMD = require('remove-markdown')
|
|
2
|
+
const { renderMarkdown } = require('../adapters/markdown')
|
|
2
3
|
const Plugin = require('imdone-api')
|
|
3
4
|
|
|
4
5
|
function getIsEpicMeta(task) {
|
|
@@ -104,7 +105,7 @@ module.exports = class EpicPlugin extends Plugin {
|
|
|
104
105
|
return
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
const epicText = removeMD(epic.text)
|
|
108
|
+
const epicText = epic.text // removeMD(epic.text)
|
|
108
109
|
const epicFilter = encodeURIComponent(
|
|
109
110
|
`(allMeta.epic="${epicId}" or allMeta.is-epic="${epicId}")`
|
|
110
111
|
)
|
|
@@ -114,13 +115,6 @@ module.exports = class EpicPlugin extends Plugin {
|
|
|
114
115
|
const epicUrl = `imdone://${epicFilePath}?line=${epic.line}&filter=${epicFilter}`
|
|
115
116
|
const epicLink = `**Epic:** [${epicText}](${epicUrl})\n\n`
|
|
116
117
|
|
|
117
|
-
const taskList =
|
|
118
|
-
epicLists.length === 0
|
|
119
|
-
? '*None*\n'
|
|
120
|
-
: '\n<div class="imdone-epic-items">\n\n' +
|
|
121
|
-
this.getTaskListMD(lists, epicFilter, epicUrl, epicId) +
|
|
122
|
-
'\n\n</div>\n'
|
|
123
|
-
|
|
124
118
|
// Add epic link to epic tasks
|
|
125
119
|
epicLists.forEach((list) => {
|
|
126
120
|
this.getEpicItems(epicId, list).forEach((task) => {
|
|
@@ -129,6 +123,13 @@ module.exports = class EpicPlugin extends Plugin {
|
|
|
129
123
|
})
|
|
130
124
|
})
|
|
131
125
|
|
|
126
|
+
const taskList =
|
|
127
|
+
epicLists.length === 0
|
|
128
|
+
? '*None*\n'
|
|
129
|
+
: '\n<div class="imdone-epic-items">\n\n' +
|
|
130
|
+
this.getTaskListMD(lists, epicFilter, epicUrl, epicId) +
|
|
131
|
+
'\n\n</div>\n'
|
|
132
|
+
|
|
132
133
|
if (epic.allMeta.epic && epic.allMeta.epic.includes(epicId)) {
|
|
133
134
|
const index = epic.allMeta.epic.findIndex((value) => value === epicId)
|
|
134
135
|
epic.allMeta.epic.splice(index, 1)
|
|
@@ -145,6 +146,7 @@ module.exports = class EpicPlugin extends Plugin {
|
|
|
145
146
|
|
|
146
147
|
lists
|
|
147
148
|
.filter((list) => this.getEpicItems(epicId, list.name))
|
|
149
|
+
.reverse()
|
|
148
150
|
.forEach((list) => {
|
|
149
151
|
const tasks = this.getEpicItems(epicId, list.name)
|
|
150
152
|
const listUrl = epicUrl + encodeURIComponent(` and list=${list.name}`)
|
|
@@ -153,7 +155,7 @@ module.exports = class EpicPlugin extends Plugin {
|
|
|
153
155
|
content += '<ul style="list-style: none;">'
|
|
154
156
|
content += tasks
|
|
155
157
|
.map((task) => {
|
|
156
|
-
const taskText = removeMD(task.text)
|
|
158
|
+
const taskText = renderMarkdown(task.text).replaceAll(/<p>|<\/p>/ig, '') // removeMD(task.text)
|
|
157
159
|
const checked =
|
|
158
160
|
task.list === this.project.doneList ? ' checked="true"' : ''
|
|
159
161
|
const taskFilePath = encodeURI(
|
package/lib/task.js
CHANGED
|
@@ -26,7 +26,7 @@ const {
|
|
|
26
26
|
* @param {} obj
|
|
27
27
|
* @return
|
|
28
28
|
*/
|
|
29
|
-
const DATE_META_KEYS = ['due', 'created', 'remind', 'completed']
|
|
29
|
+
const DATE_META_KEYS = ['due', 'defer', 'created', 'remind', 'completed']
|
|
30
30
|
class Task {
|
|
31
31
|
constructor(config, obj, dontParse) {
|
|
32
32
|
if (!_isObject(obj)) throw new Error('obj must be an Object')
|