@flexiui/svelte-rich-text 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import "./styles.css";
3
+ declare const __propDef: {
4
+ props: Record<string, never>;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ };
10
+ export type RichTextProps = typeof __propDef.props;
11
+ export type RichTextEvents = typeof __propDef.events;
12
+ export type RichTextSlots = typeof __propDef.slots;
13
+ export default class RichText extends SvelteComponentTyped<RichTextProps, RichTextEvents, RichTextSlots> {
14
+ }
15
+ export {};
@@ -0,0 +1 @@
1
+ export declare const EnhancedLink: import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any>;
@@ -0,0 +1,33 @@
1
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
2
+ import { Link } from '@tiptap/extension-link';
3
+ export const EnhancedLink = Link.extend({
4
+ addProseMirrorPlugins() {
5
+ return [
6
+ new Plugin({
7
+ key: new PluginKey('linkClickHandler'),
8
+ props: {
9
+ handleClick: (view, _pos, event) => {
10
+ // Special-handling only for Cmd+Click or mouse-wheel clicks, otherwise let TipTap handle it
11
+ const qualifiedClick = event.button === 1 || (event.button === 0 && (event.metaKey || event.ctrlKey));
12
+ if (!view.editable || !qualifiedClick) {
13
+ return false;
14
+ }
15
+ let target = event.target;
16
+ while (target !== null && target.nodeName !== 'A' && target.nodeName !== 'DIV') {
17
+ target = target.parentNode;
18
+ }
19
+ if (target?.nodeName !== 'A') {
20
+ return false;
21
+ }
22
+ const href = target.getAttribute('href');
23
+ if (href === null) {
24
+ return false;
25
+ }
26
+ window.open(href, '_blank', 'noreferrer');
27
+ return true;
28
+ },
29
+ },
30
+ }),
31
+ ];
32
+ },
33
+ });
@@ -0,0 +1,10 @@
1
+ import { Mark } from "@tiptap/core";
2
+ declare module '@tiptap/core' {
3
+ interface Commands<ReturnType> {
4
+ specialBox: {
5
+ specialBox: () => ReturnType;
6
+ isActive: (options: any) => ReturnType;
7
+ };
8
+ }
9
+ }
10
+ export declare const SpecialBox: Mark<any, any>;
@@ -0,0 +1,33 @@
1
+ import { Mark } from "@tiptap/core";
2
+ export const SpecialBox = Mark.create({
3
+ name: "specialBox",
4
+ excludes: 'code highlight',
5
+ parseHTML() {
6
+ return [
7
+ {
8
+ tag: "span[data-special-box]",
9
+ },
10
+ ];
11
+ },
12
+ renderHTML({ HTMLAttributes }) {
13
+ return [
14
+ "span",
15
+ {
16
+ "class": "special-box",
17
+ "data-special-box": "true",
18
+ style: "line-height: 1.5;",
19
+ },
20
+ 0,
21
+ ];
22
+ },
23
+ addCommands() {
24
+ return {
25
+ specialBox: () => ({ commands }) => {
26
+ return commands.toggleMark(this.name);
27
+ },
28
+ isActive: (options) => {
29
+ return options.type === this.name;
30
+ },
31
+ };
32
+ },
33
+ });
@@ -0,0 +1,2 @@
1
+ import RichText from './RichText.svelte';
2
+ export { RichText };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import RichText from './RichText.svelte';
2
+ export { RichText };
@@ -0,0 +1,181 @@
1
+ :root {
2
+ --purple-light: #d2bcff29;
3
+ --purple: #535bf2;
4
+ --black: #000;
5
+ --white: #fff;
6
+ --gray-1: #f0f0f0;
7
+ --gray-2: #e0e0e0;
8
+ --gray-3: #c0c0c0;
9
+ --toolbar-gap: 5px;
10
+ --toolbar-padding: 5px;
11
+ }
12
+
13
+ /* Basic editor styles */
14
+ .tiptap {
15
+ outline: none;
16
+
17
+ :first-child {
18
+ margin-top: 0;
19
+ }
20
+
21
+ /* Heading styles */
22
+ h1,
23
+ h2,
24
+ h3,
25
+ h4,
26
+ h5,
27
+ h6 {
28
+ line-height: 1.1;
29
+ margin-top: 1.5rem;
30
+ text-wrap: pretty;
31
+ }
32
+
33
+ h1,
34
+ h2 {
35
+ margin-top: 1.5rem;
36
+ margin-bottom: 1.5rem;
37
+ }
38
+
39
+ h1 {
40
+ font-size: 1.4rem;
41
+ }
42
+
43
+ h2 {
44
+ font-size: 1.2rem;
45
+ }
46
+
47
+ h3 {
48
+ font-size: 1.1rem;
49
+ }
50
+
51
+ h4,
52
+ h5,
53
+ h6 {
54
+ font-size: 1rem;
55
+ }
56
+
57
+ /* Code and preformatted text styles */
58
+ code {
59
+ background-color: var(--purple-light);
60
+ border-radius: 0.4rem;
61
+ color: var(--white);
62
+ font-size: 0.85rem;
63
+ padding: 0.25em 0.3em;
64
+ }
65
+
66
+ pre {
67
+ background: var(--black);
68
+ border-radius: 0.5rem;
69
+ color: var(--white);
70
+ font-family: 'JetBrainsMono', monospace;
71
+ margin: 1.5rem 0;
72
+ padding: 0.75rem 1rem;
73
+
74
+ code {
75
+ background: none;
76
+ color: inherit;
77
+ font-size: 0.8rem;
78
+ padding: 0;
79
+ }
80
+ }
81
+
82
+ blockquote {
83
+ border-left: 3px solid var(--gray-3);
84
+ margin: 1.5rem 0;
85
+ padding-left: 1rem;
86
+ }
87
+
88
+ hr {
89
+ border: none;
90
+ border-top: 1px solid var(--gray-2);
91
+ margin: 2rem 0;
92
+ }
93
+
94
+ /* List styles */
95
+ ul,
96
+ ol {
97
+ padding: 0 1.25rem;
98
+ margin: 1.25rem 1rem 1.25rem 0.4rem;
99
+
100
+ li p {
101
+ margin-top: 0.25em;
102
+ margin-bottom: 0.25em;
103
+ }
104
+ }
105
+
106
+ ul[data-type=taskList]{
107
+ padding-left: 0;
108
+
109
+ li {
110
+ display: flex;
111
+ flex-direction: row;
112
+ align-items: flex-start;
113
+ }
114
+
115
+ li[data-checked=true] > div > p {
116
+ opacity: .5;
117
+ text-decoration: line-through;
118
+ }
119
+ }
120
+
121
+ ul[data-type="taskList"] li {
122
+ & label {
123
+ position: relative;
124
+ padding-top: 0.275rem;
125
+ padding-right: 0.5rem;
126
+
127
+ input {
128
+ width: 16px;
129
+ height: 16px;
130
+ margin: 0;
131
+ accent-color: #8affd7;
132
+ }
133
+ }
134
+
135
+ & > div {
136
+ flex: auto;
137
+ }
138
+ }
139
+
140
+ .special-box {
141
+ position: relative;
142
+ padding: 0 12px;
143
+ display: inline-flex;
144
+
145
+ &::before {
146
+ content: "";
147
+ position: absolute;
148
+ height: calc(100% + 20px);
149
+ width: 100%;
150
+ border-inline: 1px dashed;
151
+ left: 0;
152
+ top: -10px;
153
+ }
154
+
155
+ &::after {
156
+ content: "";
157
+ position: absolute;
158
+ height: 100%;
159
+ top: 0;
160
+ left: -10px;
161
+ width: calc(100% + 20px);
162
+ border-block: 1px dashed;
163
+ }
164
+
165
+ &::before, &::after {
166
+ border-color: #ffffff33;
167
+ pointer-events: none;
168
+ }
169
+ }
170
+ }
171
+
172
+ .fl-rich-text-content {
173
+ outline: none;
174
+ position: relative;
175
+ display: flex;
176
+ flex-direction: column;
177
+ text-align: left;
178
+ min-height: 56px;
179
+ padding: 2rem;
180
+ background: #242424;
181
+ }
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@flexiui/svelte-rich-text",
3
+ "version": "0.0.1",
4
+ "description": "A lightweight and flexible rich text editor component for Svelte",
5
+ "keywords": [
6
+ "svelte",
7
+ "rich text",
8
+ "editor",
9
+ "wysiwyg",
10
+ "flexiui"
11
+ ],
12
+ "type": "module",
13
+ "scripts": {
14
+ "dev": "vite",
15
+ "build": "vite build && svelte-package",
16
+ "preview": "vite preview"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "!dist/**/*.test.*",
21
+ "!dist/**/*.spec.*"
22
+ ],
23
+ "sideEffects": [
24
+ "**/*.css"
25
+ ],
26
+ "main": "./dist/index.js",
27
+ "svelte": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "svelte": "./dist/index.js",
33
+ "default": "./dist/index.js"
34
+ }
35
+ },
36
+ "author": "alexgipi <alexgp895@gmail.com>",
37
+ "license": "MIT",
38
+ "dependencies": {
39
+ "@flexiui/svelte-dropdown": "^0.4.0",
40
+ "@tiptap/core": "^3.0.9",
41
+ "@tiptap/extension-text-align": "^3.6.6",
42
+ "@tiptap/extension-text-style": "^3.0.9",
43
+ "@tiptap/pm": "^3.0.9",
44
+ "@tiptap/starter-kit": "^3.0.9",
45
+ "@tiptap/static-renderer": "^3.0.9"
46
+ }
47
+ }