You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Electron: Export/Import links to notes
This commit is contained in:
@ -107,7 +107,7 @@ class Note extends BaseItem {
|
||||
return BaseModel.TYPE_NOTE;
|
||||
}
|
||||
|
||||
static linkedResourceIds(body) {
|
||||
static linkedItemIds(body) {
|
||||
// For example: 
|
||||
if (!body || body.length <= 32) return [];
|
||||
const matches = body.match(/\(:\/.{32}\)/g);
|
||||
@ -115,6 +115,35 @@ class Note extends BaseItem {
|
||||
return matches.map((m) => m.substr(3, 32));
|
||||
}
|
||||
|
||||
static async linkedItems(body) {
|
||||
const itemIds = this.linkedItemIds(body);
|
||||
const output = [];
|
||||
|
||||
for (let i = 0; i < itemIds.length; i++) {
|
||||
const item = await BaseItem.loadItemById(itemIds[i]);
|
||||
if (!item) continue;
|
||||
output.push(item);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static async linkedItemIdsByType(type, body) {
|
||||
const items = await this.linkedItems(body);
|
||||
const output = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (item.type_ === type) output.push(item.id);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
static async linkedResourceIds(body) {
|
||||
return await this.linkedItemIdsByType(BaseModel.TYPE_RESOURCE, body);
|
||||
}
|
||||
|
||||
static new(parentId = '') {
|
||||
let output = super.new();
|
||||
output.parent_id = parentId;
|
||||
|
Reference in New Issue
Block a user