generated from diplodoc-platform/package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
deaa93f
commit 103f954
Showing
11 changed files
with
59 additions
and
14 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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"name": "@diplodoc/tabs-extension-example", | ||
"name": "@diplodoc/html-extension-example", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"start": "node . 1> build/index.html; open build/index.html" | ||
}, | ||
"dependencies": { | ||
"@diplodoc/tabs-extension": "..", | ||
"@diplodoc/html-extension": "file:..", | ||
"@diplodoc/transform": "*" | ||
} | ||
} |
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,9 @@ | ||
import {HtmlController} from './runtime/HtmlController'; | ||
|
||
export const GLOBAL_SYMBOL: unique symbol = Symbol.for('diplodocHtml'); | ||
|
||
declare global { | ||
interface Window { | ||
[GLOBAL_SYMBOL]: HtmlController; | ||
} | ||
} |
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,3 +1,18 @@ | ||
import sanitizeHtml from 'sanitize-html'; | ||
|
||
export const defaultSanitize = (dirtyHtml: string) => sanitizeHtml(dirtyHtml); | ||
|
||
export function addHiddenProperty< | ||
B extends Record<string | symbol, unknown>, | ||
F extends string | symbol, | ||
V, | ||
>(box: B, field: F, value: V) { | ||
if (!(field in box)) { | ||
Object.defineProperty(box, field, { | ||
enumerable: false, | ||
value: value, | ||
}); | ||
} | ||
|
||
return box as B & {[P in F]: V}; | ||
} |
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,11 @@ | ||
export class HtmlController { | ||
// @ts-ignore | ||
private _document: Document; | ||
|
||
constructor(document: Document) { | ||
this._document = document; | ||
this._document.addEventListener('click', (event) => { | ||
console.log('event', event); | ||
}); | ||
} | ||
} |
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,7 @@ | ||
import {GLOBAL_SYMBOL} from '../common'; | ||
import {HtmlController} from './HtmlController'; | ||
import './scss/html.scss'; | ||
|
||
if (typeof window?.document !== 'undefined' && !window[GLOBAL_SYMBOL]) { | ||
window[GLOBAL_SYMBOL] = new HtmlController(document); | ||
} |
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,3 @@ | ||
.yfm-html { | ||
/* TODO: add some styles */ | ||
} |