From 8bcc3b0edd70b85650afc2252c173eb44eebd6a9 Mon Sep 17 00:00:00 2001 From: Don Sudduth Date: Fri, 8 Mar 2024 20:40:44 -0600 Subject: [PATCH] version 1.1.0 final best testing --- CHANGELOG.md | 5 +++++ README.md | 10 +++++++--- package.json | 2 +- src/extractParagraphs.ts | 27 ++++++++++++++------------- src/locales/de_DE.json | 12 ++++++------ src/locales/en_US.json | 12 ++++++------ 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f698f7..15963b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## not released +## v1.1.0 (2024-03-09) + +- Added a dialog box to set the extraction keyword and tag +- Added selection to extract at the folder level vs selecting individual notes + ## v1.0.0 (2024-02-08) - First version diff --git a/README.md b/README.md index 2a8390d..85be804 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,12 @@ Any Joplin tags in the source notes will be combined as Joplin tags in the extra Go to `Tools > Options > Paragraph Extractor` -- `Preserve Source Note Titles`: Titles of source notes will be embedded in new note. Default `true`. +- `Preserve source note titles with backlinks`: Titles of source notes will be embedded in new note with links back to the original source notes. Default `true`. - `Extract content at the bulleted list item level`: Bullets will be extracted at the top bullet level (including sub-bullets) vs all bullets within a paragraph. Default `false` - `Ignore the keyword case`: Any case for the keyword or hashtag keyword will be used for extraction. Default `false` - `Include the header of the section extracted`: Any H1-H6 header will be included with the extracted paragraph or bullet (this is ignored for keywords embedded within the header which are always extracted). Default `false` -- `Tag Prefix character`: Either the common hashtag # character (preferred) or $, %. Default `none` -- `Paragraph Tag or Keyword`: The entered keyword to search in notes to extract the paragraph. If the prefix hashtag field is set, then the tag is added to the keyword for finding paragraph blocks. +- `Default or Last Used Tag Prefix character`: Either the common hashtag # character (preferred) or $, %. Default `#` +- `Default of Last Used Paragraph Tag or Keyword`: The entered keyword to search in notes to extract the paragraph. If the prefix hashtag field is set, then the tag is added to the keyword for finding paragraph blocks. - `Remove extracted paragraph keyword and add end tag`: Any tagged/hashtagged keyword will be removed from the paragraph and an endtag will be addedin the new extraction note. Removal assumes the prefix character is entered. End tag is added always. Default `false` - `Title of the combined note`: New title of the combined note. Default `Extracted paragraphs`. - `Custom note title`: New note title with possible variables `{{FIRSTTITLE}}`, `{{LASTTITLE}}`, `{{ALLTITLE}}` and `{{DATE}}`. @@ -56,3 +56,7 @@ See [BUILD](BUILD.md) ## Changelog See [Changelog](CHANGELOG.md) + +## Thanks + +Special thanks to [Jack Gruber](https://github.com/JackGruber) for the inspiration and excellent code to help bootstrap this plugin! diff --git a/package.json b/package.json index 6110991..037b9e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "joplin-plugin-paragraph-extractor", - "version": "1.0.0", + "version": "1.1.0", "scripts": { "prepare": "npm run dist && husky install", "dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && webpack --env joplin-plugin-config=createArchive", diff --git a/src/extractParagraphs.ts b/src/extractParagraphs.ts index 3ae10f6..67fe1f4 100644 --- a/src/extractParagraphs.ts +++ b/src/extractParagraphs.ts @@ -31,8 +31,8 @@ namespace extractParagraphs { tname + `"/>
- -
+ +
` ); @@ -88,23 +88,26 @@ namespace extractParagraphs { return; } const fresults = extract.formData["extract"]; - const ckfolder = fresults["pfolder"]; + const ckbfolder = fresults["ckbfolder"]; let tagName = fresults["keyword"]; let tagPrefix = fresults["tag"]; if (tagName === "") { return; } + // Save the last search await extractParagraphs.setform(tagPrefix, tagName); let ids = []; - if (ckfolder === "true") { - let nfolder = await joplin.workspace.selectedFolder(); - const jnotes = await fetchAllItems(["search"], { - query: `notebook:"${nfolder.title}"`, - fields: ["id"], + if (ckbfolder === "true") { + let sfolder = await joplin.workspace.selectedFolder(); + const folder_notes = await fetchAllItems(["search"], { + query: `notebook:"${sfolder.title}"`, + fields: ["id", "parent_id"], }); //, "title", "body"]}); - for (const jnote of jnotes) { - ids.push(jnote.id); + for (const fnote of folder_notes) { + if (fnote.parent_id === sfolder.id) { + ids.push(fnote.id); + } } } else { ids = await joplin.workspace.selectedNoteIds(); @@ -117,6 +120,7 @@ namespace extractParagraphs { let listTags = []; let tagPages = {}; + // Save the last keyword extraction values in defaults await joplin.settings.setValue("tagName", tagName); await joplin.settings.setValue("tagPrefix", tagPrefix); @@ -130,7 +134,6 @@ namespace extractParagraphs { "extractAtBulletLevel" ); const ignoreCase = await joplin.settings.value("ignoreCase"); - const includeHeaders = await joplin.settings.value("includeHeaders"); const dateFormat = await joplin.settings.globalValue("dateFormat"); @@ -259,8 +262,6 @@ namespace extractParagraphs { p.replaceAll(regex, "").replace(/\s{2,}/g, " ") + "\n" ); } else { - //newNoteBody.push(JSON.stringify(jnotes) + "\n" + p + "\n"); - // newNoteBody.push(jids + "\n" + p + "\n"); newNoteBody.push(p + "\n"); } } diff --git a/src/locales/de_DE.json b/src/locales/de_DE.json index ea6892e..6d17c7a 100644 --- a/src/locales/de_DE.json +++ b/src/locales/de_DE.json @@ -7,12 +7,12 @@ "settings.ignoreCaseDescription": "Alle Notizen werden nach dem Schlüsselwort in beliebiger Kombination aus Groß- und Kleinschreibung durchsucht", "settings.includeHeaders": "Fügen Sie die Überschrift des extrahierten Absatzes ein", "settings.includeHeadersDescription": "Der H1-, H2- usw. Header ist in der zugrunde liegenden Extraktion enthalten (wenn ein Schlüsselwort im Header enthalten ist, wird es ignoriert).", - "settings.tagName": "Absatz-Tag oder Schlüsselwort", - "settings.tagNameDescription": "Hashtag oder Schlüsselwort, das in den Absätzen verwendet wird.", - "settings.tagPrefix": "Tag-Präfixzeichen", - "settings.tagPrefixDescription": "Präfix für Hashtags oder beliebige benutzerdefinierte Tags", - "settings.preserveSourceNoteTitles": "Titel der Quellnotizen beibehalten", - "settings.preserveSourceNoteTitlesDescription": "Behält die Titel der Orginal Notizen bei, indem diese im Notiztext eingefügt werden.", + "settings.tagName": "Standard- oder zuletzt verwendetes Absatz-Tag oder Schlüsselwort", + "settings.tagNameDescription": "Standardmäßiger oder zuletzt verwendeter Schlüsselwort- oder Hashtag-Text (ohne Präfix), der in den Absätzen verwendet wird.", + "settings.tagPrefix": "Standard- oder zuletzt verwendetes Tag-Präfixzeichen", + "settings.tagPrefixDescription": "Standard- oder zuletzt verwendetes Präfix für Hashtags oder benutzerdefinierte Tags – # wird bevorzugt, aber % oder $ können verwendet werden.", + "settings.preserveSourceNoteTitles": "Behalten Sie die Titel der Quellnotizen mit Backlinks bei", + "settings.preserveSourceNoteTitlesDescription": "Behält Titel und Links zurück zu ausgewählten Notizen im kombinierten Notiztext bei.", "settings.combinedNoteTitle": "Titel der extrahierten Absatznotiz", "settings.combinedNoteTitleValueDefault": "Extrahierte Absätze", "settings.combinedNoteTitleValueCombined": "Kombination aus allen Notiztitel", diff --git a/src/locales/en_US.json b/src/locales/en_US.json index c64e36a..6c03b0e 100644 --- a/src/locales/en_US.json +++ b/src/locales/en_US.json @@ -7,12 +7,12 @@ "settings.ignoreCaseDescription": "All notes will be searched for the keyword in any upper or lower case mix", "settings.includeHeaders": "Include the header of the paragraph extracted", "settings.includeHeadersDescription": "The H1, H2, etc header will be included with the underlying extraction (if keyword included in header, this is ignored)", - "settings.tagName": "Paragraph Tag or Keyword", - "settings.tagNameDescription": "Keyword or hashtag text (without prefix) used within the paragraphs.", - "settings.tagPrefix": "Tag Prefix character", - "settings.tagPrefixDescription": "Prefix for hashtags or any custom tags - # is preferred but % or $ can be used.", - "settings.preserveSourceNoteTitles": "Preserve source note titles", - "settings.preserveSourceNoteTitlesDescription": "Preserves titles of selected notes within the combined note body", + "settings.tagName": "Default or Last Used Paragraph Tag or Keyword", + "settings.tagNameDescription": "Default or last used keyword or hashtag text (without prefix) used within the paragraphs.", + "settings.tagPrefix": "Default or Last Used Tag Prefix Character", + "settings.tagPrefixDescription": "Default or last used prefix for hashtags or any custom tags - # is preferred but % or $ can be used.", + "settings.preserveSourceNoteTitles": "Preserve source note titles with back links", + "settings.preserveSourceNoteTitlesDescription": "Preserves titles and links back to selected notes within the combined note body", "settings.combinedNoteTitle": "Title of the extracted paragraphs note", "settings.combinedNoteTitleValueDefault": "Extracted paragraphs", "settings.combinedNoteTitleValueCombined": "Combination of all note titles",