Skip to content

Commit

Permalink
Refactor RichArtickle styles and Overflow extension: add overflow tex…
Browse files Browse the repository at this point in the history
…t styling, replace TextStyle with Bold extension, and adjust layout for improved responsiveness
  • Loading branch information
CarelessCourage committed Dec 18, 2024
1 parent ee66257 commit 0cc5101
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 7 additions & 0 deletions apps/hub/app/components/RichArtickle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,11 @@ const contentEditor = useEditor({
height: 0;
pointer-events: none;
}
// Oveflowing text
.ProseMirror p span.overflow {
color: var(--warning-100);
text-decoration: line-through;
}
</style>
6 changes: 4 additions & 2 deletions apps/hub/app/composables/useTiptap/extensions/Overflow.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import TextStyle from '@tiptap/extension-placeholder'
import Bold from '@tiptap/extension-bold'
import { mergeAttributes } from '@tiptap/core'
import type { Editor } from '@tiptap/core'

export const Overflow = TextStyle.extend({
export const Overflow = Bold.extend({
name: 'overflow',
renderHTML({ HTMLAttributes }) {
return ['span', mergeAttributes(HTMLAttributes, { class: 'overflow' }), 0]
Expand Down Expand Up @@ -39,6 +39,8 @@ export function validateOverflow(editor: Editor, props: { limit: number }) {
const limit = current.start + props.limit
const inner = Math.min(current.end, limit)

console.log('current', schema.marks)

const overflowMark = schema.marks.overflow.create()

removeMark(current.start, inner, overflowMark)
Expand Down
5 changes: 1 addition & 4 deletions apps/hub/app/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,11 @@ onKeyStroke('Escape', () => {
flex-direction: column;
justify-content: center;
place-items: center;
gap: var(--space-4);
width: 80dvw;
max-width: 1900px;
gap: var(--space-4);
min-height: 100vh;
padding-bottom: var(--space-5);
background-color: var(--base-20);
@media (max-width: 800px) {
width: 100dvw;
Expand Down

0 comments on commit 0cc5101

Please sign in to comment.