Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3893821
heading.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
780 B
Referenced Files
None
Subscribers
None
heading.ts
View Options
import
{
predicates
,
ShapeToType
}
from
"@sealcode/ts-predicates"
;
import
{
Primitive
}
from
"./primitive"
;
export
const
HeadingShape
=
{
type
:
predicates
.
const
(
<
const
>
"heading"
),
content
:
predicates
.
string
,
level
:
predicates
.
number
,
id
:
predicates
.
maybe
(
predicates
.
string
),
};
export
type
HeadingJSON
=
ShapeToType
<
typeof
HeadingShape
>
;
export
class
HeadingPrimitive
extends
Primitive
{
content
:
string
;
level
:
number
;
id
:
string
|
null
=
null
;
constructor
(
json
:
Record
<
string
,
unknown
>
)
{
super
();
this
.
content
=
json
[
"content"
]
as
string
;
this
.
level
=
json
[
"level"
]
as
number
;
this
.
id
=
json
[
"id"
]
as
string
|
null
;
}
to_html
()
:
string
{
return
/* HTML */
`<h1>
${
this
.
content
}
</h1>`
;
}
extract_headings
()
:
HeadingPrimitive
[]
{
return
[
this
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Mon, May 19, 00:56 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625629
Default Alt Text
heading.ts (780 B)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment