-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
85 additions
and
98 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,14 @@ | ||
import {Jodit} from "jodit/esm/index.js"; | ||
import {getOriginalContent} from "./originalContent.var.ts"; | ||
|
||
let changed = false | ||
|
||
export function initSaveButton(editor: Jodit){ | ||
editor.events.on('change',(content)=>{ | ||
if (changed) return | ||
if (content===getOriginalContent()) return | ||
const saveButton = document.getElementById('save_button')! | ||
saveButton.removeAttribute('disabled') | ||
changed = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let originalContent:string | ||
|
||
export function setOriginalContent(content:string):void{ | ||
originalContent = content | ||
} | ||
|
||
export function getOriginalContent():string{ | ||
return originalContent | ||
} |
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,16 +1,15 @@ | ||
// import {Jodit} from 'jodit' | ||
import {Jodit} from 'jodit/esm/index.js'; | ||
import 'jodit/esm/plugins/video/video.js' | ||
import 'jodit/esm/plugins/source/source.js' | ||
import 'jodit/esm/plugins/indent/indent.js' | ||
import 'jodit/esm/plugins/clean-html/clean-html.js' | ||
import 'jodit/esm/plugins/hr/hr.js' | ||
import 'jodit/es2021/jodit.css' | ||
|
||
import {editorConfig} from "../const/jodit.config.ts"; | ||
|
||
import {initSaveButton} from "./initSaveButton.service.ts"; | ||
export async function renderEditor(content:string):Promise<void>{ | ||
document.getElementById('editor-container')!.innerHTML = `<textarea id="editor" name="editor"></textarea>` | ||
const editor = Jodit.make('#editor', editorConfig); | ||
editor.value = content | ||
initSaveButton(editor) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,15 +1,19 @@ | ||
import {initDom, MapOf, mockFetch} from "../test.service.ts"; | ||
import {screen} from '@testing-library/dom' | ||
import {expect} from "vitest"; | ||
|
||
const dataStore:MapOf<object> = { | ||
'/api/dataStore/dashboard-information/WidgetId': { | ||
"body": "Widget content" | ||
} | ||
} | ||
|
||
test(`1 > Render Widget`, async ()=>{ | ||
test(`1 > Render Editor`, async ()=>{ | ||
mockFetch(dataStore) | ||
initDom() | ||
await import('../../index.ts') | ||
screen.getByText('Widget content') | ||
const documentationLink = screen.getByText('Documentation for the Dashboard Information widget can be found here.') | ||
expect(documentationLink.getAttribute('href')).toBe('https://github.com/pepfar-datim/dashboard-information-widget') | ||
|
||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,12 +1,12 @@ | ||
import {fetchContent} from "./services/fetchContent.service.ts"; | ||
import {sanitize} from "./services/sanitize.service.ts"; | ||
import {sanitizeContent} from "../../shared/sanitizeContent.service.ts"; | ||
import {render} from "./services/render.service.ts"; | ||
import {addEditButton} from "./services/addEditButton.service.ts"; | ||
|
||
|
||
(async ()=>{ | ||
const rawContent:string = await fetchContent() || '<h3>New Dashboard Information widget</h3>' | ||
const safeContent = sanitize(rawContent) | ||
const safeContent = sanitizeContent(rawContent) | ||
await render(safeContent) | ||
addEditButton() | ||
})() |
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
3 changes: 1 addition & 2 deletions
3
render/src/services/sanitize.service.ts → shared/sanitizeContent.service.ts
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