@pixerate/editor 0.1.0
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.
- package/LICENSE +21 -0
- package/dist/extensions/index.cjs +616 -0
- package/dist/extensions/index.cjs.map +1 -0
- package/dist/extensions/index.d.cts +84 -0
- package/dist/extensions/index.d.ts +84 -0
- package/dist/extensions/index.js +571 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/grammar/index.cjs +401 -0
- package/dist/grammar/index.cjs.map +1 -0
- package/dist/grammar/index.d.cts +65 -0
- package/dist/grammar/index.d.ts +65 -0
- package/dist/grammar/index.js +359 -0
- package/dist/grammar/index.js.map +1 -0
- package/dist/index.cjs +1149 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +1082 -0
- package/dist/index.js.map +1 -0
- package/dist/serializers/index.cjs +83 -0
- package/dist/serializers/index.cjs.map +1 -0
- package/dist/serializers/index.d.cts +20 -0
- package/dist/serializers/index.d.ts +20 -0
- package/dist/serializers/index.js +53 -0
- package/dist/serializers/index.js.map +1 -0
- package/dist/tokens-CE6SS_hd.d.cts +37 -0
- package/dist/tokens-CE6SS_hd.d.ts +37 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jack James
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,616 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/extensions/index.ts
|
|
31
|
+
var extensions_exports = {};
|
|
32
|
+
__export(extensions_exports, {
|
|
33
|
+
ColorHighlighter: () => ColorHighlighter,
|
|
34
|
+
FontSize: () => FontSize,
|
|
35
|
+
GradientText: () => GradientText,
|
|
36
|
+
LoadingNode: () => LoadingNode,
|
|
37
|
+
SlashCommands: () => SlashCommands,
|
|
38
|
+
SmilieReplacer: () => SmilieReplacer,
|
|
39
|
+
TemplateSuggestions: () => TemplateSuggestions,
|
|
40
|
+
createRichTextPreset: () => createRichTextPreset,
|
|
41
|
+
findHexColors: () => findHexColors
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(extensions_exports);
|
|
44
|
+
|
|
45
|
+
// src/extensions/gradient-text.ts
|
|
46
|
+
var import_core = require("@tiptap/core");
|
|
47
|
+
var import_state = require("@tiptap/pm/state");
|
|
48
|
+
var import_view = require("@tiptap/pm/view");
|
|
49
|
+
|
|
50
|
+
// src/grammar/tokens.ts
|
|
51
|
+
var TEMPLATE_REGEX = /{{\s*([^}]+?)\s*}}/g;
|
|
52
|
+
var VARIABLE_REGEX = /(?<!\{)\{([^{}]+)\}(?!\})/g;
|
|
53
|
+
var INSTRUCTION_REGEX = /__(.+?)__/g;
|
|
54
|
+
|
|
55
|
+
// src/extensions/gradient-text.ts
|
|
56
|
+
var createGradientDecorations = (doc, options) => {
|
|
57
|
+
const decorations = [];
|
|
58
|
+
const speed = options.speed ?? 1;
|
|
59
|
+
const jsonVarSet = options.jsonVariables ? options.jsonVariables instanceof Set ? options.jsonVariables : new Set(options.jsonVariables) : null;
|
|
60
|
+
doc.descendants((node, pos) => {
|
|
61
|
+
if (node.isText) {
|
|
62
|
+
const text = node.text || "";
|
|
63
|
+
let match;
|
|
64
|
+
const tmplRegex = new RegExp(TEMPLATE_REGEX.source, TEMPLATE_REGEX.flags);
|
|
65
|
+
while ((match = tmplRegex.exec(text)) !== null) {
|
|
66
|
+
const templateName = match[1].trim();
|
|
67
|
+
const colors = options.templateColorMap?.get(templateName);
|
|
68
|
+
if (colors) {
|
|
69
|
+
const start = pos + match.index;
|
|
70
|
+
const end = start + match[0].length;
|
|
71
|
+
const { from: colorFrom, to: colorTo } = colors;
|
|
72
|
+
const style = `--bg-size: ${speed * 300}%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important;`;
|
|
73
|
+
decorations.push(
|
|
74
|
+
import_view.Decoration.inline(start, end, {
|
|
75
|
+
class: "inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent border border-(--color-to)/20 px-1 py-0.5 rounded-sm cursor-pointer",
|
|
76
|
+
style,
|
|
77
|
+
"data-template": templateName
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const instRegex = new RegExp(
|
|
83
|
+
INSTRUCTION_REGEX.source,
|
|
84
|
+
INSTRUCTION_REGEX.flags
|
|
85
|
+
);
|
|
86
|
+
while ((match = instRegex.exec(text)) !== null) {
|
|
87
|
+
const content = match[1].trim();
|
|
88
|
+
const colors = options.templateColorMap?.get(content) || {
|
|
89
|
+
from: "#ffaa40",
|
|
90
|
+
to: "#9c40ff"
|
|
91
|
+
};
|
|
92
|
+
const start = pos + match.index;
|
|
93
|
+
const end = start + match[0].length;
|
|
94
|
+
const { from: colorFrom, to: colorTo } = colors;
|
|
95
|
+
const style = `--bg-size: ${speed * 300}%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important;`;
|
|
96
|
+
decorations.push(
|
|
97
|
+
import_view.Decoration.inline(start, end, {
|
|
98
|
+
class: "italic animate-gradient bg-gradient-to-r from-rose-400 from-50% to-violet-500 to-50% bg-size-[200%_100%] bg-clip-text text-transparent inline-flex items-baseline gap-0.5",
|
|
99
|
+
style
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const varRegex = new RegExp(
|
|
104
|
+
VARIABLE_REGEX.source,
|
|
105
|
+
VARIABLE_REGEX.flags
|
|
106
|
+
);
|
|
107
|
+
while ((match = varRegex.exec(text)) !== null) {
|
|
108
|
+
const variableName = match[1].trim();
|
|
109
|
+
const start = pos + match.index;
|
|
110
|
+
const end = start + match[0].length;
|
|
111
|
+
const isJsonVar = jsonVarSet?.has(variableName);
|
|
112
|
+
decorations.push(
|
|
113
|
+
import_view.Decoration.inline(start, end, {
|
|
114
|
+
class: isJsonVar ? "bg-violet-400/40 border-b-4 border-rose-300 dark:border-rose-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs" : "bg-rose-400/40 border-b-4 border-violet-300 dark:border-violet-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs",
|
|
115
|
+
"data-variable": variableName
|
|
116
|
+
})
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return decorations;
|
|
122
|
+
};
|
|
123
|
+
var GradientText = import_core.Mark.create({
|
|
124
|
+
name: "gradientText",
|
|
125
|
+
addOptions() {
|
|
126
|
+
return {
|
|
127
|
+
templateColorMap: /* @__PURE__ */ new Map(),
|
|
128
|
+
speed: 1,
|
|
129
|
+
jsonVariables: void 0,
|
|
130
|
+
onTemplateClick: void 0
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
renderHTML({ HTMLAttributes }) {
|
|
134
|
+
const defaultColors = {
|
|
135
|
+
from: "#ffaa40",
|
|
136
|
+
to: "#9c40ff"
|
|
137
|
+
};
|
|
138
|
+
const speed = this.options.speed ?? 1;
|
|
139
|
+
const style = `--bg-size: ${speed * 300}%; --color-from: ${defaultColors.from}; --color-to: ${defaultColors.to}; caret-color: #111 !important;`;
|
|
140
|
+
return [
|
|
141
|
+
"span",
|
|
142
|
+
{
|
|
143
|
+
class: "inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent",
|
|
144
|
+
style,
|
|
145
|
+
...HTMLAttributes
|
|
146
|
+
},
|
|
147
|
+
0
|
|
148
|
+
];
|
|
149
|
+
},
|
|
150
|
+
parseHTML() {
|
|
151
|
+
return [
|
|
152
|
+
{
|
|
153
|
+
tag: "span",
|
|
154
|
+
getAttrs: (node) => node.classList.contains("animate-gradient") && node.classList.contains("bg-clip-text") && null
|
|
155
|
+
}
|
|
156
|
+
];
|
|
157
|
+
},
|
|
158
|
+
addProseMirrorPlugins() {
|
|
159
|
+
const markOptions = this.options;
|
|
160
|
+
return [
|
|
161
|
+
new import_state.Plugin({
|
|
162
|
+
state: {
|
|
163
|
+
init(_, { doc }) {
|
|
164
|
+
return import_view.DecorationSet.create(
|
|
165
|
+
doc,
|
|
166
|
+
createGradientDecorations(doc, markOptions)
|
|
167
|
+
);
|
|
168
|
+
},
|
|
169
|
+
apply(tr, value) {
|
|
170
|
+
const newDoc = tr.doc;
|
|
171
|
+
if (tr.docChanged) {
|
|
172
|
+
return import_view.DecorationSet.create(
|
|
173
|
+
newDoc,
|
|
174
|
+
createGradientDecorations(newDoc, markOptions)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
return value.map(tr.mapping, newDoc);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
props: {
|
|
181
|
+
decorations(state) {
|
|
182
|
+
return this.getState(state);
|
|
183
|
+
},
|
|
184
|
+
handleClickOn(view, pos, _node, _nodePos, event) {
|
|
185
|
+
const decorationSet = this.getState(
|
|
186
|
+
view.state
|
|
187
|
+
);
|
|
188
|
+
const decorations = decorationSet.find(pos, pos + 1);
|
|
189
|
+
for (const decoration of decorations) {
|
|
190
|
+
const decorationWithAttrs = decoration;
|
|
191
|
+
const templateName = decorationWithAttrs.type?.attrs?.["data-template"];
|
|
192
|
+
if (templateName) {
|
|
193
|
+
if (markOptions.onTemplateClick) {
|
|
194
|
+
markOptions.onTemplateClick(templateName, event);
|
|
195
|
+
}
|
|
196
|
+
if (typeof window !== "undefined") {
|
|
197
|
+
window.dispatchEvent(
|
|
198
|
+
new CustomEvent("show-gradient-popover", {
|
|
199
|
+
detail: {
|
|
200
|
+
templateName,
|
|
201
|
+
target: event.target
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// src/extensions/slash-commands.ts
|
|
218
|
+
var import_core2 = require("@tiptap/core");
|
|
219
|
+
var import_state2 = require("@tiptap/pm/state");
|
|
220
|
+
var SlashCommands = import_core2.Extension.create({
|
|
221
|
+
name: "slashCommands",
|
|
222
|
+
addOptions() {
|
|
223
|
+
return {
|
|
224
|
+
trigger: "/",
|
|
225
|
+
onMatch: void 0,
|
|
226
|
+
onClear: void 0,
|
|
227
|
+
containerId: void 0
|
|
228
|
+
};
|
|
229
|
+
},
|
|
230
|
+
addProseMirrorPlugins() {
|
|
231
|
+
const opts = this.options;
|
|
232
|
+
return [
|
|
233
|
+
new import_state2.Plugin({
|
|
234
|
+
view() {
|
|
235
|
+
return {
|
|
236
|
+
update(view) {
|
|
237
|
+
const { state } = view;
|
|
238
|
+
const { selection } = state;
|
|
239
|
+
const { $from } = selection;
|
|
240
|
+
if (!$from.parent.isTextblock) {
|
|
241
|
+
opts.onClear?.();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const textBeforeCursor = $from.parent.textBetween(
|
|
245
|
+
0,
|
|
246
|
+
$from.parentOffset
|
|
247
|
+
);
|
|
248
|
+
const slashMatch = textBeforeCursor.match(
|
|
249
|
+
/(?:^|\s)\/([a-zA-Z0-9_-]*)$/
|
|
250
|
+
);
|
|
251
|
+
if (slashMatch) {
|
|
252
|
+
const matchIndex = slashMatch.index ?? 0;
|
|
253
|
+
const offsetInParent = matchIndex + (slashMatch[0].startsWith(" ") ? 1 : 0);
|
|
254
|
+
const matchFrom = $from.start() + offsetInParent;
|
|
255
|
+
const matchTo = $from.pos;
|
|
256
|
+
const coords = view.coordsAtPos($from.pos);
|
|
257
|
+
let relativeCoords = {
|
|
258
|
+
top: coords.top,
|
|
259
|
+
left: coords.left,
|
|
260
|
+
bottom: coords.bottom,
|
|
261
|
+
right: coords.right
|
|
262
|
+
};
|
|
263
|
+
if (opts.containerId && typeof document !== "undefined") {
|
|
264
|
+
const container = document.getElementById(opts.containerId);
|
|
265
|
+
if (container) {
|
|
266
|
+
const rect = container.getBoundingClientRect();
|
|
267
|
+
relativeCoords = {
|
|
268
|
+
top: coords.bottom - rect.top + 5,
|
|
269
|
+
left: coords.left - rect.left,
|
|
270
|
+
bottom: coords.bottom - rect.top,
|
|
271
|
+
right: coords.right - rect.left
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
opts.onMatch?.({
|
|
276
|
+
match: slashMatch,
|
|
277
|
+
query: slashMatch[1] || "",
|
|
278
|
+
from: matchFrom,
|
|
279
|
+
to: matchTo,
|
|
280
|
+
coords: relativeCoords
|
|
281
|
+
});
|
|
282
|
+
} else {
|
|
283
|
+
opts.onClear?.();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
];
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// src/extensions/template-suggestions.ts
|
|
294
|
+
var import_core3 = require("@tiptap/core");
|
|
295
|
+
var import_suggestion = __toESM(require("@tiptap/suggestion"), 1);
|
|
296
|
+
var TemplateSuggestions = import_core3.Extension.create({
|
|
297
|
+
name: "templateSuggestions",
|
|
298
|
+
addOptions() {
|
|
299
|
+
return {
|
|
300
|
+
templates: [],
|
|
301
|
+
char: "{{",
|
|
302
|
+
onSuggestion: void 0
|
|
303
|
+
};
|
|
304
|
+
},
|
|
305
|
+
addProseMirrorPlugins() {
|
|
306
|
+
const opts = this.options;
|
|
307
|
+
const suggestionConfig = {
|
|
308
|
+
char: opts.char || "{{",
|
|
309
|
+
items: ({ query }) => {
|
|
310
|
+
const lower = query.toLowerCase();
|
|
311
|
+
return (opts.templates || []).filter(
|
|
312
|
+
(t) => t.name.toLowerCase().includes(lower)
|
|
313
|
+
);
|
|
314
|
+
},
|
|
315
|
+
command: ({ editor, range, props }) => {
|
|
316
|
+
editor.chain().focus().deleteRange(range).insertContent(`{{${props.name}}}`).run();
|
|
317
|
+
},
|
|
318
|
+
render: () => {
|
|
319
|
+
return {
|
|
320
|
+
onStart: (props) => {
|
|
321
|
+
opts.onSuggestion?.(props);
|
|
322
|
+
},
|
|
323
|
+
onUpdate: (props) => {
|
|
324
|
+
opts.onSuggestion?.(props);
|
|
325
|
+
},
|
|
326
|
+
onExit: () => {
|
|
327
|
+
opts.onSuggestion?.({
|
|
328
|
+
query: "",
|
|
329
|
+
range: { from: 0, to: 0 },
|
|
330
|
+
items: [],
|
|
331
|
+
command: () => {
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
return [
|
|
339
|
+
(0, import_suggestion.default)({
|
|
340
|
+
editor: this.editor,
|
|
341
|
+
...suggestionConfig
|
|
342
|
+
})
|
|
343
|
+
];
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
// src/extensions/loading-node.ts
|
|
348
|
+
var import_core4 = require("@tiptap/core");
|
|
349
|
+
var LoadingNode = import_core4.Node.create({
|
|
350
|
+
name: "loadingNode",
|
|
351
|
+
group: "inline",
|
|
352
|
+
inline: true,
|
|
353
|
+
selectable: true,
|
|
354
|
+
atom: true,
|
|
355
|
+
addAttributes() {
|
|
356
|
+
return {
|
|
357
|
+
id: {
|
|
358
|
+
default: null,
|
|
359
|
+
parseHTML: (element) => element.getAttribute("data-id"),
|
|
360
|
+
renderHTML: (attributes) => {
|
|
361
|
+
if (!attributes.id) return {};
|
|
362
|
+
return { "data-id": attributes.id };
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
},
|
|
367
|
+
parseHTML() {
|
|
368
|
+
return [
|
|
369
|
+
{
|
|
370
|
+
tag: 'span[data-type="loading"]'
|
|
371
|
+
}
|
|
372
|
+
];
|
|
373
|
+
},
|
|
374
|
+
renderHTML({ HTMLAttributes }) {
|
|
375
|
+
return [
|
|
376
|
+
"span",
|
|
377
|
+
(0, import_core4.mergeAttributes)(HTMLAttributes, {
|
|
378
|
+
"data-type": "loading",
|
|
379
|
+
class: "inline-flex items-center px-1.5 py-0.5 text-xs text-muted-foreground animate-pulse"
|
|
380
|
+
}),
|
|
381
|
+
"\u23F3"
|
|
382
|
+
];
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
// src/extensions/SmilieReplacer.ts
|
|
387
|
+
var import_core5 = require("@tiptap/core");
|
|
388
|
+
var SmilieReplacer = import_core5.Extension.create({
|
|
389
|
+
name: "smilieReplacer",
|
|
390
|
+
addInputRules() {
|
|
391
|
+
return [
|
|
392
|
+
(0, import_core5.textInputRule)({ find: /-___- $/, replace: "\u{1F611} " }),
|
|
393
|
+
(0, import_core5.textInputRule)({ find: /:'-\) $/, replace: "\u{1F602} " }),
|
|
394
|
+
(0, import_core5.textInputRule)({ find: /':-\) $/, replace: "\u{1F605} " }),
|
|
395
|
+
(0, import_core5.textInputRule)({ find: /':-D $/, replace: "\u{1F605} " }),
|
|
396
|
+
(0, import_core5.textInputRule)({ find: />:-\) $/, replace: "\u{1F606} " }),
|
|
397
|
+
(0, import_core5.textInputRule)({ find: /-__- $/, replace: "\u{1F611} " }),
|
|
398
|
+
(0, import_core5.textInputRule)({ find: /':-\( $/, replace: "\u{1F613} " }),
|
|
399
|
+
(0, import_core5.textInputRule)({ find: /:'-\( $/, replace: "\u{1F622} " }),
|
|
400
|
+
(0, import_core5.textInputRule)({ find: />:-\( $/, replace: "\u{1F620} " }),
|
|
401
|
+
(0, import_core5.textInputRule)({ find: /O:-\) $/, replace: "\u{1F607} " }),
|
|
402
|
+
(0, import_core5.textInputRule)({ find: /:'\) $/, replace: "\u{1F602} " }),
|
|
403
|
+
(0, import_core5.textInputRule)({ find: /:-D $/, replace: "\u{1F603} " }),
|
|
404
|
+
(0, import_core5.textInputRule)({ find: /':\) $/, replace: "\u{1F605} " }),
|
|
405
|
+
(0, import_core5.textInputRule)({ find: /;-\) $/, replace: "\u{1F609} " }),
|
|
406
|
+
(0, import_core5.textInputRule)({ find: /B-\) $/, replace: "\u{1F60E} " }),
|
|
407
|
+
(0, import_core5.textInputRule)({ find: /:-\* $/, replace: "\u{1F618} " }),
|
|
408
|
+
(0, import_core5.textInputRule)({ find: /:-\) $/, replace: "\u{1F642} " }),
|
|
409
|
+
(0, import_core5.textInputRule)({ find: /-_- $/, replace: "\u{1F611} " }),
|
|
410
|
+
(0, import_core5.textInputRule)({ find: /:-O $/, replace: "\u{1F62E} " }),
|
|
411
|
+
(0, import_core5.textInputRule)({ find: /:-P $/, replace: "\u{1F61B} " }),
|
|
412
|
+
(0, import_core5.textInputRule)({ find: /:-p $/, replace: "\u{1F61B} " }),
|
|
413
|
+
(0, import_core5.textInputRule)({ find: /:-\/ $/, replace: "\u{1F615} " }),
|
|
414
|
+
(0, import_core5.textInputRule)({ find: /:-\( $/, replace: "\u{1F61E} " }),
|
|
415
|
+
(0, import_core5.textInputRule)({ find: /:'\( $/, replace: "\u{1F622} " }),
|
|
416
|
+
(0, import_core5.textInputRule)({ find: /:D $/, replace: "\u{1F603} " }),
|
|
417
|
+
(0, import_core5.textInputRule)({ find: /=D $/, replace: "\u{1F603} " }),
|
|
418
|
+
(0, import_core5.textInputRule)({ find: /;\) $/, replace: "\u{1F609} " }),
|
|
419
|
+
(0, import_core5.textInputRule)({ find: /B\) $/, replace: "\u{1F60E} " }),
|
|
420
|
+
(0, import_core5.textInputRule)({ find: /:\) $/, replace: "\u{1F642} " }),
|
|
421
|
+
(0, import_core5.textInputRule)({ find: /=\) $/, replace: "\u{1F642} " }),
|
|
422
|
+
(0, import_core5.textInputRule)({ find: /:O $/, replace: "\u{1F62E} " }),
|
|
423
|
+
(0, import_core5.textInputRule)({ find: /:P $/, replace: "\u{1F61B} " }),
|
|
424
|
+
(0, import_core5.textInputRule)({ find: /:p $/, replace: "\u{1F61B} " }),
|
|
425
|
+
(0, import_core5.textInputRule)({ find: /:\/ $/, replace: "\u{1F615} " }),
|
|
426
|
+
(0, import_core5.textInputRule)({ find: /:\( $/, replace: "\u{1F61E} " }),
|
|
427
|
+
(0, import_core5.textInputRule)({ find: /<3 $/, replace: "\u2764\uFE0F " }),
|
|
428
|
+
(0, import_core5.textInputRule)({ find: /<\/3 $/, replace: "\u{1F494} " }),
|
|
429
|
+
(0, import_core5.textInputRule)({ find: /\/shrug $/, replace: "\xAF\\_(\u30C4)_/\xAF " })
|
|
430
|
+
];
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// src/extensions/ColorHighlighter.ts
|
|
435
|
+
var import_core6 = require("@tiptap/core");
|
|
436
|
+
var import_state3 = require("@tiptap/pm/state");
|
|
437
|
+
var import_view2 = require("@tiptap/pm/view");
|
|
438
|
+
function findHexColors(doc) {
|
|
439
|
+
const hexColorRegex = /(#[0-9a-fA-F]{3,8})\b/g;
|
|
440
|
+
const decorations = [];
|
|
441
|
+
doc.descendants((node, position) => {
|
|
442
|
+
if (!node.text) return;
|
|
443
|
+
let match;
|
|
444
|
+
while ((match = hexColorRegex.exec(node.text)) !== null) {
|
|
445
|
+
const color = match[0];
|
|
446
|
+
const from = position + match.index;
|
|
447
|
+
const to = from + color.length;
|
|
448
|
+
decorations.push(
|
|
449
|
+
import_view2.Decoration.inline(from, to, {
|
|
450
|
+
class: "color-highlight px-1 py-0.5 rounded text-xs font-mono border",
|
|
451
|
+
style: `--color: ${color}; background-color: ${color}20; border-color: ${color}; color: ${color};`
|
|
452
|
+
})
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
return import_view2.DecorationSet.create(doc, decorations);
|
|
457
|
+
}
|
|
458
|
+
var ColorHighlighter = import_core6.Extension.create({
|
|
459
|
+
name: "colorHighlighter",
|
|
460
|
+
addProseMirrorPlugins() {
|
|
461
|
+
return [
|
|
462
|
+
new import_state3.Plugin({
|
|
463
|
+
state: {
|
|
464
|
+
init(_, { doc }) {
|
|
465
|
+
return findHexColors(doc);
|
|
466
|
+
},
|
|
467
|
+
apply(transaction, oldState) {
|
|
468
|
+
return transaction.docChanged ? findHexColors(transaction.doc) : oldState;
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
props: {
|
|
472
|
+
decorations(state) {
|
|
473
|
+
return this.getState(state);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
})
|
|
477
|
+
];
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// src/extensions/FontSize.ts
|
|
482
|
+
var import_core7 = require("@tiptap/core");
|
|
483
|
+
var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
484
|
+
var FontSize = import_core7.Extension.create({
|
|
485
|
+
name: "fontSize",
|
|
486
|
+
addOptions() {
|
|
487
|
+
return {
|
|
488
|
+
types: ["textStyle"]
|
|
489
|
+
};
|
|
490
|
+
},
|
|
491
|
+
addGlobalAttributes() {
|
|
492
|
+
return [
|
|
493
|
+
{
|
|
494
|
+
types: this.options.types,
|
|
495
|
+
attributes: {
|
|
496
|
+
fontSize: {
|
|
497
|
+
default: null,
|
|
498
|
+
parseHTML: (element) => element.style.fontSize.replace(/['"]+/g, ""),
|
|
499
|
+
renderHTML: (attributes) => {
|
|
500
|
+
if (!attributes.fontSize) {
|
|
501
|
+
return {};
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
style: `font-size: ${attributes.fontSize}`
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
];
|
|
511
|
+
},
|
|
512
|
+
addCommands() {
|
|
513
|
+
return {
|
|
514
|
+
setFontSize: (fontSize) => ({ chain }) => chain().setMark("textStyle", { fontSize }).run(),
|
|
515
|
+
unsetFontSize: () => ({ chain }) => chain().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
// src/extensions/rich-text-preset.ts
|
|
521
|
+
var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
522
|
+
var import_extension_color = __toESM(require("@tiptap/extension-color"), 1);
|
|
523
|
+
var import_extension_highlight = __toESM(require("@tiptap/extension-highlight"), 1);
|
|
524
|
+
var import_extension_link = __toESM(require("@tiptap/extension-link"), 1);
|
|
525
|
+
var import_extension_task_list = __toESM(require("@tiptap/extension-task-list"), 1);
|
|
526
|
+
var import_extension_task_item = __toESM(require("@tiptap/extension-task-item"), 1);
|
|
527
|
+
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"), 1);
|
|
528
|
+
var import_extension_text_style2 = __toESM(require("@tiptap/extension-text-style"), 1);
|
|
529
|
+
var import_extension_typography = __toESM(require("@tiptap/extension-typography"), 1);
|
|
530
|
+
var import_extension_underline = __toESM(require("@tiptap/extension-underline"), 1);
|
|
531
|
+
var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"), 1);
|
|
532
|
+
var import_extension_character_count = __toESM(require("@tiptap/extension-character-count"), 1);
|
|
533
|
+
function createRichTextPreset(options = {}) {
|
|
534
|
+
const {
|
|
535
|
+
placeholder = "Start typing...",
|
|
536
|
+
characterLimit,
|
|
537
|
+
openLinksOnClick = false,
|
|
538
|
+
enableSmilies = true,
|
|
539
|
+
enableColorHighlighter = true,
|
|
540
|
+
headingLevels = [1, 2, 3, 4]
|
|
541
|
+
} = options;
|
|
542
|
+
const extensions = [
|
|
543
|
+
import_starter_kit.default.configure({
|
|
544
|
+
orderedList: {
|
|
545
|
+
HTMLAttributes: {
|
|
546
|
+
class: "list-decimal pl-4"
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
bulletList: {
|
|
550
|
+
HTMLAttributes: {
|
|
551
|
+
class: "list-disc pl-4"
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
heading: {
|
|
555
|
+
levels: headingLevels,
|
|
556
|
+
HTMLAttributes: {
|
|
557
|
+
class: "font-bold tracking-tight"
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}),
|
|
561
|
+
import_extension_text_style2.default,
|
|
562
|
+
import_extension_color.default,
|
|
563
|
+
import_extension_highlight.default.configure({ multicolor: true }),
|
|
564
|
+
import_extension_underline.default,
|
|
565
|
+
import_extension_typography.default,
|
|
566
|
+
import_extension_text_align.default.configure({
|
|
567
|
+
types: ["heading", "paragraph"]
|
|
568
|
+
}),
|
|
569
|
+
import_extension_link.default.configure({
|
|
570
|
+
openOnClick: openLinksOnClick,
|
|
571
|
+
autolink: true,
|
|
572
|
+
defaultProtocol: "https",
|
|
573
|
+
HTMLAttributes: {
|
|
574
|
+
target: "_blank",
|
|
575
|
+
rel: "noopener noreferrer",
|
|
576
|
+
class: "text-blue-500 underline underline-offset-2"
|
|
577
|
+
}
|
|
578
|
+
}),
|
|
579
|
+
import_extension_task_list.default,
|
|
580
|
+
import_extension_task_item.default.configure({
|
|
581
|
+
nested: true
|
|
582
|
+
}),
|
|
583
|
+
FontSize,
|
|
584
|
+
import_extension_placeholder.default.configure({
|
|
585
|
+
emptyEditorClass: "is-empty",
|
|
586
|
+
placeholder: typeof placeholder === "function" ? placeholder : () => placeholder
|
|
587
|
+
})
|
|
588
|
+
];
|
|
589
|
+
if (characterLimit) {
|
|
590
|
+
extensions.push(
|
|
591
|
+
import_extension_character_count.default.configure({
|
|
592
|
+
limit: characterLimit
|
|
593
|
+
})
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
if (enableSmilies) {
|
|
597
|
+
extensions.push(SmilieReplacer);
|
|
598
|
+
}
|
|
599
|
+
if (enableColorHighlighter) {
|
|
600
|
+
extensions.push(ColorHighlighter);
|
|
601
|
+
}
|
|
602
|
+
return extensions;
|
|
603
|
+
}
|
|
604
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
605
|
+
0 && (module.exports = {
|
|
606
|
+
ColorHighlighter,
|
|
607
|
+
FontSize,
|
|
608
|
+
GradientText,
|
|
609
|
+
LoadingNode,
|
|
610
|
+
SlashCommands,
|
|
611
|
+
SmilieReplacer,
|
|
612
|
+
TemplateSuggestions,
|
|
613
|
+
createRichTextPreset,
|
|
614
|
+
findHexColors
|
|
615
|
+
});
|
|
616
|
+
//# sourceMappingURL=index.cjs.map
|