-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui-commons): add save feature in JSONEditor component
* create a save button in the menu * add missing typing
- Loading branch information
Showing
3 changed files
with
201 additions
and
12 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
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,20 @@ | ||
import i18n from "../../../i18n"; | ||
|
||
export function createSaveButton(onClick: VoidFunction) { | ||
const saveBtn = document.createElement("button"); | ||
saveBtn.classList.add("jsoneditor-separator"); | ||
saveBtn.title = i18n.t("global.save"); | ||
saveBtn.style.backgroundImage = | ||
"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7E" + | ||
"AAAOxAGVKw4bAAAA6klEQVQ4jaXSMUoDYRQE4G+XJYhFkNR2ggewtvQE3kS09QQKIjmDWHsEwcIrWGulIiIhBh" + | ||
"HHIptkDYlhdcr3v5l5/3tTJNlHHxu4wYPlqLCHM5wWRUGS+8ywuYiV5DzJdZJukqu69ySJCt1G79cS5x3sooPP" + | ||
"unaEp7Iea5XAMhyXLQnzqCo0RdaXNF7iFkOsNR+KJO+N4iOef3Essd0wHc0LtMVossAXbNUjsniZza92cIfeRG" + | ||
"BQFMVrC+ePJAP0JqptzzfllH8kT/HfHCjNovlngTc/49yGO6xwiH6SC+MzrtpJaZybHg6+AW/yWkXws02vAAAA" + | ||
"AElFTkSuQmCC)"; | ||
saveBtn.style.backgroundRepeat = "no-repeat"; | ||
saveBtn.style.backgroundPosition = "center"; | ||
|
||
saveBtn.addEventListener("click", onClick); | ||
|
||
return saveBtn; | ||
} |
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,32 @@ | ||
import "jsoneditor"; | ||
|
||
declare module "jsoneditor" { | ||
export interface HistoryItem { | ||
action: string; | ||
params: object; | ||
timestamp: Date; | ||
} | ||
|
||
export default interface JSONEditor { | ||
/** | ||
* Only available for mode `code`. | ||
*/ | ||
aceEditor?: AceAjax.Editor; | ||
/** | ||
* Expand all fields. Only applicable for mode `tree`, `view`, and `form`. | ||
*/ | ||
expandAll?: VoidFunction; | ||
/** | ||
* Only available for mode `tree`, `form`, and `preview`. | ||
*/ | ||
history?: { | ||
/** | ||
* Only available for mode `tree`, and `form`. | ||
*/ | ||
history?: HistoryItem[]; | ||
index: number; | ||
onChange: () => void; | ||
}; | ||
menu: HTMLDivElement; | ||
} | ||
} |