@4399ywkf/editor 0.12.0 → 0.13.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/README.md +37 -0
- package/dist/{DocView-5LI4KWEZ.js → DocView-ZC6IDEAA.js} +3 -3
- package/dist/{DocView-5LI4KWEZ.js.map → DocView-ZC6IDEAA.js.map} +1 -1
- package/dist/{chunk-SV3LH2TC.js → chunk-MKJY3LFJ.js} +1318 -391
- package/dist/chunk-MKJY3LFJ.js.map +1 -0
- package/dist/doc-standalone.js +1400 -385
- package/dist/doc-standalone.js.map +1 -1
- package/dist/doc.d.ts +48 -2
- package/dist/doc.js +93 -3
- package/dist/doc.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +19 -10
- package/package.json +2 -2
- package/dist/chunk-SV3LH2TC.js.map +0 -1
|
@@ -2,12 +2,12 @@ import { useTiptapEditor, isExtensionAvailable, isNodeInSchema, Button, cn, getS
|
|
|
2
2
|
import { resolveCalloutLook, MARKDOWN_SEQ_PATTERN, markdownSeqFor, attrsForMenuAction, AUTO_NUMBER_MAX_LEVEL, AUTO, HIGHLIGHT_SWATCHES, BLOCK_BACKGROUND_SWATCHES, defaultReminder, normalizeReminder, reminderText, reminderColor, LEGACY_SWATCHES, TEXT_SWATCHES, createCodeHighlighter, swatchValue, resolveCodeLanguage, getCodeBlockTitle, CALLOUT_EMOJIS, CALLOUT_BORDER_SWATCHES, FEISHU_DEFAULT_CALLOUT, orderText, resolveShikiTheme, filterCodeLanguages, pairedBorderFor, computeHeadingOrders, notifyOptions, withDate, withWholeDay, withTime, formatTime, withNotify, withNotifyOffset, reminderFullText, remindUsersLine, calendarDays, TIME_SLOTS, parseTimeInput, resolveColorToHex, numberMenuState, MAX_SEQ_VALUE } from './chunk-UD6MDBTN.js';
|
|
3
3
|
import { normalizeDiagram, defaultDiagram, toMermaid, DEFAULT_DIAGRAM_HEIGHT, clampDiagramHeight, toOutline, SHAPE_SIZE } from './chunk-ABMZOL26.js';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { createContext, memo, forwardRef, useState, useCallback, useRef, useEffect, useMemo, lazy, useLayoutEffect, Suspense, useContext, useReducer, Children, isValidElement, cloneElement } from 'react';
|
|
5
|
+
import { createContext, memo, forwardRef, useState, useCallback, useRef, useEffect, useMemo, lazy, useLayoutEffect, Suspense, useContext, useReducer, useId, Children, isValidElement, cloneElement } from 'react';
|
|
6
6
|
import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
7
|
-
import { createPortal } from 'react-dom';
|
|
8
|
-
import { Extension, Node as Node$2, mergeAttributes as mergeAttributes$1, textblockTypeInputRule, InputRule, PasteRule, getChangedRanges, combineTransactionSteps, getTextSerializersFromSchema, getTextBetween, generateJSON, generateHTML } from '@tiptap/core';
|
|
7
|
+
import { createPortal, flushSync } from 'react-dom';
|
|
8
|
+
import { Extension, Node as Node$2, mergeAttributes as mergeAttributes$1, textblockTypeInputRule, Mark, InputRule, PasteRule, getChangedRanges, combineTransactionSteps, getTextSerializersFromSchema, getTextBetween, generateJSON, generateHTML } from '@tiptap/core';
|
|
9
9
|
import { isChangeOrigin, Collaboration } from '@tiptap/extension-collaboration';
|
|
10
|
-
import { Fragment, Slice, Mark, DOMSerializer } from '@tiptap/pm/model';
|
|
10
|
+
import { Fragment, Slice, Mark as Mark$1, DOMSerializer } from '@tiptap/pm/model';
|
|
11
11
|
import { PluginKey, Plugin, TextSelection, Selection, NodeSelection, SelectionRange } from '@tiptap/pm/state';
|
|
12
12
|
import { createGlobalStyle, useTheme } from 'antd-style';
|
|
13
13
|
import { serialize, compile, stringify } from 'stylis';
|
|
@@ -19,6 +19,7 @@ import { MarkdownManager, Markdown } from '@tiptap/markdown';
|
|
|
19
19
|
import { Marked } from 'marked';
|
|
20
20
|
import { shift, flip, offset, useMergeRefs, useFloating, autoUpdate, useTransitionStyles, useDismiss, useInteractions, FloatingPortal, size } from '@floating-ui/react';
|
|
21
21
|
import { Doc } from 'yjs';
|
|
22
|
+
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
22
23
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
23
24
|
import throttle from 'lodash.throttle';
|
|
24
25
|
import { StarterKit } from '@tiptap/starter-kit';
|
|
@@ -34,7 +35,6 @@ import { gitHubEmojis, Emoji } from '@tiptap/extension-emoji';
|
|
|
34
35
|
import { TableOfContents, getHierarchicalIndexes } from '@tiptap/extension-table-of-contents';
|
|
35
36
|
import TiptapHorizontalRule from '@tiptap/extension-horizontal-rule';
|
|
36
37
|
import { Heading as Heading$1 } from '@tiptap/extension-heading';
|
|
37
|
-
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
38
38
|
import { Image as Image$1 } from '@tiptap/extension-image';
|
|
39
39
|
import { BlockMath, InlineMath } from '@tiptap/extension-mathematics';
|
|
40
40
|
import { columnResizing, tableEditing, cellAround, TableMap, TableView, columnResizingPluginKey, CellSelection, mergeCells, splitCell, selectedRect, findTable, deleteCellSelection, selectionCell, isInTable, addRow, addColumn, deleteRow, deleteColumn, toggleHeader as toggleHeader$1, moveTableRow, moveTableColumn, addRowBefore, addRowAfter, addColumnBefore, addColumnAfter, rowIsHeader, columnIsHeader } from '@tiptap/pm/tables';
|
|
@@ -303,7 +303,7 @@ var readOnlyGuardKey = new PluginKey("readOnlyGuard");
|
|
|
303
303
|
var IDENTITY_ATTRS = /* @__PURE__ */ new Set(["id", "data-toc-id"]);
|
|
304
304
|
function onlyIdsChanged(a, b) {
|
|
305
305
|
if (a.type !== b.type || a.childCount !== b.childCount || a.text !== b.text) return false;
|
|
306
|
-
if (!Mark.sameSet(a.marks, b.marks) || !sameAttrsExceptId(a.attrs, b.attrs)) return false;
|
|
306
|
+
if (!Mark$1.sameSet(a.marks, b.marks) || !sameAttrsExceptId(a.attrs, b.attrs)) return false;
|
|
307
307
|
for (let i = 0; i < a.childCount; i += 1) {
|
|
308
308
|
if (!onlyIdsChanged(a.child(i), b.child(i))) return false;
|
|
309
309
|
}
|
|
@@ -842,8 +842,8 @@ function feishuSurface(token, isDark) {
|
|
|
842
842
|
codeHeaderBg: "rgba(31, 35, 41, 0.04)",
|
|
843
843
|
codeDividerColor: "#dee0e3",
|
|
844
844
|
calloutBordered: true,
|
|
845
|
-
tableBorderColor: "
|
|
846
|
-
//
|
|
845
|
+
tableBorderColor: "#dee0e3",
|
|
846
|
+
// 飞书知识库 docx 实测单元格边框 N300
|
|
847
847
|
tableHeaderBg: "rgba(15, 22, 36, 0.05)",
|
|
848
848
|
// 迁移前 --tt-gray-light-a-100
|
|
849
849
|
tableRadius: 0,
|
|
@@ -2062,7 +2062,7 @@ ${isDark ? `:root .tt-block-marquee {
|
|
|
2062
2062
|
`;
|
|
2063
2063
|
|
|
2064
2064
|
// src/components/tiptap-node/blockquote-node/blockquote-node.style.ts
|
|
2065
|
-
var blockquoteNodeStyles = ({ isDark }) => `
|
|
2065
|
+
var blockquoteNodeStyles = ({ isDark, pick }) => `
|
|
2066
2066
|
.tiptap.ProseMirror {
|
|
2067
2067
|
/* 对齐飞书引用块:竖条 N400(#bbbfc4)、文字 N600(#646a73) */
|
|
2068
2068
|
/* (与 new-editor 编辑态 app 层的 --udtoken-quote-bar-bg/--text-caption 同源同值) */
|
|
@@ -2079,11 +2079,11 @@ var blockquoteNodeStyles = ({ isDark }) => `
|
|
|
2079
2079
|
BLOCKQUOTE
|
|
2080
2080
|
===================== */
|
|
2081
2081
|
.tiptap.ProseMirror {
|
|
2082
|
-
/* 对齐飞书:2px 竖条 + 12px 缩进 +
|
|
2082
|
+
/* 对齐飞书:2px 竖条 + 12px 缩进 + 灰色文字;飞书风块上下 8px(知识库 docx 实测) */
|
|
2083
2083
|
blockquote {
|
|
2084
2084
|
position: relative;
|
|
2085
2085
|
padding-left: 12px;
|
|
2086
|
-
margin: 16px 0;
|
|
2086
|
+
margin: ${pick("8px 0 8px 2px", "16px 0")};
|
|
2087
2087
|
color: var(--blockquote-text-color);
|
|
2088
2088
|
|
|
2089
2089
|
p {
|
|
@@ -2094,7 +2094,7 @@ var blockquoteNodeStyles = ({ isDark }) => `
|
|
|
2094
2094
|
&.is-empty::before {
|
|
2095
2095
|
position: absolute;
|
|
2096
2096
|
bottom: 0;
|
|
2097
|
-
left: 0;
|
|
2097
|
+
left: ${pick("-2px", "0")};
|
|
2098
2098
|
top: 0;
|
|
2099
2099
|
height: 100%;
|
|
2100
2100
|
width: 2px;
|
|
@@ -3286,7 +3286,7 @@ var cardStyles = ({ surface, gray }) => `
|
|
|
3286
3286
|
`;
|
|
3287
3287
|
|
|
3288
3288
|
// src/components/tiptap-node/code-block-node/code-block-node.style.ts
|
|
3289
|
-
var codeBlockStyles = ({ token, surface, gray }) => {
|
|
3289
|
+
var codeBlockStyles = ({ token, surface, gray, pick }) => {
|
|
3290
3290
|
const text = gray(800);
|
|
3291
3291
|
const muted = gray(600);
|
|
3292
3292
|
return `
|
|
@@ -3335,8 +3335,9 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
3335
3335
|
.tiptap-code-block {
|
|
3336
3336
|
position: relative;
|
|
3337
3337
|
margin: 16px 0;
|
|
3338
|
+
padding-bottom: ${pick("2px", "0")};
|
|
3338
3339
|
border: 1px solid ${surface.blockBorderColor};
|
|
3339
|
-
border-radius: ${surface.blockRadius}px;
|
|
3340
|
+
border-radius: ${pick("8px", `${surface.blockRadius}px`)};
|
|
3340
3341
|
background-color: ${surface.codeBg};
|
|
3341
3342
|
color: ${text};
|
|
3342
3343
|
|
|
@@ -3366,16 +3367,16 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
3366
3367
|
align-items: center;
|
|
3367
3368
|
justify-content: space-between;
|
|
3368
3369
|
gap: 8px;
|
|
3369
|
-
height: 24px;
|
|
3370
|
-
padding: 4px 8px 0;
|
|
3370
|
+
height: ${pick("32px", "24px")};
|
|
3371
|
+
padding: ${pick("8px 8px 0 12px", "4px 8px 0")};
|
|
3371
3372
|
border-radius: ${surface.blockRadius}px ${surface.blockRadius}px 0 0;
|
|
3372
3373
|
background: transparent;
|
|
3373
|
-
font-size: 12px;
|
|
3374
|
-
line-height: 20px;
|
|
3375
|
-
color: ${muted};
|
|
3374
|
+
font-size: ${pick("14px", "12px")};
|
|
3375
|
+
line-height: ${pick("22px", "20px")};
|
|
3376
|
+
color: ${pick("#646a73", muted)};
|
|
3376
3377
|
user-select: none;
|
|
3377
|
-
opacity: 0;
|
|
3378
|
-
pointer-events: none;
|
|
3378
|
+
opacity: ${pick("1", "0")};
|
|
3379
|
+
pointer-events: ${pick("auto", "none")};
|
|
3379
3380
|
transition: opacity 0.15s;
|
|
3380
3381
|
}
|
|
3381
3382
|
|
|
@@ -3386,9 +3387,14 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
3386
3387
|
}
|
|
3387
3388
|
|
|
3388
3389
|
.tiptap-code-block > pre {
|
|
3389
|
-
margin-top: 24px;
|
|
3390
|
-
padding-top: 4px
|
|
3391
|
-
|
|
3390
|
+
margin-top: ${pick("32px", "24px")};
|
|
3391
|
+
padding-top: ${pick("8px", "4px")};${pick(
|
|
3392
|
+
`
|
|
3393
|
+
padding-right: 20px;
|
|
3394
|
+
padding-bottom: 24px;`,
|
|
3395
|
+
""
|
|
3396
|
+
)}
|
|
3397
|
+
min-height: ${pick("61px", "53px")};
|
|
3392
3398
|
max-height: 1958px;
|
|
3393
3399
|
overflow-y: auto;
|
|
3394
3400
|
box-sizing: border-box;
|
|
@@ -3561,14 +3567,14 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
3561
3567
|
|
|
3562
3568
|
/* 行号:数字由 ::before 画,不进文档文本,复制不会带上 */
|
|
3563
3569
|
.tiptap-code-block__pre.has-line-numbers {
|
|
3564
|
-
padding-left: 3.5em;
|
|
3570
|
+
padding-left: ${pick("59px", "3.5em")};
|
|
3565
3571
|
}
|
|
3566
3572
|
|
|
3567
3573
|
.tt-code-line-number {
|
|
3568
3574
|
display: inline-block;
|
|
3569
|
-
width: 2.5em;
|
|
3570
|
-
margin-left: -3.5em;
|
|
3571
|
-
margin-right: 1em;
|
|
3575
|
+
width: ${pick("45px", "2.5em")};
|
|
3576
|
+
margin-left: ${pick("-59px", "-3.5em")};
|
|
3577
|
+
margin-right: ${pick("14px", "1em")};
|
|
3572
3578
|
text-align: right;
|
|
3573
3579
|
color: ${muted};
|
|
3574
3580
|
opacity: 0.7;
|
|
@@ -3880,7 +3886,7 @@ var codeGroupStyles = ({ token, surface, gray }) => `
|
|
|
3880
3886
|
`;
|
|
3881
3887
|
|
|
3882
3888
|
// src/components/tiptap-node/collapsible-node/collapsible-node.style.ts
|
|
3883
|
-
var collapsibleStyles = ({ token, surface, isDark, gray }) => `
|
|
3889
|
+
var collapsibleStyles = ({ token, surface, isDark, gray, pick }) => `
|
|
3884
3890
|
.tiptap.ProseMirror {
|
|
3885
3891
|
.tt-collapsible { position: relative; margin: 12px 0; }
|
|
3886
3892
|
.tt-collapsible__header { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 32px; user-select: none; }
|
|
@@ -3922,8 +3928,9 @@ var collapsibleStyles = ({ token, surface, isDark, gray }) => `
|
|
|
3922
3928
|
display: flex;
|
|
3923
3929
|
align-items: flex-start;
|
|
3924
3930
|
gap: 8px;
|
|
3925
|
-
|
|
3926
|
-
|
|
3931
|
+
/* 飞书知识库 docx:内边距 16,块下 16(上沿跟随前一块的 8px) */
|
|
3932
|
+
margin: ${pick("8px 0 16px", "12px 0")};
|
|
3933
|
+
padding: ${pick("16px", "12px 16px")};
|
|
3927
3934
|
/* 飞书描边、Notion 只铺底色 */
|
|
3928
3935
|
border: 1px solid ${surface.calloutBordered ? "var(--callout-border, var(--tt-color-callout-border-orange))" : "transparent"};
|
|
3929
3936
|
border-radius: ${surface.cardRadius}px;
|
|
@@ -4310,8 +4317,9 @@ var columnNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
4310
4317
|
[data-type="columns"],
|
|
4311
4318
|
.tiptap-columns {
|
|
4312
4319
|
display: grid;
|
|
4313
|
-
|
|
4314
|
-
|
|
4320
|
+
/* 飞书知识库 docx 实测:列间距 24,分栏块上下 16,列内首块不带上外边距 */
|
|
4321
|
+
gap: ${pick("24px", "1rem")};
|
|
4322
|
+
margin: ${pick("16px 0", "0.5em 0")};
|
|
4315
4323
|
}
|
|
4316
4324
|
|
|
4317
4325
|
[data-type="columns"].layout-column,
|
|
@@ -4334,6 +4342,18 @@ var columnNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
4334
4342
|
[data-type="column"] {
|
|
4335
4343
|
min-width: 0; /* 防止内容撑破网格列 */
|
|
4336
4344
|
}
|
|
4345
|
+
${pick(`
|
|
4346
|
+
/* 列是 grid 项,块的外边距出不了列;飞书列内首块不带上外边距、末块不带下外边距(图片的外边距在里层) */
|
|
4347
|
+
[data-type="column"] > :first-child,
|
|
4348
|
+
[data-type="column"] > :first-child > .tiptap-image,
|
|
4349
|
+
[data-type="column"] > .ProseMirror-widget:first-child + * {
|
|
4350
|
+
margin-top: 0;
|
|
4351
|
+
}
|
|
4352
|
+
|
|
4353
|
+
[data-type="column"] > :last-child,
|
|
4354
|
+
[data-type="column"] > :last-child > .tiptap-image {
|
|
4355
|
+
margin-bottom: 0;
|
|
4356
|
+
}`, "")}
|
|
4337
4357
|
|
|
4338
4358
|
/* React NodeView 在 grid 容器和列之间多包了一层 contentDOM,让它不参与布局,列才是 grid 的子项 */
|
|
4339
4359
|
.tiptap-columns > [data-node-view-content-react] {
|
|
@@ -4352,7 +4372,7 @@ var columnNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
4352
4372
|
/* 飞书按容器宽度(不足 578px)决定是否堆叠,所以用容器查询 */
|
|
4353
4373
|
.tiptap-columns-wrapper {
|
|
4354
4374
|
position: relative;
|
|
4355
|
-
margin: 0.5em 0;
|
|
4375
|
+
margin: ${pick("16px 0", "0.5em 0")};
|
|
4356
4376
|
container-type: inline-size;
|
|
4357
4377
|
|
|
4358
4378
|
.tiptap-columns {
|
|
@@ -6083,6 +6103,7 @@ var headingNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
6083
6103
|
/* 标题字号/行高/字重/间距对齐飞书文档(帮助中心文章页实测值): */
|
|
6084
6104
|
/* h1 26/36 600 · h2 22/30 600 · h3 20/28 600 · h4 18/26 500 · h5/h6 16/26 500, */
|
|
6085
6105
|
/* margin-top 等于自身字号,margin-bottom 8px(h1 为 10px)。 */
|
|
6106
|
+
/* 飞书风另按知识库 docx 实测:h1–h3 字重 500(加粗文字才 700)、行高 1.4、字距 -0.02em。 */
|
|
6086
6107
|
.tiptap.ProseMirror {
|
|
6087
6108
|
h1,
|
|
6088
6109
|
h2,
|
|
@@ -6093,6 +6114,7 @@ var headingNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
6093
6114
|
position: relative;
|
|
6094
6115
|
color: inherit;
|
|
6095
6116
|
font-style: inherit;
|
|
6117
|
+
letter-spacing: ${pick("-0.02em", "normal")};
|
|
6096
6118
|
}
|
|
6097
6119
|
|
|
6098
6120
|
> h1:first-child,
|
|
@@ -6110,18 +6132,28 @@ var headingNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
6110
6132
|
margin-top: 0;
|
|
6111
6133
|
}
|
|
6112
6134
|
|
|
6113
|
-
|
|
6135
|
+
${pick(` /* 飞书标题底色是 6px 圆角的蒙层 */
|
|
6136
|
+
h1[style*="background-color"],
|
|
6137
|
+
h2[style*="background-color"],
|
|
6138
|
+
h3[style*="background-color"],
|
|
6139
|
+
h4[style*="background-color"],
|
|
6140
|
+
h5[style*="background-color"],
|
|
6141
|
+
h6[style*="background-color"] {
|
|
6142
|
+
border-radius: 6px;
|
|
6143
|
+
}
|
|
6144
|
+
|
|
6145
|
+
`, "")} h1 {
|
|
6114
6146
|
font-size: 26px;
|
|
6115
|
-
line-height: 36px;
|
|
6116
|
-
font-weight: 600;
|
|
6147
|
+
line-height: ${pick("36.4px", "36px")};
|
|
6148
|
+
font-weight: ${pick("500", "600")};
|
|
6117
6149
|
margin-top: 26px;
|
|
6118
6150
|
margin-bottom: 10px;
|
|
6119
6151
|
}
|
|
6120
6152
|
|
|
6121
6153
|
h2 {
|
|
6122
6154
|
font-size: 22px;
|
|
6123
|
-
line-height: 30px;
|
|
6124
|
-
font-weight: 600;
|
|
6155
|
+
line-height: ${pick("30.8px", "30px")};
|
|
6156
|
+
font-weight: ${pick("500", "600")};
|
|
6125
6157
|
margin-top: 22px;
|
|
6126
6158
|
margin-bottom: 8px;
|
|
6127
6159
|
}
|
|
@@ -6129,14 +6161,14 @@ var headingNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
6129
6161
|
h3 {
|
|
6130
6162
|
font-size: 20px;
|
|
6131
6163
|
line-height: 28px;
|
|
6132
|
-
font-weight: 600;
|
|
6164
|
+
font-weight: ${pick("500", "600")};
|
|
6133
6165
|
margin-top: 20px;
|
|
6134
6166
|
margin-bottom: 8px;
|
|
6135
6167
|
}
|
|
6136
6168
|
|
|
6137
6169
|
h4 {
|
|
6138
6170
|
font-size: 18px;
|
|
6139
|
-
line-height: 26px;
|
|
6171
|
+
line-height: ${pick("25.2px", "26px")};
|
|
6140
6172
|
font-weight: 500;
|
|
6141
6173
|
margin-top: 18px;
|
|
6142
6174
|
margin-bottom: 8px;
|
|
@@ -6156,6 +6188,7 @@ var headingNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
6156
6188
|
.tiptap.ProseMirror {
|
|
6157
6189
|
[data-heading-level] {
|
|
6158
6190
|
position: relative;
|
|
6191
|
+
letter-spacing: ${pick("-0.02em", "normal")};
|
|
6159
6192
|
font-size: 16px;
|
|
6160
6193
|
line-height: 26px;
|
|
6161
6194
|
font-weight: 500;
|
|
@@ -6369,7 +6402,7 @@ var headingNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
6369
6402
|
`;
|
|
6370
6403
|
|
|
6371
6404
|
// src/components/tiptap-node/horizontal-rule-node/horizontal-rule-node.style.ts
|
|
6372
|
-
var horizontalRuleNodeStyles = ({ isDark }) => `
|
|
6405
|
+
var horizontalRuleNodeStyles = ({ isDark, pick }) => `
|
|
6373
6406
|
.tiptap.ProseMirror {
|
|
6374
6407
|
--horizontal-rule-color: var(--tt-gray-light-a-200);
|
|
6375
6408
|
|
|
@@ -6384,15 +6417,17 @@ var horizontalRuleNodeStyles = ({ isDark }) => `
|
|
|
6384
6417
|
.tiptap.ProseMirror {
|
|
6385
6418
|
hr {
|
|
6386
6419
|
border: none;
|
|
6387
|
-
height: 1px
|
|
6420
|
+
height: 1px;${pick(`
|
|
6421
|
+
margin: 0;`, "")}
|
|
6388
6422
|
background-color: var(--horizontal-rule-color);
|
|
6389
6423
|
}
|
|
6390
6424
|
|
|
6425
|
+
/* 飞书分割线块:上下 8px、内边距 12px,整块高 25px */
|
|
6391
6426
|
[data-type="horizontalRule"] {
|
|
6392
|
-
margin-top: 2.25em;
|
|
6393
|
-
margin-bottom: 2.25em;
|
|
6394
|
-
padding-top: 0.75rem;
|
|
6395
|
-
padding-bottom: 0.75rem;
|
|
6427
|
+
margin-top: ${pick("8px", "2.25em")};
|
|
6428
|
+
margin-bottom: ${pick("8px", "2.25em")};
|
|
6429
|
+
padding-top: ${pick("12px", "0.75rem")};
|
|
6430
|
+
padding-bottom: ${pick("12px", "0.75rem")};
|
|
6396
6431
|
}
|
|
6397
6432
|
}
|
|
6398
6433
|
`;
|
|
@@ -6456,7 +6491,7 @@ ${isDark ? `:root {
|
|
|
6456
6491
|
.tiptap-image {
|
|
6457
6492
|
display: flex;
|
|
6458
6493
|
width: 100%;
|
|
6459
|
-
margin: 1.5rem 0;
|
|
6494
|
+
margin: ${pick("16px 0", "1.5rem 0")};
|
|
6460
6495
|
|
|
6461
6496
|
&[data-align="right"] {
|
|
6462
6497
|
text-align: right;
|
|
@@ -6497,6 +6532,11 @@ ${isDark ? `:root {
|
|
|
6497
6532
|
border-radius: var(--tt-radius-xs, 0.25rem);
|
|
6498
6533
|
}
|
|
6499
6534
|
|
|
6535
|
+
/* 加载前按节点记的宽高比占位(见 image-transform.tsx),给个浅底,别是一块看不见的空白 */
|
|
6536
|
+
.tiptap-image-img[data-pending] {
|
|
6537
|
+
background: var(${isDark ? "--tt-gray-dark-a-100" : "--tt-gray-light-a-100"});
|
|
6538
|
+
}
|
|
6539
|
+
|
|
6500
6540
|
.tiptap-image-handle {
|
|
6501
6541
|
position: absolute;
|
|
6502
6542
|
top: 50%;
|
|
@@ -6525,7 +6565,7 @@ ${isDark ? `:root {
|
|
|
6525
6565
|
width: 100%;
|
|
6526
6566
|
white-space: break-spaces;
|
|
6527
6567
|
word-break: break-word;
|
|
6528
|
-
margin-top: 1rem;
|
|
6568
|
+
margin-top: ${pick("8px", "1rem")};
|
|
6529
6569
|
outline: none;
|
|
6530
6570
|
position: relative;
|
|
6531
6571
|
|
|
@@ -8138,6 +8178,8 @@ var listNodeStyles = ({ pick, surface, isDark }) => `
|
|
|
8138
8178
|
ul:not([data-type="taskList"]) > li::marker {
|
|
8139
8179
|
color: var(--tt-list-marker-color);
|
|
8140
8180
|
font-size: 1.2em;
|
|
8181
|
+
/* 放大后的 bullet 若沿用 1.625 行高(31px)会把每行撑高 3px */
|
|
8182
|
+
line-height: 1;
|
|
8141
8183
|
}
|
|
8142
8184
|
|
|
8143
8185
|
ul:not([data-type="taskList"]) {
|
|
@@ -8879,7 +8921,7 @@ var mermaidNodeStyles = ({ pick, surface }) => `
|
|
|
8879
8921
|
`;
|
|
8880
8922
|
|
|
8881
8923
|
// src/components/tiptap-templates/notion-like/notion-like-editor-header.style.ts
|
|
8882
|
-
var notionLikeEditorHeaderStyles = ({ surface, pick, isDark }) => `
|
|
8924
|
+
var notionLikeEditorHeaderStyles = ({ token, surface, pick, isDark }) => `
|
|
8883
8925
|
:root {
|
|
8884
8926
|
--tt-notion-like-editor-header-border: var(--tt-gray-light-a-200);
|
|
8885
8927
|
--tt-notion-like-editor-header-bg: var(--white);
|
|
@@ -8896,7 +8938,9 @@ ${isDark ? `:root {
|
|
|
8896
8938
|
width: 100%;
|
|
8897
8939
|
display: flex;
|
|
8898
8940
|
align-items: center;
|
|
8899
|
-
height: 3rem;
|
|
8941
|
+
min-height: 3rem;
|
|
8942
|
+
box-sizing: border-box;
|
|
8943
|
+
gap: 0.5rem;
|
|
8900
8944
|
padding: 0.5rem 0.75rem;
|
|
8901
8945
|
z-index: 50;
|
|
8902
8946
|
background-color: var(--tt-notion-like-editor-header-bg);
|
|
@@ -8906,14 +8950,189 @@ ${isDark ? `:root {
|
|
|
8906
8950
|
display: flex;
|
|
8907
8951
|
align-items: center;
|
|
8908
8952
|
flex-direction: row;
|
|
8953
|
+
flex-shrink: 0;
|
|
8954
|
+
gap: 0.25rem;
|
|
8955
|
+
}
|
|
8956
|
+
|
|
8957
|
+
&-feedback {
|
|
8958
|
+
display: flex;
|
|
8959
|
+
align-items: center;
|
|
8960
|
+
flex-shrink: 0;
|
|
8961
|
+
gap: 0.375rem;
|
|
8962
|
+
}
|
|
8963
|
+
|
|
8964
|
+
button:focus-visible {
|
|
8965
|
+
outline: 2px solid ${surface.accentColor};
|
|
8966
|
+
outline-offset: 2px;
|
|
8967
|
+
}
|
|
8968
|
+
}
|
|
8969
|
+
|
|
8970
|
+
.notion-like-editor-save-state {
|
|
8971
|
+
display: flex;
|
|
8972
|
+
align-items: center;
|
|
8973
|
+
gap: 0.375rem;
|
|
8974
|
+
color: ${surface.textSecondary};
|
|
8975
|
+
font-size: 0.75rem;
|
|
8976
|
+
line-height: 1.5rem;
|
|
8977
|
+
white-space: nowrap;
|
|
8978
|
+
|
|
8979
|
+
&[data-save-state="error"] {
|
|
8980
|
+
color: ${token.colorError};
|
|
8981
|
+
}
|
|
8982
|
+
|
|
8983
|
+
&[data-save-state="offline"] {
|
|
8984
|
+
color: ${token.colorWarningText};
|
|
8985
|
+
}
|
|
8986
|
+
|
|
8987
|
+
&-indicator {
|
|
8988
|
+
width: 0.375rem;
|
|
8989
|
+
height: 0.375rem;
|
|
8990
|
+
border-radius: 50%;
|
|
8991
|
+
background: currentColor;
|
|
8992
|
+
}
|
|
8993
|
+
|
|
8994
|
+
&[data-save-state="saving"] &-indicator {
|
|
8995
|
+
width: 0.625rem;
|
|
8996
|
+
height: 0.625rem;
|
|
8997
|
+
box-sizing: border-box;
|
|
8998
|
+
border: 1px solid currentColor;
|
|
8999
|
+
border-right-color: transparent;
|
|
9000
|
+
background: transparent;
|
|
9001
|
+
animation: notion-like-editor-saving 0.8s linear infinite;
|
|
9002
|
+
}
|
|
9003
|
+
}
|
|
9004
|
+
|
|
9005
|
+
.notion-like-editor-header .notion-like-editor-share {
|
|
9006
|
+
padding-inline: 0.875rem;
|
|
9007
|
+
color: ${token.colorTextLightSolid};
|
|
9008
|
+
background: ${surface.accentColor};
|
|
9009
|
+
|
|
9010
|
+
&:hover {
|
|
9011
|
+
color: ${token.colorTextLightSolid};
|
|
9012
|
+
background: ${token.colorPrimaryHover};
|
|
9013
|
+
}
|
|
9014
|
+
}
|
|
9015
|
+
|
|
9016
|
+
.notion-like-editor-comment-count {
|
|
9017
|
+
min-width: 0.75rem;
|
|
9018
|
+
font-variant-numeric: tabular-nums;
|
|
9019
|
+
}
|
|
9020
|
+
|
|
9021
|
+
.notion-like-editor-menu {
|
|
9022
|
+
height: auto;
|
|
9023
|
+
min-width: 11rem;
|
|
9024
|
+
max-width: calc(100vw - 1rem);
|
|
9025
|
+
padding: 0.375rem;
|
|
9026
|
+
border: 1px solid ${surface.floatBorderColor};
|
|
9027
|
+
border-radius: ${surface.floatRadius}px;
|
|
9028
|
+
color: ${surface.colorText};
|
|
9029
|
+
background: ${surface.floatBg};
|
|
9030
|
+
box-shadow: ${surface.floatShadow};
|
|
9031
|
+
z-index: 60;
|
|
9032
|
+
|
|
9033
|
+
.tiptap-menu-group {
|
|
9034
|
+
display: block;
|
|
9035
|
+
}
|
|
9036
|
+
|
|
9037
|
+
.tiptap-menu-group-label {
|
|
9038
|
+
margin-top: 0.25rem;
|
|
9039
|
+
color: ${surface.textSecondary};
|
|
9040
|
+
}
|
|
9041
|
+
|
|
9042
|
+
&-item {
|
|
9043
|
+
display: flex;
|
|
9044
|
+
align-items: center;
|
|
9045
|
+
justify-content: flex-start;
|
|
8909
9046
|
gap: 0.5rem;
|
|
9047
|
+
min-height: 2rem;
|
|
9048
|
+
padding: 0.375rem 0.5rem;
|
|
9049
|
+
border-radius: ${surface.itemRadius}px;
|
|
9050
|
+
font-size: 0.875rem;
|
|
9051
|
+
line-height: 1.25rem;
|
|
9052
|
+
cursor: pointer;
|
|
9053
|
+
outline: none;
|
|
9054
|
+
|
|
9055
|
+
&:hover,
|
|
9056
|
+
&[data-active-item] {
|
|
9057
|
+
background: ${surface.itemHoverBg};
|
|
9058
|
+
}
|
|
9059
|
+
|
|
9060
|
+
&:focus-visible {
|
|
9061
|
+
outline: 2px solid ${surface.accentColor};
|
|
9062
|
+
outline-offset: -2px;
|
|
9063
|
+
}
|
|
9064
|
+
|
|
9065
|
+
.tiptap-button-icon,
|
|
9066
|
+
.tiptap-menu-item-check {
|
|
9067
|
+
width: 1rem;
|
|
9068
|
+
height: 1rem;
|
|
9069
|
+
}
|
|
9070
|
+
|
|
9071
|
+
.tiptap-menu-item-check {
|
|
9072
|
+
margin-left: auto;
|
|
9073
|
+
}
|
|
9074
|
+
}
|
|
9075
|
+
|
|
9076
|
+
&-separator {
|
|
9077
|
+
margin: 0.375rem 0;
|
|
9078
|
+
border: 0;
|
|
9079
|
+
border-top: 1px solid ${surface.dividerColor};
|
|
9080
|
+
}
|
|
9081
|
+
|
|
9082
|
+
&-note {
|
|
9083
|
+
padding: 0.375rem 0.5rem;
|
|
9084
|
+
color: ${surface.textSecondary};
|
|
9085
|
+
font-size: 0.75rem;
|
|
9086
|
+
line-height: 1.25rem;
|
|
9087
|
+
}
|
|
9088
|
+
}
|
|
9089
|
+
|
|
9090
|
+
@keyframes notion-like-editor-saving {
|
|
9091
|
+
to { transform: rotate(360deg); }
|
|
9092
|
+
}
|
|
9093
|
+
|
|
9094
|
+
@media (prefers-reduced-motion: reduce) {
|
|
9095
|
+
.notion-like-editor-save-state-indicator {
|
|
9096
|
+
animation: none !important;
|
|
9097
|
+
}
|
|
9098
|
+
}
|
|
9099
|
+
|
|
9100
|
+
@media (max-width: 640px) {
|
|
9101
|
+
.notion-like-editor-header {
|
|
9102
|
+
flex-wrap: wrap;
|
|
9103
|
+
padding-inline: 0.5rem;
|
|
9104
|
+
|
|
9105
|
+
&-feedback {
|
|
9106
|
+
flex-basis: 100%;
|
|
9107
|
+
}
|
|
9108
|
+
|
|
9109
|
+
&-actions {
|
|
9110
|
+
margin-left: auto;
|
|
9111
|
+
}
|
|
8910
9112
|
}
|
|
8911
9113
|
}
|
|
8912
9114
|
`;
|
|
8913
9115
|
|
|
8914
9116
|
// src/components/tiptap-templates/notion-like/notion-like-editor.style.ts
|
|
8915
|
-
var
|
|
8916
|
-
|
|
9117
|
+
var ARTICLE_FONT_STACK = '"Segoe UI Emoji", "Helvetica Neue", -apple-system, BlinkMacSystemFont, "PingFang SC", Roboto, "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", "Hiragino Sans", "Lucida Grande", sans-serif';
|
|
9118
|
+
var DOCX_FONT_STACK = 'TTChineseQuote, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Tahoma, "PingFang SC", "Microsoft Yahei", Arial, "Hiragino Sans GB", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
9119
|
+
var CHINESE_QUOTE_FACES = [
|
|
9120
|
+
["400", 'local("PingFangSC-Regular"), local("PingFang SC"), local("Microsoft YaHei"), local("Hiragino Sans GB")'],
|
|
9121
|
+
["500", 'local("PingFangSC-Medium"), local("PingFang SC Medium"), local("Microsoft YaHei"), local("Hiragino Sans GB")'],
|
|
9122
|
+
["600", 'local("PingFangSC-Semibold"), local("PingFang SC Semibold"), local("Microsoft YaHei Bold"), local("Hiragino Sans GB W6")'],
|
|
9123
|
+
["700", 'local("PingFangSC-Semibold"), local("PingFang SC Semibold"), local("Microsoft YaHei Bold"), local("Hiragino Sans GB W6")']
|
|
9124
|
+
].map(
|
|
9125
|
+
([weight, src]) => `@font-face {
|
|
9126
|
+
font-family: TTChineseQuote;
|
|
9127
|
+
font-weight: ${weight};
|
|
9128
|
+
src: ${src};
|
|
9129
|
+
unicode-range: U+2018, U+2019, U+201A, U+201C, U+201D, U+201E;
|
|
9130
|
+
}`
|
|
9131
|
+
).join("\n");
|
|
9132
|
+
var notionLikeEditorStyles = ({ surface, pick }) => `
|
|
9133
|
+
${pick(CHINESE_QUOTE_FACES, "")}
|
|
9134
|
+
|
|
9135
|
+
/* 正文字体栈对齐飞书(Notion 风沿用 feishu.cn 文章页实测值,飞书风用知识库 docx 实测值),纯系统字体、无外网字体依赖 */
|
|
8917
9136
|
/* (原 Google Fonts 的 DM Sans/Inter 在内网/无外网环境加载失败,中文全靠 sans-serif 兜底)。 */
|
|
8918
9137
|
/* "Segoe UI Emoji" 放最前是飞书的做法:Windows 上 emoji 走彩色字体,文本字符自动落到后面的正文字体。 */
|
|
8919
9138
|
/* 正文色读表面 token surface.colorText(src/theme/editor-theme.ts:Notion #2c2c2b / 飞书 N900 #1f2329)。 */
|
|
@@ -8924,7 +9143,7 @@ var notionLikeEditorStyles = ({ surface }) => `
|
|
|
8924
9143
|
/* Helvetica Neue 的 0.517,整站文字缩小 1.7%,切换文章(编辑器卸载再挂载)时全站字体抖一下。 */
|
|
8925
9144
|
/* 页面底色、overscroll 归宿主管;独立整页编辑器的宿主页面自己设。 */
|
|
8926
9145
|
.notion-like-editor-wrapper {
|
|
8927
|
-
font-family:
|
|
9146
|
+
font-family: ${pick(DOCX_FONT_STACK, ARTICLE_FONT_STACK)};
|
|
8928
9147
|
color: ${surface.colorText};
|
|
8929
9148
|
font-weight: 400;
|
|
8930
9149
|
font-style: normal;
|
|
@@ -8953,7 +9172,10 @@ var notionLikeEditorStyles = ({ surface }) => `
|
|
|
8953
9172
|
}
|
|
8954
9173
|
|
|
8955
9174
|
.tiptap.ProseMirror {
|
|
8956
|
-
font-family:
|
|
9175
|
+
font-family: ${pick(DOCX_FONT_STACK, ARTICLE_FONT_STACK)};${pick(`
|
|
9176
|
+
/* 飞书 docx 正文:行尾放不下的空格也折到下一行(break-spaces),长串在任意处断行 */
|
|
9177
|
+
white-space: break-spaces;
|
|
9178
|
+
word-break: break-word;`, "")}
|
|
8957
9179
|
/* 正文基准对齐飞书文档:16px / 1.625 / #1f2329。 */
|
|
8958
9180
|
/* 字号必须显式定在编辑器根上:li>p、td/th p 等不走 paragraph-node.scss 的 */
|
|
8959
9181
|
/* p:not(:first-child) 字号声明,全靠这里继承;不写会继承宿主容器字号 */
|
|
@@ -8975,7 +9197,7 @@ var notionLikeEditorStyles = ({ surface }) => `
|
|
|
8975
9197
|
/* 用 :not() 写在原规则上而不是后面再覆盖一遍——两个类同特异性,靠源序决胜负太脆。 */
|
|
8976
9198
|
@media screen and (max-width: 480px) {
|
|
8977
9199
|
.notion-like-editor-wrapper:not(.notion-like-editor-wrapper--embedded) {
|
|
8978
|
-
width:
|
|
9200
|
+
width: 100%;
|
|
8979
9201
|
height: 100vh;
|
|
8980
9202
|
overflow: auto;
|
|
8981
9203
|
}
|
|
@@ -9307,17 +9529,22 @@ var orderedListNumberMenuStyles = ({ surface, pick }) => `
|
|
|
9307
9529
|
// src/components/tiptap-node/page-header-node/page-header-node.style.ts
|
|
9308
9530
|
var pageHeaderNodeStyles = ({ surface, pick, isDark }) => `
|
|
9309
9531
|
/* 文档页头:封面 → 添加图标 / 添加封面 → 图标 + 标题,尺寸对齐飞书(标题 40px / 粗体,封面高 200px) */
|
|
9532
|
+
${pick(`.notion-like-editor-layout {
|
|
9533
|
+
container-type: inline-size;
|
|
9534
|
+
}`, "")}
|
|
9535
|
+
|
|
9310
9536
|
.tiptap.ProseMirror {
|
|
9311
9537
|
.tt-page-header {
|
|
9312
9538
|
position: relative;
|
|
9313
9539
|
margin: 0 0 16px;
|
|
9314
9540
|
}
|
|
9315
9541
|
|
|
9316
|
-
/*
|
|
9542
|
+
/* 封面横向铺满正文列,左右多出正文内边距那一截,和飞书一样贴边;
|
|
9543
|
+
飞书风按知识库 docx:横跨整个编辑器布局区(不止正文列),高度由宿主用 --tt-page-cover-height 给 */
|
|
9317
9544
|
.tt-page-header__cover {
|
|
9318
9545
|
position: relative;
|
|
9319
|
-
height: 200px;
|
|
9320
|
-
margin: -3rem -3rem 0;
|
|
9546
|
+
height: var(--tt-page-cover-height, 200px);
|
|
9547
|
+
margin: ${pick("-3rem calc(50% - 50cqw) 0", "-3rem -3rem 0")};
|
|
9321
9548
|
user-select: none;
|
|
9322
9549
|
|
|
9323
9550
|
&[data-repositioning="true"] {
|
|
@@ -9359,6 +9586,21 @@ var pageHeaderNodeStyles = ({ surface, pick, isDark }) => `
|
|
|
9359
9586
|
align-items: baseline;
|
|
9360
9587
|
}
|
|
9361
9588
|
|
|
9589
|
+
/* 飞书知识库 docx:封面下 20px 内边距 + 28px「添加图标 / 封面」行,只读时这行也占位 */
|
|
9590
|
+
${pick(`.tt-page-header__cover + .tt-page-header__title-row {
|
|
9591
|
+
margin-top: 48px;
|
|
9592
|
+
}
|
|
9593
|
+
|
|
9594
|
+
.tt-page-header__add {
|
|
9595
|
+
margin: 20px 0 0;
|
|
9596
|
+
}
|
|
9597
|
+
|
|
9598
|
+
/* 页头下第一块不再叠加自身上外边距,和飞书一样从页头底部固定间距开始 */
|
|
9599
|
+
> .node-pageHeader + *,
|
|
9600
|
+
> [data-page-header] + * {
|
|
9601
|
+
margin-top: 0;
|
|
9602
|
+
}`, "")}
|
|
9603
|
+
|
|
9362
9604
|
.tt-page-header__title-row > .tt-page-header__title {
|
|
9363
9605
|
flex: 1;
|
|
9364
9606
|
min-width: 0;
|
|
@@ -9369,7 +9611,7 @@ var pageHeaderNodeStyles = ({ surface, pick, isDark }) => `
|
|
|
9369
9611
|
flex: none;
|
|
9370
9612
|
margin-right: 6px;
|
|
9371
9613
|
font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
|
|
9372
|
-
font-size: 40px;
|
|
9614
|
+
font-size: ${pick("34px", "40px")};
|
|
9373
9615
|
line-height: 1;
|
|
9374
9616
|
|
|
9375
9617
|
button,
|
|
@@ -9377,8 +9619,8 @@ var pageHeaderNodeStyles = ({ surface, pick, isDark }) => `
|
|
|
9377
9619
|
display: flex;
|
|
9378
9620
|
align-items: center;
|
|
9379
9621
|
justify-content: center;
|
|
9380
|
-
width: 1.18em;
|
|
9381
|
-
height: 1.18em;
|
|
9622
|
+
width: ${pick("40px", "1.18em")};
|
|
9623
|
+
height: ${pick("40px", "1.18em")};
|
|
9382
9624
|
padding: 0;
|
|
9383
9625
|
border: none;
|
|
9384
9626
|
border-radius: ${pick("6px", `${surface.inputRadius}px`)};
|
|
@@ -9433,9 +9675,9 @@ var pageHeaderNodeStyles = ({ surface, pick, isDark }) => `
|
|
|
9433
9675
|
}
|
|
9434
9676
|
|
|
9435
9677
|
.tt-page-header__title {
|
|
9436
|
-
font-size: 40px;
|
|
9437
|
-
line-height: 52px;
|
|
9438
|
-
font-weight: 700;
|
|
9678
|
+
font-size: ${pick("34px", "40px")};
|
|
9679
|
+
line-height: ${pick("55.25px", "52px")};
|
|
9680
|
+
font-weight: ${pick("500", "700")};
|
|
9439
9681
|
color: var(--tt-color-text);
|
|
9440
9682
|
word-break: break-word;
|
|
9441
9683
|
}
|
|
@@ -9718,6 +9960,11 @@ var paragraphNodeStyles = ({ isDark }) => `
|
|
|
9718
9960
|
/* 段距对齐飞书(每个段落行 margin 8px,首段 0);字号/行高统一继承编辑器根 */
|
|
9719
9961
|
/* (notion-like-editor.scss 的 16px/1.625),这里不再重复声明——重复声明会让 */
|
|
9720
9962
|
/* 被 :not() 排除的 li>p、td/th p 与普通段落走上不同的字号来源。 */
|
|
9963
|
+
/* 浏览器默认 p 有 1em 下边距:不清掉的话段距变 16px、列表项间距变 16~24px */
|
|
9964
|
+
p {
|
|
9965
|
+
margin-bottom: 0;
|
|
9966
|
+
}
|
|
9967
|
+
|
|
9721
9968
|
p:not(:first-child):not(td p):not(th p) {
|
|
9722
9969
|
margin-top: 8px;
|
|
9723
9970
|
}
|
|
@@ -11616,6 +11863,15 @@ var syncedBlockStyles = ({ surface, pick, isDark }) => `
|
|
|
11616
11863
|
linear-gradient(135deg, rgb(var(--tt-synced-a)), rgb(var(--tt-synced-b)), rgb(var(--tt-synced-c)));
|
|
11617
11864
|
}
|
|
11618
11865
|
|
|
11866
|
+
/* 飞书只读同步块:内容紧贴内边距,首块不带上外边距、末块不带下外边距 */
|
|
11867
|
+
${pick(`.tt-synced-block__content > * > :first-child {
|
|
11868
|
+
margin-top: 0;
|
|
11869
|
+
}
|
|
11870
|
+
|
|
11871
|
+
.tt-synced-block__content > * > :last-child {
|
|
11872
|
+
margin-bottom: 0;
|
|
11873
|
+
}`, "")}
|
|
11874
|
+
|
|
11619
11875
|
&.ProseMirror-selectednode,
|
|
11620
11876
|
.tt-block-selected > & {
|
|
11621
11877
|
border-color: #245bdb;
|
|
@@ -12255,10 +12511,25 @@ var tableInsertBarsStyles = ({ pick, surface }) => `
|
|
|
12255
12511
|
`;
|
|
12256
12512
|
|
|
12257
12513
|
// src/components/tiptap-node/table-node/styles/table-node.style.ts
|
|
12258
|
-
var tableStyles = ({ token, surface }) => `
|
|
12514
|
+
var tableStyles = ({ token, surface, pick }) => `
|
|
12515
|
+
/* 飞书知识库 docx:表格上沿距前一块 29.5(扣掉包裹层留给手柄的 16 内边距);
|
|
12516
|
+
下沿是「表格 + 2 + max(24, 下一块上外边距)」,只读时没有「添加行」按钮,底部内边距让给外边距去折叠 */
|
|
12259
12517
|
.tiptap [data-content-type="table"] {
|
|
12260
|
-
margin-block: var(--tt-table-margin-block);
|
|
12518
|
+
margin-block: ${pick("13.5px 2px", "var(--tt-table-margin-block)")};
|
|
12261
12519
|
}
|
|
12520
|
+
${pick(
|
|
12521
|
+
`
|
|
12522
|
+
.notion-like-editor-wrapper--readonly .tiptap [data-content-type="table"] {
|
|
12523
|
+
margin-block-end: 24px;
|
|
12524
|
+
}
|
|
12525
|
+
|
|
12526
|
+
.notion-like-editor-wrapper--readonly .tiptap [data-content-type="table"] .tableWrapper {
|
|
12527
|
+
margin-left: 0;
|
|
12528
|
+
padding-inline: 0;
|
|
12529
|
+
padding-block-end: 2px;
|
|
12530
|
+
}`,
|
|
12531
|
+
""
|
|
12532
|
+
)}
|
|
12262
12533
|
|
|
12263
12534
|
.tiptap [data-content-type="table"] .tableWrapper {
|
|
12264
12535
|
padding-block-start: var(--tt-table-pad-block-start);
|
|
@@ -12281,7 +12552,7 @@ var tableStyles = ({ token, surface }) => `
|
|
|
12281
12552
|
border: 1px solid ${surface.tableBorderColor};
|
|
12282
12553
|
padding: var(--tt-table-cell-padding);
|
|
12283
12554
|
}
|
|
12284
|
-
${surface.tableRadius ? roundedTable(surface.tableRadius, surface.tableBorderColor) :
|
|
12555
|
+
${surface.tableRadius ? roundedTable(surface.tableRadius, surface.tableBorderColor) : squareTable(surface.tableBorderColor)}
|
|
12285
12556
|
/* 单元格里的段落没走正文段距(被 :not(td p) 排除),会吃到浏览器默认的上下 1em,行高撑到 75px */
|
|
12286
12557
|
.tiptap th > p,
|
|
12287
12558
|
.tiptap td > p {
|
|
@@ -12487,6 +12758,43 @@ function roundedTable(radius, color) {
|
|
|
12487
12758
|
}
|
|
12488
12759
|
`;
|
|
12489
12760
|
}
|
|
12761
|
+
function squareTable(color) {
|
|
12762
|
+
return `
|
|
12763
|
+
.tiptap table {
|
|
12764
|
+
border-collapse: separate;
|
|
12765
|
+
border-spacing: 0;
|
|
12766
|
+
border: 0;
|
|
12767
|
+
border-radius: 0;
|
|
12768
|
+
table-layout: fixed;
|
|
12769
|
+
}
|
|
12770
|
+
|
|
12771
|
+
.tiptap th,
|
|
12772
|
+
.tiptap td {
|
|
12773
|
+
border: 0;
|
|
12774
|
+
border-right: 1px solid ${color};
|
|
12775
|
+
border-bottom: 1px solid ${color};
|
|
12776
|
+
font-size: 14px;
|
|
12777
|
+
line-height: 23px;
|
|
12778
|
+
}
|
|
12779
|
+
|
|
12780
|
+
.tiptap tr:first-child > * {
|
|
12781
|
+
border-top: 1px solid ${color};
|
|
12782
|
+
}
|
|
12783
|
+
|
|
12784
|
+
.tiptap tr > :first-child {
|
|
12785
|
+
box-shadow: inset 1px 0 0 ${color};
|
|
12786
|
+
}
|
|
12787
|
+
|
|
12788
|
+
/* 单元格里的标题等块:首块不带上外边距、末块不带下外边距 */
|
|
12789
|
+
.tiptap :is(td, th) > :first-child {
|
|
12790
|
+
margin-top: 0;
|
|
12791
|
+
}
|
|
12792
|
+
|
|
12793
|
+
.tiptap :is(td, th) > :last-child {
|
|
12794
|
+
margin-bottom: 0;
|
|
12795
|
+
}
|
|
12796
|
+
`;
|
|
12797
|
+
}
|
|
12490
12798
|
|
|
12491
12799
|
// src/components/tiptap-ui-primitive/textarea/textarea.style.ts
|
|
12492
12800
|
var textareaStyles = ({ surface, pick, isDark }) => `
|
|
@@ -12693,7 +13001,7 @@ var tocSidebarStyles = ({ pick, surface, isDark }) => `
|
|
|
12693
13001
|
--toc-progress-width-base: 1rem; /* Base width for progress lines (16px) */
|
|
12694
13002
|
--toc-progress-width-min: 0.25rem; /* Minimum width for progress lines (4px) */
|
|
12695
13003
|
/* 目录最高到视口底部(sticky top 130px,再留出底部边距) */
|
|
12696
|
-
--toc-max-height: calc(
|
|
13004
|
+
--toc-max-height: calc(100dvh - 130px - 4rem);
|
|
12697
13005
|
|
|
12698
13006
|
${isDark ? `:root & {
|
|
12699
13007
|
--tt-toc-sidebar-line-bg: var(--tt-gray-dark-200);
|
|
@@ -12746,6 +13054,38 @@ var tocSidebarStyles = ({ pick, surface, isDark }) => `
|
|
|
12746
13054
|
padding-bottom: 0.75rem;
|
|
12747
13055
|
}
|
|
12748
13056
|
|
|
13057
|
+
&-toggle {
|
|
13058
|
+
display: inline-flex;
|
|
13059
|
+
align-items: center;
|
|
13060
|
+
justify-content: center;
|
|
13061
|
+
align-self: flex-end;
|
|
13062
|
+
gap: 0.25rem;
|
|
13063
|
+
min-height: 2rem;
|
|
13064
|
+
margin-bottom: 0.5rem;
|
|
13065
|
+
padding: 0.375rem;
|
|
13066
|
+
border: 1px solid ${pick("var(--tt-toc-sidebar-border-color)", surface.floatBorderColor)};
|
|
13067
|
+
border-radius: ${pick("var(--tt-radius-md)", `${surface.itemRadius}px`)};
|
|
13068
|
+
background: ${pick("var(--tt-toc-sidebar-bg)", surface.floatBg)};
|
|
13069
|
+
color: var(--tt-toc-sidebar-text-color);
|
|
13070
|
+
font: inherit;
|
|
13071
|
+
font-size: 0.75rem;
|
|
13072
|
+
line-height: 1;
|
|
13073
|
+
white-space: nowrap;
|
|
13074
|
+
cursor: pointer;
|
|
13075
|
+
|
|
13076
|
+
&:hover,
|
|
13077
|
+
&[aria-pressed="true"] {
|
|
13078
|
+
color: var(--tt-toc-sidebar-text-active-color);
|
|
13079
|
+
background: ${pick("var(--tt-toc-sidebar-bg-hover-color)", surface.itemHoverBg)};
|
|
13080
|
+
}
|
|
13081
|
+
}
|
|
13082
|
+
|
|
13083
|
+
&-toggle:focus-visible,
|
|
13084
|
+
&-item:focus-visible {
|
|
13085
|
+
outline: 2px solid var(--tt-toc-sidebar-text-active-color);
|
|
13086
|
+
outline-offset: 2px;
|
|
13087
|
+
}
|
|
13088
|
+
|
|
12749
13089
|
/* =========================
|
|
12750
13090
|
Progress bar column
|
|
12751
13091
|
========================= */
|
|
@@ -12816,12 +13156,15 @@ var tocSidebarStyles = ({ pick, surface, isDark }) => `
|
|
|
12816
13156
|
========================= */
|
|
12817
13157
|
&-nav {
|
|
12818
13158
|
position: absolute;
|
|
12819
|
-
top:
|
|
13159
|
+
top: 2.5rem;
|
|
12820
13160
|
right: 0;
|
|
13161
|
+
width: min(17rem, calc(100vw - 2rem));
|
|
13162
|
+
box-sizing: border-box;
|
|
12821
13163
|
padding-inline: 0.625rem;
|
|
12822
13164
|
pointer-events: none;
|
|
12823
13165
|
transform: translateX(10px);
|
|
12824
13166
|
opacity: 0;
|
|
13167
|
+
visibility: hidden;
|
|
12825
13168
|
display: flex;
|
|
12826
13169
|
transition:
|
|
12827
13170
|
transform 0.3s ease,
|
|
@@ -12844,6 +13187,7 @@ var tocSidebarStyles = ({ pick, surface, isDark }) => `
|
|
|
12844
13187
|
margin-right: -0.625rem;
|
|
12845
13188
|
max-height: var(--toc-max-height);
|
|
12846
13189
|
width: 100%;
|
|
13190
|
+
box-sizing: border-box;
|
|
12847
13191
|
overflow: auto;
|
|
12848
13192
|
padding: var(--padding);
|
|
12849
13193
|
scroll-margin: 0.25rem;
|
|
@@ -12870,7 +13214,9 @@ var tocSidebarStyles = ({ pick, surface, isDark }) => `
|
|
|
12870
13214
|
text-overflow: ellipsis;
|
|
12871
13215
|
user-select: none;
|
|
12872
13216
|
cursor: pointer;
|
|
12873
|
-
transition:
|
|
13217
|
+
transition:
|
|
13218
|
+
background-color 0.15s ease,
|
|
13219
|
+
color 0.15s ease;
|
|
12874
13220
|
|
|
12875
13221
|
/* Central calculation: Base * (Depth - 1) * Factor */
|
|
12876
13222
|
margin-inline-start: calc(
|
|
@@ -12926,22 +13272,39 @@ var tocSidebarStyles = ({ pick, surface, isDark }) => `
|
|
|
12926
13272
|
Interactions / media
|
|
12927
13273
|
========================= */
|
|
12928
13274
|
|
|
12929
|
-
|
|
12930
|
-
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
12935
|
-
}
|
|
13275
|
+
&--expanded &-nav,
|
|
13276
|
+
&-wrapper:focus-within &-nav[aria-hidden="false"] {
|
|
13277
|
+
pointer-events: auto;
|
|
13278
|
+
transform: translateX(0);
|
|
13279
|
+
opacity: 1;
|
|
13280
|
+
visibility: visible;
|
|
12936
13281
|
}
|
|
12937
13282
|
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
13283
|
+
&--pinned &-wrapper {
|
|
13284
|
+
width: 100%;
|
|
13285
|
+
max-width: 15rem;
|
|
13286
|
+
margin-left: 0;
|
|
13287
|
+
}
|
|
13288
|
+
|
|
13289
|
+
&--pinned &-inner {
|
|
13290
|
+
width: 100%;
|
|
13291
|
+
box-sizing: border-box;
|
|
13292
|
+
margin-right: 0;
|
|
13293
|
+
padding-right: 0.75rem;
|
|
13294
|
+
}
|
|
13295
|
+
|
|
13296
|
+
&--pinned &-progress {
|
|
13297
|
+
display: none;
|
|
13298
|
+
}
|
|
13299
|
+
|
|
13300
|
+
&--pinned &-nav {
|
|
13301
|
+
position: static;
|
|
13302
|
+
width: 100%;
|
|
13303
|
+
padding-inline: 0;
|
|
13304
|
+
}
|
|
13305
|
+
|
|
13306
|
+
&--pinned &-popover {
|
|
13307
|
+
margin-right: 0;
|
|
12945
13308
|
}
|
|
12946
13309
|
|
|
12947
13310
|
/* Mobile */
|
|
@@ -12951,6 +13314,23 @@ var tocSidebarStyles = ({ pick, surface, isDark }) => `
|
|
|
12951
13314
|
}
|
|
12952
13315
|
}
|
|
12953
13316
|
}
|
|
13317
|
+
|
|
13318
|
+
@media screen and (min-width: 769px) {
|
|
13319
|
+
.notion-like-editor-layout:has(> .toc-sidebar--pinned) {
|
|
13320
|
+
--margin-left-width: minmax(1rem, 1fr);
|
|
13321
|
+
--margin-right-width: minmax(15rem, 1fr);
|
|
13322
|
+
|
|
13323
|
+
> .notion-like-editor-content {
|
|
13324
|
+
min-width: 0;
|
|
13325
|
+
}
|
|
13326
|
+
}
|
|
13327
|
+
}
|
|
13328
|
+
|
|
13329
|
+
@media screen and (min-width: 769px) and (max-width: 1024px) {
|
|
13330
|
+
.notion-like-editor-layout:has(> .toc-sidebar:not(.toc-sidebar--pinned)) {
|
|
13331
|
+
--margin-right-width: minmax(5rem, 1fr);
|
|
13332
|
+
}
|
|
13333
|
+
}
|
|
12954
13334
|
`;
|
|
12955
13335
|
|
|
12956
13336
|
// src/components/tiptap-ui-primitive/toolbar/toolbar.style.ts
|
|
@@ -13002,6 +13382,7 @@ var toolbarStyles = ({ token, surface, isDark, gray }) => `
|
|
|
13002
13382
|
@media (max-width: 480px) {
|
|
13003
13383
|
position: absolute;
|
|
13004
13384
|
top: auto;
|
|
13385
|
+
inset-inline: 0;
|
|
13005
13386
|
height: calc(var(--tt-toolbar-height) + var(--tt-safe-area-bottom));
|
|
13006
13387
|
border-top: 1px solid ${isDark ? gray(50) : gray(100)};
|
|
13007
13388
|
border-bottom: none;
|
|
@@ -14276,6 +14657,48 @@ function parseWidthAttr(value) {
|
|
|
14276
14657
|
const n = typeof value === "number" ? value : Number.parseInt(String(value ?? ""), 10);
|
|
14277
14658
|
return Number.isFinite(n) && n > 0 ? n : void 0;
|
|
14278
14659
|
}
|
|
14660
|
+
|
|
14661
|
+
// src/lib/lazy-media.ts
|
|
14662
|
+
var ROOT_MARGIN = "800px 0px";
|
|
14663
|
+
function release(el) {
|
|
14664
|
+
if (!el.hasAttribute("src")) return;
|
|
14665
|
+
el.pause();
|
|
14666
|
+
el.removeAttribute("src");
|
|
14667
|
+
el.load();
|
|
14668
|
+
}
|
|
14669
|
+
function attachLazyMedia(el, src) {
|
|
14670
|
+
const load2 = () => {
|
|
14671
|
+
if (src && el.getAttribute("src") !== src) el.setAttribute("src", src);
|
|
14672
|
+
};
|
|
14673
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
14674
|
+
load2();
|
|
14675
|
+
return () => release(el);
|
|
14676
|
+
}
|
|
14677
|
+
const observer = new IntersectionObserver(
|
|
14678
|
+
(entries) => {
|
|
14679
|
+
const near = entries.some((entry) => entry.isIntersecting);
|
|
14680
|
+
if (near) load2();
|
|
14681
|
+
else if (el.paused) release(el);
|
|
14682
|
+
},
|
|
14683
|
+
{ rootMargin: ROOT_MARGIN }
|
|
14684
|
+
);
|
|
14685
|
+
observer.observe(el);
|
|
14686
|
+
return () => {
|
|
14687
|
+
observer.disconnect();
|
|
14688
|
+
release(el);
|
|
14689
|
+
};
|
|
14690
|
+
}
|
|
14691
|
+
|
|
14692
|
+
// src/hooks/use-lazy-media.ts
|
|
14693
|
+
function useLazyMedia(src) {
|
|
14694
|
+
const ref = useRef(null);
|
|
14695
|
+
useEffect(() => {
|
|
14696
|
+
const el = ref.current;
|
|
14697
|
+
if (!el) return;
|
|
14698
|
+
return attachLazyMedia(el, src);
|
|
14699
|
+
}, [src]);
|
|
14700
|
+
return ref;
|
|
14701
|
+
}
|
|
14279
14702
|
function useResizableWidth({
|
|
14280
14703
|
editor,
|
|
14281
14704
|
nodeName,
|
|
@@ -14658,6 +15081,16 @@ function useImageDownload(config) {
|
|
|
14658
15081
|
Icon: ArrowDownToLineIcon
|
|
14659
15082
|
};
|
|
14660
15083
|
}
|
|
15084
|
+
|
|
15085
|
+
// src/lib/media-size.ts
|
|
15086
|
+
function parseSizeHint(width, height) {
|
|
15087
|
+
const w = Number.parseFloat(String(width ?? ""));
|
|
15088
|
+
const h = Number.parseFloat(String(height ?? ""));
|
|
15089
|
+
return w > 0 && h > 0 ? { width: w, height: h } : void 0;
|
|
15090
|
+
}
|
|
15091
|
+
function heightForWidth(width, size4) {
|
|
15092
|
+
return size4 ? Math.round(width * size4.height / size4.width) : null;
|
|
15093
|
+
}
|
|
14661
15094
|
var VIDEO_MIN_WIDTH = 200;
|
|
14662
15095
|
var VIDEO_MAX_WIDTH = 800;
|
|
14663
15096
|
function VideoPlayer({
|
|
@@ -14667,27 +15100,31 @@ function VideoPlayer({
|
|
|
14667
15100
|
naturalSize,
|
|
14668
15101
|
onNaturalSize,
|
|
14669
15102
|
fillContainer,
|
|
14670
|
-
noDownload
|
|
15103
|
+
noDownload,
|
|
15104
|
+
sizeHint
|
|
14671
15105
|
}) {
|
|
15106
|
+
const size4 = naturalSize ?? sizeHint;
|
|
15107
|
+
const ratio = size4 ? `${size4.width} / ${size4.height}` : "16 / 9";
|
|
15108
|
+
const ref = useLazyMedia(src);
|
|
14672
15109
|
return (
|
|
14673
15110
|
// biome-ignore lint/a11y/useMediaCaption: 节点没有字幕字段,上传的视频也不带字幕文件;要加字幕时在这里补 <track>
|
|
14674
15111
|
/* @__PURE__ */ jsx(
|
|
14675
15112
|
"video",
|
|
14676
15113
|
{
|
|
15114
|
+
ref,
|
|
14677
15115
|
className: "tiptap-video-player",
|
|
14678
15116
|
controls: true,
|
|
14679
15117
|
controlsList: noDownload ? "nodownload" : void 0,
|
|
14680
15118
|
preload: "metadata",
|
|
14681
|
-
src,
|
|
14682
15119
|
title,
|
|
14683
15120
|
poster,
|
|
14684
|
-
style:
|
|
14685
|
-
aspectRatio:
|
|
15121
|
+
style: {
|
|
15122
|
+
aspectRatio: ratio,
|
|
14686
15123
|
// 没设宽度时按视频原始宽度显示。这个像素宽必须写在 <video> 上而不是外层 div:
|
|
14687
15124
|
// 带百分比 max-width 的 video 是「可压缩替换元素」,算最小内容宽时按 0 计;
|
|
14688
15125
|
// 写在 div 上会被当成最小宽度,把编辑器正文列(grid 轨道)整个撑宽、溢出外框。
|
|
14689
|
-
width: fillContainer ? void 0 : `${
|
|
14690
|
-
}
|
|
15126
|
+
width: fillContainer || !size4 ? void 0 : `${size4.width}px`
|
|
15127
|
+
},
|
|
14691
15128
|
onLoadedMetadata: (e) => {
|
|
14692
15129
|
const { videoWidth, videoHeight } = e.currentTarget;
|
|
14693
15130
|
if (videoWidth > 0 && videoHeight > 0) {
|
|
@@ -14700,6 +15137,7 @@ function VideoPlayer({
|
|
|
14700
15137
|
}
|
|
14701
15138
|
function VideoNodeView({ editor, node, getPos, updateAttributes }) {
|
|
14702
15139
|
const [naturalSize, setNaturalSize] = useState();
|
|
15140
|
+
const sizeHint = parseSizeHint(node.attrs.width, node.attrs.height);
|
|
14703
15141
|
const align = node.attrs["data-align"] ?? "left";
|
|
14704
15142
|
const canDownload = getDocPermissions(editor).download;
|
|
14705
15143
|
const {
|
|
@@ -14718,8 +15156,8 @@ function VideoNodeView({ editor, node, getPos, updateAttributes }) {
|
|
|
14718
15156
|
minWidth: VIDEO_MIN_WIDTH,
|
|
14719
15157
|
maxWidth: VIDEO_MAX_WIDTH,
|
|
14720
15158
|
align,
|
|
14721
|
-
//
|
|
14722
|
-
onResize: (w) => updateAttributes({ width: w, height:
|
|
15159
|
+
// height 只当宽高比用(不当像素高度,不会拉变形):按比例同步写回,下次打开视频加载前也能按真实比例占位
|
|
15160
|
+
onResize: (w) => updateAttributes({ width: w, height: heightForWidth(w, naturalSize ?? sizeHint) })
|
|
14723
15161
|
});
|
|
14724
15162
|
return /* @__PURE__ */ jsx(
|
|
14725
15163
|
NodeViewWrapper,
|
|
@@ -14744,6 +15182,7 @@ function VideoNodeView({ editor, node, getPos, updateAttributes }) {
|
|
|
14744
15182
|
poster: node.attrs.poster ?? void 0,
|
|
14745
15183
|
naturalSize,
|
|
14746
15184
|
onNaturalSize: setNaturalSize,
|
|
15185
|
+
sizeHint,
|
|
14747
15186
|
fillContainer: !!width,
|
|
14748
15187
|
noDownload: !canDownload
|
|
14749
15188
|
}
|
|
@@ -14811,7 +15250,10 @@ var Video = Node$1.create({
|
|
|
14811
15250
|
renderHTML({ node, HTMLAttributes }) {
|
|
14812
15251
|
const attrs = {
|
|
14813
15252
|
controls: "true",
|
|
14814
|
-
|
|
15253
|
+
// renderHTML 只用于序列化(getHTML、复制、导出)和 tiptap 卸载时的过渡 DOM,编辑器里的播放器是节点视图。
|
|
15254
|
+
// 这些 DOM 即使不插入文档,带 src + preload=metadata 也会各自创建播放器,Chrome 每页上限 1000 个;
|
|
15255
|
+
// preload="none" 不创建播放器,点播放时照常加载(见 lib/lazy-media.ts)
|
|
15256
|
+
preload: "none",
|
|
14815
15257
|
src: node.attrs.src
|
|
14816
15258
|
};
|
|
14817
15259
|
if (node.attrs.title) attrs.title = node.attrs.title;
|
|
@@ -14874,7 +15316,10 @@ var Audio = Node$1.create({
|
|
|
14874
15316
|
renderHTML({ node, HTMLAttributes }) {
|
|
14875
15317
|
const attrs = {
|
|
14876
15318
|
controls: "true",
|
|
14877
|
-
|
|
15319
|
+
// renderHTML 只用于序列化(getHTML、复制、导出)和 tiptap 卸载时的过渡 DOM,编辑器里的播放器是节点视图。
|
|
15320
|
+
// 这些 DOM 即使不插入文档,带 src + preload=metadata 也会各自创建播放器,Chrome 每页上限 1000 个;
|
|
15321
|
+
// preload="none" 不创建播放器,点播放时照常加载(见 lib/lazy-media.ts)
|
|
15322
|
+
preload: "none",
|
|
14878
15323
|
src: node.attrs.src
|
|
14879
15324
|
};
|
|
14880
15325
|
if (node.attrs.title) attrs.title = node.attrs.title;
|
|
@@ -14888,18 +15333,19 @@ var Audio = Node$1.create({
|
|
|
14888
15333
|
addNodeView() {
|
|
14889
15334
|
return ({ node, HTMLAttributes, editor }) => {
|
|
14890
15335
|
const dom = document.createElement("audio");
|
|
14891
|
-
const attrs = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
15336
|
+
const { src: _src, ...attrs } = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
14892
15337
|
controls: "true",
|
|
14893
15338
|
preload: "metadata",
|
|
14894
|
-
src: node.attrs.src,
|
|
14895
15339
|
...node.attrs.title ? { title: node.attrs.title } : {}
|
|
14896
15340
|
});
|
|
14897
15341
|
for (const [k, v] of Object.entries(attrs)) if (v != null && v !== false) dom.setAttribute(k, String(v));
|
|
14898
15342
|
if (!getDocPermissions(editor).download) dom.setAttribute("controlslist", "nodownload");
|
|
15343
|
+
const detach = attachLazyMedia(dom, node.attrs.src);
|
|
14899
15344
|
return {
|
|
14900
15345
|
dom,
|
|
14901
15346
|
stopEvent: () => !editor.isEditable,
|
|
14902
|
-
ignoreMutation: () => true
|
|
15347
|
+
ignoreMutation: () => true,
|
|
15348
|
+
destroy: detach
|
|
14903
15349
|
};
|
|
14904
15350
|
};
|
|
14905
15351
|
},
|
|
@@ -15275,10 +15721,10 @@ function FilePreview({
|
|
|
15275
15721
|
body = /* @__PURE__ */ jsx("img", { className: "tt-file-preview__media", src: file.src, alt: file.name });
|
|
15276
15722
|
} else if (kind === "video") {
|
|
15277
15723
|
sized = false;
|
|
15278
|
-
body = /* @__PURE__ */ jsx(
|
|
15724
|
+
body = /* @__PURE__ */ jsx(PreviewVideo, { src: file.src });
|
|
15279
15725
|
} else if (kind === "audio") {
|
|
15280
15726
|
sized = false;
|
|
15281
|
-
body = /* @__PURE__ */ jsx(
|
|
15727
|
+
body = /* @__PURE__ */ jsx(PreviewAudio, { src: file.src });
|
|
15282
15728
|
} else if (kind === "text") {
|
|
15283
15729
|
body = /* @__PURE__ */ jsx(TextPreview, { src: file.src, name: file.name });
|
|
15284
15730
|
} else {
|
|
@@ -15343,6 +15789,14 @@ function useFullscreen() {
|
|
|
15343
15789
|
}, []);
|
|
15344
15790
|
return on;
|
|
15345
15791
|
}
|
|
15792
|
+
function PreviewVideo({ src }) {
|
|
15793
|
+
const ref = useLazyMedia(src);
|
|
15794
|
+
return /* @__PURE__ */ jsx("video", { ref, className: "tt-file-preview__media", controls: true, preload: "metadata" });
|
|
15795
|
+
}
|
|
15796
|
+
function PreviewAudio({ src }) {
|
|
15797
|
+
const ref = useLazyMedia(src);
|
|
15798
|
+
return /* @__PURE__ */ jsx("audio", { ref, className: "tt-file-preview__audio", controls: true, preload: "metadata" });
|
|
15799
|
+
}
|
|
15346
15800
|
var FileAttachmentSchema = Node$2.create({
|
|
15347
15801
|
name: "fileAttachment",
|
|
15348
15802
|
group: "block",
|
|
@@ -16998,6 +17452,34 @@ function containsCompleteContainer(text, names = ALL_CONTAINER_NAMES) {
|
|
|
16998
17452
|
}
|
|
16999
17453
|
return false;
|
|
17000
17454
|
}
|
|
17455
|
+
var HEADING_RE = /^ {0,3}#{1,6}[ \t]+\S/;
|
|
17456
|
+
var LIST_RE = /^ {0,3}(?:[-*+]|\d{1,9}[.)])[ \t]+\S/;
|
|
17457
|
+
var QUOTE_RE = /^ {0,3}>/;
|
|
17458
|
+
var LINK_RE = /\[[^\]\n]+\]\([^)\s]+\)/;
|
|
17459
|
+
var TABLE_DELIMITER_RE = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
|
|
17460
|
+
function looksLikeMarkdown(text) {
|
|
17461
|
+
const lines = text.replace(/\r\n?/g, "\n").split("\n");
|
|
17462
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
17463
|
+
let fence = null;
|
|
17464
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
17465
|
+
const line = lines[i];
|
|
17466
|
+
if (fence) {
|
|
17467
|
+
if (isFenceClose(line, fence)) return true;
|
|
17468
|
+
continue;
|
|
17469
|
+
}
|
|
17470
|
+
fence = matchFenceOpen(line);
|
|
17471
|
+
if (fence) continue;
|
|
17472
|
+
if (i > 0 && line.includes("|") && line.includes("-") && TABLE_DELIMITER_RE.test(line)) {
|
|
17473
|
+
if (lines[i - 1].includes("|")) return true;
|
|
17474
|
+
}
|
|
17475
|
+
if (HEADING_RE.test(line)) kinds.add("heading");
|
|
17476
|
+
else if (LIST_RE.test(line)) kinds.add("list");
|
|
17477
|
+
else if (QUOTE_RE.test(line)) kinds.add("quote");
|
|
17478
|
+
if (LINK_RE.test(line)) kinds.add("link");
|
|
17479
|
+
if (kinds.size >= 2) return true;
|
|
17480
|
+
}
|
|
17481
|
+
return false;
|
|
17482
|
+
}
|
|
17001
17483
|
var REQUIRED_WORDS = /* @__PURE__ */ new Set(["必选", "required"]);
|
|
17002
17484
|
var DEFAULT_WORDS = /* @__PURE__ */ new Set(["默认", "default"]);
|
|
17003
17485
|
function tokenizeInfo(info) {
|
|
@@ -20276,73 +20758,198 @@ function CollabProvider({
|
|
|
20276
20758
|
);
|
|
20277
20759
|
return /* @__PURE__ */ jsx(CollabContext.Provider, { value, children });
|
|
20278
20760
|
}
|
|
20279
|
-
|
|
20280
|
-
|
|
20281
|
-
|
|
20282
|
-
]
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
|
|
20286
|
-
|
|
20287
|
-
|
|
20288
|
-
|
|
20289
|
-
|
|
20290
|
-
|
|
20291
|
-
|
|
20292
|
-
|
|
20293
|
-
|
|
20294
|
-
|
|
20295
|
-
|
|
20296
|
-
|
|
20297
|
-
|
|
20298
|
-
|
|
20299
|
-
|
|
20300
|
-
|
|
20301
|
-
|
|
20761
|
+
|
|
20762
|
+
// src/components/tiptap-extension/comment-thread/comment-thread.style.ts
|
|
20763
|
+
var commentThreadFocusStyle = `
|
|
20764
|
+
[data-comment-thread-interactive]:focus-visible {
|
|
20765
|
+
outline: 2px solid var(--tt-brand-color-500, #3370ff);
|
|
20766
|
+
outline-offset: 2px;
|
|
20767
|
+
}
|
|
20768
|
+
`;
|
|
20769
|
+
|
|
20770
|
+
// src/components/tiptap-extension/comment-thread/comment-thread.ts
|
|
20771
|
+
var commentThreadInteractivityKey = new PluginKey(
|
|
20772
|
+
"commentThreadInteractivity"
|
|
20773
|
+
);
|
|
20774
|
+
function refreshCommentThreadInteractivity(editor, interactive) {
|
|
20775
|
+
if (editor.isDestroyed) return;
|
|
20776
|
+
editor.view.dispatch(
|
|
20777
|
+
editor.state.tr.setMeta(commentThreadInteractivityKey, interactive ?? true).setMeta("addToHistory", false)
|
|
20778
|
+
);
|
|
20779
|
+
}
|
|
20780
|
+
function getCommentSelection(state) {
|
|
20781
|
+
const { selection, doc } = state;
|
|
20782
|
+
if (!(selection instanceof TextSelection) || selection.empty || selection.$from.parent.type.spec.code)
|
|
20783
|
+
return null;
|
|
20784
|
+
const { from, to } = selection;
|
|
20785
|
+
const text = doc.textBetween(from, to, "\n");
|
|
20786
|
+
return text.trim() ? { from, to, text } : null;
|
|
20787
|
+
}
|
|
20788
|
+
function canWriteComment(editor) {
|
|
20789
|
+
const storage = editor.storage;
|
|
20790
|
+
return editor.isEditable && !storage.readOnlyGuard?.locked;
|
|
20791
|
+
}
|
|
20792
|
+
var CommentThread = Mark.create({
|
|
20793
|
+
name: "commentThread",
|
|
20794
|
+
priority: 1100,
|
|
20795
|
+
excludes: "",
|
|
20796
|
+
inclusive: false,
|
|
20797
|
+
addOptions() {
|
|
20798
|
+
return { onSelectThread: void 0, isInteractive: void 0 };
|
|
20799
|
+
},
|
|
20800
|
+
addAttributes() {
|
|
20801
|
+
return {
|
|
20802
|
+
threadId: {
|
|
20803
|
+
default: null,
|
|
20804
|
+
parseHTML: (element) => element.getAttribute("data-comment-thread"),
|
|
20805
|
+
renderHTML: (attributes) => ({ "data-comment-thread": attributes.threadId })
|
|
20806
|
+
}
|
|
20302
20807
|
};
|
|
20303
|
-
},
|
|
20304
|
-
|
|
20305
|
-
|
|
20306
|
-
"button",
|
|
20808
|
+
},
|
|
20809
|
+
parseHTML() {
|
|
20810
|
+
return [
|
|
20307
20811
|
{
|
|
20308
|
-
|
|
20309
|
-
|
|
20310
|
-
"aria-label": WIDTH_MODE_MENU_TITLE,
|
|
20311
|
-
title: WIDTH_MODE_MENU_TITLE,
|
|
20312
|
-
"aria-haspopup": "menu",
|
|
20313
|
-
"aria-expanded": open,
|
|
20314
|
-
onClick: () => setOpen((o) => !o),
|
|
20315
|
-
children: /* @__PURE__ */ jsx(PageWidthIcon, {})
|
|
20812
|
+
tag: "span[data-comment-thread]",
|
|
20813
|
+
getAttrs: (element) => element.getAttribute("data-comment-thread")?.trim() ? null : false
|
|
20316
20814
|
}
|
|
20317
|
-
|
|
20318
|
-
|
|
20319
|
-
|
|
20320
|
-
|
|
20321
|
-
|
|
20322
|
-
|
|
20323
|
-
|
|
20324
|
-
|
|
20325
|
-
|
|
20326
|
-
|
|
20327
|
-
|
|
20328
|
-
|
|
20329
|
-
|
|
20815
|
+
];
|
|
20816
|
+
},
|
|
20817
|
+
renderHTML({ HTMLAttributes }) {
|
|
20818
|
+
return [
|
|
20819
|
+
"span",
|
|
20820
|
+
{
|
|
20821
|
+
...HTMLAttributes,
|
|
20822
|
+
style: "background-color: var(--tt-color-highlight-yellow, rgba(255, 246, 122, 0.4)); border-radius: 2px; box-decoration-break: clone;"
|
|
20823
|
+
},
|
|
20824
|
+
0
|
|
20825
|
+
];
|
|
20826
|
+
},
|
|
20827
|
+
addCommands() {
|
|
20828
|
+
return {
|
|
20829
|
+
setCommentThread: (threadId) => ({ editor, tr, dispatch }) => {
|
|
20830
|
+
if (!canWriteComment(editor) || !threadId.trim()) return false;
|
|
20831
|
+
const selection = getCommentSelection(tr);
|
|
20832
|
+
if (!selection) return false;
|
|
20833
|
+
let supported = false;
|
|
20834
|
+
tr.doc.nodesBetween(selection.from, selection.to, (node, pos, parent) => {
|
|
20835
|
+
if (!node.isText || !parent?.type.allowsMarkType(this.type) || node.marks.some((mark) => mark.type.excludes(this.type)))
|
|
20836
|
+
return;
|
|
20837
|
+
supported = true;
|
|
20838
|
+
if (dispatch)
|
|
20839
|
+
tr.addMark(
|
|
20840
|
+
Math.max(pos, selection.from),
|
|
20841
|
+
Math.min(pos + node.nodeSize, selection.to),
|
|
20842
|
+
this.type.create({ threadId })
|
|
20843
|
+
);
|
|
20844
|
+
});
|
|
20845
|
+
return supported;
|
|
20846
|
+
},
|
|
20847
|
+
unsetCommentThread: (threadId) => ({ editor, tr, dispatch }) => {
|
|
20848
|
+
if (!canWriteComment(editor) || !threadId.trim()) return false;
|
|
20849
|
+
const storedMarks = tr.storedMarks;
|
|
20850
|
+
let found = Boolean(
|
|
20851
|
+
storedMarks?.some(
|
|
20852
|
+
(mark) => mark.type === this.type && mark.attrs.threadId === threadId
|
|
20853
|
+
)
|
|
20854
|
+
);
|
|
20855
|
+
tr.doc.descendants((node, pos) => {
|
|
20856
|
+
for (const mark of node.marks) {
|
|
20857
|
+
if (mark.type !== this.type || mark.attrs.threadId !== threadId) continue;
|
|
20858
|
+
found = true;
|
|
20859
|
+
if (dispatch) tr.removeMark(pos, pos + node.nodeSize, mark);
|
|
20860
|
+
}
|
|
20861
|
+
});
|
|
20862
|
+
if (dispatch && storedMarks && found)
|
|
20863
|
+
tr.setStoredMarks(
|
|
20864
|
+
storedMarks.filter(
|
|
20865
|
+
(mark) => mark.type !== this.type || mark.attrs.threadId !== threadId
|
|
20866
|
+
)
|
|
20867
|
+
);
|
|
20868
|
+
return found;
|
|
20869
|
+
}
|
|
20870
|
+
};
|
|
20871
|
+
},
|
|
20872
|
+
addProseMirrorPlugins() {
|
|
20873
|
+
const isInteractive = () => Boolean(this.options.onSelectThread) && (this.options.isInteractive?.() ?? true);
|
|
20874
|
+
const decorations = (state) => {
|
|
20875
|
+
if (!isInteractive()) return DecorationSet.empty;
|
|
20876
|
+
const ranges = [];
|
|
20877
|
+
state.doc.descendants((node, pos) => {
|
|
20878
|
+
if (!node.isText || node.marks.some((mark2) => mark2.type.name === "link")) return;
|
|
20879
|
+
const mark = node.marks.filter((mark2) => mark2.type === this.type).at(-1);
|
|
20880
|
+
const threadId = mark?.attrs.threadId;
|
|
20881
|
+
if (typeof threadId !== "string" || !threadId.trim()) return;
|
|
20882
|
+
const previous = ranges.at(-1);
|
|
20883
|
+
if (previous?.to === pos && previous.threadId === threadId) previous.to += node.nodeSize;
|
|
20884
|
+
else ranges.push({ from: pos, to: pos + node.nodeSize, threadId });
|
|
20885
|
+
});
|
|
20886
|
+
return DecorationSet.create(
|
|
20887
|
+
state.doc,
|
|
20888
|
+
ranges.map(
|
|
20889
|
+
({ from, to, threadId }) => Decoration.inline(from, to, {
|
|
20890
|
+
nodeName: "span",
|
|
20891
|
+
"data-comment-thread-interactive": threadId,
|
|
20892
|
+
role: "button",
|
|
20893
|
+
tabindex: "0",
|
|
20894
|
+
"aria-label": "查看评论"
|
|
20895
|
+
})
|
|
20896
|
+
)
|
|
20897
|
+
);
|
|
20898
|
+
};
|
|
20899
|
+
const threadTarget = (view, event) => {
|
|
20900
|
+
const element = event.target;
|
|
20901
|
+
if (element?.closest?.("a[href]")) return null;
|
|
20902
|
+
const target = element?.closest?.(
|
|
20903
|
+
"[data-comment-thread-interactive], span[data-comment-thread]"
|
|
20904
|
+
);
|
|
20905
|
+
return target && view.dom.contains(target) ? target : null;
|
|
20906
|
+
};
|
|
20907
|
+
return [
|
|
20908
|
+
new Plugin({
|
|
20909
|
+
key: commentThreadInteractivityKey,
|
|
20910
|
+
state: {
|
|
20911
|
+
init: (_config, state) => decorations(state),
|
|
20912
|
+
apply: (tr, previous, _oldState, state) => tr.docChanged || tr.getMeta(commentThreadInteractivityKey) !== void 0 ? decorations(state) : previous
|
|
20913
|
+
},
|
|
20914
|
+
props: {
|
|
20915
|
+
decorations: (state) => commentThreadInteractivityKey.getState(state),
|
|
20916
|
+
handleClick: (view, _pos, event) => {
|
|
20917
|
+
if (!isInteractive() || event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || !view.state.selection.empty)
|
|
20918
|
+
return false;
|
|
20919
|
+
const target = threadTarget(view, event);
|
|
20920
|
+
const threadId = target?.getAttribute("data-comment-thread-interactive") ?? target?.getAttribute("data-comment-thread");
|
|
20921
|
+
if (!threadId?.trim()) return false;
|
|
20922
|
+
event.preventDefault();
|
|
20923
|
+
this.options.onSelectThread?.(threadId);
|
|
20924
|
+
return true;
|
|
20330
20925
|
},
|
|
20331
|
-
|
|
20332
|
-
|
|
20333
|
-
|
|
20334
|
-
|
|
20335
|
-
|
|
20336
|
-
|
|
20337
|
-
|
|
20338
|
-
|
|
20339
|
-
|
|
20926
|
+
handleDOMEvents: {
|
|
20927
|
+
keydown: (view, event) => {
|
|
20928
|
+
if (event.defaultPrevented || event.key !== "Enter" && event.key !== " " || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
|
20929
|
+
return false;
|
|
20930
|
+
const target = threadTarget(view, event);
|
|
20931
|
+
if (!target || target !== view.root.activeElement) return false;
|
|
20932
|
+
const threadId = target.getAttribute("data-comment-thread-interactive") ?? target.getAttribute("data-comment-thread");
|
|
20933
|
+
if (!threadId?.trim()) return false;
|
|
20934
|
+
event.preventDefault();
|
|
20935
|
+
if (isInteractive()) this.options.onSelectThread?.(threadId);
|
|
20936
|
+
return true;
|
|
20937
|
+
}
|
|
20938
|
+
}
|
|
20340
20939
|
},
|
|
20341
|
-
|
|
20342
|
-
|
|
20343
|
-
|
|
20344
|
-
|
|
20345
|
-
|
|
20940
|
+
view: (view) => {
|
|
20941
|
+
const style = view.dom.ownerDocument.createElement("style");
|
|
20942
|
+
style.setAttribute("data-comment-thread-style", "");
|
|
20943
|
+
style.textContent = commentThreadFocusStyle;
|
|
20944
|
+
const root = view.dom.getRootNode();
|
|
20945
|
+
const container = root.nodeType === 9 ? view.dom.ownerDocument.head : root;
|
|
20946
|
+
container.appendChild(style);
|
|
20947
|
+
return { destroy: () => style.remove() };
|
|
20948
|
+
}
|
|
20949
|
+
})
|
|
20950
|
+
];
|
|
20951
|
+
}
|
|
20952
|
+
});
|
|
20346
20953
|
function DropdownMenu({
|
|
20347
20954
|
...props
|
|
20348
20955
|
}) {
|
|
@@ -21690,7 +22297,7 @@ function dragCrop(start, handle, dx, dy) {
|
|
|
21690
22297
|
if (handle.includes("s")) y1 = Math.max(y0 + MIN_CROP_SIZE, Math.min(1, y1 + dy));
|
|
21691
22298
|
return [x0, y0, x1, y1];
|
|
21692
22299
|
}
|
|
21693
|
-
var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onClick, cursor }, ref) {
|
|
22300
|
+
var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onClick, cursor, sizeHint }, ref) {
|
|
21694
22301
|
const [natural, setNatural] = useState(null);
|
|
21695
22302
|
const [failed, setFailed] = useState(false);
|
|
21696
22303
|
const [attempt, setAttempt] = useState(0);
|
|
@@ -21710,6 +22317,7 @@ var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onC
|
|
|
21710
22317
|
"div",
|
|
21711
22318
|
{
|
|
21712
22319
|
className: "tiptap-image-error",
|
|
22320
|
+
style: sizeHint ? { aspectRatio: `${sizeHint.width} / ${sizeHint.height}`, minHeight: 0 } : void 0,
|
|
21713
22321
|
contentEditable: false,
|
|
21714
22322
|
draggable: false,
|
|
21715
22323
|
onClick: (e) => {
|
|
@@ -21745,8 +22353,13 @@ var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onC
|
|
|
21745
22353
|
"img",
|
|
21746
22354
|
{
|
|
21747
22355
|
ref,
|
|
22356
|
+
loading: "lazy",
|
|
22357
|
+
decoding: "async",
|
|
21748
22358
|
src,
|
|
21749
22359
|
alt,
|
|
22360
|
+
width: sizeHint?.width,
|
|
22361
|
+
height: sizeHint?.height,
|
|
22362
|
+
"data-pending": natural ? void 0 : "",
|
|
21750
22363
|
className: "tiptap-image-img",
|
|
21751
22364
|
contentEditable: false,
|
|
21752
22365
|
draggable: false,
|
|
@@ -21762,8 +22375,9 @@ var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onC
|
|
|
21762
22375
|
attempt
|
|
21763
22376
|
)
|
|
21764
22377
|
);
|
|
21765
|
-
|
|
21766
|
-
|
|
22378
|
+
const size4 = natural ?? sizeHint;
|
|
22379
|
+
if (plain || !size4) return img();
|
|
22380
|
+
const layout = frameLayout(size4, crop ?? [0, 0, 1, 1], rotation);
|
|
21767
22381
|
return /* @__PURE__ */ jsx("div", { className: "tiptap-image-frame", style: { aspectRatio: String(layout.aspect) }, children: /* @__PURE__ */ jsx(
|
|
21768
22382
|
"div",
|
|
21769
22383
|
{
|
|
@@ -21895,11 +22509,12 @@ function ImageNodeView(props) {
|
|
|
21895
22509
|
showCaption: node.attrs.showCaption,
|
|
21896
22510
|
hasContent,
|
|
21897
22511
|
nodeSize: node.nodeSize,
|
|
21898
|
-
onImageResize: (width) => updateAttributes({ width }),
|
|
22512
|
+
onImageResize: (width, size4) => updateAttributes({ width, height: width ? heightForWidth(width, size4) : null }),
|
|
21899
22513
|
onUpdateAttributes: updateAttributes,
|
|
21900
22514
|
getPos,
|
|
21901
22515
|
crop: node.attrs.crop ? normalizeCrop(node.attrs.crop) : null,
|
|
21902
|
-
rotation: normalizeRotation(node.attrs.rotation)
|
|
22516
|
+
rotation: normalizeRotation(node.attrs.rotation),
|
|
22517
|
+
sizeHint: parseSizeHint(node.attrs.width, node.attrs.height)
|
|
21903
22518
|
}
|
|
21904
22519
|
);
|
|
21905
22520
|
}
|
|
@@ -21918,7 +22533,8 @@ var ResizableImage = ({
|
|
|
21918
22533
|
onUpdateAttributes,
|
|
21919
22534
|
getPos,
|
|
21920
22535
|
crop = null,
|
|
21921
|
-
rotation = 0
|
|
22536
|
+
rotation = 0,
|
|
22537
|
+
sizeHint
|
|
21922
22538
|
}) => {
|
|
21923
22539
|
const [cropping, setCropping] = useState(false);
|
|
21924
22540
|
const submitCropRef = useRef(null);
|
|
@@ -21951,7 +22567,11 @@ var ResizableImage = ({
|
|
|
21951
22567
|
minWidth,
|
|
21952
22568
|
maxWidth,
|
|
21953
22569
|
align,
|
|
21954
|
-
onResize: (w) =>
|
|
22570
|
+
onResize: (w) => {
|
|
22571
|
+
const img = imageRef.current;
|
|
22572
|
+
const natural = img?.naturalWidth && img.naturalHeight ? { width: img.naturalWidth, height: img.naturalHeight } : void 0;
|
|
22573
|
+
onImageResize?.(w, natural ?? sizeHint);
|
|
22574
|
+
}
|
|
21955
22575
|
});
|
|
21956
22576
|
const imageRef = useRef(null);
|
|
21957
22577
|
useEffect(() => {
|
|
@@ -22035,7 +22655,8 @@ var ResizableImage = ({
|
|
|
22035
22655
|
crop,
|
|
22036
22656
|
rotation,
|
|
22037
22657
|
onClick: handleImageClick,
|
|
22038
|
-
cursor: editor?.isEditable ? "pointer" : "zoom-in"
|
|
22658
|
+
cursor: editor?.isEditable ? "pointer" : "zoom-in",
|
|
22659
|
+
sizeHint
|
|
22039
22660
|
}
|
|
22040
22661
|
),
|
|
22041
22662
|
showHandles && !cropping && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -22043,11 +22664,12 @@ var ResizableImage = ({
|
|
|
22043
22664
|
/* @__PURE__ */ jsx("div", { ...rightHandleProps, className: "tiptap-image-handle tiptap-image-handle-right" })
|
|
22044
22665
|
] })
|
|
22045
22666
|
] }),
|
|
22046
|
-
|
|
22667
|
+
/* @__PURE__ */ jsx(
|
|
22047
22668
|
NodeViewContent,
|
|
22048
22669
|
{
|
|
22049
22670
|
as: "div",
|
|
22050
22671
|
className: "tiptap-image-caption",
|
|
22672
|
+
hidden: !(editor?.isEditable ? shouldShowCaption : hasContent),
|
|
22051
22673
|
"data-placeholder": "输入图片描述"
|
|
22052
22674
|
}
|
|
22053
22675
|
)
|
|
@@ -22201,13 +22823,16 @@ var Image2 = Image$1.extend({
|
|
|
22201
22823
|
renderHTML({ node }) {
|
|
22202
22824
|
const { src, alt, title, width, height, showCaption } = node.attrs;
|
|
22203
22825
|
const align = node.attrs["data-align"];
|
|
22204
|
-
const imgAttrs =
|
|
22205
|
-
|
|
22206
|
-
|
|
22207
|
-
|
|
22208
|
-
|
|
22209
|
-
|
|
22210
|
-
|
|
22826
|
+
const imgAttrs = {
|
|
22827
|
+
loading: "lazy",
|
|
22828
|
+
...buildImageHTMLAttributes({
|
|
22829
|
+
src,
|
|
22830
|
+
alt,
|
|
22831
|
+
title,
|
|
22832
|
+
width,
|
|
22833
|
+
height
|
|
22834
|
+
})
|
|
22835
|
+
};
|
|
22211
22836
|
const rotation = normalizeRotation(node.attrs.rotation);
|
|
22212
22837
|
const crop = formatCropAttr(node.attrs.crop);
|
|
22213
22838
|
if (rotation) {
|
|
@@ -26486,6 +27111,68 @@ function replaceAllMatches(tr, matches, text) {
|
|
|
26486
27111
|
}
|
|
26487
27112
|
return count;
|
|
26488
27113
|
}
|
|
27114
|
+
function idConfig(editor) {
|
|
27115
|
+
const ext = editor.extensionManager.extensions.find((e) => e.name === "uniqueID");
|
|
27116
|
+
const options = ext?.options;
|
|
27117
|
+
if (!options || !Array.isArray(options.types) || !options.attributeName || !options.generateID)
|
|
27118
|
+
return null;
|
|
27119
|
+
return options;
|
|
27120
|
+
}
|
|
27121
|
+
function fillFragment(fragment, config) {
|
|
27122
|
+
let changed = false;
|
|
27123
|
+
const nodes = [];
|
|
27124
|
+
fragment.forEach((node) => {
|
|
27125
|
+
let next = node;
|
|
27126
|
+
const content = node.isText ? node.content : fillFragment(node.content, config);
|
|
27127
|
+
if (config.types.includes(node.type.name) && node.attrs[config.attributeName] == null) {
|
|
27128
|
+
const id = config.generateID({ node, pos: -1 });
|
|
27129
|
+
next = node.type.create({ ...node.attrs, [config.attributeName]: id }, content, node.marks);
|
|
27130
|
+
} else if (content !== node.content) {
|
|
27131
|
+
next = node.copy(content);
|
|
27132
|
+
}
|
|
27133
|
+
if (next !== node) changed = true;
|
|
27134
|
+
nodes.push(next);
|
|
27135
|
+
});
|
|
27136
|
+
return changed ? Fragment.from(nodes) : fragment;
|
|
27137
|
+
}
|
|
27138
|
+
function fillJSON(nodes, config) {
|
|
27139
|
+
return nodes.map((node) => {
|
|
27140
|
+
const out = { ...node };
|
|
27141
|
+
if (node.type && config.types.includes(node.type) && node.attrs?.[config.attributeName] == null) {
|
|
27142
|
+
out.attrs = {
|
|
27143
|
+
...node.attrs,
|
|
27144
|
+
[config.attributeName]: config.generateID({ node: null, pos: -1 })
|
|
27145
|
+
};
|
|
27146
|
+
}
|
|
27147
|
+
if (node.content) out.content = fillJSON(node.content, config);
|
|
27148
|
+
return out;
|
|
27149
|
+
});
|
|
27150
|
+
}
|
|
27151
|
+
function withNodeIds(editor, content) {
|
|
27152
|
+
const config = idConfig(editor);
|
|
27153
|
+
return config ? fillJSON(content, config) : content;
|
|
27154
|
+
}
|
|
27155
|
+
var PasteNodeIds = Extension.create({
|
|
27156
|
+
name: "pasteNodeIds",
|
|
27157
|
+
addProseMirrorPlugins() {
|
|
27158
|
+
const editor = this.editor;
|
|
27159
|
+
return [
|
|
27160
|
+
new Plugin({
|
|
27161
|
+
key: new PluginKey("pasteNodeIds"),
|
|
27162
|
+
props: {
|
|
27163
|
+
transformPasted(slice) {
|
|
27164
|
+
const config = idConfig(editor);
|
|
27165
|
+
if (!config) return slice;
|
|
27166
|
+
const content = fillFragment(slice.content, config);
|
|
27167
|
+
return content === slice.content ? slice : new Slice(content, slice.openStart, slice.openEnd);
|
|
27168
|
+
}
|
|
27169
|
+
}
|
|
27170
|
+
})
|
|
27171
|
+
];
|
|
27172
|
+
}
|
|
27173
|
+
});
|
|
27174
|
+
|
|
27175
|
+
// src/components/tiptap-node/code-block-node/code-group-input.ts
|
|
26489
27176
|
var codeGroupInputPluginKey = new PluginKey("codeGroupInput");
|
|
26490
27177
|
var OPENER_RE3 = /^ {0,3}:::[ \t]*code-group[ \t]*$/;
|
|
26491
27178
|
var CLOSER_RE2 = /^ {0,3}:::[ \t]*$/;
|
|
@@ -26600,11 +27287,21 @@ function containerPasteText(data, slice, schema) {
|
|
|
26600
27287
|
if (/\sdata-pm-slice=/.test(html)) return sliceLines(slice, schema);
|
|
26601
27288
|
return text || null;
|
|
26602
27289
|
}
|
|
27290
|
+
function isMarkdownPaste(data, text) {
|
|
27291
|
+
if (/\sdata-pm-slice=/.test(data.getData("text/html"))) return false;
|
|
27292
|
+
let mode = null;
|
|
27293
|
+
try {
|
|
27294
|
+
mode = JSON.parse(data.getData("vscode-editor-data") || "null")?.mode;
|
|
27295
|
+
} catch {
|
|
27296
|
+
}
|
|
27297
|
+
if (mode && mode !== "markdown") return false;
|
|
27298
|
+
return looksLikeMarkdown(text);
|
|
27299
|
+
}
|
|
26603
27300
|
function resolveMarkConflicts(nodes, schema) {
|
|
26604
27301
|
return nodes.map((node) => {
|
|
26605
27302
|
const out = { ...node };
|
|
26606
27303
|
if (node.marks?.length) {
|
|
26607
|
-
out.marks = node.marks.reduce((set, json) => schema.markFromJSON(json).addToSet(set), Mark.none).map((mark) => mark.toJSON());
|
|
27304
|
+
out.marks = node.marks.reduce((set, json) => schema.markFromJSON(json).addToSet(set), Mark$1.none).map((mark) => mark.toJSON());
|
|
26608
27305
|
}
|
|
26609
27306
|
if (node.content) out.content = resolveMarkConflicts(node.content, schema);
|
|
26610
27307
|
return out;
|
|
@@ -26643,14 +27340,14 @@ function createCodeGroupInputPlugin(editor) {
|
|
|
26643
27340
|
if (!data) return false;
|
|
26644
27341
|
if (view.input?.shiftKey) return false;
|
|
26645
27342
|
const text = containerPasteText(data, slice, state.schema);
|
|
26646
|
-
if (!text || !containsCompleteContainer(text)) return false;
|
|
27343
|
+
if (!text || !(containsCompleteContainer(text) || isMarkdownPaste(data, text))) return false;
|
|
26647
27344
|
const manager = editor.markdown;
|
|
26648
27345
|
if (!manager) return false;
|
|
26649
27346
|
let content;
|
|
26650
27347
|
try {
|
|
26651
27348
|
const json = manager.parse(text.replace(/\r\n?/g, "\n"));
|
|
26652
27349
|
if (!json.content?.length) return false;
|
|
26653
|
-
content = resolveMarkConflicts(json.content, state.schema);
|
|
27350
|
+
content = withNodeIds(editor, resolveMarkConflicts(json.content, state.schema));
|
|
26654
27351
|
} catch {
|
|
26655
27352
|
return false;
|
|
26656
27353
|
}
|
|
@@ -35111,6 +35808,9 @@ function ComboboxItem2({ className, ...props }) {
|
|
|
35111
35808
|
}
|
|
35112
35809
|
);
|
|
35113
35810
|
}
|
|
35811
|
+
function MenuProvider2({ ...props }) {
|
|
35812
|
+
return /* @__PURE__ */ jsx(Ariakit2.MenuProvider, { ...props });
|
|
35813
|
+
}
|
|
35114
35814
|
function Menu2({
|
|
35115
35815
|
children,
|
|
35116
35816
|
trigger,
|
|
@@ -35227,6 +35927,31 @@ function MenuGroupLabel2({
|
|
|
35227
35927
|
}
|
|
35228
35928
|
);
|
|
35229
35929
|
}
|
|
35930
|
+
function MenuSeparator2({
|
|
35931
|
+
className,
|
|
35932
|
+
...props
|
|
35933
|
+
}) {
|
|
35934
|
+
return /* @__PURE__ */ jsx(
|
|
35935
|
+
Ariakit2.MenuSeparator,
|
|
35936
|
+
{
|
|
35937
|
+
"data-slot": "tiptap-menu-separator",
|
|
35938
|
+
className: cn("tiptap-menu-separator", className),
|
|
35939
|
+
...props
|
|
35940
|
+
}
|
|
35941
|
+
);
|
|
35942
|
+
}
|
|
35943
|
+
function MenuItemCheck2({
|
|
35944
|
+
className,
|
|
35945
|
+
...props
|
|
35946
|
+
}) {
|
|
35947
|
+
return /* @__PURE__ */ jsx(
|
|
35948
|
+
Ariakit2.MenuItemCheck,
|
|
35949
|
+
{
|
|
35950
|
+
...props,
|
|
35951
|
+
className: cn("tiptap-menu-item-check", className)
|
|
35952
|
+
}
|
|
35953
|
+
);
|
|
35954
|
+
}
|
|
35230
35955
|
function MenuItemRadio2({
|
|
35231
35956
|
className,
|
|
35232
35957
|
...props
|
|
@@ -46853,90 +47578,8 @@ var DragContextMenu = ({
|
|
|
46853
47578
|
}
|
|
46854
47579
|
);
|
|
46855
47580
|
};
|
|
46856
|
-
var
|
|
46857
|
-
return /* @__PURE__ */
|
|
46858
|
-
"svg",
|
|
46859
|
-
{
|
|
46860
|
-
width: "24",
|
|
46861
|
-
height: "24",
|
|
46862
|
-
className,
|
|
46863
|
-
viewBox: "0 0 24 24",
|
|
46864
|
-
fill: "currentColor",
|
|
46865
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
46866
|
-
...props,
|
|
46867
|
-
children: [
|
|
46868
|
-
/* @__PURE__ */ jsx(
|
|
46869
|
-
"path",
|
|
46870
|
-
{
|
|
46871
|
-
d: "M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",
|
|
46872
|
-
fill: "currentColor"
|
|
46873
|
-
}
|
|
46874
|
-
),
|
|
46875
|
-
/* @__PURE__ */ jsx(
|
|
46876
|
-
"path",
|
|
46877
|
-
{
|
|
46878
|
-
fillRule: "evenodd",
|
|
46879
|
-
clipRule: "evenodd",
|
|
46880
|
-
d: "M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",
|
|
46881
|
-
fill: "currentColor"
|
|
46882
|
-
}
|
|
46883
|
-
),
|
|
46884
|
-
/* @__PURE__ */ jsx(
|
|
46885
|
-
"path",
|
|
46886
|
-
{
|
|
46887
|
-
d: "M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",
|
|
46888
|
-
fill: "currentColor"
|
|
46889
|
-
}
|
|
46890
|
-
),
|
|
46891
|
-
/* @__PURE__ */ jsx(
|
|
46892
|
-
"path",
|
|
46893
|
-
{
|
|
46894
|
-
d: "M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",
|
|
46895
|
-
fill: "currentColor"
|
|
46896
|
-
}
|
|
46897
|
-
),
|
|
46898
|
-
/* @__PURE__ */ jsx(
|
|
46899
|
-
"path",
|
|
46900
|
-
{
|
|
46901
|
-
d: "M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",
|
|
46902
|
-
fill: "currentColor"
|
|
46903
|
-
}
|
|
46904
|
-
),
|
|
46905
|
-
/* @__PURE__ */ jsx(
|
|
46906
|
-
"path",
|
|
46907
|
-
{
|
|
46908
|
-
d: "M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",
|
|
46909
|
-
fill: "currentColor"
|
|
46910
|
-
}
|
|
46911
|
-
),
|
|
46912
|
-
/* @__PURE__ */ jsx(
|
|
46913
|
-
"path",
|
|
46914
|
-
{
|
|
46915
|
-
d: "M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",
|
|
46916
|
-
fill: "currentColor"
|
|
46917
|
-
}
|
|
46918
|
-
),
|
|
46919
|
-
/* @__PURE__ */ jsx(
|
|
46920
|
-
"path",
|
|
46921
|
-
{
|
|
46922
|
-
d: "M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",
|
|
46923
|
-
fill: "currentColor"
|
|
46924
|
-
}
|
|
46925
|
-
),
|
|
46926
|
-
/* @__PURE__ */ jsx(
|
|
46927
|
-
"path",
|
|
46928
|
-
{
|
|
46929
|
-
d: "M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",
|
|
46930
|
-
fill: "currentColor"
|
|
46931
|
-
}
|
|
46932
|
-
)
|
|
46933
|
-
]
|
|
46934
|
-
}
|
|
46935
|
-
);
|
|
46936
|
-
});
|
|
46937
|
-
SunIcon.displayName = "SunIcon";
|
|
46938
|
-
var MoonStarIcon = memo(({ className, ...props }) => {
|
|
46939
|
-
return /* @__PURE__ */ jsxs(
|
|
47581
|
+
var MessageSquareIcon = memo(({ className, ...props }) => {
|
|
47582
|
+
return /* @__PURE__ */ jsx(
|
|
46940
47583
|
"svg",
|
|
46941
47584
|
{
|
|
46942
47585
|
width: "24",
|
|
@@ -46946,54 +47589,19 @@ var MoonStarIcon = memo(({ className, ...props }) => {
|
|
|
46946
47589
|
fill: "currentColor",
|
|
46947
47590
|
xmlns: "http://www.w3.org/2000/svg",
|
|
46948
47591
|
...props,
|
|
46949
|
-
children:
|
|
46950
|
-
|
|
46951
|
-
|
|
46952
|
-
|
|
46953
|
-
|
|
46954
|
-
|
|
46955
|
-
|
|
46956
|
-
|
|
46957
|
-
|
|
46958
|
-
),
|
|
46959
|
-
/* @__PURE__ */ jsx(
|
|
46960
|
-
"path",
|
|
46961
|
-
{
|
|
46962
|
-
d: "M19 2C19.5523 2 20 2.44772 20 3V4H21C21.5523 4 22 4.44772 22 5C22 5.55228 21.5523 6 21 6H20V7C20 7.55228 19.5523 8 19 8C18.4477 8 18 7.55228 18 7V6H17C16.4477 6 16 5.55228 16 5C16 4.44772 16.4477 4 17 4H18V3C18 2.44772 18.4477 2 19 2Z",
|
|
46963
|
-
fill: "currentColor"
|
|
46964
|
-
}
|
|
46965
|
-
)
|
|
46966
|
-
]
|
|
47592
|
+
children: /* @__PURE__ */ jsx(
|
|
47593
|
+
"path",
|
|
47594
|
+
{
|
|
47595
|
+
fillRule: "evenodd",
|
|
47596
|
+
clipRule: "evenodd",
|
|
47597
|
+
d: "M5 5C4.73478 5 4.48043 5.10536 4.29289 5.29289C4.10536 5.48043 4 5.73478 4 6V19.5858L6.29289 17.2929C6.48043 17.1054 6.73478 17 7 17H19C19.2652 17 19.5196 16.8946 19.7071 16.7071C19.8946 16.5196 20 16.2652 20 16V6C20 5.73478 19.8946 5.48043 19.7071 5.29289C19.5196 5.10536 19.2652 5 19 5H5ZM2.87868 3.87868C3.44129 3.31607 4.20435 3 5 3H19C19.7957 3 20.5587 3.31607 21.1213 3.87868C21.6839 4.44129 22 5.20435 22 6V16C22 16.7957 21.6839 17.5587 21.1213 18.1213C20.5587 18.6839 19.7957 19 19 19H7.41421L3.70711 22.7071C3.42111 22.9931 2.99099 23.0787 2.61732 22.9239C2.24364 22.7691 2 22.4045 2 22V6C2 5.20435 2.31607 4.44129 2.87868 3.87868Z",
|
|
47598
|
+
fill: "currentColor"
|
|
47599
|
+
}
|
|
47600
|
+
)
|
|
46967
47601
|
}
|
|
46968
47602
|
);
|
|
46969
47603
|
});
|
|
46970
|
-
|
|
46971
|
-
function ThemeToggle() {
|
|
46972
|
-
const [isDarkMode, setIsDarkMode] = useState(false);
|
|
46973
|
-
useEffect(() => {
|
|
46974
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
46975
|
-
const handleChange = () => setIsDarkMode(mediaQuery.matches);
|
|
46976
|
-
mediaQuery.addEventListener("change", handleChange);
|
|
46977
|
-
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
46978
|
-
}, []);
|
|
46979
|
-
useEffect(() => {
|
|
46980
|
-
const initialDarkMode = !!document.querySelector('meta[name="color-scheme"][content="dark"]') || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
46981
|
-
setIsDarkMode(initialDarkMode);
|
|
46982
|
-
}, []);
|
|
46983
|
-
useEffect(() => {
|
|
46984
|
-
document.documentElement.classList.toggle("dark", isDarkMode);
|
|
46985
|
-
}, [isDarkMode]);
|
|
46986
|
-
const toggleDarkMode = () => setIsDarkMode((isDark) => !isDark);
|
|
46987
|
-
return /* @__PURE__ */ jsx(
|
|
46988
|
-
Button,
|
|
46989
|
-
{
|
|
46990
|
-
onClick: toggleDarkMode,
|
|
46991
|
-
"aria-label": `Switch to ${isDarkMode ? "light" : "dark"} mode`,
|
|
46992
|
-
variant: "ghost",
|
|
46993
|
-
children: isDarkMode ? /* @__PURE__ */ jsx(MoonStarIcon, { className: "tiptap-button-icon" }) : /* @__PURE__ */ jsx(SunIcon, { className: "tiptap-button-icon" })
|
|
46994
|
-
}
|
|
46995
|
-
);
|
|
46996
|
-
}
|
|
47604
|
+
MessageSquareIcon.displayName = "MessageSquareIcon";
|
|
46997
47605
|
var PrinterIcon = memo(({ className, ...props }) => {
|
|
46998
47606
|
return /* @__PURE__ */ jsxs(
|
|
46999
47607
|
"svg",
|
|
@@ -47240,40 +47848,199 @@ function CollaborationUsers() {
|
|
|
47240
47848
|
] }) }, user.id)) }) })
|
|
47241
47849
|
] });
|
|
47242
47850
|
}
|
|
47243
|
-
|
|
47851
|
+
var SAVE_STATE_LABELS = {
|
|
47852
|
+
unsaved: "未保存",
|
|
47853
|
+
saving: "正在保存",
|
|
47854
|
+
saved: "已保存",
|
|
47855
|
+
error: "保存失败",
|
|
47856
|
+
offline: "离线"
|
|
47857
|
+
};
|
|
47858
|
+
function DocumentViewModeMenu() {
|
|
47859
|
+
const { mode, canEdit, setMode } = useViewMode();
|
|
47860
|
+
const [open, setOpen] = useState(false);
|
|
47861
|
+
if (!canEdit) return null;
|
|
47862
|
+
const current = VIEW_MODE_ITEMS.find((item) => item.mode === mode) ?? VIEW_MODE_ITEMS[0];
|
|
47863
|
+
return /* @__PURE__ */ jsx(MenuProvider2, { placement: "bottom-start", open, setOpen, children: /* @__PURE__ */ jsxs(MenuContext.Provider, { value: { isRootMenu: true, open }, children: [
|
|
47864
|
+
/* @__PURE__ */ jsxs(
|
|
47865
|
+
MenuButton2,
|
|
47866
|
+
{
|
|
47867
|
+
render: /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost" }),
|
|
47868
|
+
"aria-label": `文档模式:${current.name}`,
|
|
47869
|
+
children: [
|
|
47870
|
+
/* @__PURE__ */ jsx("span", { children: current.name }),
|
|
47871
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "tiptap-button-dropdown-small", "aria-hidden": "true" })
|
|
47872
|
+
]
|
|
47873
|
+
}
|
|
47874
|
+
),
|
|
47875
|
+
/* @__PURE__ */ jsx(
|
|
47876
|
+
MenuContent,
|
|
47877
|
+
{
|
|
47878
|
+
className: "notion-like-editor-menu",
|
|
47879
|
+
"aria-label": "文档模式",
|
|
47880
|
+
composite: true,
|
|
47881
|
+
modal: false,
|
|
47882
|
+
portal: true,
|
|
47883
|
+
preventBodyScroll: false,
|
|
47884
|
+
children: VIEW_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
|
|
47885
|
+
MenuItemRadio2,
|
|
47886
|
+
{
|
|
47887
|
+
className: "notion-like-editor-menu-item",
|
|
47888
|
+
name: "document-view-mode",
|
|
47889
|
+
value: item.mode,
|
|
47890
|
+
checked: item.mode === mode,
|
|
47891
|
+
"aria-label": item.name,
|
|
47892
|
+
hideOnClick: true,
|
|
47893
|
+
onClick: () => {
|
|
47894
|
+
if (item.mode !== mode) setMode(item.mode, "user");
|
|
47895
|
+
},
|
|
47896
|
+
children: [
|
|
47897
|
+
/* @__PURE__ */ jsx("span", { children: item.name }),
|
|
47898
|
+
/* @__PURE__ */ jsx(MenuItemCheck2, {})
|
|
47899
|
+
]
|
|
47900
|
+
},
|
|
47901
|
+
item.mode
|
|
47902
|
+
))
|
|
47903
|
+
}
|
|
47904
|
+
)
|
|
47905
|
+
] }) });
|
|
47906
|
+
}
|
|
47907
|
+
function DocumentMoreMenu() {
|
|
47244
47908
|
const { editor } = useTiptapEditor();
|
|
47245
|
-
|
|
47246
|
-
|
|
47247
|
-
|
|
47248
|
-
|
|
47249
|
-
|
|
47250
|
-
|
|
47251
|
-
|
|
47252
|
-
|
|
47253
|
-
|
|
47254
|
-
|
|
47255
|
-
|
|
47256
|
-
|
|
47257
|
-
|
|
47258
|
-
|
|
47909
|
+
const documentConfig = useEditorConfig()?.document;
|
|
47910
|
+
const { mode, setMode } = useWidthMode();
|
|
47911
|
+
const [open, setOpen] = useState(false);
|
|
47912
|
+
const theme = useTheme();
|
|
47913
|
+
const isDark = isDarkAntdToken(theme, theme.isDarkMode);
|
|
47914
|
+
return /* @__PURE__ */ jsx(MenuProvider2, { placement: "bottom-end", open, setOpen, children: /* @__PURE__ */ jsxs(MenuContext.Provider, { value: { isRootMenu: true, open }, children: [
|
|
47915
|
+
/* @__PURE__ */ jsx(MenuButton2, { render: /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost" }), "aria-label": "更多操作", children: /* @__PURE__ */ jsx(MoreVerticalIcon, { className: "tiptap-button-icon", "aria-hidden": "true" }) }),
|
|
47916
|
+
/* @__PURE__ */ jsxs(
|
|
47917
|
+
MenuContent,
|
|
47918
|
+
{
|
|
47919
|
+
className: "notion-like-editor-menu",
|
|
47920
|
+
"aria-label": "更多操作",
|
|
47921
|
+
composite: true,
|
|
47922
|
+
modal: false,
|
|
47923
|
+
portal: true,
|
|
47924
|
+
preventBodyScroll: false,
|
|
47925
|
+
children: [
|
|
47926
|
+
/* @__PURE__ */ jsxs(MenuGroup2, { children: [
|
|
47927
|
+
/* @__PURE__ */ jsx(MenuGroupLabel2, { children: "页宽设置" }),
|
|
47928
|
+
WIDTH_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
|
|
47929
|
+
MenuItemRadio2,
|
|
47930
|
+
{
|
|
47931
|
+
className: "notion-like-editor-menu-item",
|
|
47932
|
+
name: "document-width",
|
|
47933
|
+
value: item.mode,
|
|
47934
|
+
checked: item.mode === mode,
|
|
47935
|
+
hideOnClick: true,
|
|
47936
|
+
onClick: () => {
|
|
47937
|
+
if (item.mode !== mode) setMode(item.mode);
|
|
47938
|
+
},
|
|
47939
|
+
children: [
|
|
47940
|
+
/* @__PURE__ */ jsx("span", { children: item.name }),
|
|
47941
|
+
/* @__PURE__ */ jsx(MenuItemCheck2, {})
|
|
47942
|
+
]
|
|
47943
|
+
},
|
|
47944
|
+
item.mode
|
|
47945
|
+
))
|
|
47946
|
+
] }),
|
|
47947
|
+
editor && getDocPermissions(editor).print && typeof editor.commands.printDocument === "function" ? /* @__PURE__ */ jsxs(
|
|
47948
|
+
MenuItem3,
|
|
47949
|
+
{
|
|
47950
|
+
className: "notion-like-editor-menu-item",
|
|
47951
|
+
"aria-label": "打印",
|
|
47952
|
+
onClick: () => {
|
|
47953
|
+
if (getDocPermissions(editor).print) editor.commands.printDocument();
|
|
47954
|
+
},
|
|
47955
|
+
children: [
|
|
47956
|
+
/* @__PURE__ */ jsx(PrinterIcon, { className: "tiptap-button-icon", "aria-hidden": "true" }),
|
|
47957
|
+
/* @__PURE__ */ jsx("span", { children: "打印" })
|
|
47958
|
+
]
|
|
47959
|
+
}
|
|
47960
|
+
) : null,
|
|
47961
|
+
documentConfig?.onOpenHistory ? /* @__PURE__ */ jsx(
|
|
47962
|
+
MenuItem3,
|
|
47963
|
+
{
|
|
47964
|
+
className: "notion-like-editor-menu-item",
|
|
47965
|
+
onClick: documentConfig.onOpenHistory,
|
|
47966
|
+
children: "历史记录"
|
|
47967
|
+
}
|
|
47968
|
+
) : null,
|
|
47969
|
+
/* @__PURE__ */ jsx(MenuSeparator2, { className: "notion-like-editor-menu-separator" }),
|
|
47970
|
+
/* @__PURE__ */ jsxs("div", { className: "notion-like-editor-menu-note", children: [
|
|
47971
|
+
"主题:跟随宿主(",
|
|
47972
|
+
isDark ? "深色" : "浅色",
|
|
47973
|
+
")"
|
|
47974
|
+
] })
|
|
47975
|
+
]
|
|
47976
|
+
}
|
|
47977
|
+
)
|
|
47978
|
+
] }) });
|
|
47259
47979
|
}
|
|
47260
47980
|
function NotionEditorHeader() {
|
|
47981
|
+
const documentConfig = useEditorConfig()?.document;
|
|
47982
|
+
const saveState = documentConfig?.saveState;
|
|
47983
|
+
const commentCount = documentConfig?.commentCount;
|
|
47261
47984
|
return /* @__PURE__ */ jsxs("header", { className: "notion-like-editor-header", children: [
|
|
47985
|
+
saveState ? /* @__PURE__ */ jsxs("div", { className: "notion-like-editor-header-feedback", children: [
|
|
47986
|
+
/* @__PURE__ */ jsxs(
|
|
47987
|
+
"output",
|
|
47988
|
+
{
|
|
47989
|
+
className: "notion-like-editor-save-state",
|
|
47990
|
+
"data-save-state": saveState,
|
|
47991
|
+
"aria-live": "polite",
|
|
47992
|
+
"aria-atomic": "true",
|
|
47993
|
+
children: [
|
|
47994
|
+
/* @__PURE__ */ jsx("span", { className: "notion-like-editor-save-state-indicator", "aria-hidden": "true" }),
|
|
47995
|
+
/* @__PURE__ */ jsx("span", { children: SAVE_STATE_LABELS[saveState] })
|
|
47996
|
+
]
|
|
47997
|
+
}
|
|
47998
|
+
),
|
|
47999
|
+
saveState === "error" && documentConfig?.onRetrySave ? /* @__PURE__ */ jsx(
|
|
48000
|
+
Button,
|
|
48001
|
+
{
|
|
48002
|
+
type: "button",
|
|
48003
|
+
variant: "ghost",
|
|
48004
|
+
size: "small",
|
|
48005
|
+
"aria-label": "重试保存",
|
|
48006
|
+
onClick: documentConfig.onRetrySave,
|
|
48007
|
+
children: "重试"
|
|
48008
|
+
}
|
|
48009
|
+
) : null
|
|
48010
|
+
] }) : null,
|
|
47262
48011
|
/* @__PURE__ */ jsx(Spacer, {}),
|
|
47263
48012
|
/* @__PURE__ */ jsxs("div", { className: "notion-like-editor-header-actions", children: [
|
|
47264
|
-
/* @__PURE__ */ jsx(
|
|
47265
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
48013
|
+
/* @__PURE__ */ jsx(DocumentViewModeMenu, {}),
|
|
47266
48014
|
/* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
47267
|
-
/* @__PURE__ */ jsx(
|
|
47268
|
-
/* @__PURE__ */ jsx(
|
|
48015
|
+
/* @__PURE__ */ jsx(UndoRedoButton, { action: "undo", tabIndex: 0 }),
|
|
48016
|
+
/* @__PURE__ */ jsx(UndoRedoButton, { action: "redo", tabIndex: 0 })
|
|
47269
48017
|
] }),
|
|
47270
48018
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
47271
|
-
/* @__PURE__ */ jsx(
|
|
47272
|
-
/* @__PURE__ */
|
|
47273
|
-
|
|
47274
|
-
|
|
47275
|
-
|
|
47276
|
-
|
|
48019
|
+
/* @__PURE__ */ jsx(CollaborationUsers, {}),
|
|
48020
|
+
documentConfig?.onOpenComments ? /* @__PURE__ */ jsxs(
|
|
48021
|
+
Button,
|
|
48022
|
+
{
|
|
48023
|
+
type: "button",
|
|
48024
|
+
variant: "ghost",
|
|
48025
|
+
"aria-label": commentCount === void 0 ? "评论" : `评论(${commentCount})`,
|
|
48026
|
+
onClick: documentConfig.onOpenComments,
|
|
48027
|
+
children: [
|
|
48028
|
+
/* @__PURE__ */ jsx(MessageSquareIcon, { className: "tiptap-button-icon", "aria-hidden": "true" }),
|
|
48029
|
+
commentCount !== void 0 ? /* @__PURE__ */ jsx("span", { className: "notion-like-editor-comment-count", "aria-hidden": "true", children: commentCount }) : null
|
|
48030
|
+
]
|
|
48031
|
+
}
|
|
48032
|
+
) : null,
|
|
48033
|
+
documentConfig?.onShare ? /* @__PURE__ */ jsx(
|
|
48034
|
+
Button,
|
|
48035
|
+
{
|
|
48036
|
+
type: "button",
|
|
48037
|
+
variant: "primary",
|
|
48038
|
+
className: "notion-like-editor-share",
|
|
48039
|
+
onClick: documentConfig.onShare,
|
|
48040
|
+
children: "分享"
|
|
48041
|
+
}
|
|
48042
|
+
) : null,
|
|
48043
|
+
/* @__PURE__ */ jsx(DocumentMoreMenu, {})
|
|
47277
48044
|
] })
|
|
47278
48045
|
] });
|
|
47279
48046
|
}
|
|
@@ -49925,9 +50692,33 @@ function MainToolbarContent({
|
|
|
49925
50692
|
toolbarViews,
|
|
49926
50693
|
onViewChange
|
|
49927
50694
|
}) {
|
|
50695
|
+
const comments = useEditorConfig()?.comments;
|
|
50696
|
+
const commentSelection = useEditorState({
|
|
50697
|
+
editor,
|
|
50698
|
+
selector: ({ editor: current }) => current ? getCommentSelection(current.state) : null
|
|
50699
|
+
});
|
|
50700
|
+
const commentSelectionRef = useRef(null);
|
|
49928
50701
|
const hasSelection = hasTextSelection(editor);
|
|
49929
50702
|
const hasContent = (editor?.getText().length ?? 0) > 0;
|
|
49930
50703
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
50704
|
+
comments && editor?.isEditable && commentSelection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
|
|
50705
|
+
Button,
|
|
50706
|
+
{
|
|
50707
|
+
type: "button",
|
|
50708
|
+
variant: "ghost",
|
|
50709
|
+
"aria-label": "添加评论",
|
|
50710
|
+
onMouseDown: (event) => {
|
|
50711
|
+
event.preventDefault();
|
|
50712
|
+
commentSelectionRef.current = getCommentSelection(editor.state);
|
|
50713
|
+
},
|
|
50714
|
+
onClick: () => {
|
|
50715
|
+
const selection = commentSelectionRef.current ?? commentSelection;
|
|
50716
|
+
commentSelectionRef.current = null;
|
|
50717
|
+
if (editor.isEditable && selection) comments.onCreateComment(selection);
|
|
50718
|
+
},
|
|
50719
|
+
children: "添加评论"
|
|
50720
|
+
}
|
|
50721
|
+
) }),
|
|
49931
50722
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
49932
50723
|
/* @__PURE__ */ jsx(SlashCommandTriggerButton, {}),
|
|
49933
50724
|
/* @__PURE__ */ jsx(MoreActionsDropdown, { editor }),
|
|
@@ -50022,6 +50813,12 @@ function MobileToolbar({ editor: providedEditor }) {
|
|
|
50022
50813
|
}
|
|
50023
50814
|
function NotionToolbarFloating() {
|
|
50024
50815
|
const { editor } = useTiptapEditor();
|
|
50816
|
+
const comments = useEditorConfig()?.comments;
|
|
50817
|
+
const commentSelection = useEditorState({
|
|
50818
|
+
editor,
|
|
50819
|
+
selector: ({ editor: current }) => current ? getCommentSelection(current.state) : null
|
|
50820
|
+
});
|
|
50821
|
+
const commentSelectionRef = useRef(null);
|
|
50025
50822
|
const isMobile = useIsBreakpoint("max", 480);
|
|
50026
50823
|
const { lockDragHandle, commentInputVisible } = useUiEditorState(editor);
|
|
50027
50824
|
const linkPanelOpen = useEditorState({
|
|
@@ -50060,6 +50857,24 @@ function NotionToolbarFloating() {
|
|
|
50060
50857
|
/* @__PURE__ */ jsx(VideoNodeFloating, {})
|
|
50061
50858
|
] }),
|
|
50062
50859
|
/* @__PURE__ */ jsx(MoreOptions, { hideWhenUnavailable: true }),
|
|
50860
|
+
comments && editor?.isEditable && commentSelection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
|
|
50861
|
+
Button,
|
|
50862
|
+
{
|
|
50863
|
+
type: "button",
|
|
50864
|
+
variant: "ghost",
|
|
50865
|
+
"aria-label": "添加评论",
|
|
50866
|
+
onMouseDown: (event) => {
|
|
50867
|
+
event.preventDefault();
|
|
50868
|
+
commentSelectionRef.current = getCommentSelection(editor.state);
|
|
50869
|
+
},
|
|
50870
|
+
onClick: () => {
|
|
50871
|
+
const selection = commentSelectionRef.current ?? commentSelection;
|
|
50872
|
+
commentSelectionRef.current = null;
|
|
50873
|
+
if (editor.isEditable && selection) comments.onCreateComment(selection);
|
|
50874
|
+
},
|
|
50875
|
+
children: "添加评论"
|
|
50876
|
+
}
|
|
50877
|
+
) }),
|
|
50063
50878
|
editor?.isEditable && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
|
|
50064
50879
|
Button,
|
|
50065
50880
|
{
|
|
@@ -50234,6 +51049,13 @@ function TocSidebar({
|
|
|
50234
51049
|
}) {
|
|
50235
51050
|
const { tocContent, navigateToHeading, normalizeHeadingDepths: normalizeHeadingDepths2 } = useToc();
|
|
50236
51051
|
const hasRestoredHashRef = useRef(false);
|
|
51052
|
+
const navigationId = useId();
|
|
51053
|
+
const toggleRef = useRef(null);
|
|
51054
|
+
const [isPinned, setIsPinned] = useState(false);
|
|
51055
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
51056
|
+
const [hasFocus, setHasFocus] = useState(false);
|
|
51057
|
+
const [isDismissed, setIsDismissed] = useState(false);
|
|
51058
|
+
const isExpanded = !isDismissed && (isPinned || isHovered || hasFocus);
|
|
50237
51059
|
const lastClickTimeRef = useRef(null);
|
|
50238
51060
|
const [manualActiveId, setManualActiveId] = useState(null);
|
|
50239
51061
|
const headingList = useMemo(
|
|
@@ -50328,7 +51150,7 @@ function TocSidebar({
|
|
|
50328
51150
|
const popoverRef = useRef(null);
|
|
50329
51151
|
useEffect(() => {
|
|
50330
51152
|
if (!activeContentId) return;
|
|
50331
|
-
for (const box of [progressRef.current, popoverRef.current]) {
|
|
51153
|
+
for (const box of [isPinned ? null : progressRef.current, isExpanded ? popoverRef.current : null]) {
|
|
50332
51154
|
const el = box?.querySelector(`[data-toc-id="${CSS.escape(activeContentId)}"]`);
|
|
50333
51155
|
if (!box || !el) continue;
|
|
50334
51156
|
const top = el.offsetTop - box.offsetTop;
|
|
@@ -50336,60 +51158,154 @@ function TocSidebar({
|
|
|
50336
51158
|
if (top < box.scrollTop) box.scrollTop = top;
|
|
50337
51159
|
else if (bottom > box.scrollTop + box.clientHeight) box.scrollTop = bottom - box.clientHeight;
|
|
50338
51160
|
}
|
|
50339
|
-
}, [activeContentId]);
|
|
51161
|
+
}, [activeContentId, isExpanded, isPinned]);
|
|
50340
51162
|
const hasHeadings = headingList.length > 0;
|
|
50341
|
-
|
|
50342
|
-
|
|
50343
|
-
|
|
50344
|
-
|
|
50345
|
-
|
|
50346
|
-
|
|
51163
|
+
const closeSidebar = () => {
|
|
51164
|
+
setIsPinned(false);
|
|
51165
|
+
setIsDismissed(true);
|
|
51166
|
+
toggleRef.current?.focus({ preventScroll: true });
|
|
51167
|
+
};
|
|
51168
|
+
return /* @__PURE__ */ jsx(
|
|
51169
|
+
"div",
|
|
51170
|
+
{
|
|
51171
|
+
ref: sidebarRef,
|
|
51172
|
+
className: cn(
|
|
51173
|
+
"toc-sidebar",
|
|
51174
|
+
hasHeadings && isPinned && "toc-sidebar--pinned",
|
|
51175
|
+
hasHeadings && isExpanded && "toc-sidebar--expanded",
|
|
51176
|
+
className
|
|
51177
|
+
),
|
|
51178
|
+
...props,
|
|
51179
|
+
children: /* @__PURE__ */ jsx(
|
|
51180
|
+
"aside",
|
|
50347
51181
|
{
|
|
50348
|
-
"
|
|
50349
|
-
|
|
50350
|
-
|
|
50351
|
-
|
|
50352
|
-
|
|
50353
|
-
|
|
50354
|
-
|
|
50355
|
-
|
|
50356
|
-
|
|
50357
|
-
|
|
50358
|
-
|
|
50359
|
-
|
|
50360
|
-
|
|
50361
|
-
|
|
50362
|
-
|
|
50363
|
-
|
|
50364
|
-
|
|
50365
|
-
|
|
50366
|
-
|
|
50367
|
-
|
|
50368
|
-
|
|
50369
|
-
|
|
50370
|
-
|
|
50371
|
-
|
|
50372
|
-
|
|
50373
|
-
"
|
|
50374
|
-
|
|
50375
|
-
|
|
50376
|
-
|
|
50377
|
-
|
|
50378
|
-
"
|
|
50379
|
-
|
|
50380
|
-
|
|
50381
|
-
|
|
50382
|
-
|
|
50383
|
-
|
|
50384
|
-
|
|
50385
|
-
|
|
50386
|
-
|
|
50387
|
-
|
|
50388
|
-
|
|
50389
|
-
|
|
50390
|
-
|
|
50391
|
-
|
|
50392
|
-
|
|
51182
|
+
className: "toc-sidebar-wrapper",
|
|
51183
|
+
"aria-label": "文档目录",
|
|
51184
|
+
onMouseEnter: () => {
|
|
51185
|
+
setIsHovered(true);
|
|
51186
|
+
setIsDismissed(false);
|
|
51187
|
+
},
|
|
51188
|
+
onMouseLeave: () => setIsHovered(false),
|
|
51189
|
+
onFocusCapture: (event) => {
|
|
51190
|
+
setHasFocus(true);
|
|
51191
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setIsDismissed(false);
|
|
51192
|
+
},
|
|
51193
|
+
onBlurCapture: (event) => {
|
|
51194
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setHasFocus(false);
|
|
51195
|
+
},
|
|
51196
|
+
onKeyDownCapture: (event) => {
|
|
51197
|
+
if (event.key === "Escape" && isExpanded) {
|
|
51198
|
+
event.preventDefault();
|
|
51199
|
+
event.stopPropagation();
|
|
51200
|
+
closeSidebar();
|
|
51201
|
+
} else if (isDismissed && event.key === "Tab" && !event.shiftKey && event.target === toggleRef.current) {
|
|
51202
|
+
flushSync(() => setIsDismissed(false));
|
|
51203
|
+
}
|
|
51204
|
+
},
|
|
51205
|
+
children: /* @__PURE__ */ jsxs("div", { className: "toc-sidebar-inner", children: [
|
|
51206
|
+
hasHeadings && /* @__PURE__ */ jsxs(
|
|
51207
|
+
"button",
|
|
51208
|
+
{
|
|
51209
|
+
ref: toggleRef,
|
|
51210
|
+
type: "button",
|
|
51211
|
+
className: "toc-sidebar-toggle",
|
|
51212
|
+
"aria-label": isPinned ? "收起目录" : "固定目录",
|
|
51213
|
+
title: isPinned ? "收起目录" : "固定目录",
|
|
51214
|
+
"aria-controls": navigationId,
|
|
51215
|
+
"aria-pressed": isPinned,
|
|
51216
|
+
"aria-expanded": isExpanded,
|
|
51217
|
+
onClick: () => {
|
|
51218
|
+
if (isPinned) closeSidebar();
|
|
51219
|
+
else {
|
|
51220
|
+
setIsDismissed(false);
|
|
51221
|
+
setIsPinned(true);
|
|
51222
|
+
}
|
|
51223
|
+
},
|
|
51224
|
+
children: [
|
|
51225
|
+
/* @__PURE__ */ jsx(
|
|
51226
|
+
"svg",
|
|
51227
|
+
{
|
|
51228
|
+
width: "14",
|
|
51229
|
+
height: "14",
|
|
51230
|
+
viewBox: "0 0 24 24",
|
|
51231
|
+
fill: "none",
|
|
51232
|
+
stroke: "currentColor",
|
|
51233
|
+
strokeWidth: "1.8",
|
|
51234
|
+
"aria-hidden": "true",
|
|
51235
|
+
focusable: "false",
|
|
51236
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4 5h16M4 12h16M4 19h10" })
|
|
51237
|
+
}
|
|
51238
|
+
),
|
|
51239
|
+
isPinned ? "收起目录" : "目录"
|
|
51240
|
+
]
|
|
51241
|
+
}
|
|
51242
|
+
),
|
|
51243
|
+
/* @__PURE__ */ jsx(
|
|
51244
|
+
"div",
|
|
51245
|
+
{
|
|
51246
|
+
ref: progressRef,
|
|
51247
|
+
className: "toc-sidebar-progress",
|
|
51248
|
+
"aria-hidden": "true",
|
|
51249
|
+
tabIndex: -1,
|
|
51250
|
+
children: visibleHeadings.map((item) => {
|
|
51251
|
+
const depth = depthById.get(item.id) ?? 1;
|
|
51252
|
+
const isActive = activeContentId === item.id;
|
|
51253
|
+
return /* @__PURE__ */ jsx(
|
|
51254
|
+
"div",
|
|
51255
|
+
{
|
|
51256
|
+
"data-toc-id": item.id,
|
|
51257
|
+
className: cn(
|
|
51258
|
+
"toc-sidebar-progress-line",
|
|
51259
|
+
isActive && "toc-sidebar-progress-line--active"
|
|
51260
|
+
),
|
|
51261
|
+
"data-depth": depth,
|
|
51262
|
+
style: { "--toc-depth": depth }
|
|
51263
|
+
},
|
|
51264
|
+
item.id
|
|
51265
|
+
);
|
|
51266
|
+
})
|
|
51267
|
+
}
|
|
51268
|
+
),
|
|
51269
|
+
/* @__PURE__ */ jsx(
|
|
51270
|
+
"nav",
|
|
51271
|
+
{
|
|
51272
|
+
id: navigationId,
|
|
51273
|
+
className: cn(
|
|
51274
|
+
"toc-sidebar-nav",
|
|
51275
|
+
!hasHeadings && "toc-sidebar-nav--hidden"
|
|
51276
|
+
),
|
|
51277
|
+
"aria-label": "目录",
|
|
51278
|
+
"aria-hidden": !hasHeadings || !isExpanded,
|
|
51279
|
+
children: /* @__PURE__ */ jsx("div", { ref: popoverRef, className: "toc-sidebar-popover", tabIndex: -1, children: visibleHeadings.map((item) => {
|
|
51280
|
+
const depth = depthById.get(item.id) ?? 1;
|
|
51281
|
+
const isActive = activeContentId === item.id;
|
|
51282
|
+
return /* @__PURE__ */ jsx(
|
|
51283
|
+
"a",
|
|
51284
|
+
{
|
|
51285
|
+
"data-toc-id": item.id,
|
|
51286
|
+
title: item.textContent,
|
|
51287
|
+
href: `#${item.id}`,
|
|
51288
|
+
rel: "noopener noreferrer",
|
|
51289
|
+
className: cn(
|
|
51290
|
+
"toc-sidebar-item notranslate",
|
|
51291
|
+
isActive && "toc-sidebar-item--active"
|
|
51292
|
+
),
|
|
51293
|
+
"data-depth": depth,
|
|
51294
|
+
style: { "--toc-depth": depth },
|
|
51295
|
+
onClick: (e) => handleContentClick(e, item),
|
|
51296
|
+
"aria-current": isActive ? "location" : void 0,
|
|
51297
|
+
children: withOrder(item)
|
|
51298
|
+
},
|
|
51299
|
+
item.id
|
|
51300
|
+
);
|
|
51301
|
+
}) })
|
|
51302
|
+
}
|
|
51303
|
+
)
|
|
51304
|
+
] })
|
|
51305
|
+
}
|
|
51306
|
+
)
|
|
51307
|
+
}
|
|
51308
|
+
);
|
|
50393
51309
|
}
|
|
50394
51310
|
var ListNormalizationExtension = Extension.create({
|
|
50395
51311
|
name: "listNormalization",
|
|
@@ -51405,6 +52321,8 @@ function EditorProvider(props) {
|
|
|
51405
52321
|
return found;
|
|
51406
52322
|
}, []);
|
|
51407
52323
|
const editorConfig = useEditorConfig();
|
|
52324
|
+
const editorConfigRef = useRef(editorConfig);
|
|
52325
|
+
editorConfigRef.current = editorConfig;
|
|
51408
52326
|
const onSendRef = useRef(onSend);
|
|
51409
52327
|
onSendRef.current = onSend;
|
|
51410
52328
|
const sendKeyRef = useRef(sendKey);
|
|
@@ -51564,6 +52482,10 @@ function EditorProvider(props) {
|
|
|
51564
52482
|
FindReplace,
|
|
51565
52483
|
PrintDocument,
|
|
51566
52484
|
ReadOnlyGuard,
|
|
52485
|
+
CommentThread.configure({
|
|
52486
|
+
isInteractive: () => Boolean(editorConfigRef.current?.comments?.onSelectThread),
|
|
52487
|
+
onSelectThread: (threadId) => editorConfigRef.current?.comments?.onSelectThread?.(threadId)
|
|
52488
|
+
}),
|
|
51567
52489
|
Color,
|
|
51568
52490
|
FeishuTaskList,
|
|
51569
52491
|
TaskItem.configure({ nested: true }),
|
|
@@ -51669,6 +52591,7 @@ function EditorProvider(props) {
|
|
|
51669
52591
|
],
|
|
51670
52592
|
filterTransaction: (transaction) => !isChangeOrigin(transaction)
|
|
51671
52593
|
}),
|
|
52594
|
+
PasteNodeIds,
|
|
51672
52595
|
// 不挂 Typography:飞书没有任何排版替换(MD 规则全集 vT 里没有),它会把中文文档里的
|
|
51673
52596
|
// 引号、`--`、`1*2` 改写掉
|
|
51674
52597
|
UiState,
|
|
@@ -51710,6 +52633,10 @@ function EditorProvider(props) {
|
|
|
51710
52633
|
extensions
|
|
51711
52634
|
});
|
|
51712
52635
|
editorRef.current = editor;
|
|
52636
|
+
const canSelectComment = Boolean(editorConfig?.comments?.onSelectThread);
|
|
52637
|
+
useEffect(() => {
|
|
52638
|
+
if (editor) refreshCommentThreadInteractivity(editor, canSelectComment);
|
|
52639
|
+
}, [editor, canSelectComment]);
|
|
51713
52640
|
useEffect(() => {
|
|
51714
52641
|
if (!editor) return;
|
|
51715
52642
|
editorRef.current = editor;
|
|
@@ -52015,6 +52942,6 @@ function ArticleViewer({
|
|
|
52015
52942
|
] });
|
|
52016
52943
|
}
|
|
52017
52944
|
|
|
52018
|
-
export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, DetailsExtension, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorProvider, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch,
|
|
52019
|
-
//# sourceMappingURL=chunk-
|
|
52020
|
-
//# sourceMappingURL=chunk-
|
|
52945
|
+
export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, CommentThread, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, DetailsExtension, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorProvider, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WIDTH_MODE_ITEMS, WIDTH_MODE_MENU_HEADER, WIDTH_MODE_MENU_TITLE, countDocument, countRange, countText, defaultUiState, detectMediaKind, findSelectionPosition, getDocPermissions, getEditorMarkdown, hasContentAbove, markHideFloatingOnNext, parseEditorContent, pickFile, printDocument, refreshCommentThreadInteractivity, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, serializeEditorMarkdown, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize, use_ui_editor_state_default };
|
|
52946
|
+
//# sourceMappingURL=chunk-MKJY3LFJ.js.map
|
|
52947
|
+
//# sourceMappingURL=chunk-MKJY3LFJ.js.map
|