Utility methods
- Source:
- util.js
Requires
Methods
-
<static> publicUpdateImage(imgPath)
-
Force a reload of an image matching provided file path
Parameters:
Name Type Description imgPath
string The image path
- Source:
- util.js
-
<static> typeOf(obj)
-
Returns a lowercase string defining object class. (differentiates between array and object);
Parameters:
Name Type Description obj
object | array | string | number The object to test
- Source:
- util.js
Returns:
lowercase class [object|array|string|number]
- Type
- string
Examples
Marked.util.typeOf('some text'); // => 'string'
Marked.util.typeOf([1,2,3]); // => 'array'
-
elementToJson(el, type [, forcedText] [, inText])
-
Convert an element to a JSON object
Parameters:
Name Type Argument Description el
object Element to convert
type
string Type of element, only 'spelling' implented, otherwise null
forcedText
string <optional>
Force text content
inText
string <optional>
Context
- Source:
- util.js
Returns:
JSON string description of element
- Type
- string
-
extractText(el)
-
Extract text for spell checking
Parameters:
Name Type Description el
string CSS selector to extract text from
- Source:
- util.js
Returns:
Object containing extracted text and string data
- Type
- object
-
fixBG()
-
Force a tiny scroll to refresh background
- Source:
- util.js
-
getPref(key)
-
Retrieve a value from NSUserDefaults
Parameters:
Name Type Description key
string The key to retrieve
- Source:
- util.js
Returns:
Value of the NSUserDefaults key
- Type
- id
-
isHorizontal()
-
Determine if the current preview style uses horizontal columns
- Source:
- util.js
Returns:
true if view is horizontal columns
- Type
- boolean
-
prefKeys()
-
Get an array of all keys from NSUserDefaults
- Source:
- util.js
Returns:
Array of strings representing NSUserDefaults dictionary keys
- Type
- array
-
retrieve(key)
-
Retrieve data in Cocoa webview storage
Parameters:
Name Type Description key
string The key to retrieve
- Source:
- util.js
Returns:
JSON.parse result of retured value
- Type
- id
-
setContrastMode(flag)
-
Toggle high/normal contrast modes
Parameters:
Name Type Description flag
boolean True for high contrast
- Source:
- util.js
-
setFullScreen(flag)
-
Set fullscreen state to modify necessary elements
Parameters:
Name Type Description flag
Boolean Set fullscreen to true or false
- Source:
- util.js
-
setPref(key, bool)
-
Store data in Cocoa NSUserDefaults key, persist across launches
Parameters:
Name Type Description key
string key name
bool
boolean | string | json value to store
- Source:
- util.js
Returns:
success
- Type
- boolean
Example
Marked.util.setPref('shouldCheckGrammar',true); Marked.util.setPref('zoomLevel', 150);
-
store(key, value)
-
Store data in Cocoa webview storage, persistent across loads
Parameters:
Name Type Description key
string key name
value
string value to store
- Source:
- util.js
Returns:
success
- Type
- boolean
-
toggleEditMarker(flag)
-
Toggle edit marker visibility*
Parameters:
Name Type Description flag
Boolean On/off stage
- Source:
- util.js