@cyberyozh/text-editor 0.1.6 → 0.1.8
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/dist/editor.css +46 -20
- package/dist/editor.css.map +1 -1
- package/dist/editor.js +483 -456
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +481 -454
- package/dist/editor.mjs.map +1 -1
- package/dist/render.js +68 -29
- package/dist/render.js.map +1 -1
- package/dist/render.mjs +68 -29
- package/dist/render.mjs.map +1 -1
- package/dist/styles/index.css +46 -20
- package/package.json +5 -3
- package/src/editor/commands/items.ts +1 -1
- package/src/editor/components/common-modal/common-modal.css +2 -1
- package/src/editor/context/dialog-command.tsx +0 -2
- package/src/editor/controls/bubble-menu-content.tsx +6 -2
- package/src/editor/controls/commands-list.tsx +7 -0
- package/src/editor/dialogs/add-video-dialog/add-video-dialog.tsx +2 -5
- package/src/editor/dialogs/image-dialog/image-dialog.tsx +0 -1
- package/src/editor/editor.tsx +68 -44
- package/src/editor/handlers/dialog-handlers.ts +74 -62
- package/src/editor/handlers/index.ts +1 -2
- package/src/extensions/views/components/index.ts +1 -0
- package/src/extensions/views/components/table.tsx +48 -0
- package/src/render/static-renderer-config.tsx +16 -2
- package/src/styles/editor/base.css +7 -5
- package/src/styles/editor/states.css +4 -3
- package/src/styles/editor/typography.css +10 -2
- package/src/styles/editor/variables.css +1 -0
- package/src/styles/extensions/callout.css +5 -2
- package/src/styles/extensions/code-block.css +2 -1
- package/src/styles/extensions/commands-list.css +5 -1
- package/src/styles/extensions/custom-quote.css +5 -0
- package/src/styles/extensions/details.css +4 -4
- package/src/styles/extensions/myth-reality.css +3 -1
- package/src/styles/extensions/prompt.css +4 -1
- package/src/editor/handlers/create-image-upload-handler.ts +0 -24
package/dist/render.js
CHANGED
|
@@ -2222,6 +2222,30 @@ var PromptContent = ({ children, isEmpty, placeholder }) => /* @__PURE__ */ (0,
|
|
|
2222
2222
|
}
|
|
2223
2223
|
) });
|
|
2224
2224
|
|
|
2225
|
+
// src/extensions/views/components/table.tsx
|
|
2226
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
2227
|
+
function Table({ children }) {
|
|
2228
|
+
let colWidths = [];
|
|
2229
|
+
if (Array.isArray(children) && children.length > 0) {
|
|
2230
|
+
const firstRow = children[0];
|
|
2231
|
+
if (firstRow?.props?.children) {
|
|
2232
|
+
const cells = Array.isArray(firstRow.props.children) ? firstRow.props.children : [firstRow.props.children];
|
|
2233
|
+
colWidths = cells.map((cell) => cell?.props?.node?.attrs?.colwidth?.[0]).filter((width) => width !== void 0);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
const tableWidth = colWidths.length > 0 ? colWidths.reduce((total, width) => total + width, 0) : null;
|
|
2237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "tableWrapper", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("table", { style: tableWidth ? { width: `${tableWidth}px` } : void 0, children: [
|
|
2238
|
+
colWidths.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("colgroup", { children: colWidths.map((width, index) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
2239
|
+
"col",
|
|
2240
|
+
{
|
|
2241
|
+
style: { width: `${width}px` }
|
|
2242
|
+
},
|
|
2243
|
+
index
|
|
2244
|
+
)) }),
|
|
2245
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)("tbody", { children })
|
|
2246
|
+
] }) });
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2225
2249
|
// src/utils/detect-video-hosting.ts
|
|
2226
2250
|
var VIDEO_PATTERNS = {
|
|
2227
2251
|
youtube: /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|shorts\/)?([a-zA-Z0-9_-]{11})/,
|
|
@@ -2294,22 +2318,22 @@ var detectVideoHosting = (src) => {
|
|
|
2294
2318
|
};
|
|
2295
2319
|
|
|
2296
2320
|
// src/extensions/views/components/video.tsx
|
|
2297
|
-
var
|
|
2321
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
2298
2322
|
var Video = ({ src, children }) => {
|
|
2299
2323
|
const videoInfo = detectVideoHosting(src);
|
|
2300
2324
|
if (!videoInfo?.embedUrl) {
|
|
2301
|
-
return /* @__PURE__ */ (0,
|
|
2302
|
-
/* @__PURE__ */ (0,
|
|
2325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "video-node", children: [
|
|
2326
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "video-error", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)("span", { children: "Unsupported or invalid video URL" }) }),
|
|
2303
2327
|
children
|
|
2304
2328
|
] });
|
|
2305
2329
|
}
|
|
2306
|
-
return /* @__PURE__ */ (0,
|
|
2330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(
|
|
2307
2331
|
"div",
|
|
2308
2332
|
{
|
|
2309
2333
|
className: "video-node",
|
|
2310
2334
|
"data-video": "",
|
|
2311
2335
|
children: [
|
|
2312
|
-
/* @__PURE__ */ (0,
|
|
2336
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)("div", { className: "video-player-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
2313
2337
|
"iframe",
|
|
2314
2338
|
{
|
|
2315
2339
|
className: "video-iframe",
|
|
@@ -2326,10 +2350,10 @@ var Video = ({ src, children }) => {
|
|
|
2326
2350
|
};
|
|
2327
2351
|
|
|
2328
2352
|
// src/render/static-renderer-config.tsx
|
|
2329
|
-
var
|
|
2353
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
2330
2354
|
var getNodeMapping = (getImageById) => ({
|
|
2331
2355
|
callout({ node, children }) {
|
|
2332
|
-
return /* @__PURE__ */ (0,
|
|
2356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Callout, { ...node.attrs, children });
|
|
2333
2357
|
},
|
|
2334
2358
|
codeBlock({ node, children }) {
|
|
2335
2359
|
const language = node.attrs.language || "";
|
|
@@ -2353,41 +2377,56 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2353
2377
|
console.warn(`Failed to highlight code for language "${language}":`, error);
|
|
2354
2378
|
highlightedHtml = codeText.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2355
2379
|
}
|
|
2356
|
-
return /* @__PURE__ */ (0,
|
|
2380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
2357
2381
|
CodeBlock,
|
|
2358
2382
|
{
|
|
2359
2383
|
language,
|
|
2360
2384
|
isEditable: false,
|
|
2361
|
-
children: /* @__PURE__ */ (0,
|
|
2385
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("code", { dangerouslySetInnerHTML: { __html: highlightedHtml } })
|
|
2362
2386
|
}
|
|
2363
2387
|
);
|
|
2364
2388
|
},
|
|
2365
2389
|
customQuote({ children }) {
|
|
2366
|
-
return /* @__PURE__ */ (0,
|
|
2390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CustomQuote, { children });
|
|
2367
2391
|
},
|
|
2368
2392
|
customQuoteText({ children }) {
|
|
2369
|
-
return /* @__PURE__ */ (0,
|
|
2393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CustomQuoteText, { children });
|
|
2370
2394
|
},
|
|
2371
2395
|
customQuoteAuthor({ children }) {
|
|
2372
|
-
return /* @__PURE__ */ (0,
|
|
2396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CustomQuoteAuthor, { children });
|
|
2373
2397
|
},
|
|
2374
2398
|
customQuoteSign({ children }) {
|
|
2375
|
-
return /* @__PURE__ */ (0,
|
|
2399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CustomQuoteSign, { children });
|
|
2376
2400
|
},
|
|
2377
2401
|
promptHeader({ children }) {
|
|
2378
|
-
return /* @__PURE__ */ (0,
|
|
2402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(PromptHeader, { children });
|
|
2379
2403
|
},
|
|
2380
2404
|
promptContent({ children }) {
|
|
2381
|
-
return /* @__PURE__ */ (0,
|
|
2405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(PromptContent, { children });
|
|
2382
2406
|
},
|
|
2383
2407
|
video({ node }) {
|
|
2384
|
-
return /* @__PURE__ */ (0,
|
|
2408
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Video, { src: node.attrs.src });
|
|
2409
|
+
},
|
|
2410
|
+
table({ children }) {
|
|
2411
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Table, { children });
|
|
2385
2412
|
},
|
|
2386
2413
|
figure({ node }) {
|
|
2387
|
-
return /* @__PURE__ */ (0,
|
|
2414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
2415
|
+
Figure,
|
|
2416
|
+
{
|
|
2417
|
+
...node.attrs,
|
|
2418
|
+
getImageById
|
|
2419
|
+
}
|
|
2420
|
+
);
|
|
2388
2421
|
},
|
|
2389
2422
|
image({ node }) {
|
|
2390
|
-
return /* @__PURE__ */ (0,
|
|
2423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
2424
|
+
Figure,
|
|
2425
|
+
{
|
|
2426
|
+
...node.attrs,
|
|
2427
|
+
getImageById
|
|
2428
|
+
}
|
|
2429
|
+
);
|
|
2391
2430
|
},
|
|
2392
2431
|
inlineMath({ node }) {
|
|
2393
2432
|
const latex = node.attrs.latex || "";
|
|
@@ -2400,7 +2439,7 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2400
2439
|
} catch (error) {
|
|
2401
2440
|
console.warn("KaTeX rendering error for inline math:", error);
|
|
2402
2441
|
}
|
|
2403
|
-
return /* @__PURE__ */ (0,
|
|
2442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
2404
2443
|
"span",
|
|
2405
2444
|
{
|
|
2406
2445
|
className: "react-renderer node-inlineMath",
|
|
@@ -2421,7 +2460,7 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2421
2460
|
} catch (error) {
|
|
2422
2461
|
console.warn("KaTeX rendering error for block math:", error);
|
|
2423
2462
|
}
|
|
2424
|
-
return /* @__PURE__ */ (0,
|
|
2463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "react-renderer node-blockMath", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
2425
2464
|
"div",
|
|
2426
2465
|
{
|
|
2427
2466
|
className: "tiptap-mathematics-render",
|
|
@@ -2442,7 +2481,7 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2442
2481
|
} catch (error) {
|
|
2443
2482
|
console.warn("KaTeX rendering error for inline latex:", error);
|
|
2444
2483
|
}
|
|
2445
|
-
return /* @__PURE__ */ (0,
|
|
2484
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
2446
2485
|
"span",
|
|
2447
2486
|
{
|
|
2448
2487
|
className: "react-renderer node-inlineLatex inline-latex",
|
|
@@ -2455,33 +2494,33 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2455
2494
|
*/
|
|
2456
2495
|
calloutAlert({ node, children }) {
|
|
2457
2496
|
const type = node.attrs.type || "info";
|
|
2458
|
-
return /* @__PURE__ */ (0,
|
|
2497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Callout, { type, children });
|
|
2459
2498
|
},
|
|
2460
2499
|
calloutTip({ node, children }) {
|
|
2461
2500
|
const type = node.attrs.type || "info";
|
|
2462
|
-
return /* @__PURE__ */ (0,
|
|
2501
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Callout, { type, children });
|
|
2463
2502
|
},
|
|
2464
2503
|
customQuoteV2({ children }) {
|
|
2465
|
-
return /* @__PURE__ */ (0,
|
|
2504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CustomQuote, { children });
|
|
2466
2505
|
},
|
|
2467
2506
|
promptV2Header({ children }) {
|
|
2468
|
-
return /* @__PURE__ */ (0,
|
|
2507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(PromptHeader, { children });
|
|
2469
2508
|
},
|
|
2470
2509
|
promptV2Content({ children }) {
|
|
2471
|
-
return /* @__PURE__ */ (0,
|
|
2510
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(PromptContent, { children });
|
|
2472
2511
|
}
|
|
2473
2512
|
});
|
|
2474
2513
|
var nodeMapping = getNodeMapping();
|
|
2475
2514
|
var markMapping = {
|
|
2476
2515
|
"copyable-text"({ children }) {
|
|
2477
|
-
return /* @__PURE__ */ (0,
|
|
2516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(CopyableText2, { children });
|
|
2478
2517
|
}
|
|
2479
2518
|
};
|
|
2480
2519
|
|
|
2481
2520
|
// src/render/tiptap-render.tsx
|
|
2482
2521
|
var import_github_dark = require("highlight.js/styles/github-dark.css");
|
|
2483
2522
|
var import_katex_min = require("katex/dist/katex.min.css");
|
|
2484
|
-
var
|
|
2523
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
2485
2524
|
function renderTiptapToReact(content, getImageById) {
|
|
2486
2525
|
let parsedContent;
|
|
2487
2526
|
try {
|
|
@@ -2502,7 +2541,7 @@ function renderTiptapToReact(content, getImageById) {
|
|
|
2502
2541
|
markMapping
|
|
2503
2542
|
}
|
|
2504
2543
|
});
|
|
2505
|
-
return /* @__PURE__ */ (0,
|
|
2544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
2506
2545
|
"div",
|
|
2507
2546
|
{
|
|
2508
2547
|
className: "tiptap",
|