- Incorporate some bug fixes provided by @Myliak
- Provide a "Batch Mode" so that multiple parses can be made on a single file with different parameters for each pass. The file should contain a JSON array, with each element of the array being a JSON object containing any of the following fields:
- "fieldName": "Field containing the data"
- "noteName": "Field to use as Note name"
- "folderName": "Name of Destination Folder in Vault"
- "namePrefix": Note name prefix/suffix"
- "nameSuffix": "Note name suffix"
- "batchStep": "A name for this iteration which will be available in the handlebars file as
@importBatchStep
) - Any of the above values which are not set will be left at the values from the previous/earlier entries in the array (or the values entered into the dialog if they are not present in any array element).
- Ensure that
@importSourceIndex
is set (rather than the erroneous@sourceIndex
name). - Update README to identify that
this.SourceIndex
will always be available to allow any JavaScript used for defining the note's name to use this information.
- Ensure that when accessing folders in the vault we always uses "/" as the directory separator, rather than
path.sep
which is the underlying O/S's preferred slash.
- Update all the Obsidian-specific version files so that users know that the improvements added in 0.36.0 are actually present in their Vault.
- Provide an alternative method for creating the note name for each note. The "Field to use as note name" can contain some javascript which should perform a "return" in order to provide the required value. The syntax is
@{...some javascript...}
The JS can reference eitherthis.field
to reference items within the current record being processed, ordataRoot.field
to access any data in the entire JSON record. A typical example would be:
@{return `${(this.state > 0) && dataRoot.pack.states.find(state => state.i === this.state)?.name || "Unknown" }-${this.name}`}
- Allow the notename to be constructed from more than one field. The "Field Name" can contain either a single field name, or a more complex format with field names surrounded by "${...}", for example "${country}-${name}" (without the double-quotes).
- Provide an additional option "Add suffix on duplicate Note Names" which will append a number to the end of a Note if its name matches the name of a Note that was created during this import (it will NOT look for existing Notes in the vault before the import was started).
- Change target JS version to 2021 (instead of ES6).
- Handle multiple slashes properly in the file's path.
- Include vault path+filename when note creation fails.
- Ignore any elements of the selected object/array which are not valid JS objects (an INFO line is added to Obsidian's log to report the ignore.)
- Provide new variables for handlebars templates: -- @importSourceIndex (index/fieldname of the current row/field) -- @importSourceFile (File: the source file containing the CSV/JSON data [.name and .path are available]) -- @importDataRoot (the root of the data from the source file) -- @importHelperFile (File: the file containing the JS handlebars helpers [.name and .path are available]) -- @importSettings (Values from the Dialog window) --- @importSettings.jsonName: (string) "Field to use as Note name" --- @importSettings.jsonNamePath: (boolean) "Allow paths in Note name" --- @importSettings.jsonUrl: (string) "Specify URL to JSON data" --- @importSettings.folderName: (string) "Name of Destination Folder in Vault" --- @importSettings.topField: (string) "Field containing the data" --- @importSettings.notePrefix: (string) "Note name prefix" --- @importSettings.noteSuffix: (string) "Note name suffix" --- @importSettings.handleExistingNote: (integer) "How to handle existing Notes" --- @importSettings.forceArray: (boolean) "Each subfield is a separate note" --- @importSettings.multipleJSON: (boolean) "Data contains multiple JSON objects"
BREAKING CHANGE: @dataRoot
has been replaced by @importDataRoot
FUTURE BREAKING CHANGE: SourceIndex
will be removed, since it can be accessed via @importSourceIndex
- Provide a new field in the object passed to the handlebars helper called
dataRoot
. This will allow you to access the root of the JSON file which was imported (whereas normally you can only access the fields of the element currently being converted into a Note).
- Ensure that the handlebars processing is done with
{noEscape: true}
so that no characters are substituted by a HTML entity&#number;
.
- When processing JSON, only look for multiple JSON records if the "Multiple JSON" checkbox is selected.
- Add support for JSON files which contain more than one json object. Each object will be handled separately against the configured import parameters.
- Add the ability to specify a URL from which to read JSON data. A GET operation to the URL must return the actual JSON data.
- When handling of existing notes is set to REPLACE, then simply use vault.modify rather than deleting the old note and creating a new note.
- Use the correct option names in the hint information about the new 'How to handle existing Notes' option.
- Improve the handling of existing notes so that you can APPEND to an existing note instead of only REPLACE it.
- This version also includes a rework of how settings are managed.
Let the user specify a hotkey to open the import dialog.
Provide an additional setting 'Each subfield is a separate note' which can be selected for JSON data files. When used with a JSON file where the 'Field containing the data' is an Object rather than an Array, then selecting this new option will create a separate note for each field of that object. (If not selected, then the object will be parsed once to create a single note.)
If required, the name of the field can be referenced using the handlebars name of 'SourceField'.
This will help users who have JSON files which contain objects for what should probably be simple arrays.
Fix an issue where only the first '/' was replaced when 'Allow paths in Note name' was not selected. This fix also means that all invalid characters in the generated file name will be correctly replaced by '_' (rather than only the first occurrence).
Allow users to specify a specific note which will contain some additional handlebars helpers. See additional section in the README file.
When processing a JSON file, if "Field containing the data" is left blank, then it will only check the very top of the JSON object tree to see if it is an array or not. (It will no longer search for the first child field which is an array.)
The {{table ...}} helper function now explicitly checks for the first parameter being undefined or null in order to determine if the table search should be attempted (this will allow boolean false or numberic 0 to be valid strings for table lookups).
The handlebars helper function {{ setVar *varName* *varValue* }}
has been added to allow creation of local variables. Note that usually varName is a string, so the variable name will need to be wrapped in double-quote marks. The created variable can be later referenced using {{varName}}
or {{@root.varName}}
Add an option to NOT overwrite existing Notes (the entries in the JSON/CSV file for those notes will be ignored).
Provide additional configuration which allows a prefix and/or suffix to be used in the filename either side of value read from the Note name field.
Fix version numbering between issues!
Add the 'strsplit' function so that a single string can be split into an array based on a single string or a regular expression.
Add a new field "Field containing the data" which can be used to specify the specific part of the JSON file from which to read the data (normally an array). If left blank, then the top of the JSON file will be used if it is an array, otherwise the first array child of the top record in the JSON file will be used.
If the field is not an array then the entire JSON data object tree (below "Field containing the data") will be passed for processing, so a single JSON record can be read without needing to modify the JSON file to contain an array.
Both the "Field containing the data" and the "Field to use as Note name" can now contain a path to a field (field names separated by '.') instead of only allowing a direct field to be used.
Add a new variable which is automatically added to the field names available for your handlebars template file:
- "SourceFilename" contains the name of the data file from which the data is being read.
Ensure that the state of the "Allow paths in Note name" tick box is saved, so that it retains the same state when the window is reopened.
Add an additional flag 'Allow paths in Note name'. When ticked, this option will allow "/" within the name field to be used as part of the file path, allowing for a hierarchy of folders to be created from a single json file.
If not ticked, then the existing behaviour will be used where all "/" within the name field will be replaced as "_".
Add 'replacereg' helper routine to support replacing regular expressions in strings.
Support use of numbers as the name of each note (previously only strings were allowed).
Allow multiple source files to be selected for conversion.
Switch to Budibase's fork of handlebars-helpers, since that builds properly.
Add .tsv as an additional file type for matching (tab separated value files).
Clarify some field names in the launch dialogue.
The "table" function now supports pattern matching as per the Javascript Regular Expression syntax.
For example, the following contains two tables, first looking at the first part of the string to determine Lawful/Neutral/Chaotic, and a second table to look at the second half of the string for Good/Neutral/Evil.
{{table alignment "U" "Unaligned" "A" "Any" "N" "True Neutral" "L,." "Lawful" "N,." "Neutral" "C,." "Chaotic"}}{{table alignment "[A|N|U]" "" ".,G" " Good" ".,N" " Neutral" ".,E" " Evil"}}
It also supports numbered groups, so a search pattern of "M(\d+)" will allow you to specify "Medium $1" as the replacement string - where $1 will be replaced by the "\d+" part of the search pattern. (The parenthese identify the pattern that will be usable as $1, the second pair of parentheses will be usable as $2, etc.)
Add new handlers helper function: {{ strarray string }}
(converts a string into an array, e.g. for use with #each)
Add new Handlebars helper function: {{ substring string start length }}
(returns the part of 'string' starting at 'start' (first character = 0) with a length of 'length')
Improve CSV conversion to use more capabilities of the PapaParse library.
The library tries to auto-detect the separator; any of comma, tab, pipe, semicolon, ASCII record separator (30), ASCII unit separator(31).
Fix version information in various configuration files.
Ignore any entry in the source data which does not have a value present for the note filename.
Add initial support for CSV files, which REQUIRE that the first line of the file is a HEADER line.
Add a text box into which the JSON text can be pasted, as an alternative to reading in a file.
Remove use of forEach()
Add handlebars-helpers as an additional library of options available.
Add our own "{{table ...}}" helper to perform string look-up mapping tables efficiently.
Get build working automatically on github.
Put "IMPORT" label onto the GO button.
Allow top-level of JSON to be an array, or a single variable which is an array.
Ensure 'JSON Name field' and 'Set Folder' are saved/restored within the dialog window.
Add Notice when a generated Note contains "[object Object]"
Initial Beta version