-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nested Condition re-implemented using fieldType 1 (#7)
* fix for nested condition using fieldType 1 * refactor: unused code removed * fix for conditional test * fix: format added in .prettierrc and file changed accordingly * version bumped
- Loading branch information
Showing
10 changed files
with
1,323 additions
and
591 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"arrowParens": "always", | ||
"bracketSpacing": false, | ||
"htmlWhitespaceSensitivity": "css", | ||
"insertPragma": false, | ||
"jsxBracketSameLine": false, | ||
"jsxSingleQuote": true, | ||
"printWidth": 120, | ||
"proseWrap": "preserve", | ||
"quoteProps": "as-needed", | ||
"requirePragma": false, | ||
"singleQuote": true, | ||
"tabWidth": 4, | ||
"trailingComma": "none", | ||
"useTabs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
import get from 'lodash/get' | ||
import {inline} from '../types/sfdt' | ||
import get from 'lodash/get'; | ||
import {inline} from '../types/sfdt'; | ||
type inlineObject = inline; | ||
|
||
// is inlineObject a bookmark? | ||
export const isBookmark: (inlineObject?: inlineObject) => inlineObject | boolean = (inlineObject) => { | ||
if (!inlineObject) return false; | ||
|
||
if (inlineObject.bookmarkType !== undefined) { | ||
return inlineObject | ||
return inlineObject; | ||
} | ||
|
||
return false | ||
} | ||
return false; | ||
}; | ||
|
||
// see if inlineObject is a bookmark matching the one we are checking for | ||
export const isMatchingBookmark = (inlineObject, name) => { | ||
const matched = isBookmark(inlineObject) | ||
const matched = isBookmark(inlineObject); | ||
|
||
if (get(matched, 'name') === name) { | ||
return matched | ||
return matched; | ||
} | ||
|
||
return false | ||
} | ||
return false; | ||
}; | ||
|
||
export const isConditionalBookmark = (inlineObject, prefix = 'COND') => { | ||
const {name} = inlineObject | ||
return (isBookmark(inlineObject) && name && name.split('::').includes(prefix)) ? true : false | ||
} | ||
const {name} = inlineObject; | ||
return isBookmark(inlineObject) && name && name.split('::').includes(prefix) ? true : false; | ||
}; | ||
|
||
// is inlineObject a bookmark start object | ||
export const isBookmarkStart = (inlineObject) => { | ||
const matched = isBookmark(inlineObject) | ||
const matched = isBookmark(inlineObject); | ||
|
||
if (get(matched, 'bookmarkType') === 0) { | ||
return matched | ||
return matched; | ||
} | ||
|
||
return false | ||
} | ||
return false; | ||
}; | ||
|
||
// is inlineObject a bookmark end object | ||
export const isBookmarkEnd = (inlineObject) => { | ||
const matched = isBookmark(inlineObject) | ||
const matched = isBookmark(inlineObject); | ||
|
||
if (get(matched, 'bookmarkType') === 1) { | ||
return matched | ||
return matched; | ||
} | ||
|
||
return false | ||
} | ||
return false; | ||
}; | ||
|
||
export const isToggleStart = (inlineObject) => { | ||
return get(inlineObject, 'hasFieldEnd') ? true : false | ||
} | ||
return get(inlineObject, 'hasFieldEnd') ? true : false; | ||
}; | ||
|
||
export const isToggleEnd = (inlineObject) => { | ||
return get(inlineObject, 'fieldType') === 2 ? true : false | ||
} | ||
return get(inlineObject, 'fieldType') === 1 ? true : false; | ||
}; | ||
|
||
export const isToggleObject = (inlineObject) => { | ||
return isToggleStart(inlineObject) || isToggleEnd(inlineObject) | ||
} | ||
return isToggleStart(inlineObject) || isToggleEnd(inlineObject); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.