mirror of
https://github.com/He4eT/huge-link.git
synced 2026-05-05 00:47:27 +00:00
Add lz-string for encoding
This commit is contained in:
parent
ac2051a104
commit
3393209fd2
3 changed files with 14 additions and 6 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -9065,6 +9065,11 @@
|
||||||
"yallist": "^4.0.0"
|
"yallist": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"lz-string": {
|
||||||
|
"version": "1.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.4.4.tgz",
|
||||||
|
"integrity": "sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY="
|
||||||
|
},
|
||||||
"magic-string": {
|
"magic-string": {
|
||||||
"version": "0.25.7",
|
"version": "0.25.7",
|
||||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz",
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
"sirv-cli": "1.0.3"
|
"sirv-cli": "1.0.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"lz-string": "^1.4.4",
|
||||||
"preact": "^10.3.2",
|
"preact": "^10.3.2",
|
||||||
"preact-render-to-string": "^5.1.4",
|
"preact-render-to-string": "^5.1.4",
|
||||||
"preact-router": "^3.2.1",
|
"preact-router": "^3.2.1",
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,14 @@ import {h} from 'preact'
|
||||||
import {Link} from 'preact-router/match'
|
import {Link} from 'preact-router/match'
|
||||||
import ReactMarkdown from 'react-markdown'
|
import ReactMarkdown from 'react-markdown'
|
||||||
|
|
||||||
|
import {
|
||||||
|
compressToEncodedURIComponent as encode,
|
||||||
|
decompressFromEncodedURIComponent as decode
|
||||||
|
} from 'lz-string'
|
||||||
|
|
||||||
|
const noop = _ => null
|
||||||
|
const ident = _ => _
|
||||||
|
|
||||||
const previewContorls = content => (
|
const previewContorls = content => (
|
||||||
<header><nav>
|
<header><nav>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
@ -14,12 +22,6 @@ const previewContorls = content => (
|
||||||
</ul>
|
</ul>
|
||||||
</nav></header>)
|
</nav></header>)
|
||||||
|
|
||||||
const noop = _ => null
|
|
||||||
const ident = _ => _
|
|
||||||
|
|
||||||
const decode = x => decodeURIComponent(atob(x))
|
|
||||||
const encode = x => btoa(encodeURIComponent(x))
|
|
||||||
|
|
||||||
const Post = ({mode, payload, setMarkdown}) => {
|
const Post = ({mode, payload, setMarkdown}) => {
|
||||||
const [controls, decodeFn, encodeFn] = {
|
const [controls, decodeFn, encodeFn] = {
|
||||||
preview: [previewContorls, ident, encode],
|
preview: [previewContorls, ident, encode],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue