imdone-core 1.53.9 → 1.53.10
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
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
content = content.replace(opts.interpolate, `~~\${${e}}~~`)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (mustache) {
|
|
23
|
+
const opts = { interpolate: /(?<!`){{([\s\S]+?)}}/g }
|
|
24
|
+
try {
|
|
25
|
+
content = template(content, opts)(data)
|
|
26
|
+
} catch (e) {
|
|
27
|
+
content = content.replace(opts.interpolate, `~~{{${e}}}~~`)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return content
|
|
32
|
+
}
|
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`),
|
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,6 +52,8 @@ 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) {
|
|
@@ -497,13 +500,16 @@ module.exports = class WorkerProject extends Project {
|
|
|
497
500
|
* @param {String} opts.comments - The comments to add to the new card
|
|
498
501
|
* @param {Boolean} opts.emit - Whether to emit the new card event
|
|
499
502
|
*/
|
|
500
|
-
newCard({ list, path, template, title, comments, emit = true }) {
|
|
503
|
+
async newCard({ list, path, template, title, comments, emit = true }) {
|
|
501
504
|
if (!path || !_path.parse(path).ext) path = this.getNewCardsFile({title})
|
|
502
505
|
path = this.getFullPath(path)
|
|
503
506
|
|
|
504
507
|
const { isFile, isDirectory } = fileGateway.preparePathForWriting(path)
|
|
505
508
|
|
|
506
509
|
if (!template) template = this.getNewCardTemplate(path, isFile)
|
|
510
|
+
|
|
511
|
+
const boardData = await this.pluginManager.getBoardProperties();
|
|
512
|
+
template = format(template, boardData)
|
|
507
513
|
|
|
508
514
|
if (comments) template = Task.addToLastCommentInContent(template, comments, this.config.isMetaNewLine())
|
|
509
515
|
|
|
@@ -532,10 +538,14 @@ module.exports = class WorkerProject extends Project {
|
|
|
532
538
|
meta = pluginMods.meta
|
|
533
539
|
tags = pluginMods.tags
|
|
534
540
|
contexts = pluginMods.contexts
|
|
535
|
-
const cardData = this.newCard({list, path, title: eol.split(content)[0], emit: false})
|
|
541
|
+
const cardData = await this.newCard({list, path, title: eol.split(content)[0], emit: false})
|
|
536
542
|
const filePath = cardData.path
|
|
537
543
|
if (useCardTemplate) content += cardData.template
|
|
538
544
|
|
|
545
|
+
const boardData = await this.pluginManager.getBoardProperties();
|
|
546
|
+
const data = { ...boardData, ...cardData}
|
|
547
|
+
content = format(content, data)
|
|
548
|
+
|
|
539
549
|
content = this.addTagsToContent(tags, content)
|
|
540
550
|
content = this.addContextsToContent(contexts, content)
|
|
541
551
|
content = this.addMetaToContent(meta, content)
|
|
@@ -733,11 +743,11 @@ module.exports = class WorkerProject extends Project {
|
|
|
733
743
|
filter: (filter) => {
|
|
734
744
|
this.setFilter(filter)
|
|
735
745
|
},
|
|
736
|
-
newCard: (list, path) => {
|
|
746
|
+
newCard: async (list, path) => {
|
|
737
747
|
if (task.source.lang !== 'text')
|
|
738
748
|
return this.alert('Unable to append cards in code files.')
|
|
739
749
|
if (path) path = this.getFullPath(path)
|
|
740
|
-
this.newCard({ list, path })
|
|
750
|
+
await this.newCard({ list, path })
|
|
741
751
|
},
|
|
742
752
|
alert: (msg) => {
|
|
743
753
|
this.toast({ message: msg })
|