imdone-core 1.53.9 → 1.53.11
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/.imdoneignore +1 -0
- package/lib/adapters/markdown.js +1 -0
- package/lib/adapters/parsers/content-transformer.js +34 -0
- package/lib/card.js +2 -26
- package/lib/plugins/default-board-actions-plugin.js +10 -2
- package/lib/plugins/plugin-manager.js +0 -1
- package/lib/project.js +33 -18
- package/package.json +1 -1
package/.imdoneignore
CHANGED
package/lib/adapters/markdown.js
CHANGED
|
@@ -138,6 +138,7 @@ function resolveFileUrl(src, filePath) {
|
|
|
138
138
|
const srcDir = dirname(filePath);
|
|
139
139
|
const srcPath = resolve(srcDir, src) // filePath ? path.join(filePath, src) : path.resolve(src);
|
|
140
140
|
const srcUrl = pathToFileURL(srcPath);
|
|
141
|
+
if (src.endsWith('/')) return srcUrl + '/';
|
|
141
142
|
|
|
142
143
|
return srcUrl;
|
|
143
144
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const template = require('lodash.template')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
format,
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function removeDisplayComments(description) {
|
|
8
|
+
return description.replace(/<!--\s*\[([\s\S]*?)\]\s*-->/g, '$1')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function format(content, data, mustache) {
|
|
12
|
+
const opts = { interpolate: /(?<![`\\])\${([\s\S]+?)}/g }
|
|
13
|
+
|
|
14
|
+
if (mustache) content = removeDisplayComments(content)
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
content = template(content, opts)(data)
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error(e)
|
|
20
|
+
// content = content.replace(opts.interpolate, `~~\${${e}}~~`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (mustache) {
|
|
24
|
+
const opts = { interpolate: /(?<!`){{([\s\S]+?)}}/g }
|
|
25
|
+
try {
|
|
26
|
+
content = template(content, opts)(data)
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error(e)
|
|
29
|
+
content = content.replace(opts.interpolate, `~~{{${e}}}~~`)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return content
|
|
34
|
+
}
|
package/lib/card.js
CHANGED
|
@@ -9,16 +9,12 @@ const _get = require('lodash.get')
|
|
|
9
9
|
const eol = require('eol')
|
|
10
10
|
const allEmoji = require('markdown-it-emoji/lib/data/full.json')
|
|
11
11
|
const { getFunctionSignature } = require('./adapters/parsers/function-parser')
|
|
12
|
-
|
|
12
|
+
const { format } = require('./adapters/parsers/content-transformer')
|
|
13
13
|
const { removeMD } = require('./adapters/markdown')
|
|
14
14
|
|
|
15
15
|
const CONTENT_TOKEN = '__CONTENT__'
|
|
16
16
|
const lf = String(eol.lf)
|
|
17
17
|
|
|
18
|
-
function removeDisplayComments(description) {
|
|
19
|
-
return description.replace(/<!--\s*\[([\s\S]*?)\]\s*-->/g, '$1')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
18
|
module.exports = function newCard(task, _project, dontParse) {
|
|
23
19
|
const project = _project
|
|
24
20
|
const pluginManager = _project && _project.pluginManager
|
|
@@ -240,27 +236,7 @@ module.exports = function newCard(task, _project, dontParse) {
|
|
|
240
236
|
format(content, mustache) {
|
|
241
237
|
const projectData = project ? { ...project.data } : {}
|
|
242
238
|
const data = { ...this.data, ...projectData }
|
|
243
|
-
|
|
244
|
-
const opts = { interpolate: /(?<![`\\])\${([\s\S]+?)}/g }
|
|
245
|
-
|
|
246
|
-
if (mustache) content = removeDisplayComments(content)
|
|
247
|
-
|
|
248
|
-
try {
|
|
249
|
-
content = template(content, opts)(data)
|
|
250
|
-
} catch (e) {
|
|
251
|
-
content = content.replace(opts.interpolate, `~~\${${e}}~~`)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (mustache) {
|
|
255
|
-
const opts = { interpolate: /(?<!`){{([\s\S]+?)}}/g }
|
|
256
|
-
try {
|
|
257
|
-
content = template(content, opts)(data)
|
|
258
|
-
} catch (e) {
|
|
259
|
-
content = content.replace(opts.interpolate, `~~{{${e}}}~~`)
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return content
|
|
239
|
+
return format(content, data, mustache)
|
|
264
240
|
}
|
|
265
241
|
|
|
266
242
|
getCardMarkdown() {
|
|
@@ -13,9 +13,9 @@ module.exports = class DefaultBoardActionsPlugin extends Plugin {
|
|
|
13
13
|
title: 'Duplicate card',
|
|
14
14
|
keys: ['shift+d'],
|
|
15
15
|
icon: 'clone',
|
|
16
|
-
action: (task) => {
|
|
16
|
+
action: async (task) => {
|
|
17
17
|
const timestamp = project.isoDateWithOffset
|
|
18
|
-
project.newCard({
|
|
18
|
+
await project.newCard({
|
|
19
19
|
list: project.config.getDefaultList(),
|
|
20
20
|
path: task.relPath,
|
|
21
21
|
template: task.content.replace(/(\screated:).*(\s)/, `$1${timestamp}$2`),
|
|
@@ -40,6 +40,14 @@ module.exports = class DefaultBoardActionsPlugin extends Plugin {
|
|
|
40
40
|
return project.copyToClipboard(title, `"${title}" copied to clipboard`)
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
title: `Open in ${isWindows ? 'Explorer' : 'Finder'}`,
|
|
45
|
+
keys: ['alt+shift+o'],
|
|
46
|
+
icon: "folder",
|
|
47
|
+
async action () {
|
|
48
|
+
await project.openPath(project.path)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
43
51
|
]
|
|
44
52
|
}
|
|
45
53
|
|
|
@@ -22,7 +22,6 @@ module.exports = class PluginManager extends Emitter {
|
|
|
22
22
|
this.pluginsMap = {}
|
|
23
23
|
this.pluginPath = _path.join(project.path, '.imdone', 'plugins')
|
|
24
24
|
this.onDevChange = debounce(this.onDevChange.bind(this), 1000)
|
|
25
|
-
this.loadPlugins()
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
async startDevMode() {
|
package/lib/project.js
CHANGED
|
@@ -18,6 +18,7 @@ const Task = require('./task')
|
|
|
18
18
|
const eol = require('eol')
|
|
19
19
|
const { renderMarkdown, extractWikilinkTopics } = require('./adapters/markdown')
|
|
20
20
|
const { getFunctionSignature } = require('./adapters/parsers/function-parser')
|
|
21
|
+
const { format } = require('./adapters/parsers/content-transformer')
|
|
21
22
|
|
|
22
23
|
function calculateTotals(lists) {
|
|
23
24
|
const totals = {}
|
|
@@ -51,24 +52,31 @@ module.exports = class WorkerProject extends Project {
|
|
|
51
52
|
this.innerFilter = ''
|
|
52
53
|
this.fileGateway = fileGateway
|
|
53
54
|
this._updatedAt = undefined
|
|
55
|
+
this.data = {}
|
|
56
|
+
this.dataKeys = []
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
init(cb) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const promise = new Promise(async (resolve, reject) => {
|
|
61
|
+
this.repo.project = this
|
|
62
|
+
|
|
63
|
+
this.pluginManager = new PluginManager(this)
|
|
64
|
+
this.pluginManager.on('plugin-installed', () => this.emitUpdate())
|
|
65
|
+
this.pluginManager.on('plugin-uninstalled', () => this.emitUpdate())
|
|
66
|
+
this.pluginManager.on('plugins-reloaded', () => this.emitUpdate())
|
|
67
|
+
await this.pluginManager.loadPlugins()
|
|
68
|
+
this.data = this.pluginManager.getBoardProperties()
|
|
69
|
+
this.dataKeys = this.getDataKeys(this.data)
|
|
70
|
+
|
|
71
|
+
console.log('data', this.data)
|
|
72
|
+
console.log('dataKeys', this.dataKeys)
|
|
73
|
+
EVENTS.forEach((event) => {
|
|
74
|
+
this.repo.on(event, (data) => onChange(this, event, data))
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
this.repo.on('task.found', (task) => this.pluginManager.onTaskFound(task))
|
|
69
78
|
|
|
70
|
-
|
|
71
|
-
this.repo.init((err, files) => {
|
|
79
|
+
this.repo.init(async (err, files) => {
|
|
72
80
|
if (err) {
|
|
73
81
|
if (cb) cb(err)
|
|
74
82
|
else reject(err)
|
|
@@ -497,13 +505,16 @@ module.exports = class WorkerProject extends Project {
|
|
|
497
505
|
* @param {String} opts.comments - The comments to add to the new card
|
|
498
506
|
* @param {Boolean} opts.emit - Whether to emit the new card event
|
|
499
507
|
*/
|
|
500
|
-
newCard({ list, path, template, title, comments, emit = true }) {
|
|
508
|
+
async newCard({ list, path, template, title, comments, emit = true }) {
|
|
501
509
|
if (!path || !_path.parse(path).ext) path = this.getNewCardsFile({title})
|
|
502
510
|
path = this.getFullPath(path)
|
|
503
511
|
|
|
504
512
|
const { isFile, isDirectory } = fileGateway.preparePathForWriting(path)
|
|
505
513
|
|
|
506
514
|
if (!template) template = this.getNewCardTemplate(path, isFile)
|
|
515
|
+
|
|
516
|
+
const boardData = await this.pluginManager.getBoardProperties();
|
|
517
|
+
template = format(template, boardData)
|
|
507
518
|
|
|
508
519
|
if (comments) template = Task.addToLastCommentInContent(template, comments, this.config.isMetaNewLine())
|
|
509
520
|
|
|
@@ -532,10 +543,14 @@ module.exports = class WorkerProject extends Project {
|
|
|
532
543
|
meta = pluginMods.meta
|
|
533
544
|
tags = pluginMods.tags
|
|
534
545
|
contexts = pluginMods.contexts
|
|
535
|
-
const cardData = this.newCard({list, path, title: eol.split(content)[0], emit: false})
|
|
546
|
+
const cardData = await this.newCard({list, path, title: eol.split(content)[0], emit: false})
|
|
536
547
|
const filePath = cardData.path
|
|
537
548
|
if (useCardTemplate) content += cardData.template
|
|
538
549
|
|
|
550
|
+
const boardData = await this.pluginManager.getBoardProperties();
|
|
551
|
+
const data = { ...boardData, ...cardData}
|
|
552
|
+
content = format(content, data)
|
|
553
|
+
|
|
539
554
|
content = this.addTagsToContent(tags, content)
|
|
540
555
|
content = this.addContextsToContent(contexts, content)
|
|
541
556
|
content = this.addMetaToContent(meta, content)
|
|
@@ -733,11 +748,11 @@ module.exports = class WorkerProject extends Project {
|
|
|
733
748
|
filter: (filter) => {
|
|
734
749
|
this.setFilter(filter)
|
|
735
750
|
},
|
|
736
|
-
newCard: (list, path) => {
|
|
751
|
+
newCard: async (list, path) => {
|
|
737
752
|
if (task.source.lang !== 'text')
|
|
738
753
|
return this.alert('Unable to append cards in code files.')
|
|
739
754
|
if (path) path = this.getFullPath(path)
|
|
740
|
-
this.newCard({ list, path })
|
|
755
|
+
await this.newCard({ list, path })
|
|
741
756
|
},
|
|
742
757
|
alert: (msg) => {
|
|
743
758
|
this.toast({ message: msg })
|