Add a tangent block

This commit is contained in:
Jake Howard 2022-07-05 09:03:45 +01:00
parent e8c3ec86ae
commit ef9128313d
Signed by: jake
GPG key ID: 57AFB45680EDD477
7 changed files with 3020 additions and 1 deletions

View file

@ -34,3 +34,10 @@ div.block-embed {
@include center-block(50%); @include center-block(50%);
} }
} }
div.block-tangent {
.inner {
margin: math.div($content-block-margin-bottom, 4) 0;
padding-left: 1.5rem;
}
}

View file

@ -5,3 +5,8 @@ $pre-background: unset;
$family-code: "Fira Code", monospace; $family-code: "Fira Code", monospace;
$dropdown-content-radius: 0px; $dropdown-content-radius: 0px;
$dropdown-content-offset: 0px; $dropdown-content-offset: 0px;
$code-background: none;
$pre-background: none;
$code-padding: 0px;
$code: inherit;

View file

@ -1,3 +1,5 @@
@use "sass:math";
@use "variables" as *; @use "variables" as *;
@use "bulma_overrides" as *; @use "bulma_overrides" as *;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -27,9 +27,20 @@ RICH_TEXT_FEATURES = [
"strikethrough", "strikethrough",
] ]
RICH_TEXT_FEATURES_PLAIN = [
"bold",
"italic",
"link",
"document-link",
"code",
"strikethrough",
]
RICH_TEXT_FEATURES_SIMPLE = [ RICH_TEXT_FEATURES_SIMPLE = [
"bold", "bold",
"italic", "italic",
"ol",
"ul",
"link", "link",
"document-link", "document-link",
"code", "code",
@ -54,7 +65,7 @@ class LoremBlock(blocks.StructBlock):
class ImageCaptionBlock(blocks.StructBlock): class ImageCaptionBlock(blocks.StructBlock):
image = ImageChooserBlock() image = ImageChooserBlock()
caption = blocks.RichTextBlock(features=RICH_TEXT_FEATURES_SIMPLE) caption = blocks.RichTextBlock(features=RICH_TEXT_FEATURES_PLAIN)
class Meta: class Meta:
icon = "image" icon = "image"
@ -62,6 +73,16 @@ class ImageCaptionBlock(blocks.StructBlock):
template = "common/blocks/image-caption.html" template = "common/blocks/image-caption.html"
class TangentBlock(blocks.StructBlock):
name = blocks.CharBlock(max_length=64)
content = blocks.RichTextBlock(features=RICH_TEXT_FEATURES_SIMPLE)
class Meta:
icon = "comment"
label = "Tangent"
template = "common/blocks/tangent.html"
IGNORE_PLAINTEXT_BLOCKS = (blocks.RawHTMLBlock, EmbedBlock, ImageCaptionBlock) IGNORE_PLAINTEXT_BLOCKS = (blocks.RawHTMLBlock, EmbedBlock, ImageCaptionBlock)
IGNORE_HEADING_BLOCKS = (*IGNORE_PLAINTEXT_BLOCKS, LoremBlock) IGNORE_HEADING_BLOCKS = (*IGNORE_PLAINTEXT_BLOCKS, LoremBlock)
@ -74,6 +95,7 @@ def get_blocks() -> list[tuple[str, blocks.BaseBlock]]:
("html", blocks.RawHTMLBlock()), ("html", blocks.RawHTMLBlock()),
("image", ImageCaptionBlock()), ("image", ImageCaptionBlock()),
("code", CodeBlock()), ("code", CodeBlock()),
("tangent", TangentBlock()),
] ]

View file

@ -0,0 +1,9 @@
{% load wagtailcore_tags %}
<code>&lt;{{ value.name }}&gt;</code>
<div class="inner">
{{ value.content|richtext }}
</div>
<code>&lt;/{{ value.name }}&gt;</code>