@cyberyozh/text-editor 0.1.5 → 0.1.7
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 +505 -430
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +506 -431
- package/dist/editor.mjs.map +1 -1
- package/dist/render.js +62 -29
- package/dist/render.js.map +1 -1
- package/dist/render.mjs +62 -29
- package/dist/render.mjs.map +1 -1
- package/dist/styles/index.css +46 -20
- package/package.json +5 -1
- 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/editor.tsx +69 -44
- package/src/editor/handlers/dialog-handlers.ts +118 -36
- package/src/extensions/views/components/index.ts +1 -0
- package/src/extensions/views/components/table.tsx +29 -0
- package/src/render/static-renderer-config.tsx +32 -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/dist/render.mjs
CHANGED
|
@@ -2186,6 +2186,16 @@ var PromptContent = ({ children, isEmpty, placeholder }) => /* @__PURE__ */ jsx6
|
|
|
2186
2186
|
}
|
|
2187
2187
|
) });
|
|
2188
2188
|
|
|
2189
|
+
// src/extensions/views/components/table.tsx
|
|
2190
|
+
import { jsx as jsx67, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2191
|
+
function Table({ children, colWidths = [] }) {
|
|
2192
|
+
const tableWidth = colWidths.length > 0 ? colWidths.reduce((total, width) => total + width, 0) : null;
|
|
2193
|
+
return /* @__PURE__ */ jsx67("div", { className: "tableWrapper", children: /* @__PURE__ */ jsxs21("table", { style: tableWidth ? { width: `${tableWidth}px` } : void 0, children: [
|
|
2194
|
+
colWidths.length > 0 && /* @__PURE__ */ jsx67("colgroup", { children: colWidths.map((width, index) => /* @__PURE__ */ jsx67("col", { style: { width: `${width}px` } }, index)) }),
|
|
2195
|
+
/* @__PURE__ */ jsx67("tbody", { children })
|
|
2196
|
+
] }) });
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2189
2199
|
// src/utils/detect-video-hosting.ts
|
|
2190
2200
|
var VIDEO_PATTERNS = {
|
|
2191
2201
|
youtube: /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|shorts\/)?([a-zA-Z0-9_-]{11})/,
|
|
@@ -2258,22 +2268,22 @@ var detectVideoHosting = (src) => {
|
|
|
2258
2268
|
};
|
|
2259
2269
|
|
|
2260
2270
|
// src/extensions/views/components/video.tsx
|
|
2261
|
-
import { jsx as
|
|
2271
|
+
import { jsx as jsx68, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2262
2272
|
var Video = ({ src, children }) => {
|
|
2263
2273
|
const videoInfo = detectVideoHosting(src);
|
|
2264
2274
|
if (!videoInfo?.embedUrl) {
|
|
2265
|
-
return /* @__PURE__ */
|
|
2266
|
-
/* @__PURE__ */
|
|
2275
|
+
return /* @__PURE__ */ jsxs22("div", { className: "video-node", children: [
|
|
2276
|
+
/* @__PURE__ */ jsx68("div", { className: "video-error", children: /* @__PURE__ */ jsx68("span", { children: "Unsupported or invalid video URL" }) }),
|
|
2267
2277
|
children
|
|
2268
2278
|
] });
|
|
2269
2279
|
}
|
|
2270
|
-
return /* @__PURE__ */
|
|
2280
|
+
return /* @__PURE__ */ jsxs22(
|
|
2271
2281
|
"div",
|
|
2272
2282
|
{
|
|
2273
2283
|
className: "video-node",
|
|
2274
2284
|
"data-video": "",
|
|
2275
2285
|
children: [
|
|
2276
|
-
/* @__PURE__ */
|
|
2286
|
+
/* @__PURE__ */ jsx68("div", { className: "video-player-wrapper", children: /* @__PURE__ */ jsx68(
|
|
2277
2287
|
"iframe",
|
|
2278
2288
|
{
|
|
2279
2289
|
className: "video-iframe",
|
|
@@ -2290,10 +2300,10 @@ var Video = ({ src, children }) => {
|
|
|
2290
2300
|
};
|
|
2291
2301
|
|
|
2292
2302
|
// src/render/static-renderer-config.tsx
|
|
2293
|
-
import { jsx as
|
|
2303
|
+
import { jsx as jsx69 } from "react/jsx-runtime";
|
|
2294
2304
|
var getNodeMapping = (getImageById) => ({
|
|
2295
2305
|
callout({ node, children }) {
|
|
2296
|
-
return /* @__PURE__ */
|
|
2306
|
+
return /* @__PURE__ */ jsx69(Callout, { ...node.attrs, children });
|
|
2297
2307
|
},
|
|
2298
2308
|
codeBlock({ node, children }) {
|
|
2299
2309
|
const language = node.attrs.language || "";
|
|
@@ -2317,41 +2327,64 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2317
2327
|
console.warn(`Failed to highlight code for language "${language}":`, error);
|
|
2318
2328
|
highlightedHtml = codeText.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2319
2329
|
}
|
|
2320
|
-
return /* @__PURE__ */
|
|
2330
|
+
return /* @__PURE__ */ jsx69(
|
|
2321
2331
|
CodeBlock,
|
|
2322
2332
|
{
|
|
2323
2333
|
language,
|
|
2324
2334
|
isEditable: false,
|
|
2325
|
-
children: /* @__PURE__ */
|
|
2335
|
+
children: /* @__PURE__ */ jsx69("code", { dangerouslySetInnerHTML: { __html: highlightedHtml } })
|
|
2326
2336
|
}
|
|
2327
2337
|
);
|
|
2328
2338
|
},
|
|
2329
2339
|
customQuote({ children }) {
|
|
2330
|
-
return /* @__PURE__ */
|
|
2340
|
+
return /* @__PURE__ */ jsx69(CustomQuote, { children });
|
|
2331
2341
|
},
|
|
2332
2342
|
customQuoteText({ children }) {
|
|
2333
|
-
return /* @__PURE__ */
|
|
2343
|
+
return /* @__PURE__ */ jsx69(CustomQuoteText, { children });
|
|
2334
2344
|
},
|
|
2335
2345
|
customQuoteAuthor({ children }) {
|
|
2336
|
-
return /* @__PURE__ */
|
|
2346
|
+
return /* @__PURE__ */ jsx69(CustomQuoteAuthor, { children });
|
|
2337
2347
|
},
|
|
2338
2348
|
customQuoteSign({ children }) {
|
|
2339
|
-
return /* @__PURE__ */
|
|
2349
|
+
return /* @__PURE__ */ jsx69(CustomQuoteSign, { children });
|
|
2340
2350
|
},
|
|
2341
2351
|
promptHeader({ children }) {
|
|
2342
|
-
return /* @__PURE__ */
|
|
2352
|
+
return /* @__PURE__ */ jsx69(PromptHeader, { children });
|
|
2343
2353
|
},
|
|
2344
2354
|
promptContent({ children }) {
|
|
2345
|
-
return /* @__PURE__ */
|
|
2355
|
+
return /* @__PURE__ */ jsx69(PromptContent, { children });
|
|
2346
2356
|
},
|
|
2347
2357
|
video({ node }) {
|
|
2348
|
-
return /* @__PURE__ */
|
|
2358
|
+
return /* @__PURE__ */ jsx69(Video, { src: node.attrs.src });
|
|
2359
|
+
},
|
|
2360
|
+
table({ children }) {
|
|
2361
|
+
let colWidths = [];
|
|
2362
|
+
if (Array.isArray(children) && children.length > 0) {
|
|
2363
|
+
const firstRow = children[0];
|
|
2364
|
+
if (firstRow?.props?.children) {
|
|
2365
|
+
const cells = Array.isArray(firstRow.props.children) ? firstRow.props.children : [firstRow.props.children];
|
|
2366
|
+
colWidths = cells.map((cell) => cell?.props?.node?.attrs?.colwidth?.[0]).filter((width) => width !== void 0);
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
return /* @__PURE__ */ jsx69(Table, { colWidths, children });
|
|
2349
2370
|
},
|
|
2350
2371
|
figure({ node }) {
|
|
2351
|
-
return /* @__PURE__ */
|
|
2372
|
+
return /* @__PURE__ */ jsx69(
|
|
2373
|
+
Figure,
|
|
2374
|
+
{
|
|
2375
|
+
...node.attrs,
|
|
2376
|
+
getImageById
|
|
2377
|
+
}
|
|
2378
|
+
);
|
|
2352
2379
|
},
|
|
2353
2380
|
image({ node }) {
|
|
2354
|
-
return /* @__PURE__ */
|
|
2381
|
+
return /* @__PURE__ */ jsx69(
|
|
2382
|
+
Figure,
|
|
2383
|
+
{
|
|
2384
|
+
...node.attrs,
|
|
2385
|
+
getImageById
|
|
2386
|
+
}
|
|
2387
|
+
);
|
|
2355
2388
|
},
|
|
2356
2389
|
inlineMath({ node }) {
|
|
2357
2390
|
const latex = node.attrs.latex || "";
|
|
@@ -2364,7 +2397,7 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2364
2397
|
} catch (error) {
|
|
2365
2398
|
console.warn("KaTeX rendering error for inline math:", error);
|
|
2366
2399
|
}
|
|
2367
|
-
return /* @__PURE__ */
|
|
2400
|
+
return /* @__PURE__ */ jsx69(
|
|
2368
2401
|
"span",
|
|
2369
2402
|
{
|
|
2370
2403
|
className: "react-renderer node-inlineMath",
|
|
@@ -2385,7 +2418,7 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2385
2418
|
} catch (error) {
|
|
2386
2419
|
console.warn("KaTeX rendering error for block math:", error);
|
|
2387
2420
|
}
|
|
2388
|
-
return /* @__PURE__ */
|
|
2421
|
+
return /* @__PURE__ */ jsx69("div", { className: "react-renderer node-blockMath", children: /* @__PURE__ */ jsx69(
|
|
2389
2422
|
"div",
|
|
2390
2423
|
{
|
|
2391
2424
|
className: "tiptap-mathematics-render",
|
|
@@ -2406,7 +2439,7 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2406
2439
|
} catch (error) {
|
|
2407
2440
|
console.warn("KaTeX rendering error for inline latex:", error);
|
|
2408
2441
|
}
|
|
2409
|
-
return /* @__PURE__ */
|
|
2442
|
+
return /* @__PURE__ */ jsx69(
|
|
2410
2443
|
"span",
|
|
2411
2444
|
{
|
|
2412
2445
|
className: "react-renderer node-inlineLatex inline-latex",
|
|
@@ -2419,33 +2452,33 @@ var getNodeMapping = (getImageById) => ({
|
|
|
2419
2452
|
*/
|
|
2420
2453
|
calloutAlert({ node, children }) {
|
|
2421
2454
|
const type = node.attrs.type || "info";
|
|
2422
|
-
return /* @__PURE__ */
|
|
2455
|
+
return /* @__PURE__ */ jsx69(Callout, { type, children });
|
|
2423
2456
|
},
|
|
2424
2457
|
calloutTip({ node, children }) {
|
|
2425
2458
|
const type = node.attrs.type || "info";
|
|
2426
|
-
return /* @__PURE__ */
|
|
2459
|
+
return /* @__PURE__ */ jsx69(Callout, { type, children });
|
|
2427
2460
|
},
|
|
2428
2461
|
customQuoteV2({ children }) {
|
|
2429
|
-
return /* @__PURE__ */
|
|
2462
|
+
return /* @__PURE__ */ jsx69(CustomQuote, { children });
|
|
2430
2463
|
},
|
|
2431
2464
|
promptV2Header({ children }) {
|
|
2432
|
-
return /* @__PURE__ */
|
|
2465
|
+
return /* @__PURE__ */ jsx69(PromptHeader, { children });
|
|
2433
2466
|
},
|
|
2434
2467
|
promptV2Content({ children }) {
|
|
2435
|
-
return /* @__PURE__ */
|
|
2468
|
+
return /* @__PURE__ */ jsx69(PromptContent, { children });
|
|
2436
2469
|
}
|
|
2437
2470
|
});
|
|
2438
2471
|
var nodeMapping = getNodeMapping();
|
|
2439
2472
|
var markMapping = {
|
|
2440
2473
|
"copyable-text"({ children }) {
|
|
2441
|
-
return /* @__PURE__ */
|
|
2474
|
+
return /* @__PURE__ */ jsx69(CopyableText2, { children });
|
|
2442
2475
|
}
|
|
2443
2476
|
};
|
|
2444
2477
|
|
|
2445
2478
|
// src/render/tiptap-render.tsx
|
|
2446
2479
|
import "highlight.js/styles/github-dark.css";
|
|
2447
2480
|
import "katex/dist/katex.min.css";
|
|
2448
|
-
import { jsx as
|
|
2481
|
+
import { jsx as jsx70 } from "react/jsx-runtime";
|
|
2449
2482
|
function renderTiptapToReact(content, getImageById) {
|
|
2450
2483
|
let parsedContent;
|
|
2451
2484
|
try {
|
|
@@ -2466,7 +2499,7 @@ function renderTiptapToReact(content, getImageById) {
|
|
|
2466
2499
|
markMapping
|
|
2467
2500
|
}
|
|
2468
2501
|
});
|
|
2469
|
-
return /* @__PURE__ */
|
|
2502
|
+
return /* @__PURE__ */ jsx70(
|
|
2470
2503
|
"div",
|
|
2471
2504
|
{
|
|
2472
2505
|
className: "tiptap",
|