+
p {
- @apply mb-1.5 first:mt-0 last:mb-0;
+ @apply richtext-mb-1.5 first:richtext-mt-0 last:richtext-mb-0;
}
h1 {
- @apply text-3xl;
+ @apply richtext-text-3xl;
}
h2 {
- @apply text-2xl;
+ @apply richtext-text-2xl;
}
h3 {
- @apply text-xl;
+ @apply richtext-text-xl;
}
h4 {
- @apply text-lg;
+ @apply richtext-text-lg;
}
h5 {
- @apply text-base;
+ @apply richtext-text-base;
}
h6 {
- @apply text-sm;
+ @apply richtext-text-sm;
}
h1,
@@ -38,31 +38,31 @@
h4,
h5,
h6 {
- @apply font-bold first:mt-0 last:mb-0;
+ @apply richtext-font-bold first:richtext-mt-0 last:richtext-mb-0;
}
h1,
h2,
h3 {
- @apply mt-12;
+ @apply richtext-mt-12;
}
h4,
h5,
h6 {
- @apply mt-8;
+ @apply richtext-mt-8;
}
a.link {
- @apply text-blue-500 font-extrabold dark:text-blue-400;
+ @apply richtext-text-blue-500 richtext-font-extrabold dark:richtext-text-blue-400;
}
mark {
- @apply bg-red-500 rounded-sm decoration-clone text-inherit py-1 px-0 dark:bg-red-400;
+ @apply richtext-bg-red-500 richtext-rounded-sm richtext-decoration-clone richtext-text-inherit richtext-py-1 richtext-px-0 dark:richtext-bg-red-400;
}
& img {
- @apply h-auto max-w-full;
+ @apply richtext-h-auto richtext-max-w-full;
}
@for $i from 1 through 7 /* max-indent */ {
@@ -73,25 +73,25 @@
}
}
iframe {
- @apply w-full border border-border mt-2 rounded-sm h-[400px];
+ @apply richtext-w-full richtext-border richtext-border-border richtext-mt-2 richtext-rounded-sm richtext-h-[400px];
}
[data-type='horizontalRule'] {
- @apply my-8 py-4;
+ @apply richtext-my-8 richtext-py-4;
hr {
- @apply border-0 border-t border-black/20 bg-black/80;
- @apply dark:border-white/20 dark:bg-white/80;
+ @apply richtext-border-0 richtext-border-t richtext-border-black/20 richtext-bg-black/80;
+ @apply dark:richtext-border-white/20 dark:richtext-bg-white/80;
}
}
/* Block Quote */
.blockquote {
- @apply border-l-4 text-black border-l-neutral-700 py-2 px-4 bg-opacity-80 rounded-lg rounded-tl-none rounded-bl-none;
- @apply dark:border-l-neutral-300 dark:text-white;
+ @apply richtext-border-l-4 richtext-text-black richtext-border-l-neutral-700 richtext-py-2 richtext-px-4 richtext-bg-opacity-80 richtext-rounded-lg richtext-rounded-tl-none richtext-rounded-bl-none;
+ @apply dark:richtext-border-l-neutral-300 dark:richtext-text-white;
}
/* Columns */
[data-type='columns'] {
- @apply grid gap-4 mt-14 mb-12;
+ @apply richtext-grid richtext-gap-4 richtext-mt-14 richtext-mb-12;
&.layout-sidebar-left {
grid-template-columns: 40fr 60fr;
@@ -111,156 +111,104 @@
}
[data-type='column'] {
- @apply overflow-auto;
+ @apply richtext-overflow-auto;
}
code {
- @apply caret-white text-white bg-neutral-900 rounded-sm shadow-lg font-mono;
+ @apply richtext-caret-white richtext-text-white richtext-bg-neutral-900 richtext-rounded-sm richtext-shadow-lg richtext-font-mono;
&::selection {
- @apply bg-white/30;
+ @apply richtext-bg-white/30;
}
}
pre {
- @apply caret-white bg-neutral-700 text-white rounded my-12 p-4 border border-black dark:bg-neutral-900 dark:border-neutral-800;
+ @apply richtext-caret-white richtext-bg-neutral-700 richtext-text-white richtext-rounded richtext-my-12 richtext-p-4 richtext-border richtext-border-black dark:richtext-bg-neutral-900 dark:richtext-border-neutral-800;
*::selection {
- @apply bg-white/20;
+ @apply richtext-bg-white/20;
}
code {
- @apply bg-inherit text-inherit p-0 shadow-none;
- }
-
- .hljs-comment,
- .hljs-quote {
- @apply text-neutral-400;
- }
-
- .hljs-variable,
- .hljs-template-variable,
- .hljs-attribute,
- .hljs-tag,
- .hljs-name,
- .hljs-regexp,
- .hljs-link,
- .hljs-name,
- .hljs-selector-id,
- .hljs-selector-class {
- @apply text-red-300;
- }
-
- .hljs-number,
- .hljs-meta,
- .hljs-built_in,
- .hljs-builtin-name,
- .hljs-literal,
- .hljs-type,
- .hljs-params {
- @apply text-orange-300;
- }
-
- .hljs-string,
- .hljs-symbol,
- .hljs-bullet {
- @apply text-lime-300;
- }
-
- .hljs-title,
- .hljs-section {
- @apply text-yellow-300;
- }
-
- .hljs-keyword,
- .hljs-selector-tag {
- @apply text-teal-300;
- }
-
- .hljs-emphasis {
- font-style: italic;
- }
-
- .hljs-strong {
- font-weight: 700;
+ @apply richtext-bg-inherit richtext-text-inherit richtext-p-0 richtext-shadow-none;
}
}
/* List */
ol {
- @apply list-decimal;
+ @apply richtext-list-decimal;
}
ul {
- @apply list-disc;
+ @apply richtext-list-disc;
}
ul,
ol {
- @apply py-0 px-8 my-6 first:mt-0 last:mb-0;
+ @apply richtext-py-0 richtext-px-8 richtext-my-6 first:richtext-mt-0 last:richtext-mb-0;
ul,
ol,
li {
- @apply my-1;
+ @apply richtext-my-1;
}
p {
- @apply mt-0 mb-1;
+ @apply richtext-mt-0 richtext-mb-1;
}
}
& > ul,
& > ol {
- @apply my-8 first:mt-0 last:mb-0;
+ @apply richtext-my-8 first:richtext-mt-0 last:richtext-mb-0;
}
ul[data-type='taskList'] {
- @apply list-none p-0;
+ @apply richtext-list-none richtext-p-0;
p {
- @apply m-0;
+ @apply richtext-m-0;
}
li {
- @apply flex;
+ @apply richtext-flex;
> label {
- @apply grow-0 shrink-0 flex-auto inline-flex mr-2 select-none;
+ @apply richtext-grow-0 richtext-shrink-0 richtext-flex-auto richtext-inline-flex richtext-mr-2 richtext-select-none;
}
> div {
- @apply flex-auto;
+ @apply richtext-flex-auto;
}
&[data-checked='true'] {
- @apply line-through;
+ @apply richtext-line-through;
}
}
}
table {
- @apply border-collapse border-black/10 table-fixed box-border overflow-x-auto overflow-y-hidden block;
- @apply dark:border-white/20;
+ @apply richtext-border-collapse richtext-border-black/10 richtext-table-fixed richtext-box-border richtext-overflow-x-auto richtext-overflow-y-hidden richtext-block;
+ @apply dark:richtext-border-white/20;
td,
th {
- @apply border border-black/10 min-w-[1em] p-2 box-border relative text-left align-top;
- @apply dark:border-white/20;
+ @apply richtext-border richtext-border-black/10 richtext-min-w-[1em] richtext-p-2 richtext-box-border richtext-relative richtext-text-left richtext-align-top;
+ @apply dark:richtext-border-white/20;
&:first-of-type:not(a) {
- @apply mt-0;
+ @apply richtext-mt-0;
}
p {
- @apply m-0;
+ @apply richtext-m-0;
& + p {
- @apply mt-3;
+ @apply richtext-mt-3;
}
}
}
th {
- @apply font-bold text-left;
+ @apply richtext-font-bold richtext-text-left;
}
}
}
diff --git a/src/styles/editor.scss b/src/styles/editor.scss
index 689c7a0..7435edb 100644
--- a/src/styles/editor.scss
+++ b/src/styles/editor.scss
@@ -1,15 +1,13 @@
.reactjs-tiptap-editor {
.ProseMirror {
- @apply caret-black dark:caret-white outline-0 pr-8 pl-20 py-16 z-0 lg:pl-8 lg:pr-8;
+ @apply richtext-caret-black dark:richtext-caret-white richtext-outline-0 richtext-pr-8 richtext-pl-20 richtext-py-16 richtext-z-0 lg:richtext-pl-8 lg:richtext-pr-8;
min-height: 180px;
padding: 32px 80px;
- // & > * {
- // @apply mx-auto max-w-2xl;
- // }
+
.img-placeholder {
width: fit-content;
position: relative;
- @apply backdrop-blur-sm bg-white/30;
+ @apply richtext-backdrop-blur-sm richtext-bg-white/30;
&:before {
content: '';
@@ -20,44 +18,44 @@
width: 24px;
height: 24px;
margin: -12px 0 0 -12px;
- @apply animate-spin border-current border-t-transparent rounded-full border-[3px] inline-block;
+ @apply richtext-animate-spin richtext-border-current richtext-border-t-transparent richtext-rounded-full richtext-border-[3px] richtext-inline-block;
}
}
.tableWrapper {
margin: 1em 0;
- @apply overflow-x-auto;
+ @apply richtext-overflow-x-auto;
table {
overflow: hidden;
display: table;
.column-resize-handle {
- @apply -bottom-[2px] absolute -right-1 top-0 w-1 z-10 pointer-events-none bg-primary;
+ @apply richtext-bottom-[-2px] richtext-absolute richtext-right-[-2px] richtext-top-0 richtext-w-1 richtext-z-10 richtext-pointer-events-none richtext-bg-primary;
}
.resize-cursor {
cursor: 'col-resize';
}
.selectedCell {
- @apply bg-black/5 border-black/20 border-double;
- @apply dark:bg-white/10 dark:border-white/20;
+ @apply richtext-bg-black/5 richtext-border-black/20 richtext-border-double;
+ @apply dark:richtext-bg-white/10 dark:richtext-border-white/20;
}
}
}
/* Column */
& > *:first-child,
[data-type='column'] > * {
- @apply first:mt-0 last:mb-0;
+ @apply first:richtext-mt-0 last:richtext-mb-0;
}
[data-type='columns'] {
&.focus [data-type='column'],
&:hover [data-type='column'] {
- @apply bg-accent;
+ @apply richtext-bg-accent;
}
[data-type='column'].focus {
- @apply bg-accent;
+ @apply richtext-bg-accent;
}
}
[data-type='columns']::before,
@@ -66,41 +64,41 @@
}
[data-type='column'] {
- @apply rounded border border-solid border-transparent p-1;
+ @apply richtext-rounded richtext-border richtext-border-solid richtext-border-transparent richtext-p-1;
transition: border 160ms cubic-bezier(0.45, 0.05, 0.55, 0.95);
&:hover {
- @apply border-gray-50 dark:border-gray-900;
+ @apply richtext-border-gray-50 dark:richtext-border-gray-900;
}
&:has(.is-active),
&.focus {
- @apply border-neutral-100 dark:border-neutral-900;
+ @apply richtext-border-neutral-100 dark:richtext-border-neutral-900;
}
}
[data-type='horizontalRule'] {
- @apply transition-all duration-100 ease-in-out cursor-pointer;
+ @apply richtext-transition-all richtext-duration-100 richtext-ease-in-out richtext-cursor-pointer;
&.ProseMirror-selectednode {
- @apply bg-black/5 dark:bg-white/10;
+ @apply richtext-bg-black/5 dark:richtext-bg-white/10;
hr {
- @apply border-t-black/30 dark:border-t-white/30;
+ @apply richtext-border-t-black/30 dark:richtext-border-t-white/30;
}
}
&:hover:not(&.ProseMirror-selectednode) {
- @apply bg-black/5;
- @apply dark:bg-white/10;
+ @apply richtext-bg-black/5;
+ @apply dark:richtext-bg-white/10;
}
}
:not(.dragging) .ProseMirror-selectednode:not(.image-view) {
- @apply outline-none bg-black/10 dark:bg-white/20 shadow-none transition-colors;
+ @apply richtext-outline-none richtext-bg-black/10 dark:richtext-bg-white/20 richtext-shadow-none richtext-transition-colors;
}
.selection:not(.image-view),
*:not(.image-view)::selection {
- @apply bg-black/10 dark:bg-white/20;
+ @apply richtext-bg-black/10 dark:richtext-bg-white/20;
}
.is-empty::before {
@@ -128,17 +126,17 @@
content: attr(data-placeholder);
}
.ProseMirror-gapcursor {
- @apply relative w-full max-w-2xl mx-auto;
+ @apply richtext-relative richtext-w-full richtext-max-w-2xl richtext-mx-auto;
&:after {
- @apply border-t-black/40 dark:border-t-white/40 w-full -top-[1.5em] max-w-2xl mx-auto left-0 right-0;
+ @apply richtext-border-t-black/40 dark:richtext-border-t-white/40 richtext-w-full richtext-top-[-1.5em] richtext-max-w-2xl richtext-mx-auto richtext-left-0 richtext-right-0;
}
}
.iframe-wrapper {
&.focus {
> div {
- @apply outline-primary outline-4 outline;
+ @apply richtext-outline-primary richtext-outline-4 richtext-outline;
}
}
}
@@ -202,11 +200,13 @@
&.focus {
img {
- @apply outline-primary outline-2 outline;
+ @apply richtext-outline-primary richtext-outline-2 richtext-outline;
}
}
}
+
+
.image-resizer {
position: absolute;
top: 0;
@@ -214,7 +214,7 @@
z-index: 1;
width: 100%;
height: 100%;
- @apply border border-border;
+ @apply richtext-border richtext-border-border;
border-style: dashed;
&__handler {
@@ -226,7 +226,7 @@
height: 12px;
border: 1px solid #fff;
border-radius: 2px;
- @apply bg-blue-500;
+ @apply richtext-bg-blue-500;
&--tl {
top: -6px;
@@ -272,110 +272,11 @@
}
}
-.ai-modal-main-container {
- width: 100%;
- min-height: 24px;
- border-radius: 4px;
- border: 1px solid transparent;
- box-sizing: border-box;
- overflow: hidden;
- background: linear-gradient(0deg, #fff, #fff) content-box,
- linear-gradient(81.99deg, #e215ed 0%, #0e80b9 73.05%, #d192ff 100%) border-box;
- box-shadow: 0 5px 12px 4px rgba(0, 0, 0, 0.08);
-}
-
-.ai_modal_input_area {
- flex-grow: 1;
- line-height: 20px;
- font-size: 14px;
- white-space: pre-wrap;
- word-break: break-word;
- padding: 2px 8px;
- caret-color: #1e6fff;
- max-height: 200px;
- box-sizing: border-box;
- overflow-y: auto;
- outline: none;
-}
-.ai_modal_input_area:empty:before {
- content: attr(placeholder);
- color: rgba(0, 0, 0, 0.24);
- pointer-events: none;
-}
[data-dui-1-3-5~='dui-tooltip-wrapper'] {
display: inline-block;
position: relative;
}
-.ai_modal_input_submit_button_active {
- cursor: pointer;
- background-image: url('data:image/svg+xml,%3Csvg width%3D%2224%22 height%3D%2224%22 viewBox%3D%220 0 24 24%22 fill%3D%22none%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Ccircle cx%3D%2212%22 cy%3D%2212%22 r%3D%229%22 fill%3D%22url(%23paint0_linear_5_2540)%22%2F%3E%3Cpath d%3D%22M11.8535 8.11091L16.0962 12.3536L11.8535 16.5962%22 stroke%3D%22white%22 stroke-width%3D%221.25%22%2F%3E%3Cline x1%3D%2215.3891%22 y1%3D%2212.2714%22 x2%3D%226.90382%22 y2%3D%2212.2714%22 stroke%3D%22white%22 stroke-width%3D%221.25%22%2F%3E%3Cdefs%3E%3ClinearGradient id%3D%22paint0_linear_5_2540%22 x1%3D%2221%22 y1%3D%223%22 x2%3D%223%22 y2%3D%2221%22 gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop stop-color%3D%22%23DB94FF%22%2F%3E%3Cstop offset%3D%220.456607%22 stop-color%3D%22%235179FF%22%2F%3E%3Cstop offset%3D%221%22 stop-color%3D%22%235AB0FF%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E');
-}
-.ai_modal_input_submit_button_active:hover {
- background-image: url('data:image/svg+xml,%3Csvg width%3D%2224%22 height%3D%2224%22 viewBox%3D%220 0 24 24%22 fill%3D%22none%22 xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Ccircle cx%3D%2212%22 cy%3D%2212%22 r%3D%229%22 fill%3D%22url(%23paint0_linear_1387_127239)%22%2F%3E%3Cpath d%3D%22M11.8536 8.11091L16.0962 12.3536L11.8536 16.5962%22 stroke%3D%22white%22 stroke-width%3D%221.25%22%2F%3E%3Cline x1%3D%2215.3891%22 y1%3D%2212.2714%22 x2%3D%226.90382%22 y2%3D%2212.2714%22 stroke%3D%22white%22 stroke-width%3D%221.25%22%2F%3E%3Cdefs%3E%3ClinearGradient id%3D%22paint0_linear_1387_127239%22 x1%3D%2221%22 y1%3D%223%22 x2%3D%223%22 y2%3D%2221%22 gradientUnits%3D%22userSpaceOnUse%22%3E%3Cstop stop-color%3D%22%23C182E0%22%2F%3E%3Cstop offset%3D%220.456607%22 stop-color%3D%22%23476BE0%22%2F%3E%3Cstop offset%3D%221%22 stop-color%3D%22%234F9BE0%22%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3C%2Fsvg%3E');
-}
-.ai_modal_input_submit_button {
- width: 24px;
- height: 24px;
- background-repeat: no-repeat;
-}
-
-.ai_modal_popup_menu {
- position: absolute;
- top: 100%;
- margin-top: 8px;
- border-radius: 4px;
- width: 232px;
- background: var(--bg-lv4-default);
- box-shadow: 0px 0px 0px 1px rgba(0, 0, 0, 0.04), 0px 4px 6px 2px rgba(0, 0, 0, 0.04),
- 0px 6px 32px 2px rgba(0, 0, 0, 0.16);
-}
-
-.ai_modal_writing_tips_button_wrapper {
- display: flex;
- flex-direction: row;
-}
-
-.ai_modal_message_board {
- position: relative;
- overflow-y: auto;
- max-height: 300px;
- font-size: 14px;
- font-variant-numeric: tabular-nums;
- -webkit-font-smoothing: antialiased;
- text-size-adjust: none;
- text-rendering: auto;
-}
-.ai_modal_edit_board_footer {
- padding: 16px 0 8px 0;
-}
-.ai_model_edit_board_buttons {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- height: 30px;
- width: 100%;
-}
-.ai_model_edit_board_left_buttons {
- display: flex;
- flex-direction: row;
-}
-.ai_model_edit_board_right_button {
- display: flex;
- flex-direction: column;
- justify-content: center;
-}
-.ai_modal_edit_board_header {
- display: flex;
- justify-content: space-between;
- flex-direction: row;
- padding: 4px 0;
- font-size: 12px;
- line-height: 24px;
- height: 24px;
- color: #999;
- box-sizing: content-box;
-}
.heading-0 {
font-weight: 700;
@@ -412,11 +313,12 @@
line-height: 1.6;
}
-.bg-foreground {
+.tableCellActive {
border-radius: 2px !important;
transition: all 100ms ease-in-out;
}
-.bg-foreground > div {
+.tableCellActive > div {
border: unset !important;
}
+
diff --git a/src/styles/global.scss b/src/styles/global.scss
index 5156255..65cf3ef 100644
--- a/src/styles/global.scss
+++ b/src/styles/global.scss
@@ -70,10 +70,10 @@
@layer base {
* {
- @apply border-border;
+ @apply richtext-border-border;
}
body {
- @apply bg-background text-foreground;
+ @apply richtext-bg-background richtext-text-foreground;
}
}
diff --git a/tailwind.config.js b/tailwind.config.js
index 942d934..ba3597a 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -1,10 +1,10 @@
-import animate from 'tailwindcss-animate';
+import animate from 'tailwindcss-animate'
/** @type {import('tailwindcss').Config} */
export default {
- darkMode: ['class'],
+ darkMode: ['class', '[class~=\'dark\']'],
safelist: ['dark'],
- prefix: '',
+ prefix: 'richtext-',
content: [
'./pages/**/*.{ts,tsx}',
@@ -90,4 +90,4 @@ export default {
},
},
plugins: [animate],
-};
+}
diff --git a/vite.config.ts b/vite.config.ts
index da08cd9..fa17e75 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -6,6 +6,7 @@ import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import tailwind from 'tailwindcss'
import autoprefixer from 'autoprefixer'
+import postcssReplace from 'postcss-replace'
// https://vitejs.dev/config/
export default defineConfig(() => {
@@ -29,7 +30,13 @@ export default defineConfig(() => {
},
css: {
postcss: {
- plugins: [tailwind(), autoprefixer()],
+ plugins: [tailwind(), autoprefixer(), postcssReplace({
+ pattern: /(--tw|\*, ::before, ::after)/g,
+ data: {
+ '--tw': '--richtext', // Prefixing
+ '*, ::before, ::after': ':root', // So variables does not pollute every element
+ },
+ })],
},
preprocessorOptions: {
scss: {