Zettlr

1.0.0-beta.2

Main Classes

These classes handle the core functionality of Zettlr.

Static Members
Zettlr
new Zettlr(parentApp)
new ZettlrRenderer()
new ZettlrConfig(parent)
new ZettlrWindow(parent)

Inter-Process Communication

These classes handle the IPC between the main widnow and the main process.

Static Members
new ZettlrIPC(zettlrObj)
new ZettlrRendererIPC(zettlrObj, parent)

File Classes

These classes read in all directories and files for the app to use.

Static Members
new ZettlrDir(parent, dir)
new ZettlrFile(parent, fname)
new ZettlrAttachment(parent, fname)
new ZettlrVirtualDirectory(dir, vd, model)
new ZettlrProject(directory)
new ZettlrImport(fileOrFolder, dirToImport, errorCallback, successCallback)
new ZettlrExport(options)
makeExport(options)
new ZettlrInterface(dbPath)

Writing Aid Classes

These classes handle various tasks that aid the writing process, such as citing correctly, checking for potential typos, enable tag autocompletion and some statistics.

Static Members
new ZettlrCiteproc()
new ZettlrDictionary()
new ZettlrTags(parent)
new ZettlrStats(parent)

GUI Classes

These classes obviously control various elements inside the graphical user interface.

Static Members
new ZettlrBody(parent)
new ZettlrEditor(parent)
new ZettlrToolbar(parent)
new ZettlrQuicklook(parent, file, standalone)
new ZettlrDialog(parent)
new ZettlrPopup(elem, content, callback)
new ZettlrPreview(parent)
new ZettlrDirectories(parent)
new TreeView(parent, paths, level, isRoot)
new FileView(parent, paths, isRoot)
new ZettlrPomodoro(parent)
new ZettlrStatsView(parent)
new ZettlrAttachments(parent)
new ZettlrCon(parent)
new ZettlrNotification(parent, message, position)
new EmptyPaths(dirobj)

Helper Functions

These functions provide helper functionality that is used in various places around the app.

Static Members
hash(string)
flattenDirectoryTree(tree, newarr)
asciiSorting(a, b)
dateSorting(a, b)
sort(arr, type)
generateName()
generateId(pattern)
formatDate(dateObj)
ignoreDir(p)
ignoreFile(p)
isDir(p)
isFile(p)
isAttachment(p)
isDictAvailable(lang)
localiseNumber(number)
makeImgPathsAbsolute(basePath, mdstring, basepath)
makeSearchRegEx(term, injectFlags)
trans(string, args)

Other Classes

These classes serve complex helper functionality, e.g. they combine too much functionality for simple functions, but are not specialised to one of the other categories here.

Static Members
new ZettlrWatchdog(paths, path)
new ZettlrUpdater(app)
new ZettlrMenu(parent)

zettlr

The main Zettlr object. As long as this exists in memory, the app will run.

zettlr

Type: Zettlr

filesToOpen

Global array containing files collected from argv before process start

filesToOpen

Type: Array

send

Sends a message and and saves the callback.

send(cmd: string, cnt: Object, callback: Callable): void
Parameters
cmd (string) The command to be sent
cnt (Object = {}) The payload for the command
callback (Callable = null) An optional callback
Returns
void: This function does not return.

isFirstInstance

This variable is false, if this process is the only one, or if there is already one running on this system.

isFirstInstance

Type: Boolean

on

This gets executed when the user wants to open a file on macOS.

on

on

Hook into the ready event and initialize the main object creating everything else. It is necessary to wait for the ready event, because prior, some APIs may not work correctly.

on

on

Quit as soon as all windows are closed and we are not on macOS.

on

on

On macOS also hook into the will-quit event to save config.json and stats.JSON

on

on

On macOS, open a new window as soon as the user re-activates the app.

on

on

Hook into the unhandledRejection-event to prevent nasty error messages when a Promise is rejected somewhere.

on

on

Listen to the beforeChange event to modify pasted image paths into real markdown images.

on

Type: function

quit

Quit if this is a second instance of Zettlr.

quit
Parameters
isFirstInstance (Boolean) Whether or not this is a second instance.

constructor

Initates the Quicklook Window reference array.

constructor()

openQuicklook

Opens a Quicklook window with a specific file

openQuicklook(file: ZettlrFile): void
Parameters
file (ZettlrFile) The file to be opened
Returns
void: No return.

closeQuicklook

Closes a specific quicklook window

closeQuicklook(win: BrowserWindow, alreadyClosed: Boolean): void
Parameters
win (BrowserWindow) The reference to a BrowserWindow
alreadyClosed (Boolean = false) Whether or not the window is already closed
Returns
void: No return.

closeAll

Closes all Quicklook windows.

closeAll(): void
Returns
void: No return.

fs

BEGIN HEADER

Contains: Internationalization functions CVM-Role: Maintainer: Hendrik Erz License: GNU GPL v3

Description: This file contains several functions, not classes, that help with the internationalization of the app.

END HEADER

fs

DirectoryError

Error object constructor

new DirectoryError(msg: string)
Parameters
msg (string) The error message

FileError

Error Object

new FileError(msg: String)
Parameters
msg (String) The error message

ExportError

Error object constructor.

new ExportError(msg: String, name: String)
Parameters
msg (String) The message
name (String = 'Exporting error') The name of the error.

checkImportIntegrity

This function checks a given file list and checks how good it is at guessing the file format. Also this is used to decide manually which files to import and which not.

checkImportIntegrity(fileList: Array): Object
Parameters
fileList (Array) An array containing a file list. If it's a string, a directory is assumed which is then read.
Returns
Object: A sanitised object containing all files with some detected attributes.

i18n

This function loads a language JSON file specified by lang into the global i18n-object

i18n(lang: String): void
Parameters
lang (String = 'en_US') The language to be loaded
Returns
void: Function does not return anything.

filetypes

BEGIN HEADER

Contains: General helper functions CVM-Role: Maintainer: Hendrik Erz License: GNU GPL v3

Description: This file contains several functions, not classes, that are used for general purposes.

END HEADER

filetypes

markdownInline

Converts selection into a markdown inline element (or removes formatting)

markdownInline(cm: CodeMirror, pre: String, post: String, tokentype: any)
Parameters
cm (CodeMirror) The CodeMirror instance
pre (String) The formatting mark before the element
post (String) The formatting mark behind the element
tokentype (any = undefined)

markdownBlock

Converts a selection into a block element

markdownBlock(cm: CodeMirror, mark: String)
Parameters
cm (CodeMirror) The codemirror instance
mark (String) The formatting mark to be inserted

defineMode

Define the spellchecker mode that will simply check all found words against the renderer's typoCheck function.

defineMode
Parameters
config (Object) The original mode config
parsercfg (Object) The parser config
Returns
OverlayMode: The generated overlay mode

defineMode

This defines the Markdown Zettelkasten system mode, which highlights IDs and tags for easy use of linking and searching for files. THIS MODE WILL AUTOMATICALLY LOAD THE SPELLCHECKER MODE WHICH WILL THEN LOAD THE GFM MODE AS THE BACKING MODE.

defineMode
Parameters
config (Object) The config with which the mode was loaded
parserConfig (Object) The previous config object
Returns
OverlayMode: The loaded overlay mode.

defineMode

MULTIPLEX MODE: This will by default load our internal mode cascade (consisting of the zkn-mode, the spellchecker and finally the gfm mode) OR in code blocks use the respective highlighting modes.

defineMode
Parameters
config (Object) The previous configuration object
Returns
CodeMirrorMode: The multiplex mode

markdownRenderImages

Defines the CodeMirror command to render all found markdown images.

markdownRenderImages(cm: CodeMirror): void
Parameters
cm (CodeMirror) The calling CodeMirror instance
Returns
void: Commands do not return.

markdownHeaderClasses

This command applies the classes size-header-x for all six different markdown headings.

markdownHeaderClasses(cm: CodeMirror): void
Parameters
cm (CodeMirror) The CodeMirror instance
Returns
void: Commands do not return.

DialogError

Dialog errors may occur.

new DialogError(msg: String)
Parameters
msg (String = '') An additional error message.

constructor

Create a validation ruleset.

constructor(option: string, ruleset: string)
Parameters
option (string) The key/option that can be validated with this ruleset.
ruleset (string) The unparsed ruleset, e.g. "required|min:4|max:5|string"

_parseRules

Parses the rules and prepares the validation of a value.

_parseRules(rules: string): void
Parameters
rules (string) The rulset provided to the constructor.
Returns
void: There's nothing to return.

validate

Validates an input and returns a boolean indicating the result.

validate(input: Mixed): Boolean
Parameters
input (Mixed) The input to be checked.
Returns
Boolean: True, if the input passes the validation, or false.

isValid

Returns whether or not the last given input has been successfully validated.

isValid(): Boolean
Returns
Boolean: Whether or not the last input was valid.

isRequired

Returns whether this option is required.

isRequired(): Boolean
Returns
Boolean: True, if the option is required, false if not.

isEmpty

Returns whether or not the last given input was empty.

isEmpty(): Boolean
Returns
Boolean: True, if the input was empty, or false.

isInRange

Returns whether or not the input meets the min/max criteria of the ruleset.

isInRange(): Boolean
Returns
Boolean: Returns false, if one of the range criteria were not met, otherwise true.

isTypeCorrect

Returns whether or not the type of the last given input is correct.

isTypeCorrect(): Boolean
Returns
Boolean: True, if the type matches the criteria, or false.

isValueCorrect

Returns whether or not the provided input is included in the predefined keys.

isValueCorrect(): Boolean
Returns
Boolean: True, if the given value has been mentioned in the "in:"-criterium

why

Returns a message explaining why the last validation failed, or an empty string.

why(): string
Returns
string: A fully parsed and translated string indicating the first violated rule.

getDefault

Returns the default value that inputs for this rule should have, if any.

getDefault(): [type]
Returns
[type]: [description]

getKey

Returns the key for which this rule is made.

getKey(): string
Returns
string: The key.