Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ECorpus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pirvi-public
ECorpus
Commits
2a3311b8
Commit
2a3311b8
authored
1 year ago
by
Sebastien DUMETZ
Browse files
Options
Downloads
Patches
Plain Diff
remove deprecated DocView component
parent
90a3abac
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/ui/composants/DocView.ts
+0
-103
0 additions, 103 deletions
source/ui/composants/DocView.ts
with
0 additions
and
103 deletions
source/ui/composants/DocView.ts
deleted
100644 → 0
+
0
−
103
View file @
90a3abac
import
{
customElement
,
property
,
html
,
TemplateResult
,
LitElement
,
css
}
from
"
lit-element
"
;
import
{
unsafeHTML
}
from
'
lit-html/directives/unsafe-html.js
'
;
import
"
./Spinner
"
;
import
i18n
from
"
../state/translate
"
;
import
{
Language
}
from
"
../state/strings
"
;
import
styles
from
'
!lit-css-loader?{"specifier":"lit-element"}!sass-loader!../styles/common.scss
'
;
/**
* Main UI view for the Voyager Explorer application.
*/
@
customElement
(
"
doc-view
"
)
export
default
class
DocView
extends
i18n
(
LitElement
)
{
static
_converter
:
Promise
<
showdown
.
Converter
>
;
async
getConverter
(){
return
await
(
DocView
.
_converter
??=
import
(
"
showdown
"
).
then
(({
default
:
showdown
})
=>
{
return
new
showdown
.
Converter
({
// see https://github.com/showdownjs/showdown/blob/master/README.md#valid-options
simplifiedAutoLink
:
true
,
});
}));
}
#c
=
new
AbortController
();
@
property
({
attribute
:
false
,
type
:
Object
})
error
:
Error
;
@
property
({
attribute
:
false
})
content
:
string
;
@
property
({
type
:
String
})
path
:
string
=
"
/
"
;
constructor
()
{
super
();
}
public
connectedCallback
():
void
{
super
.
connectedCallback
();
}
public
disconnectedCallback
():
void
{
this
.
#c
.
abort
();
}
protected
update
(
changedProperties
:
Map
<
string
|
number
|
symbol
,
unknown
>
):
void
{
console
.
log
(
"
Update :
"
,
changedProperties
);
if
((
!
this
.
content
||
changedProperties
.
has
(
"
language
"
)
||
changedProperties
.
has
(
"
doc
"
))
&&
this
.
language
){
Promise
.
all
([
this
.
getConverter
(),
this
.
getDocument
(),
]).
then
(([
converter
,
doc
])
=>
{
this
.
content
=
converter
.
makeHtml
(
doc
);
}).
catch
((
e
)
=>
{
this
.
error
=
e
});
}
super
.
update
(
changedProperties
);
}
private
async
getDocument
(
lang
:
Language
=
this
.
language
){
this
.
#c
.
abort
();
this
.
#c
=
new
AbortController
();
let
file
=
(
this
.
path
.
indexOf
(
"
/
"
)
==
0
)?
this
.
path
.
slice
(
1
):
this
.
path
;
this
.
content
=
"
loading...
"
;
let
r
=
await
fetch
(
`/doc/
${
lang
}
/
${
file
}
`
,
{
headers
:
{
'
Accept
'
:
"
text/plain
"
,
},
signal
:
this
.
#c
.
signal
,
});
if
(
r
.
ok
)
return
await
r
.
text
();
else
if
(
r
.
status
==
404
&&
lang
!=
"
en
"
){
try
{
return
await
this
.
getDocument
(
"
en
"
);
}
catch
(
e
){
console
.
warn
(
"
Failed to fetch fallback document :
"
,
e
);
}
}
throw
new
Error
(
`
${
await
r
.
text
()}
`
);
}
protected
render
()
:
TemplateResult
{
if
(
this
.
error
){
return
html
`<h1>Error</h1><div>
${
this
.
error
.
message
}
</div>`
;
}
else
if
(
!
this
.
content
||
this
.
content
==
"
loading...
"
){
return
html
`<div style="margin-top:10vh">Loading...<spin-loader visible></spin-loader></div>`
}
return
html
`
${
unsafeHTML
(
this
.
content
)}
`
;
}
static
styles
=
[
styles
,
css
`
:host{
color: white;
}
`
]
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment