Skip to content

Commit

Permalink
Add RichText Code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcibotari committed Nov 30, 2024
1 parent 105131e commit 42885f9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@tiptap/extension-list-item": "^2.7.1",
"@tiptap/extension-bullet-list": "^2.7.1",
"@tiptap/extension-ordered-list": "^2.7.1",
"@tiptap/extension-code": "^2.7.1",
"uuid": "^10.0.0",
"zone.js": "~0.14.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@
</svg>
</button>
<span class="vertical-divider">&nbsp; </span>
<button
class="rounded h-7 w-7 flex justify-center items-center ml-1"
[ngClass]="{ selected: editor.isActive('code') }"
(click)="editor.chain().focus().toggleCode().run()">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-code" viewBox="0 0 16 16">
<path
d="M5.854 4.854a.5.5 0 1 0-.708-.708l-3.5 3.5a.5.5 0 0 0 0 .708l3.5 3.5a.5.5 0 0 0 .708-.708L2.707 8zm4.292 0a.5.5 0 0 1 .708-.708l3.5 3.5a.5.5 0 0 1 0 .708l-3.5 3.5a.5.5 0 0 1-.708-.708L13.293 8z" />
</svg>
</button>
<span class="vertical-divider">&nbsp; </span>
<span class="spacer"></span>
@if (field.translatable) {
<span class="vertical-divider">&nbsp; </span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import History from '@tiptap/extension-history';
import ListItem from '@tiptap/extension-list-item';
import OrderedList from '@tiptap/extension-ordered-list';
import BulletList from '@tiptap/extension-bullet-list';
import Code from '@tiptap/extension-code';

@Component({
selector: 'll-rich-text-editor',
Expand Down Expand Up @@ -47,6 +48,7 @@ export class RichTextEditorComponent implements OnDestroy {
}),
OrderedList,
BulletList,
Code,
],
editorProps: {
attributes: {
Expand Down
8 changes: 8 additions & 0 deletions src/styles/_rich-text-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ ll-rich-text-editor {
margin-top: 0;
}

/* Code and preformatted text styles */
code {
background-color: var(--sys-on-secondary-container);
border-radius: 0.5rem;
color: var(--sys-on-secondary);
font-size: 0.85rem;
padding: 0.3em 0.3em;
}
/* List styles */
ul {
list-style: disc;
Expand Down

0 comments on commit 42885f9

Please sign in to comment.