Utility methods
Requires
Methods
elementToJson(el, type, forcedTextopt, inTextopt) → {string}
Convert an element to a JSON object
Parameters:
Name | Type | Attributes | 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 |
Returns:
JSON string description of element
- Type
- string
extractText(el) → {object}
Extract text for spell checking
Parameters:
Name | Type | Description |
---|---|---|
el |
string | CSS selector to extract text from |
Returns:
Object containing extracted text and string data
- Type
- object
fixBG()
Force a tiny scroll to refresh background
getPref(key) → {id}
Retrieve a value from NSUserDefaults
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key to retrieve |
Returns:
Value of the NSUserDefaults key
- Type
- id
isHorizontal() → {boolean}
Determine if the current preview style uses horizontal columns
Returns:
true if view is horizontal columns
- Type
- boolean
(static) publicUpdateImage(imgPath)
Force a reload of an image matching provided file path
Parameters:
Name | Type | Description |
---|---|---|
imgPath |
string | The image path |
(static) typeOf(obj) → {string}
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 |
Returns:
lowercase class [object|array|string|number]
- Type
- string
Examples
Marked.util.typeOf('some text'); // => 'string'
Marked.util.typeOf([1,2,3]); // => 'array'
prefKeys() → {array}
Get an array of all keys from NSUserDefaults
Returns:
Array of strings representing NSUserDefaults dictionary keys
- Type
- array
retrieve(key) → {id}
Retrieve data in Cocoa webview storage
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key to retrieve |
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 |
setFullScreen(flag)
Set fullscreen state to modify necessary elements
Parameters:
Name | Type | Description |
---|---|---|
flag |
Boolean | Set fullscreen to true or false |
setPref(key, bool) → {boolean}
Store data in Cocoa NSUserDefaults key, persist across launches
Parameters:
Name | Type | Description |
---|---|---|
key |
string | key name |
bool |
boolean | string | json | value to store |
Returns:
success
- Type
- boolean
Example
Marked.util.setPref('shouldCheckGrammar',true);
Marked.util.setPref('zoomLevel', 150);
store(key, value) → {boolean}
Store data in Cocoa webview storage, persistent across loads
Parameters:
Name | Type | Description |
---|---|---|
key |
string | key name |
value |
string | value to store |
Returns:
success
- Type
- boolean
toggleEditMarker(flag)
Toggle edit marker visibility*
Parameters:
Name | Type | Description |
---|---|---|
flag |
Boolean | On/off stage |