imdone-core 1.49.2 → 1.50.1
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/card.js +5 -1
- package/lib/plugins/default-board-actions-plugin.js +46 -0
- package/lib/plugins/extension-plugin.js +3 -2
- package/lib/plugins/plugin-manager.js +1 -0
- package/lib/project.js +9 -2
- package/lib/repository.js +24 -24
- package/lib/usecases/get-project-tags.js +1 -1
- package/package.json +2 -2
package/lib/card.js
CHANGED
|
@@ -187,8 +187,12 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
187
187
|
this.dataKeys = keys
|
|
188
188
|
|
|
189
189
|
this.data = { ...data }
|
|
190
|
+
this.updateDescriptionData()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
updateDescriptionData() {
|
|
190
194
|
this.desc = this.getDescriptionData()
|
|
191
|
-
this.data = { ...data, ...this.desc }
|
|
195
|
+
this.data = { ...this.data, ...this.desc }
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
getEncodedContent(content) {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const Plugin = require('imdone-api')
|
|
2
|
+
|
|
3
|
+
module.exports = class DefaultBoardActionsPlugin extends Plugin {
|
|
4
|
+
constructor(project) {
|
|
5
|
+
super(project)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
getBoardActions() {
|
|
9
|
+
const project = this.project
|
|
10
|
+
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
title: 'Duplicate card',
|
|
14
|
+
keys: ['shift+d'],
|
|
15
|
+
icon: 'clone',
|
|
16
|
+
action: (task) => {
|
|
17
|
+
const timestamp = project.isoDateWithOffset
|
|
18
|
+
project.newCard({
|
|
19
|
+
list: project.config.getDefaultList(),
|
|
20
|
+
path: task.relPath,
|
|
21
|
+
template: task.content.replace(/(\screated:).*(\s)/, `$1${timestamp}$2`),
|
|
22
|
+
})
|
|
23
|
+
project.toast({ message: `"${task.text}" duplicated` })
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
title: 'Copy card to clipboard',
|
|
28
|
+
keys: ['c'],
|
|
29
|
+
icon: 'clone',
|
|
30
|
+
action: (task) => {
|
|
31
|
+
return project.copyToClipboard(task.content, `"${task.text} markdown" copied to clipboard`)
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'Copy card title to clipboard',
|
|
36
|
+
keys: ['mod+t'],
|
|
37
|
+
icon: 'clone',
|
|
38
|
+
action: (task) => {
|
|
39
|
+
const title = project.renderMarkdown(task.text).replaceAll(/<\/*p>/gi, '')
|
|
40
|
+
return project.copyToClipboard(title, `"${title}" copied to clipboard`)
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
@@ -36,10 +36,11 @@ module.exports = class ExtensionPlugin extends Plugin {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
getBoardActions() {
|
|
39
|
-
return this.boardActionsFunction().map(({ title, action, keys }) => ({
|
|
39
|
+
return this.boardActionsFunction().map(({ title, action, keys, icon }) => ({
|
|
40
40
|
name: title,
|
|
41
41
|
action,
|
|
42
|
-
keys
|
|
42
|
+
keys,
|
|
43
|
+
icon
|
|
43
44
|
}))
|
|
44
45
|
}
|
|
45
46
|
|
package/lib/project.js
CHANGED
|
@@ -258,7 +258,7 @@ module.exports = class WorkerProject extends Project {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
getDefaultFilteredCards() {
|
|
261
|
-
return
|
|
261
|
+
return this.filterCards(this.repo.getTasks(), this.defaultFilter)
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
getAllCards(filter) {
|
|
@@ -267,10 +267,17 @@ module.exports = class WorkerProject extends Project {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
getCards(filter, tasks = this.getDefaultFilteredCards()) {
|
|
270
|
-
tasks = filter ?
|
|
270
|
+
tasks = filter ? this.filterCards(tasks, filter) : tasks
|
|
271
271
|
return tasks
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
filterCards(tasks, filter) {
|
|
275
|
+
const {
|
|
276
|
+
result,
|
|
277
|
+
} = Repository.filterCards(tasks, filter)
|
|
278
|
+
return result
|
|
279
|
+
}
|
|
280
|
+
|
|
274
281
|
get files() {
|
|
275
282
|
return this.repo.getFilePaths()
|
|
276
283
|
}
|
package/lib/repository.js
CHANGED
|
@@ -972,7 +972,7 @@ Repository.prototype.deleteTask = function (task, cb) {
|
|
|
972
972
|
if (!file) return cb(null)
|
|
973
973
|
const execute = function (file) {
|
|
974
974
|
file.deleteTask(task, self.getConfig())
|
|
975
|
-
if (file.getContentForFile().trim() === '') {
|
|
975
|
+
if (file.getContentForFile().trim() === '' && file.isMarkDownFile()) {
|
|
976
976
|
if (file.deleted) return
|
|
977
977
|
console.log('Deleting empty file:', file.path)
|
|
978
978
|
self.deleteFile(file.path, cb)
|
|
@@ -1573,20 +1573,15 @@ Repository.deserialize = function (repo, cb) {
|
|
|
1573
1573
|
}
|
|
1574
1574
|
|
|
1575
1575
|
Repository.regexQuery = function (tasks, queryString) {
|
|
1576
|
-
return tasks.
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
)
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
if (
|
|
1583
|
-
task.description[i].search(
|
|
1584
|
-
new RegExp(tools.escapeRegExp(queryString), 'i')
|
|
1585
|
-
) > -1
|
|
1586
|
-
)
|
|
1587
|
-
return true
|
|
1576
|
+
return tasks.map((task) => {
|
|
1577
|
+
const match = task.content.match(new RegExp(tools.escapeRegExp(queryString), 'i'))
|
|
1578
|
+
task.match = match
|
|
1579
|
+
if (match && queryString.trim() && task.interpretedContent) {
|
|
1580
|
+
task.interpretedContent = task.interpretedContent.replace(new RegExp(`(${tools.escapeRegExp(queryString.trim())})`, 'gi'), '==$1==' )
|
|
1581
|
+
task.updateDescriptionData()
|
|
1588
1582
|
}
|
|
1589
|
-
|
|
1583
|
+
return task
|
|
1584
|
+
}).filter(({match}) => match)
|
|
1590
1585
|
}
|
|
1591
1586
|
|
|
1592
1587
|
Repository.parseSortFromQueryString = function (queryString) {
|
|
@@ -1622,26 +1617,31 @@ Repository.sortByQuery = function (tasks, queryString = '') {
|
|
|
1622
1617
|
fastSort(tasks).by(sort)
|
|
1623
1618
|
}
|
|
1624
1619
|
|
|
1625
|
-
Repository.
|
|
1620
|
+
Repository.filterCards = function (tasks, _queryString = '') {
|
|
1626
1621
|
let query
|
|
1627
|
-
|
|
1628
|
-
queryString =
|
|
1629
|
-
const resp = Repository.parseSortFromQueryString(queryString)
|
|
1622
|
+
_queryString = replaceDateLanguage(_queryString)
|
|
1623
|
+
let { sort, queryString } = Repository.parseSortFromQueryString(_queryString)
|
|
1630
1624
|
try {
|
|
1631
|
-
query = monquery(
|
|
1632
|
-
sort = resp.sort
|
|
1625
|
+
query = monquery(queryString)
|
|
1633
1626
|
} catch (e) {
|
|
1634
|
-
log(`Unable to parse ${
|
|
1627
|
+
log(`Unable to parse ${_queryString} using monquery`)
|
|
1635
1628
|
}
|
|
1636
1629
|
let result = []
|
|
1637
1630
|
if (query) result = tasks.filter(sift.default(query))
|
|
1638
1631
|
if (!query || result.length === 0) {
|
|
1639
|
-
result = Repository.regexQuery(tasks,
|
|
1640
|
-
sort = resp.sort
|
|
1632
|
+
result = Repository.regexQuery(tasks, queryString)
|
|
1641
1633
|
}
|
|
1642
1634
|
if (!sort || sort.length === 0) sort = DEFAULT_SORT
|
|
1643
1635
|
fastSort(result).by(sort)
|
|
1644
|
-
return
|
|
1636
|
+
return {
|
|
1637
|
+
result,
|
|
1638
|
+
query,
|
|
1639
|
+
sort
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
Repository.query = function (tasks, queryString) {
|
|
1644
|
+
return Repository.filterCards(tasks, queryString).result
|
|
1645
1645
|
}
|
|
1646
1646
|
|
|
1647
1647
|
Repository.replaceDatesInQuery = function (query) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imdone-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.50.1",
|
|
4
4
|
"description": "imdone-core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"find-up": "^5.0.0",
|
|
60
60
|
"gray-matter": "^4.0.2",
|
|
61
61
|
"ignore": "^5.2.0",
|
|
62
|
-
"imdone-api": "^1.
|
|
62
|
+
"imdone-api": "^1.50.0",
|
|
63
63
|
"isbinaryfile": "^3.0.2",
|
|
64
64
|
"js-yaml": "^3.14.1",
|
|
65
65
|
"json-fns": "^1.0.0",
|