@4399ywkf/editor 0.11.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-KUVYBQ66.js → DocView-ZC6IDEAA.js} +3 -3
- package/dist/{DocView-KUVYBQ66.js.map → DocView-ZC6IDEAA.js.map} +1 -1
- package/dist/{chunk-6MZAYCF6.js → chunk-MKJY3LFJ.js} +1542 -402
- package/dist/chunk-MKJY3LFJ.js.map +1 -0
- package/dist/doc-standalone.js +1624 -397
- package/dist/doc-standalone.js.map +1 -1
- package/dist/doc.d.ts +75 -7
- 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 +3 -2
- package/dist/chunk-6MZAYCF6.js.map +0 -1
package/dist/doc-standalone.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactFlowProvider, Position, MarkerType, useNodesState, useEdgesState, useReactFlow, addEdge, ReactFlow, ConnectionMode, Background, Controls, Panel, Handle } from '@xyflow/react';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import React__default, { createContext, forwardRef, useState, useEffect, memo, isValidElement, version, cloneElement, useMemo, useCallback, lazy, useLayoutEffect, useRef, useContext, Fragment as Fragment$2, createRef, createElement, useDebugValue, Suspense, useReducer, Children } from 'react';
|
|
3
|
+
import React__default, { createContext, forwardRef, useState, useEffect, memo, isValidElement, version, cloneElement, useMemo, useCallback, lazy, useLayoutEffect, useRef, useContext, Fragment as Fragment$2, createRef, createElement, useDebugValue, Suspense, useReducer, useId, Children } from 'react';
|
|
4
4
|
import { jsxs, Fragment as Fragment$1, jsx } from 'react/jsx-runtime';
|
|
5
5
|
import ReactDOM, { flushSync, createPortal } from 'react-dom';
|
|
6
6
|
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
@@ -33404,7 +33404,7 @@ ${isDark ? `:root .tt-block-marquee {
|
|
|
33404
33404
|
`;
|
|
33405
33405
|
|
|
33406
33406
|
// src/components/tiptap-node/blockquote-node/blockquote-node.style.ts
|
|
33407
|
-
var blockquoteNodeStyles = ({ isDark }) => `
|
|
33407
|
+
var blockquoteNodeStyles = ({ isDark, pick: pick2 }) => `
|
|
33408
33408
|
.tiptap.ProseMirror {
|
|
33409
33409
|
/* 对齐飞书引用块:竖条 N400(#bbbfc4)、文字 N600(#646a73) */
|
|
33410
33410
|
/* (与 new-editor 编辑态 app 层的 --udtoken-quote-bar-bg/--text-caption 同源同值) */
|
|
@@ -33421,11 +33421,11 @@ var blockquoteNodeStyles = ({ isDark }) => `
|
|
|
33421
33421
|
BLOCKQUOTE
|
|
33422
33422
|
===================== */
|
|
33423
33423
|
.tiptap.ProseMirror {
|
|
33424
|
-
/* 对齐飞书:2px 竖条 + 12px 缩进 +
|
|
33424
|
+
/* 对齐飞书:2px 竖条 + 12px 缩进 + 灰色文字;飞书风块上下 8px(知识库 docx 实测) */
|
|
33425
33425
|
blockquote {
|
|
33426
33426
|
position: relative;
|
|
33427
33427
|
padding-left: 12px;
|
|
33428
|
-
margin: 16px 0;
|
|
33428
|
+
margin: ${pick2("8px 0 8px 2px", "16px 0")};
|
|
33429
33429
|
color: var(--blockquote-text-color);
|
|
33430
33430
|
|
|
33431
33431
|
p {
|
|
@@ -33436,7 +33436,7 @@ var blockquoteNodeStyles = ({ isDark }) => `
|
|
|
33436
33436
|
&.is-empty::before {
|
|
33437
33437
|
position: absolute;
|
|
33438
33438
|
bottom: 0;
|
|
33439
|
-
left: 0;
|
|
33439
|
+
left: ${pick2("-2px", "0")};
|
|
33440
33440
|
top: 0;
|
|
33441
33441
|
height: 100%;
|
|
33442
33442
|
width: 2px;
|
|
@@ -34628,7 +34628,7 @@ var cardStyles = ({ surface, gray }) => `
|
|
|
34628
34628
|
`;
|
|
34629
34629
|
|
|
34630
34630
|
// src/components/tiptap-node/code-block-node/code-block-node.style.ts
|
|
34631
|
-
var codeBlockStyles = ({ token, surface, gray }) => {
|
|
34631
|
+
var codeBlockStyles = ({ token, surface, gray, pick: pick2 }) => {
|
|
34632
34632
|
const text = gray(800);
|
|
34633
34633
|
const muted = gray(600);
|
|
34634
34634
|
return `
|
|
@@ -34677,8 +34677,9 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
34677
34677
|
.tiptap-code-block {
|
|
34678
34678
|
position: relative;
|
|
34679
34679
|
margin: 16px 0;
|
|
34680
|
+
padding-bottom: ${pick2("2px", "0")};
|
|
34680
34681
|
border: 1px solid ${surface.blockBorderColor};
|
|
34681
|
-
border-radius: ${surface.blockRadius}px;
|
|
34682
|
+
border-radius: ${pick2("8px", `${surface.blockRadius}px`)};
|
|
34682
34683
|
background-color: ${surface.codeBg};
|
|
34683
34684
|
color: ${text};
|
|
34684
34685
|
|
|
@@ -34708,16 +34709,16 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
34708
34709
|
align-items: center;
|
|
34709
34710
|
justify-content: space-between;
|
|
34710
34711
|
gap: 8px;
|
|
34711
|
-
height: 24px;
|
|
34712
|
-
padding: 4px 8px 0;
|
|
34712
|
+
height: ${pick2("32px", "24px")};
|
|
34713
|
+
padding: ${pick2("8px 8px 0 12px", "4px 8px 0")};
|
|
34713
34714
|
border-radius: ${surface.blockRadius}px ${surface.blockRadius}px 0 0;
|
|
34714
34715
|
background: transparent;
|
|
34715
|
-
font-size: 12px;
|
|
34716
|
-
line-height: 20px;
|
|
34717
|
-
color: ${muted};
|
|
34716
|
+
font-size: ${pick2("14px", "12px")};
|
|
34717
|
+
line-height: ${pick2("22px", "20px")};
|
|
34718
|
+
color: ${pick2("#646a73", muted)};
|
|
34718
34719
|
user-select: none;
|
|
34719
|
-
opacity: 0;
|
|
34720
|
-
pointer-events: none;
|
|
34720
|
+
opacity: ${pick2("1", "0")};
|
|
34721
|
+
pointer-events: ${pick2("auto", "none")};
|
|
34721
34722
|
transition: opacity 0.15s;
|
|
34722
34723
|
}
|
|
34723
34724
|
|
|
@@ -34728,9 +34729,14 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
34728
34729
|
}
|
|
34729
34730
|
|
|
34730
34731
|
.tiptap-code-block > pre {
|
|
34731
|
-
margin-top: 24px;
|
|
34732
|
-
padding-top: 4px
|
|
34733
|
-
|
|
34732
|
+
margin-top: ${pick2("32px", "24px")};
|
|
34733
|
+
padding-top: ${pick2("8px", "4px")};${pick2(
|
|
34734
|
+
`
|
|
34735
|
+
padding-right: 20px;
|
|
34736
|
+
padding-bottom: 24px;`,
|
|
34737
|
+
""
|
|
34738
|
+
)}
|
|
34739
|
+
min-height: ${pick2("61px", "53px")};
|
|
34734
34740
|
max-height: 1958px;
|
|
34735
34741
|
overflow-y: auto;
|
|
34736
34742
|
box-sizing: border-box;
|
|
@@ -34903,14 +34909,14 @@ var codeBlockStyles = ({ token, surface, gray }) => {
|
|
|
34903
34909
|
|
|
34904
34910
|
/* 行号:数字由 ::before 画,不进文档文本,复制不会带上 */
|
|
34905
34911
|
.tiptap-code-block__pre.has-line-numbers {
|
|
34906
|
-
padding-left: 3.5em;
|
|
34912
|
+
padding-left: ${pick2("59px", "3.5em")};
|
|
34907
34913
|
}
|
|
34908
34914
|
|
|
34909
34915
|
.tt-code-line-number {
|
|
34910
34916
|
display: inline-block;
|
|
34911
|
-
width: 2.5em;
|
|
34912
|
-
margin-left: -3.5em;
|
|
34913
|
-
margin-right: 1em;
|
|
34917
|
+
width: ${pick2("45px", "2.5em")};
|
|
34918
|
+
margin-left: ${pick2("-59px", "-3.5em")};
|
|
34919
|
+
margin-right: ${pick2("14px", "1em")};
|
|
34914
34920
|
text-align: right;
|
|
34915
34921
|
color: ${muted};
|
|
34916
34922
|
opacity: 0.7;
|
|
@@ -35222,7 +35228,7 @@ var codeGroupStyles = ({ token, surface, gray }) => `
|
|
|
35222
35228
|
`;
|
|
35223
35229
|
|
|
35224
35230
|
// src/components/tiptap-node/collapsible-node/collapsible-node.style.ts
|
|
35225
|
-
var collapsibleStyles = ({ token, surface, isDark, gray }) => `
|
|
35231
|
+
var collapsibleStyles = ({ token, surface, isDark, gray, pick: pick2 }) => `
|
|
35226
35232
|
.tiptap.ProseMirror {
|
|
35227
35233
|
.tt-collapsible { position: relative; margin: 12px 0; }
|
|
35228
35234
|
.tt-collapsible__header { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 32px; user-select: none; }
|
|
@@ -35264,8 +35270,9 @@ var collapsibleStyles = ({ token, surface, isDark, gray }) => `
|
|
|
35264
35270
|
display: flex;
|
|
35265
35271
|
align-items: flex-start;
|
|
35266
35272
|
gap: 8px;
|
|
35267
|
-
|
|
35268
|
-
|
|
35273
|
+
/* 飞书知识库 docx:内边距 16,块下 16(上沿跟随前一块的 8px) */
|
|
35274
|
+
margin: ${pick2("8px 0 16px", "12px 0")};
|
|
35275
|
+
padding: ${pick2("16px", "12px 16px")};
|
|
35269
35276
|
/* 飞书描边、Notion 只铺底色 */
|
|
35270
35277
|
border: 1px solid ${surface.calloutBordered ? "var(--callout-border, var(--tt-color-callout-border-orange))" : "transparent"};
|
|
35271
35278
|
border-radius: ${surface.cardRadius}px;
|
|
@@ -35652,8 +35659,9 @@ var columnNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
35652
35659
|
[data-type="columns"],
|
|
35653
35660
|
.tiptap-columns {
|
|
35654
35661
|
display: grid;
|
|
35655
|
-
|
|
35656
|
-
|
|
35662
|
+
/* 飞书知识库 docx 实测:列间距 24,分栏块上下 16,列内首块不带上外边距 */
|
|
35663
|
+
gap: ${pick2("24px", "1rem")};
|
|
35664
|
+
margin: ${pick2("16px 0", "0.5em 0")};
|
|
35657
35665
|
}
|
|
35658
35666
|
|
|
35659
35667
|
[data-type="columns"].layout-column,
|
|
@@ -35676,6 +35684,18 @@ var columnNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
35676
35684
|
[data-type="column"] {
|
|
35677
35685
|
min-width: 0; /* 防止内容撑破网格列 */
|
|
35678
35686
|
}
|
|
35687
|
+
${pick2(`
|
|
35688
|
+
/* 列是 grid 项,块的外边距出不了列;飞书列内首块不带上外边距、末块不带下外边距(图片的外边距在里层) */
|
|
35689
|
+
[data-type="column"] > :first-child,
|
|
35690
|
+
[data-type="column"] > :first-child > .tiptap-image,
|
|
35691
|
+
[data-type="column"] > .ProseMirror-widget:first-child + * {
|
|
35692
|
+
margin-top: 0;
|
|
35693
|
+
}
|
|
35694
|
+
|
|
35695
|
+
[data-type="column"] > :last-child,
|
|
35696
|
+
[data-type="column"] > :last-child > .tiptap-image {
|
|
35697
|
+
margin-bottom: 0;
|
|
35698
|
+
}`, "")}
|
|
35679
35699
|
|
|
35680
35700
|
/* React NodeView 在 grid 容器和列之间多包了一层 contentDOM,让它不参与布局,列才是 grid 的子项 */
|
|
35681
35701
|
.tiptap-columns > [data-node-view-content-react] {
|
|
@@ -35694,7 +35714,7 @@ var columnNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
35694
35714
|
/* 飞书按容器宽度(不足 578px)决定是否堆叠,所以用容器查询 */
|
|
35695
35715
|
.tiptap-columns-wrapper {
|
|
35696
35716
|
position: relative;
|
|
35697
|
-
margin: 0.5em 0;
|
|
35717
|
+
margin: ${pick2("16px 0", "0.5em 0")};
|
|
35698
35718
|
container-type: inline-size;
|
|
35699
35719
|
|
|
35700
35720
|
.tiptap-columns {
|
|
@@ -37425,6 +37445,7 @@ var headingNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
37425
37445
|
/* 标题字号/行高/字重/间距对齐飞书文档(帮助中心文章页实测值): */
|
|
37426
37446
|
/* h1 26/36 600 · h2 22/30 600 · h3 20/28 600 · h4 18/26 500 · h5/h6 16/26 500, */
|
|
37427
37447
|
/* margin-top 等于自身字号,margin-bottom 8px(h1 为 10px)。 */
|
|
37448
|
+
/* 飞书风另按知识库 docx 实测:h1–h3 字重 500(加粗文字才 700)、行高 1.4、字距 -0.02em。 */
|
|
37428
37449
|
.tiptap.ProseMirror {
|
|
37429
37450
|
h1,
|
|
37430
37451
|
h2,
|
|
@@ -37435,6 +37456,7 @@ var headingNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
37435
37456
|
position: relative;
|
|
37436
37457
|
color: inherit;
|
|
37437
37458
|
font-style: inherit;
|
|
37459
|
+
letter-spacing: ${pick2("-0.02em", "normal")};
|
|
37438
37460
|
}
|
|
37439
37461
|
|
|
37440
37462
|
> h1:first-child,
|
|
@@ -37452,18 +37474,28 @@ var headingNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
37452
37474
|
margin-top: 0;
|
|
37453
37475
|
}
|
|
37454
37476
|
|
|
37455
|
-
|
|
37477
|
+
${pick2(` /* 飞书标题底色是 6px 圆角的蒙层 */
|
|
37478
|
+
h1[style*="background-color"],
|
|
37479
|
+
h2[style*="background-color"],
|
|
37480
|
+
h3[style*="background-color"],
|
|
37481
|
+
h4[style*="background-color"],
|
|
37482
|
+
h5[style*="background-color"],
|
|
37483
|
+
h6[style*="background-color"] {
|
|
37484
|
+
border-radius: 6px;
|
|
37485
|
+
}
|
|
37486
|
+
|
|
37487
|
+
`, "")} h1 {
|
|
37456
37488
|
font-size: 26px;
|
|
37457
|
-
line-height: 36px;
|
|
37458
|
-
font-weight: 600;
|
|
37489
|
+
line-height: ${pick2("36.4px", "36px")};
|
|
37490
|
+
font-weight: ${pick2("500", "600")};
|
|
37459
37491
|
margin-top: 26px;
|
|
37460
37492
|
margin-bottom: 10px;
|
|
37461
37493
|
}
|
|
37462
37494
|
|
|
37463
37495
|
h2 {
|
|
37464
37496
|
font-size: 22px;
|
|
37465
|
-
line-height: 30px;
|
|
37466
|
-
font-weight: 600;
|
|
37497
|
+
line-height: ${pick2("30.8px", "30px")};
|
|
37498
|
+
font-weight: ${pick2("500", "600")};
|
|
37467
37499
|
margin-top: 22px;
|
|
37468
37500
|
margin-bottom: 8px;
|
|
37469
37501
|
}
|
|
@@ -37471,14 +37503,14 @@ var headingNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
37471
37503
|
h3 {
|
|
37472
37504
|
font-size: 20px;
|
|
37473
37505
|
line-height: 28px;
|
|
37474
|
-
font-weight: 600;
|
|
37506
|
+
font-weight: ${pick2("500", "600")};
|
|
37475
37507
|
margin-top: 20px;
|
|
37476
37508
|
margin-bottom: 8px;
|
|
37477
37509
|
}
|
|
37478
37510
|
|
|
37479
37511
|
h4 {
|
|
37480
37512
|
font-size: 18px;
|
|
37481
|
-
line-height: 26px;
|
|
37513
|
+
line-height: ${pick2("25.2px", "26px")};
|
|
37482
37514
|
font-weight: 500;
|
|
37483
37515
|
margin-top: 18px;
|
|
37484
37516
|
margin-bottom: 8px;
|
|
@@ -37498,6 +37530,7 @@ var headingNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
37498
37530
|
.tiptap.ProseMirror {
|
|
37499
37531
|
[data-heading-level] {
|
|
37500
37532
|
position: relative;
|
|
37533
|
+
letter-spacing: ${pick2("-0.02em", "normal")};
|
|
37501
37534
|
font-size: 16px;
|
|
37502
37535
|
line-height: 26px;
|
|
37503
37536
|
font-weight: 500;
|
|
@@ -37711,7 +37744,7 @@ var headingNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
37711
37744
|
`;
|
|
37712
37745
|
|
|
37713
37746
|
// src/components/tiptap-node/horizontal-rule-node/horizontal-rule-node.style.ts
|
|
37714
|
-
var horizontalRuleNodeStyles = ({ isDark }) => `
|
|
37747
|
+
var horizontalRuleNodeStyles = ({ isDark, pick: pick2 }) => `
|
|
37715
37748
|
.tiptap.ProseMirror {
|
|
37716
37749
|
--horizontal-rule-color: var(--tt-gray-light-a-200);
|
|
37717
37750
|
|
|
@@ -37726,15 +37759,17 @@ var horizontalRuleNodeStyles = ({ isDark }) => `
|
|
|
37726
37759
|
.tiptap.ProseMirror {
|
|
37727
37760
|
hr {
|
|
37728
37761
|
border: none;
|
|
37729
|
-
height: 1px
|
|
37762
|
+
height: 1px;${pick2(`
|
|
37763
|
+
margin: 0;`, "")}
|
|
37730
37764
|
background-color: var(--horizontal-rule-color);
|
|
37731
37765
|
}
|
|
37732
37766
|
|
|
37767
|
+
/* 飞书分割线块:上下 8px、内边距 12px,整块高 25px */
|
|
37733
37768
|
[data-type="horizontalRule"] {
|
|
37734
|
-
margin-top: 2.25em;
|
|
37735
|
-
margin-bottom: 2.25em;
|
|
37736
|
-
padding-top: 0.75rem;
|
|
37737
|
-
padding-bottom: 0.75rem;
|
|
37769
|
+
margin-top: ${pick2("8px", "2.25em")};
|
|
37770
|
+
margin-bottom: ${pick2("8px", "2.25em")};
|
|
37771
|
+
padding-top: ${pick2("12px", "0.75rem")};
|
|
37772
|
+
padding-bottom: ${pick2("12px", "0.75rem")};
|
|
37738
37773
|
}
|
|
37739
37774
|
}
|
|
37740
37775
|
`;
|
|
@@ -37798,7 +37833,7 @@ ${isDark ? `:root {
|
|
|
37798
37833
|
.tiptap-image {
|
|
37799
37834
|
display: flex;
|
|
37800
37835
|
width: 100%;
|
|
37801
|
-
margin: 1.5rem 0;
|
|
37836
|
+
margin: ${pick2("16px 0", "1.5rem 0")};
|
|
37802
37837
|
|
|
37803
37838
|
&[data-align="right"] {
|
|
37804
37839
|
text-align: right;
|
|
@@ -37839,6 +37874,11 @@ ${isDark ? `:root {
|
|
|
37839
37874
|
border-radius: var(--tt-radius-xs, 0.25rem);
|
|
37840
37875
|
}
|
|
37841
37876
|
|
|
37877
|
+
/* 加载前按节点记的宽高比占位(见 image-transform.tsx),给个浅底,别是一块看不见的空白 */
|
|
37878
|
+
.tiptap-image-img[data-pending] {
|
|
37879
|
+
background: var(${isDark ? "--tt-gray-dark-a-100" : "--tt-gray-light-a-100"});
|
|
37880
|
+
}
|
|
37881
|
+
|
|
37842
37882
|
.tiptap-image-handle {
|
|
37843
37883
|
position: absolute;
|
|
37844
37884
|
top: 50%;
|
|
@@ -37867,7 +37907,7 @@ ${isDark ? `:root {
|
|
|
37867
37907
|
width: 100%;
|
|
37868
37908
|
white-space: break-spaces;
|
|
37869
37909
|
word-break: break-word;
|
|
37870
|
-
margin-top: 1rem;
|
|
37910
|
+
margin-top: ${pick2("8px", "1rem")};
|
|
37871
37911
|
outline: none;
|
|
37872
37912
|
position: relative;
|
|
37873
37913
|
|
|
@@ -39480,6 +39520,8 @@ var listNodeStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
39480
39520
|
ul:not([data-type="taskList"]) > li::marker {
|
|
39481
39521
|
color: var(--tt-list-marker-color);
|
|
39482
39522
|
font-size: 1.2em;
|
|
39523
|
+
/* 放大后的 bullet 若沿用 1.625 行高(31px)会把每行撑高 3px */
|
|
39524
|
+
line-height: 1;
|
|
39483
39525
|
}
|
|
39484
39526
|
|
|
39485
39527
|
ul:not([data-type="taskList"]) {
|
|
@@ -40221,7 +40263,7 @@ var mermaidNodeStyles = ({ pick: pick2, surface }) => `
|
|
|
40221
40263
|
`;
|
|
40222
40264
|
|
|
40223
40265
|
// src/components/tiptap-templates/notion-like/notion-like-editor-header.style.ts
|
|
40224
|
-
var notionLikeEditorHeaderStyles = ({ surface, pick: pick2, isDark }) => `
|
|
40266
|
+
var notionLikeEditorHeaderStyles = ({ token, surface, pick: pick2, isDark }) => `
|
|
40225
40267
|
:root {
|
|
40226
40268
|
--tt-notion-like-editor-header-border: var(--tt-gray-light-a-200);
|
|
40227
40269
|
--tt-notion-like-editor-header-bg: var(--white);
|
|
@@ -40238,7 +40280,9 @@ ${isDark ? `:root {
|
|
|
40238
40280
|
width: 100%;
|
|
40239
40281
|
display: flex;
|
|
40240
40282
|
align-items: center;
|
|
40241
|
-
height: 3rem;
|
|
40283
|
+
min-height: 3rem;
|
|
40284
|
+
box-sizing: border-box;
|
|
40285
|
+
gap: 0.5rem;
|
|
40242
40286
|
padding: 0.5rem 0.75rem;
|
|
40243
40287
|
z-index: 50;
|
|
40244
40288
|
background-color: var(--tt-notion-like-editor-header-bg);
|
|
@@ -40248,14 +40292,189 @@ ${isDark ? `:root {
|
|
|
40248
40292
|
display: flex;
|
|
40249
40293
|
align-items: center;
|
|
40250
40294
|
flex-direction: row;
|
|
40295
|
+
flex-shrink: 0;
|
|
40296
|
+
gap: 0.25rem;
|
|
40297
|
+
}
|
|
40298
|
+
|
|
40299
|
+
&-feedback {
|
|
40300
|
+
display: flex;
|
|
40301
|
+
align-items: center;
|
|
40302
|
+
flex-shrink: 0;
|
|
40303
|
+
gap: 0.375rem;
|
|
40304
|
+
}
|
|
40305
|
+
|
|
40306
|
+
button:focus-visible {
|
|
40307
|
+
outline: 2px solid ${surface.accentColor};
|
|
40308
|
+
outline-offset: 2px;
|
|
40309
|
+
}
|
|
40310
|
+
}
|
|
40311
|
+
|
|
40312
|
+
.notion-like-editor-save-state {
|
|
40313
|
+
display: flex;
|
|
40314
|
+
align-items: center;
|
|
40315
|
+
gap: 0.375rem;
|
|
40316
|
+
color: ${surface.textSecondary};
|
|
40317
|
+
font-size: 0.75rem;
|
|
40318
|
+
line-height: 1.5rem;
|
|
40319
|
+
white-space: nowrap;
|
|
40320
|
+
|
|
40321
|
+
&[data-save-state="error"] {
|
|
40322
|
+
color: ${token.colorError};
|
|
40323
|
+
}
|
|
40324
|
+
|
|
40325
|
+
&[data-save-state="offline"] {
|
|
40326
|
+
color: ${token.colorWarningText};
|
|
40327
|
+
}
|
|
40328
|
+
|
|
40329
|
+
&-indicator {
|
|
40330
|
+
width: 0.375rem;
|
|
40331
|
+
height: 0.375rem;
|
|
40332
|
+
border-radius: 50%;
|
|
40333
|
+
background: currentColor;
|
|
40334
|
+
}
|
|
40335
|
+
|
|
40336
|
+
&[data-save-state="saving"] &-indicator {
|
|
40337
|
+
width: 0.625rem;
|
|
40338
|
+
height: 0.625rem;
|
|
40339
|
+
box-sizing: border-box;
|
|
40340
|
+
border: 1px solid currentColor;
|
|
40341
|
+
border-right-color: transparent;
|
|
40342
|
+
background: transparent;
|
|
40343
|
+
animation: notion-like-editor-saving 0.8s linear infinite;
|
|
40344
|
+
}
|
|
40345
|
+
}
|
|
40346
|
+
|
|
40347
|
+
.notion-like-editor-header .notion-like-editor-share {
|
|
40348
|
+
padding-inline: 0.875rem;
|
|
40349
|
+
color: ${token.colorTextLightSolid};
|
|
40350
|
+
background: ${surface.accentColor};
|
|
40351
|
+
|
|
40352
|
+
&:hover {
|
|
40353
|
+
color: ${token.colorTextLightSolid};
|
|
40354
|
+
background: ${token.colorPrimaryHover};
|
|
40355
|
+
}
|
|
40356
|
+
}
|
|
40357
|
+
|
|
40358
|
+
.notion-like-editor-comment-count {
|
|
40359
|
+
min-width: 0.75rem;
|
|
40360
|
+
font-variant-numeric: tabular-nums;
|
|
40361
|
+
}
|
|
40362
|
+
|
|
40363
|
+
.notion-like-editor-menu {
|
|
40364
|
+
height: auto;
|
|
40365
|
+
min-width: 11rem;
|
|
40366
|
+
max-width: calc(100vw - 1rem);
|
|
40367
|
+
padding: 0.375rem;
|
|
40368
|
+
border: 1px solid ${surface.floatBorderColor};
|
|
40369
|
+
border-radius: ${surface.floatRadius}px;
|
|
40370
|
+
color: ${surface.colorText};
|
|
40371
|
+
background: ${surface.floatBg};
|
|
40372
|
+
box-shadow: ${surface.floatShadow};
|
|
40373
|
+
z-index: 60;
|
|
40374
|
+
|
|
40375
|
+
.tiptap-menu-group {
|
|
40376
|
+
display: block;
|
|
40377
|
+
}
|
|
40378
|
+
|
|
40379
|
+
.tiptap-menu-group-label {
|
|
40380
|
+
margin-top: 0.25rem;
|
|
40381
|
+
color: ${surface.textSecondary};
|
|
40382
|
+
}
|
|
40383
|
+
|
|
40384
|
+
&-item {
|
|
40385
|
+
display: flex;
|
|
40386
|
+
align-items: center;
|
|
40387
|
+
justify-content: flex-start;
|
|
40251
40388
|
gap: 0.5rem;
|
|
40389
|
+
min-height: 2rem;
|
|
40390
|
+
padding: 0.375rem 0.5rem;
|
|
40391
|
+
border-radius: ${surface.itemRadius}px;
|
|
40392
|
+
font-size: 0.875rem;
|
|
40393
|
+
line-height: 1.25rem;
|
|
40394
|
+
cursor: pointer;
|
|
40395
|
+
outline: none;
|
|
40396
|
+
|
|
40397
|
+
&:hover,
|
|
40398
|
+
&[data-active-item] {
|
|
40399
|
+
background: ${surface.itemHoverBg};
|
|
40400
|
+
}
|
|
40401
|
+
|
|
40402
|
+
&:focus-visible {
|
|
40403
|
+
outline: 2px solid ${surface.accentColor};
|
|
40404
|
+
outline-offset: -2px;
|
|
40405
|
+
}
|
|
40406
|
+
|
|
40407
|
+
.tiptap-button-icon,
|
|
40408
|
+
.tiptap-menu-item-check {
|
|
40409
|
+
width: 1rem;
|
|
40410
|
+
height: 1rem;
|
|
40411
|
+
}
|
|
40412
|
+
|
|
40413
|
+
.tiptap-menu-item-check {
|
|
40414
|
+
margin-left: auto;
|
|
40415
|
+
}
|
|
40416
|
+
}
|
|
40417
|
+
|
|
40418
|
+
&-separator {
|
|
40419
|
+
margin: 0.375rem 0;
|
|
40420
|
+
border: 0;
|
|
40421
|
+
border-top: 1px solid ${surface.dividerColor};
|
|
40422
|
+
}
|
|
40423
|
+
|
|
40424
|
+
&-note {
|
|
40425
|
+
padding: 0.375rem 0.5rem;
|
|
40426
|
+
color: ${surface.textSecondary};
|
|
40427
|
+
font-size: 0.75rem;
|
|
40428
|
+
line-height: 1.25rem;
|
|
40429
|
+
}
|
|
40430
|
+
}
|
|
40431
|
+
|
|
40432
|
+
@keyframes notion-like-editor-saving {
|
|
40433
|
+
to { transform: rotate(360deg); }
|
|
40434
|
+
}
|
|
40435
|
+
|
|
40436
|
+
@media (prefers-reduced-motion: reduce) {
|
|
40437
|
+
.notion-like-editor-save-state-indicator {
|
|
40438
|
+
animation: none !important;
|
|
40439
|
+
}
|
|
40440
|
+
}
|
|
40441
|
+
|
|
40442
|
+
@media (max-width: 640px) {
|
|
40443
|
+
.notion-like-editor-header {
|
|
40444
|
+
flex-wrap: wrap;
|
|
40445
|
+
padding-inline: 0.5rem;
|
|
40446
|
+
|
|
40447
|
+
&-feedback {
|
|
40448
|
+
flex-basis: 100%;
|
|
40449
|
+
}
|
|
40450
|
+
|
|
40451
|
+
&-actions {
|
|
40452
|
+
margin-left: auto;
|
|
40453
|
+
}
|
|
40252
40454
|
}
|
|
40253
40455
|
}
|
|
40254
40456
|
`;
|
|
40255
40457
|
|
|
40256
40458
|
// src/components/tiptap-templates/notion-like/notion-like-editor.style.ts
|
|
40257
|
-
var
|
|
40258
|
-
|
|
40459
|
+
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';
|
|
40460
|
+
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"';
|
|
40461
|
+
var CHINESE_QUOTE_FACES = [
|
|
40462
|
+
["400", 'local("PingFangSC-Regular"), local("PingFang SC"), local("Microsoft YaHei"), local("Hiragino Sans GB")'],
|
|
40463
|
+
["500", 'local("PingFangSC-Medium"), local("PingFang SC Medium"), local("Microsoft YaHei"), local("Hiragino Sans GB")'],
|
|
40464
|
+
["600", 'local("PingFangSC-Semibold"), local("PingFang SC Semibold"), local("Microsoft YaHei Bold"), local("Hiragino Sans GB W6")'],
|
|
40465
|
+
["700", 'local("PingFangSC-Semibold"), local("PingFang SC Semibold"), local("Microsoft YaHei Bold"), local("Hiragino Sans GB W6")']
|
|
40466
|
+
].map(
|
|
40467
|
+
([weight, src]) => `@font-face {
|
|
40468
|
+
font-family: TTChineseQuote;
|
|
40469
|
+
font-weight: ${weight};
|
|
40470
|
+
src: ${src};
|
|
40471
|
+
unicode-range: U+2018, U+2019, U+201A, U+201C, U+201D, U+201E;
|
|
40472
|
+
}`
|
|
40473
|
+
).join("\n");
|
|
40474
|
+
var notionLikeEditorStyles = ({ surface, pick: pick2 }) => `
|
|
40475
|
+
${pick2(CHINESE_QUOTE_FACES, "")}
|
|
40476
|
+
|
|
40477
|
+
/* 正文字体栈对齐飞书(Notion 风沿用 feishu.cn 文章页实测值,飞书风用知识库 docx 实测值),纯系统字体、无外网字体依赖 */
|
|
40259
40478
|
/* (原 Google Fonts 的 DM Sans/Inter 在内网/无外网环境加载失败,中文全靠 sans-serif 兜底)。 */
|
|
40260
40479
|
/* "Segoe UI Emoji" 放最前是飞书的做法:Windows 上 emoji 走彩色字体,文本字符自动落到后面的正文字体。 */
|
|
40261
40480
|
/* 正文色读表面 token surface.colorText(src/theme/editor-theme.ts:Notion #2c2c2b / 飞书 N900 #1f2329)。 */
|
|
@@ -40266,7 +40485,7 @@ var notionLikeEditorStyles = ({ surface }) => `
|
|
|
40266
40485
|
/* Helvetica Neue 的 0.517,整站文字缩小 1.7%,切换文章(编辑器卸载再挂载)时全站字体抖一下。 */
|
|
40267
40486
|
/* 页面底色、overscroll 归宿主管;独立整页编辑器的宿主页面自己设。 */
|
|
40268
40487
|
.notion-like-editor-wrapper {
|
|
40269
|
-
font-family:
|
|
40488
|
+
font-family: ${pick2(DOCX_FONT_STACK, ARTICLE_FONT_STACK)};
|
|
40270
40489
|
color: ${surface.colorText};
|
|
40271
40490
|
font-weight: 400;
|
|
40272
40491
|
font-style: normal;
|
|
@@ -40295,7 +40514,10 @@ var notionLikeEditorStyles = ({ surface }) => `
|
|
|
40295
40514
|
}
|
|
40296
40515
|
|
|
40297
40516
|
.tiptap.ProseMirror {
|
|
40298
|
-
font-family:
|
|
40517
|
+
font-family: ${pick2(DOCX_FONT_STACK, ARTICLE_FONT_STACK)};${pick2(`
|
|
40518
|
+
/* 飞书 docx 正文:行尾放不下的空格也折到下一行(break-spaces),长串在任意处断行 */
|
|
40519
|
+
white-space: break-spaces;
|
|
40520
|
+
word-break: break-word;`, "")}
|
|
40299
40521
|
/* 正文基准对齐飞书文档:16px / 1.625 / #1f2329。 */
|
|
40300
40522
|
/* 字号必须显式定在编辑器根上:li>p、td/th p 等不走 paragraph-node.scss 的 */
|
|
40301
40523
|
/* p:not(:first-child) 字号声明,全靠这里继承;不写会继承宿主容器字号 */
|
|
@@ -40317,7 +40539,7 @@ var notionLikeEditorStyles = ({ surface }) => `
|
|
|
40317
40539
|
/* 用 :not() 写在原规则上而不是后面再覆盖一遍——两个类同特异性,靠源序决胜负太脆。 */
|
|
40318
40540
|
@media screen and (max-width: 480px) {
|
|
40319
40541
|
.notion-like-editor-wrapper:not(.notion-like-editor-wrapper--embedded) {
|
|
40320
|
-
width:
|
|
40542
|
+
width: 100%;
|
|
40321
40543
|
height: 100vh;
|
|
40322
40544
|
overflow: auto;
|
|
40323
40545
|
}
|
|
@@ -40649,17 +40871,22 @@ var orderedListNumberMenuStyles = ({ surface, pick: pick2 }) => `
|
|
|
40649
40871
|
// src/components/tiptap-node/page-header-node/page-header-node.style.ts
|
|
40650
40872
|
var pageHeaderNodeStyles = ({ surface, pick: pick2, isDark }) => `
|
|
40651
40873
|
/* 文档页头:封面 → 添加图标 / 添加封面 → 图标 + 标题,尺寸对齐飞书(标题 40px / 粗体,封面高 200px) */
|
|
40874
|
+
${pick2(`.notion-like-editor-layout {
|
|
40875
|
+
container-type: inline-size;
|
|
40876
|
+
}`, "")}
|
|
40877
|
+
|
|
40652
40878
|
.tiptap.ProseMirror {
|
|
40653
40879
|
.tt-page-header {
|
|
40654
40880
|
position: relative;
|
|
40655
40881
|
margin: 0 0 16px;
|
|
40656
40882
|
}
|
|
40657
40883
|
|
|
40658
|
-
/*
|
|
40884
|
+
/* 封面横向铺满正文列,左右多出正文内边距那一截,和飞书一样贴边;
|
|
40885
|
+
飞书风按知识库 docx:横跨整个编辑器布局区(不止正文列),高度由宿主用 --tt-page-cover-height 给 */
|
|
40659
40886
|
.tt-page-header__cover {
|
|
40660
40887
|
position: relative;
|
|
40661
|
-
height: 200px;
|
|
40662
|
-
margin: -3rem -3rem 0;
|
|
40888
|
+
height: var(--tt-page-cover-height, 200px);
|
|
40889
|
+
margin: ${pick2("-3rem calc(50% - 50cqw) 0", "-3rem -3rem 0")};
|
|
40663
40890
|
user-select: none;
|
|
40664
40891
|
|
|
40665
40892
|
&[data-repositioning="true"] {
|
|
@@ -40701,6 +40928,21 @@ var pageHeaderNodeStyles = ({ surface, pick: pick2, isDark }) => `
|
|
|
40701
40928
|
align-items: baseline;
|
|
40702
40929
|
}
|
|
40703
40930
|
|
|
40931
|
+
/* 飞书知识库 docx:封面下 20px 内边距 + 28px「添加图标 / 封面」行,只读时这行也占位 */
|
|
40932
|
+
${pick2(`.tt-page-header__cover + .tt-page-header__title-row {
|
|
40933
|
+
margin-top: 48px;
|
|
40934
|
+
}
|
|
40935
|
+
|
|
40936
|
+
.tt-page-header__add {
|
|
40937
|
+
margin: 20px 0 0;
|
|
40938
|
+
}
|
|
40939
|
+
|
|
40940
|
+
/* 页头下第一块不再叠加自身上外边距,和飞书一样从页头底部固定间距开始 */
|
|
40941
|
+
> .node-pageHeader + *,
|
|
40942
|
+
> [data-page-header] + * {
|
|
40943
|
+
margin-top: 0;
|
|
40944
|
+
}`, "")}
|
|
40945
|
+
|
|
40704
40946
|
.tt-page-header__title-row > .tt-page-header__title {
|
|
40705
40947
|
flex: 1;
|
|
40706
40948
|
min-width: 0;
|
|
@@ -40711,7 +40953,7 @@ var pageHeaderNodeStyles = ({ surface, pick: pick2, isDark }) => `
|
|
|
40711
40953
|
flex: none;
|
|
40712
40954
|
margin-right: 6px;
|
|
40713
40955
|
font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
|
|
40714
|
-
font-size: 40px;
|
|
40956
|
+
font-size: ${pick2("34px", "40px")};
|
|
40715
40957
|
line-height: 1;
|
|
40716
40958
|
|
|
40717
40959
|
button,
|
|
@@ -40719,8 +40961,8 @@ var pageHeaderNodeStyles = ({ surface, pick: pick2, isDark }) => `
|
|
|
40719
40961
|
display: flex;
|
|
40720
40962
|
align-items: center;
|
|
40721
40963
|
justify-content: center;
|
|
40722
|
-
width: 1.18em;
|
|
40723
|
-
height: 1.18em;
|
|
40964
|
+
width: ${pick2("40px", "1.18em")};
|
|
40965
|
+
height: ${pick2("40px", "1.18em")};
|
|
40724
40966
|
padding: 0;
|
|
40725
40967
|
border: none;
|
|
40726
40968
|
border-radius: ${pick2("6px", `${surface.inputRadius}px`)};
|
|
@@ -40775,9 +41017,9 @@ var pageHeaderNodeStyles = ({ surface, pick: pick2, isDark }) => `
|
|
|
40775
41017
|
}
|
|
40776
41018
|
|
|
40777
41019
|
.tt-page-header__title {
|
|
40778
|
-
font-size: 40px;
|
|
40779
|
-
line-height: 52px;
|
|
40780
|
-
font-weight: 700;
|
|
41020
|
+
font-size: ${pick2("34px", "40px")};
|
|
41021
|
+
line-height: ${pick2("55.25px", "52px")};
|
|
41022
|
+
font-weight: ${pick2("500", "700")};
|
|
40781
41023
|
color: var(--tt-color-text);
|
|
40782
41024
|
word-break: break-word;
|
|
40783
41025
|
}
|
|
@@ -41060,6 +41302,11 @@ var paragraphNodeStyles = ({ isDark }) => `
|
|
|
41060
41302
|
/* 段距对齐飞书(每个段落行 margin 8px,首段 0);字号/行高统一继承编辑器根 */
|
|
41061
41303
|
/* (notion-like-editor.scss 的 16px/1.625),这里不再重复声明——重复声明会让 */
|
|
41062
41304
|
/* 被 :not() 排除的 li>p、td/th p 与普通段落走上不同的字号来源。 */
|
|
41305
|
+
/* 浏览器默认 p 有 1em 下边距:不清掉的话段距变 16px、列表项间距变 16~24px */
|
|
41306
|
+
p {
|
|
41307
|
+
margin-bottom: 0;
|
|
41308
|
+
}
|
|
41309
|
+
|
|
41063
41310
|
p:not(:first-child):not(td p):not(th p) {
|
|
41064
41311
|
margin-top: 8px;
|
|
41065
41312
|
}
|
|
@@ -42958,6 +43205,15 @@ var syncedBlockStyles = ({ surface, pick: pick2, isDark }) => `
|
|
|
42958
43205
|
linear-gradient(135deg, rgb(var(--tt-synced-a)), rgb(var(--tt-synced-b)), rgb(var(--tt-synced-c)));
|
|
42959
43206
|
}
|
|
42960
43207
|
|
|
43208
|
+
/* 飞书只读同步块:内容紧贴内边距,首块不带上外边距、末块不带下外边距 */
|
|
43209
|
+
${pick2(`.tt-synced-block__content > * > :first-child {
|
|
43210
|
+
margin-top: 0;
|
|
43211
|
+
}
|
|
43212
|
+
|
|
43213
|
+
.tt-synced-block__content > * > :last-child {
|
|
43214
|
+
margin-bottom: 0;
|
|
43215
|
+
}`, "")}
|
|
43216
|
+
|
|
42961
43217
|
&.ProseMirror-selectednode,
|
|
42962
43218
|
.tt-block-selected > & {
|
|
42963
43219
|
border-color: #245bdb;
|
|
@@ -43597,10 +43853,25 @@ var tableInsertBarsStyles = ({ pick: pick2, surface }) => `
|
|
|
43597
43853
|
`;
|
|
43598
43854
|
|
|
43599
43855
|
// src/components/tiptap-node/table-node/styles/table-node.style.ts
|
|
43600
|
-
var tableStyles = ({ token, surface }) => `
|
|
43856
|
+
var tableStyles = ({ token, surface, pick: pick2 }) => `
|
|
43857
|
+
/* 飞书知识库 docx:表格上沿距前一块 29.5(扣掉包裹层留给手柄的 16 内边距);
|
|
43858
|
+
下沿是「表格 + 2 + max(24, 下一块上外边距)」,只读时没有「添加行」按钮,底部内边距让给外边距去折叠 */
|
|
43601
43859
|
.tiptap [data-content-type="table"] {
|
|
43602
|
-
margin-block: var(--tt-table-margin-block);
|
|
43860
|
+
margin-block: ${pick2("13.5px 2px", "var(--tt-table-margin-block)")};
|
|
43603
43861
|
}
|
|
43862
|
+
${pick2(
|
|
43863
|
+
`
|
|
43864
|
+
.notion-like-editor-wrapper--readonly .tiptap [data-content-type="table"] {
|
|
43865
|
+
margin-block-end: 24px;
|
|
43866
|
+
}
|
|
43867
|
+
|
|
43868
|
+
.notion-like-editor-wrapper--readonly .tiptap [data-content-type="table"] .tableWrapper {
|
|
43869
|
+
margin-left: 0;
|
|
43870
|
+
padding-inline: 0;
|
|
43871
|
+
padding-block-end: 2px;
|
|
43872
|
+
}`,
|
|
43873
|
+
""
|
|
43874
|
+
)}
|
|
43604
43875
|
|
|
43605
43876
|
.tiptap [data-content-type="table"] .tableWrapper {
|
|
43606
43877
|
padding-block-start: var(--tt-table-pad-block-start);
|
|
@@ -43623,7 +43894,7 @@ var tableStyles = ({ token, surface }) => `
|
|
|
43623
43894
|
border: 1px solid ${surface.tableBorderColor};
|
|
43624
43895
|
padding: var(--tt-table-cell-padding);
|
|
43625
43896
|
}
|
|
43626
|
-
${surface.tableRadius ? roundedTable(surface.tableRadius, surface.tableBorderColor) :
|
|
43897
|
+
${surface.tableRadius ? roundedTable(surface.tableRadius, surface.tableBorderColor) : squareTable(surface.tableBorderColor)}
|
|
43627
43898
|
/* 单元格里的段落没走正文段距(被 :not(td p) 排除),会吃到浏览器默认的上下 1em,行高撑到 75px */
|
|
43628
43899
|
.tiptap th > p,
|
|
43629
43900
|
.tiptap td > p {
|
|
@@ -43829,6 +44100,43 @@ function roundedTable(radius, color) {
|
|
|
43829
44100
|
}
|
|
43830
44101
|
`;
|
|
43831
44102
|
}
|
|
44103
|
+
function squareTable(color) {
|
|
44104
|
+
return `
|
|
44105
|
+
.tiptap table {
|
|
44106
|
+
border-collapse: separate;
|
|
44107
|
+
border-spacing: 0;
|
|
44108
|
+
border: 0;
|
|
44109
|
+
border-radius: 0;
|
|
44110
|
+
table-layout: fixed;
|
|
44111
|
+
}
|
|
44112
|
+
|
|
44113
|
+
.tiptap th,
|
|
44114
|
+
.tiptap td {
|
|
44115
|
+
border: 0;
|
|
44116
|
+
border-right: 1px solid ${color};
|
|
44117
|
+
border-bottom: 1px solid ${color};
|
|
44118
|
+
font-size: 14px;
|
|
44119
|
+
line-height: 23px;
|
|
44120
|
+
}
|
|
44121
|
+
|
|
44122
|
+
.tiptap tr:first-child > * {
|
|
44123
|
+
border-top: 1px solid ${color};
|
|
44124
|
+
}
|
|
44125
|
+
|
|
44126
|
+
.tiptap tr > :first-child {
|
|
44127
|
+
box-shadow: inset 1px 0 0 ${color};
|
|
44128
|
+
}
|
|
44129
|
+
|
|
44130
|
+
/* 单元格里的标题等块:首块不带上外边距、末块不带下外边距 */
|
|
44131
|
+
.tiptap :is(td, th) > :first-child {
|
|
44132
|
+
margin-top: 0;
|
|
44133
|
+
}
|
|
44134
|
+
|
|
44135
|
+
.tiptap :is(td, th) > :last-child {
|
|
44136
|
+
margin-bottom: 0;
|
|
44137
|
+
}
|
|
44138
|
+
`;
|
|
44139
|
+
}
|
|
43832
44140
|
|
|
43833
44141
|
// src/components/tiptap-ui-primitive/textarea/textarea.style.ts
|
|
43834
44142
|
var textareaStyles = ({ surface, pick: pick2, isDark }) => `
|
|
@@ -44035,7 +44343,7 @@ var tocSidebarStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
44035
44343
|
--toc-progress-width-base: 1rem; /* Base width for progress lines (16px) */
|
|
44036
44344
|
--toc-progress-width-min: 0.25rem; /* Minimum width for progress lines (4px) */
|
|
44037
44345
|
/* 目录最高到视口底部(sticky top 130px,再留出底部边距) */
|
|
44038
|
-
--toc-max-height: calc(
|
|
44346
|
+
--toc-max-height: calc(100dvh - 130px - 4rem);
|
|
44039
44347
|
|
|
44040
44348
|
${isDark ? `:root & {
|
|
44041
44349
|
--tt-toc-sidebar-line-bg: var(--tt-gray-dark-200);
|
|
@@ -44088,6 +44396,38 @@ var tocSidebarStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
44088
44396
|
padding-bottom: 0.75rem;
|
|
44089
44397
|
}
|
|
44090
44398
|
|
|
44399
|
+
&-toggle {
|
|
44400
|
+
display: inline-flex;
|
|
44401
|
+
align-items: center;
|
|
44402
|
+
justify-content: center;
|
|
44403
|
+
align-self: flex-end;
|
|
44404
|
+
gap: 0.25rem;
|
|
44405
|
+
min-height: 2rem;
|
|
44406
|
+
margin-bottom: 0.5rem;
|
|
44407
|
+
padding: 0.375rem;
|
|
44408
|
+
border: 1px solid ${pick2("var(--tt-toc-sidebar-border-color)", surface.floatBorderColor)};
|
|
44409
|
+
border-radius: ${pick2("var(--tt-radius-md)", `${surface.itemRadius}px`)};
|
|
44410
|
+
background: ${pick2("var(--tt-toc-sidebar-bg)", surface.floatBg)};
|
|
44411
|
+
color: var(--tt-toc-sidebar-text-color);
|
|
44412
|
+
font: inherit;
|
|
44413
|
+
font-size: 0.75rem;
|
|
44414
|
+
line-height: 1;
|
|
44415
|
+
white-space: nowrap;
|
|
44416
|
+
cursor: pointer;
|
|
44417
|
+
|
|
44418
|
+
&:hover,
|
|
44419
|
+
&[aria-pressed="true"] {
|
|
44420
|
+
color: var(--tt-toc-sidebar-text-active-color);
|
|
44421
|
+
background: ${pick2("var(--tt-toc-sidebar-bg-hover-color)", surface.itemHoverBg)};
|
|
44422
|
+
}
|
|
44423
|
+
}
|
|
44424
|
+
|
|
44425
|
+
&-toggle:focus-visible,
|
|
44426
|
+
&-item:focus-visible {
|
|
44427
|
+
outline: 2px solid var(--tt-toc-sidebar-text-active-color);
|
|
44428
|
+
outline-offset: 2px;
|
|
44429
|
+
}
|
|
44430
|
+
|
|
44091
44431
|
/* =========================
|
|
44092
44432
|
Progress bar column
|
|
44093
44433
|
========================= */
|
|
@@ -44158,12 +44498,15 @@ var tocSidebarStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
44158
44498
|
========================= */
|
|
44159
44499
|
&-nav {
|
|
44160
44500
|
position: absolute;
|
|
44161
|
-
top:
|
|
44501
|
+
top: 2.5rem;
|
|
44162
44502
|
right: 0;
|
|
44503
|
+
width: min(17rem, calc(100vw - 2rem));
|
|
44504
|
+
box-sizing: border-box;
|
|
44163
44505
|
padding-inline: 0.625rem;
|
|
44164
44506
|
pointer-events: none;
|
|
44165
44507
|
transform: translateX(10px);
|
|
44166
44508
|
opacity: 0;
|
|
44509
|
+
visibility: hidden;
|
|
44167
44510
|
display: flex;
|
|
44168
44511
|
transition:
|
|
44169
44512
|
transform 0.3s ease,
|
|
@@ -44186,6 +44529,7 @@ var tocSidebarStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
44186
44529
|
margin-right: -0.625rem;
|
|
44187
44530
|
max-height: var(--toc-max-height);
|
|
44188
44531
|
width: 100%;
|
|
44532
|
+
box-sizing: border-box;
|
|
44189
44533
|
overflow: auto;
|
|
44190
44534
|
padding: var(--padding);
|
|
44191
44535
|
scroll-margin: 0.25rem;
|
|
@@ -44212,7 +44556,9 @@ var tocSidebarStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
44212
44556
|
text-overflow: ellipsis;
|
|
44213
44557
|
user-select: none;
|
|
44214
44558
|
cursor: pointer;
|
|
44215
|
-
transition:
|
|
44559
|
+
transition:
|
|
44560
|
+
background-color 0.15s ease,
|
|
44561
|
+
color 0.15s ease;
|
|
44216
44562
|
|
|
44217
44563
|
/* Central calculation: Base * (Depth - 1) * Factor */
|
|
44218
44564
|
margin-inline-start: calc(
|
|
@@ -44268,22 +44614,39 @@ var tocSidebarStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
44268
44614
|
Interactions / media
|
|
44269
44615
|
========================= */
|
|
44270
44616
|
|
|
44271
|
-
|
|
44272
|
-
|
|
44273
|
-
|
|
44274
|
-
|
|
44275
|
-
|
|
44276
|
-
|
|
44277
|
-
}
|
|
44617
|
+
&--expanded &-nav,
|
|
44618
|
+
&-wrapper:focus-within &-nav[aria-hidden="false"] {
|
|
44619
|
+
pointer-events: auto;
|
|
44620
|
+
transform: translateX(0);
|
|
44621
|
+
opacity: 1;
|
|
44622
|
+
visibility: visible;
|
|
44278
44623
|
}
|
|
44279
44624
|
|
|
44280
|
-
|
|
44281
|
-
|
|
44282
|
-
|
|
44283
|
-
|
|
44284
|
-
|
|
44285
|
-
|
|
44286
|
-
|
|
44625
|
+
&--pinned &-wrapper {
|
|
44626
|
+
width: 100%;
|
|
44627
|
+
max-width: 15rem;
|
|
44628
|
+
margin-left: 0;
|
|
44629
|
+
}
|
|
44630
|
+
|
|
44631
|
+
&--pinned &-inner {
|
|
44632
|
+
width: 100%;
|
|
44633
|
+
box-sizing: border-box;
|
|
44634
|
+
margin-right: 0;
|
|
44635
|
+
padding-right: 0.75rem;
|
|
44636
|
+
}
|
|
44637
|
+
|
|
44638
|
+
&--pinned &-progress {
|
|
44639
|
+
display: none;
|
|
44640
|
+
}
|
|
44641
|
+
|
|
44642
|
+
&--pinned &-nav {
|
|
44643
|
+
position: static;
|
|
44644
|
+
width: 100%;
|
|
44645
|
+
padding-inline: 0;
|
|
44646
|
+
}
|
|
44647
|
+
|
|
44648
|
+
&--pinned &-popover {
|
|
44649
|
+
margin-right: 0;
|
|
44287
44650
|
}
|
|
44288
44651
|
|
|
44289
44652
|
/* Mobile */
|
|
@@ -44293,6 +44656,23 @@ var tocSidebarStyles = ({ pick: pick2, surface, isDark }) => `
|
|
|
44293
44656
|
}
|
|
44294
44657
|
}
|
|
44295
44658
|
}
|
|
44659
|
+
|
|
44660
|
+
@media screen and (min-width: 769px) {
|
|
44661
|
+
.notion-like-editor-layout:has(> .toc-sidebar--pinned) {
|
|
44662
|
+
--margin-left-width: minmax(1rem, 1fr);
|
|
44663
|
+
--margin-right-width: minmax(15rem, 1fr);
|
|
44664
|
+
|
|
44665
|
+
> .notion-like-editor-content {
|
|
44666
|
+
min-width: 0;
|
|
44667
|
+
}
|
|
44668
|
+
}
|
|
44669
|
+
}
|
|
44670
|
+
|
|
44671
|
+
@media screen and (min-width: 769px) and (max-width: 1024px) {
|
|
44672
|
+
.notion-like-editor-layout:has(> .toc-sidebar:not(.toc-sidebar--pinned)) {
|
|
44673
|
+
--margin-right-width: minmax(5rem, 1fr);
|
|
44674
|
+
}
|
|
44675
|
+
}
|
|
44296
44676
|
`;
|
|
44297
44677
|
|
|
44298
44678
|
// src/components/tiptap-ui-primitive/toolbar/toolbar.style.ts
|
|
@@ -44344,6 +44724,7 @@ var toolbarStyles = ({ token, surface, isDark, gray }) => `
|
|
|
44344
44724
|
@media (max-width: 480px) {
|
|
44345
44725
|
position: absolute;
|
|
44346
44726
|
top: auto;
|
|
44727
|
+
inset-inline: 0;
|
|
44347
44728
|
height: calc(var(--tt-toolbar-height) + var(--tt-safe-area-bottom));
|
|
44348
44729
|
border-top: 1px solid ${isDark ? gray(50) : gray(100)};
|
|
44349
44730
|
border-bottom: none;
|
|
@@ -45387,8 +45768,8 @@ function feishuSurface(token, isDark) {
|
|
|
45387
45768
|
codeHeaderBg: "rgba(31, 35, 41, 0.04)",
|
|
45388
45769
|
codeDividerColor: "#dee0e3",
|
|
45389
45770
|
calloutBordered: true,
|
|
45390
|
-
tableBorderColor: "
|
|
45391
|
-
//
|
|
45771
|
+
tableBorderColor: "#dee0e3",
|
|
45772
|
+
// 飞书知识库 docx 实测单元格边框 N300
|
|
45392
45773
|
tableHeaderBg: "rgba(15, 22, 36, 0.05)",
|
|
45393
45774
|
// 迁移前 --tt-gray-light-a-100
|
|
45394
45775
|
tableRadius: 0,
|
|
@@ -75267,6 +75648,16 @@ function useResizableWidth({
|
|
|
75267
75648
|
};
|
|
75268
75649
|
}
|
|
75269
75650
|
|
|
75651
|
+
// src/lib/media-size.ts
|
|
75652
|
+
function parseSizeHint(width, height) {
|
|
75653
|
+
const w = Number.parseFloat(String(width ?? ""));
|
|
75654
|
+
const h2 = Number.parseFloat(String(height ?? ""));
|
|
75655
|
+
return w > 0 && h2 > 0 ? { width: w, height: h2 } : void 0;
|
|
75656
|
+
}
|
|
75657
|
+
function heightForWidth(width, size6) {
|
|
75658
|
+
return size6 ? Math.round(width * size6.height / size6.width) : null;
|
|
75659
|
+
}
|
|
75660
|
+
|
|
75270
75661
|
// src/components/tiptap-node/image-node/image-crop.ts
|
|
75271
75662
|
var FULL_CROP = [0, 0, 1, 1];
|
|
75272
75663
|
var MIN_CROP_SIZE = 0.05;
|
|
@@ -75334,7 +75725,7 @@ function dragCrop(start, handle, dx, dy) {
|
|
|
75334
75725
|
if (handle.includes("s")) y1 = Math.max(y0 + MIN_CROP_SIZE, Math.min(1, y1 + dy));
|
|
75335
75726
|
return [x0, y0, x1, y1];
|
|
75336
75727
|
}
|
|
75337
|
-
var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onClick, cursor }, ref) {
|
|
75728
|
+
var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onClick, cursor, sizeHint }, ref) {
|
|
75338
75729
|
const [natural, setNatural] = useState(null);
|
|
75339
75730
|
const [failed, setFailed] = useState(false);
|
|
75340
75731
|
const [attempt, setAttempt] = useState(0);
|
|
@@ -75354,6 +75745,7 @@ var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onC
|
|
|
75354
75745
|
"div",
|
|
75355
75746
|
{
|
|
75356
75747
|
className: "tiptap-image-error",
|
|
75748
|
+
style: sizeHint ? { aspectRatio: `${sizeHint.width} / ${sizeHint.height}`, minHeight: 0 } : void 0,
|
|
75357
75749
|
contentEditable: false,
|
|
75358
75750
|
draggable: false,
|
|
75359
75751
|
onClick: (e) => {
|
|
@@ -75389,8 +75781,13 @@ var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onC
|
|
|
75389
75781
|
"img",
|
|
75390
75782
|
{
|
|
75391
75783
|
ref,
|
|
75784
|
+
loading: "lazy",
|
|
75785
|
+
decoding: "async",
|
|
75392
75786
|
src,
|
|
75393
75787
|
alt,
|
|
75788
|
+
width: sizeHint?.width,
|
|
75789
|
+
height: sizeHint?.height,
|
|
75790
|
+
"data-pending": natural ? void 0 : "",
|
|
75394
75791
|
className: "tiptap-image-img",
|
|
75395
75792
|
contentEditable: false,
|
|
75396
75793
|
draggable: false,
|
|
@@ -75406,8 +75803,9 @@ var ImageFrame = forwardRef(function ImageFrame2({ src, alt, crop, rotation, onC
|
|
|
75406
75803
|
attempt
|
|
75407
75804
|
)
|
|
75408
75805
|
);
|
|
75409
|
-
|
|
75410
|
-
|
|
75806
|
+
const size6 = natural ?? sizeHint;
|
|
75807
|
+
if (plain || !size6) return img();
|
|
75808
|
+
const layout = frameLayout(size6, crop ?? [0, 0, 1, 1], rotation);
|
|
75411
75809
|
return /* @__PURE__ */ jsx("div", { className: "tiptap-image-frame", style: { aspectRatio: String(layout.aspect) }, children: /* @__PURE__ */ jsx(
|
|
75412
75810
|
"div",
|
|
75413
75811
|
{
|
|
@@ -75539,11 +75937,12 @@ function ImageNodeView(props) {
|
|
|
75539
75937
|
showCaption: node.attrs.showCaption,
|
|
75540
75938
|
hasContent,
|
|
75541
75939
|
nodeSize: node.nodeSize,
|
|
75542
|
-
onImageResize: (width) => updateAttributes2({ width }),
|
|
75940
|
+
onImageResize: (width, size6) => updateAttributes2({ width, height: width ? heightForWidth(width, size6) : null }),
|
|
75543
75941
|
onUpdateAttributes: updateAttributes2,
|
|
75544
75942
|
getPos,
|
|
75545
75943
|
crop: node.attrs.crop ? normalizeCrop(node.attrs.crop) : null,
|
|
75546
|
-
rotation: normalizeRotation(node.attrs.rotation)
|
|
75944
|
+
rotation: normalizeRotation(node.attrs.rotation),
|
|
75945
|
+
sizeHint: parseSizeHint(node.attrs.width, node.attrs.height)
|
|
75547
75946
|
}
|
|
75548
75947
|
);
|
|
75549
75948
|
}
|
|
@@ -75562,7 +75961,8 @@ var ResizableImage = ({
|
|
|
75562
75961
|
onUpdateAttributes,
|
|
75563
75962
|
getPos,
|
|
75564
75963
|
crop = null,
|
|
75565
|
-
rotation = 0
|
|
75964
|
+
rotation = 0,
|
|
75965
|
+
sizeHint
|
|
75566
75966
|
}) => {
|
|
75567
75967
|
const [cropping, setCropping] = useState(false);
|
|
75568
75968
|
const submitCropRef = useRef(null);
|
|
@@ -75595,7 +75995,11 @@ var ResizableImage = ({
|
|
|
75595
75995
|
minWidth,
|
|
75596
75996
|
maxWidth,
|
|
75597
75997
|
align,
|
|
75598
|
-
onResize: (w) =>
|
|
75998
|
+
onResize: (w) => {
|
|
75999
|
+
const img = imageRef.current;
|
|
76000
|
+
const natural = img?.naturalWidth && img.naturalHeight ? { width: img.naturalWidth, height: img.naturalHeight } : void 0;
|
|
76001
|
+
onImageResize?.(w, natural ?? sizeHint);
|
|
76002
|
+
}
|
|
75599
76003
|
});
|
|
75600
76004
|
const imageRef = useRef(null);
|
|
75601
76005
|
useEffect(() => {
|
|
@@ -75679,7 +76083,8 @@ var ResizableImage = ({
|
|
|
75679
76083
|
crop,
|
|
75680
76084
|
rotation,
|
|
75681
76085
|
onClick: handleImageClick,
|
|
75682
|
-
cursor: editor?.isEditable ? "pointer" : "zoom-in"
|
|
76086
|
+
cursor: editor?.isEditable ? "pointer" : "zoom-in",
|
|
76087
|
+
sizeHint
|
|
75683
76088
|
}
|
|
75684
76089
|
),
|
|
75685
76090
|
showHandles && !cropping && /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -75687,11 +76092,12 @@ var ResizableImage = ({
|
|
|
75687
76092
|
/* @__PURE__ */ jsx("div", { ...rightHandleProps, className: "tiptap-image-handle tiptap-image-handle-right" })
|
|
75688
76093
|
] })
|
|
75689
76094
|
] }),
|
|
75690
|
-
|
|
76095
|
+
/* @__PURE__ */ jsx(
|
|
75691
76096
|
NodeViewContent,
|
|
75692
76097
|
{
|
|
75693
76098
|
as: "div",
|
|
75694
76099
|
className: "tiptap-image-caption",
|
|
76100
|
+
hidden: !(editor?.isEditable ? shouldShowCaption : hasContent),
|
|
75695
76101
|
"data-placeholder": "输入图片描述"
|
|
75696
76102
|
}
|
|
75697
76103
|
)
|
|
@@ -75847,13 +76253,16 @@ var Image3 = Image2.extend({
|
|
|
75847
76253
|
renderHTML({ node }) {
|
|
75848
76254
|
const { src, alt, title, width, height, showCaption } = node.attrs;
|
|
75849
76255
|
const align = node.attrs["data-align"];
|
|
75850
|
-
const imgAttrs =
|
|
75851
|
-
|
|
75852
|
-
|
|
75853
|
-
|
|
75854
|
-
|
|
75855
|
-
|
|
75856
|
-
|
|
76256
|
+
const imgAttrs = {
|
|
76257
|
+
loading: "lazy",
|
|
76258
|
+
...buildImageHTMLAttributes({
|
|
76259
|
+
src,
|
|
76260
|
+
alt,
|
|
76261
|
+
title,
|
|
76262
|
+
width,
|
|
76263
|
+
height
|
|
76264
|
+
})
|
|
76265
|
+
};
|
|
75857
76266
|
const rotation = normalizeRotation(node.attrs.rotation);
|
|
75858
76267
|
const crop = formatCropAttr(node.attrs.crop);
|
|
75859
76268
|
if (rotation) {
|
|
@@ -78833,6 +79242,34 @@ function containsCompleteContainer(text, names = ALL_CONTAINER_NAMES) {
|
|
|
78833
79242
|
}
|
|
78834
79243
|
return false;
|
|
78835
79244
|
}
|
|
79245
|
+
var HEADING_RE = /^ {0,3}#{1,6}[ \t]+\S/;
|
|
79246
|
+
var LIST_RE = /^ {0,3}(?:[-*+]|\d{1,9}[.)])[ \t]+\S/;
|
|
79247
|
+
var QUOTE_RE = /^ {0,3}>/;
|
|
79248
|
+
var LINK_RE = /\[[^\]\n]+\]\([^)\s]+\)/;
|
|
79249
|
+
var TABLE_DELIMITER_RE = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
|
|
79250
|
+
function looksLikeMarkdown(text) {
|
|
79251
|
+
const lines = text.replace(/\r\n?/g, "\n").split("\n");
|
|
79252
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
79253
|
+
let fence = null;
|
|
79254
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
79255
|
+
const line = lines[i];
|
|
79256
|
+
if (fence) {
|
|
79257
|
+
if (isFenceClose(line, fence)) return true;
|
|
79258
|
+
continue;
|
|
79259
|
+
}
|
|
79260
|
+
fence = matchFenceOpen(line);
|
|
79261
|
+
if (fence) continue;
|
|
79262
|
+
if (i > 0 && line.includes("|") && line.includes("-") && TABLE_DELIMITER_RE.test(line)) {
|
|
79263
|
+
if (lines[i - 1].includes("|")) return true;
|
|
79264
|
+
}
|
|
79265
|
+
if (HEADING_RE.test(line)) kinds.add("heading");
|
|
79266
|
+
else if (LIST_RE.test(line)) kinds.add("list");
|
|
79267
|
+
else if (QUOTE_RE.test(line)) kinds.add("quote");
|
|
79268
|
+
if (LINK_RE.test(line)) kinds.add("link");
|
|
79269
|
+
if (kinds.size >= 2) return true;
|
|
79270
|
+
}
|
|
79271
|
+
return false;
|
|
79272
|
+
}
|
|
78836
79273
|
var REQUIRED_WORDS = /* @__PURE__ */ new Set(["必选", "required"]);
|
|
78837
79274
|
var DEFAULT_WORDS = /* @__PURE__ */ new Set(["默认", "default"]);
|
|
78838
79275
|
function tokenizeInfo(info) {
|
|
@@ -82285,6 +82722,68 @@ function replaceAllMatches(tr2, matches2, text) {
|
|
|
82285
82722
|
return count;
|
|
82286
82723
|
}
|
|
82287
82724
|
|
|
82725
|
+
// src/components/tiptap-extension/paste-node-ids/paste-node-ids.ts
|
|
82726
|
+
function idConfig(editor) {
|
|
82727
|
+
const ext = editor.extensionManager.extensions.find((e) => e.name === "uniqueID");
|
|
82728
|
+
const options = ext?.options;
|
|
82729
|
+
if (!options || !Array.isArray(options.types) || !options.attributeName || !options.generateID)
|
|
82730
|
+
return null;
|
|
82731
|
+
return options;
|
|
82732
|
+
}
|
|
82733
|
+
function fillFragment(fragment, config) {
|
|
82734
|
+
let changed = false;
|
|
82735
|
+
const nodes = [];
|
|
82736
|
+
fragment.forEach((node) => {
|
|
82737
|
+
let next = node;
|
|
82738
|
+
const content = node.isText ? node.content : fillFragment(node.content, config);
|
|
82739
|
+
if (config.types.includes(node.type.name) && node.attrs[config.attributeName] == null) {
|
|
82740
|
+
const id = config.generateID({ node, pos: -1 });
|
|
82741
|
+
next = node.type.create({ ...node.attrs, [config.attributeName]: id }, content, node.marks);
|
|
82742
|
+
} else if (content !== node.content) {
|
|
82743
|
+
next = node.copy(content);
|
|
82744
|
+
}
|
|
82745
|
+
if (next !== node) changed = true;
|
|
82746
|
+
nodes.push(next);
|
|
82747
|
+
});
|
|
82748
|
+
return changed ? Fragment.from(nodes) : fragment;
|
|
82749
|
+
}
|
|
82750
|
+
function fillJSON(nodes, config) {
|
|
82751
|
+
return nodes.map((node) => {
|
|
82752
|
+
const out = { ...node };
|
|
82753
|
+
if (node.type && config.types.includes(node.type) && node.attrs?.[config.attributeName] == null) {
|
|
82754
|
+
out.attrs = {
|
|
82755
|
+
...node.attrs,
|
|
82756
|
+
[config.attributeName]: config.generateID({ node: null, pos: -1 })
|
|
82757
|
+
};
|
|
82758
|
+
}
|
|
82759
|
+
if (node.content) out.content = fillJSON(node.content, config);
|
|
82760
|
+
return out;
|
|
82761
|
+
});
|
|
82762
|
+
}
|
|
82763
|
+
function withNodeIds(editor, content) {
|
|
82764
|
+
const config = idConfig(editor);
|
|
82765
|
+
return config ? fillJSON(content, config) : content;
|
|
82766
|
+
}
|
|
82767
|
+
var PasteNodeIds = Extension.create({
|
|
82768
|
+
name: "pasteNodeIds",
|
|
82769
|
+
addProseMirrorPlugins() {
|
|
82770
|
+
const editor = this.editor;
|
|
82771
|
+
return [
|
|
82772
|
+
new Plugin({
|
|
82773
|
+
key: new PluginKey("pasteNodeIds"),
|
|
82774
|
+
props: {
|
|
82775
|
+
transformPasted(slice2) {
|
|
82776
|
+
const config = idConfig(editor);
|
|
82777
|
+
if (!config) return slice2;
|
|
82778
|
+
const content = fillFragment(slice2.content, config);
|
|
82779
|
+
return content === slice2.content ? slice2 : new Slice(content, slice2.openStart, slice2.openEnd);
|
|
82780
|
+
}
|
|
82781
|
+
}
|
|
82782
|
+
})
|
|
82783
|
+
];
|
|
82784
|
+
}
|
|
82785
|
+
});
|
|
82786
|
+
|
|
82288
82787
|
// src/components/tiptap-node/code-block-node/code-group-schema.ts
|
|
82289
82788
|
var CODE_GROUP_NAME = CODE_GROUP_TOKEN;
|
|
82290
82789
|
var CODE_GROUP_ATTR = "data-code-group";
|
|
@@ -82522,6 +83021,26 @@ function containerPasteText(data, slice2, schema) {
|
|
|
82522
83021
|
if (/\sdata-pm-slice=/.test(html)) return sliceLines(slice2, schema);
|
|
82523
83022
|
return text || null;
|
|
82524
83023
|
}
|
|
83024
|
+
function isMarkdownPaste(data, text) {
|
|
83025
|
+
if (/\sdata-pm-slice=/.test(data.getData("text/html"))) return false;
|
|
83026
|
+
let mode = null;
|
|
83027
|
+
try {
|
|
83028
|
+
mode = JSON.parse(data.getData("vscode-editor-data") || "null")?.mode;
|
|
83029
|
+
} catch {
|
|
83030
|
+
}
|
|
83031
|
+
if (mode && mode !== "markdown") return false;
|
|
83032
|
+
return looksLikeMarkdown(text);
|
|
83033
|
+
}
|
|
83034
|
+
function resolveMarkConflicts(nodes, schema) {
|
|
83035
|
+
return nodes.map((node) => {
|
|
83036
|
+
const out = { ...node };
|
|
83037
|
+
if (node.marks?.length) {
|
|
83038
|
+
out.marks = node.marks.reduce((set, json) => schema.markFromJSON(json).addToSet(set), Mark.none).map((mark) => mark.toJSON());
|
|
83039
|
+
}
|
|
83040
|
+
if (node.content) out.content = resolveMarkConflicts(node.content, schema);
|
|
83041
|
+
return out;
|
|
83042
|
+
});
|
|
83043
|
+
}
|
|
82525
83044
|
function isComposing(view, event) {
|
|
82526
83045
|
if (event?.isComposing) return true;
|
|
82527
83046
|
return Boolean(view.composing);
|
|
@@ -82555,23 +83074,29 @@ function createCodeGroupInputPlugin(editor) {
|
|
|
82555
83074
|
if (!data) return false;
|
|
82556
83075
|
if (view.input?.shiftKey) return false;
|
|
82557
83076
|
const text = containerPasteText(data, slice2, state.schema);
|
|
82558
|
-
if (!text || !containsCompleteContainer(text)) return false;
|
|
83077
|
+
if (!text || !(containsCompleteContainer(text) || isMarkdownPaste(data, text))) return false;
|
|
82559
83078
|
const manager = editor.markdown;
|
|
82560
83079
|
if (!manager) return false;
|
|
82561
|
-
let
|
|
83080
|
+
let content;
|
|
82562
83081
|
try {
|
|
82563
|
-
json = manager.parse(text.replace(/\r\n?/g, "\n"));
|
|
83082
|
+
const json = manager.parse(text.replace(/\r\n?/g, "\n"));
|
|
83083
|
+
if (!json.content?.length) return false;
|
|
83084
|
+
content = withNodeIds(editor, resolveMarkConflicts(json.content, state.schema));
|
|
82564
83085
|
} catch {
|
|
82565
83086
|
return false;
|
|
82566
83087
|
}
|
|
82567
|
-
if (!json.content?.length) return false;
|
|
82568
83088
|
stopYjsCapturing(view.state);
|
|
82569
83089
|
view.dispatch(closeHistory(view.state.tr));
|
|
82570
|
-
|
|
82571
|
-
|
|
82572
|
-
|
|
82573
|
-
|
|
82574
|
-
|
|
83090
|
+
let inserted = false;
|
|
83091
|
+
try {
|
|
83092
|
+
inserted = editor.commands.insertContentAt(
|
|
83093
|
+
{ from: state.selection.from, to: state.selection.to },
|
|
83094
|
+
content,
|
|
83095
|
+
{ updateSelection: true }
|
|
83096
|
+
);
|
|
83097
|
+
} catch (error) {
|
|
83098
|
+
console.warn("Markdown 粘贴转换失败,按普通粘贴处理", error);
|
|
83099
|
+
}
|
|
82575
83100
|
stopYjsCapturing(view.state);
|
|
82576
83101
|
view.dispatch(closeHistory(view.state.tr));
|
|
82577
83102
|
return inserted;
|
|
@@ -90563,6 +91088,48 @@ var ImageUploadNode2 = Node3.create({
|
|
|
90563
91088
|
};
|
|
90564
91089
|
}
|
|
90565
91090
|
});
|
|
91091
|
+
|
|
91092
|
+
// src/lib/lazy-media.ts
|
|
91093
|
+
var ROOT_MARGIN = "800px 0px";
|
|
91094
|
+
function release(el) {
|
|
91095
|
+
if (!el.hasAttribute("src")) return;
|
|
91096
|
+
el.pause();
|
|
91097
|
+
el.removeAttribute("src");
|
|
91098
|
+
el.load();
|
|
91099
|
+
}
|
|
91100
|
+
function attachLazyMedia(el, src) {
|
|
91101
|
+
const load2 = () => {
|
|
91102
|
+
if (src && el.getAttribute("src") !== src) el.setAttribute("src", src);
|
|
91103
|
+
};
|
|
91104
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
91105
|
+
load2();
|
|
91106
|
+
return () => release(el);
|
|
91107
|
+
}
|
|
91108
|
+
const observer = new IntersectionObserver(
|
|
91109
|
+
(entries) => {
|
|
91110
|
+
const near = entries.some((entry) => entry.isIntersecting);
|
|
91111
|
+
if (near) load2();
|
|
91112
|
+
else if (el.paused) release(el);
|
|
91113
|
+
},
|
|
91114
|
+
{ rootMargin: ROOT_MARGIN }
|
|
91115
|
+
);
|
|
91116
|
+
observer.observe(el);
|
|
91117
|
+
return () => {
|
|
91118
|
+
observer.disconnect();
|
|
91119
|
+
release(el);
|
|
91120
|
+
};
|
|
91121
|
+
}
|
|
91122
|
+
|
|
91123
|
+
// src/hooks/use-lazy-media.ts
|
|
91124
|
+
function useLazyMedia(src) {
|
|
91125
|
+
const ref = useRef(null);
|
|
91126
|
+
useEffect(() => {
|
|
91127
|
+
const el = ref.current;
|
|
91128
|
+
if (!el) return;
|
|
91129
|
+
return attachLazyMedia(el, src);
|
|
91130
|
+
}, [src]);
|
|
91131
|
+
return ref;
|
|
91132
|
+
}
|
|
90566
91133
|
var VIDEO_MIN_WIDTH = 200;
|
|
90567
91134
|
var VIDEO_MAX_WIDTH = 800;
|
|
90568
91135
|
function VideoPlayer({
|
|
@@ -90572,27 +91139,31 @@ function VideoPlayer({
|
|
|
90572
91139
|
naturalSize,
|
|
90573
91140
|
onNaturalSize,
|
|
90574
91141
|
fillContainer,
|
|
90575
|
-
noDownload
|
|
91142
|
+
noDownload,
|
|
91143
|
+
sizeHint
|
|
90576
91144
|
}) {
|
|
91145
|
+
const size6 = naturalSize ?? sizeHint;
|
|
91146
|
+
const ratio = size6 ? `${size6.width} / ${size6.height}` : "16 / 9";
|
|
91147
|
+
const ref = useLazyMedia(src);
|
|
90577
91148
|
return (
|
|
90578
91149
|
// biome-ignore lint/a11y/useMediaCaption: 节点没有字幕字段,上传的视频也不带字幕文件;要加字幕时在这里补 <track>
|
|
90579
91150
|
/* @__PURE__ */ jsx(
|
|
90580
91151
|
"video",
|
|
90581
91152
|
{
|
|
91153
|
+
ref,
|
|
90582
91154
|
className: "tiptap-video-player",
|
|
90583
91155
|
controls: true,
|
|
90584
91156
|
controlsList: noDownload ? "nodownload" : void 0,
|
|
90585
91157
|
preload: "metadata",
|
|
90586
|
-
src,
|
|
90587
91158
|
title,
|
|
90588
91159
|
poster,
|
|
90589
|
-
style:
|
|
90590
|
-
aspectRatio:
|
|
91160
|
+
style: {
|
|
91161
|
+
aspectRatio: ratio,
|
|
90591
91162
|
// 没设宽度时按视频原始宽度显示。这个像素宽必须写在 <video> 上而不是外层 div:
|
|
90592
91163
|
// 带百分比 max-width 的 video 是「可压缩替换元素」,算最小内容宽时按 0 计;
|
|
90593
91164
|
// 写在 div 上会被当成最小宽度,把编辑器正文列(grid 轨道)整个撑宽、溢出外框。
|
|
90594
|
-
width: fillContainer ? void 0 : `${
|
|
90595
|
-
}
|
|
91165
|
+
width: fillContainer || !size6 ? void 0 : `${size6.width}px`
|
|
91166
|
+
},
|
|
90596
91167
|
onLoadedMetadata: (e) => {
|
|
90597
91168
|
const { videoWidth, videoHeight } = e.currentTarget;
|
|
90598
91169
|
if (videoWidth > 0 && videoHeight > 0) {
|
|
@@ -90605,6 +91176,7 @@ function VideoPlayer({
|
|
|
90605
91176
|
}
|
|
90606
91177
|
function VideoNodeView({ editor, node, getPos, updateAttributes: updateAttributes2 }) {
|
|
90607
91178
|
const [naturalSize, setNaturalSize] = useState();
|
|
91179
|
+
const sizeHint = parseSizeHint(node.attrs.width, node.attrs.height);
|
|
90608
91180
|
const align = node.attrs["data-align"] ?? "left";
|
|
90609
91181
|
const canDownload = getDocPermissions(editor).download;
|
|
90610
91182
|
const {
|
|
@@ -90623,8 +91195,8 @@ function VideoNodeView({ editor, node, getPos, updateAttributes: updateAttribute
|
|
|
90623
91195
|
minWidth: VIDEO_MIN_WIDTH,
|
|
90624
91196
|
maxWidth: VIDEO_MAX_WIDTH,
|
|
90625
91197
|
align,
|
|
90626
|
-
//
|
|
90627
|
-
onResize: (w) => updateAttributes2({ width: w, height:
|
|
91198
|
+
// height 只当宽高比用(不当像素高度,不会拉变形):按比例同步写回,下次打开视频加载前也能按真实比例占位
|
|
91199
|
+
onResize: (w) => updateAttributes2({ width: w, height: heightForWidth(w, naturalSize ?? sizeHint) })
|
|
90628
91200
|
});
|
|
90629
91201
|
return /* @__PURE__ */ jsx(
|
|
90630
91202
|
NodeViewWrapper,
|
|
@@ -90649,6 +91221,7 @@ function VideoNodeView({ editor, node, getPos, updateAttributes: updateAttribute
|
|
|
90649
91221
|
poster: node.attrs.poster ?? void 0,
|
|
90650
91222
|
naturalSize,
|
|
90651
91223
|
onNaturalSize: setNaturalSize,
|
|
91224
|
+
sizeHint,
|
|
90652
91225
|
fillContainer: !!width,
|
|
90653
91226
|
noDownload: !canDownload
|
|
90654
91227
|
}
|
|
@@ -90716,7 +91289,10 @@ var Video = Node3.create({
|
|
|
90716
91289
|
renderHTML({ node, HTMLAttributes }) {
|
|
90717
91290
|
const attrs = {
|
|
90718
91291
|
controls: "true",
|
|
90719
|
-
|
|
91292
|
+
// renderHTML 只用于序列化(getHTML、复制、导出)和 tiptap 卸载时的过渡 DOM,编辑器里的播放器是节点视图。
|
|
91293
|
+
// 这些 DOM 即使不插入文档,带 src + preload=metadata 也会各自创建播放器,Chrome 每页上限 1000 个;
|
|
91294
|
+
// preload="none" 不创建播放器,点播放时照常加载(见 lib/lazy-media.ts)
|
|
91295
|
+
preload: "none",
|
|
90720
91296
|
src: node.attrs.src
|
|
90721
91297
|
};
|
|
90722
91298
|
if (node.attrs.title) attrs.title = node.attrs.title;
|
|
@@ -90781,7 +91357,10 @@ var Audio = Node3.create({
|
|
|
90781
91357
|
renderHTML({ node, HTMLAttributes }) {
|
|
90782
91358
|
const attrs = {
|
|
90783
91359
|
controls: "true",
|
|
90784
|
-
|
|
91360
|
+
// renderHTML 只用于序列化(getHTML、复制、导出)和 tiptap 卸载时的过渡 DOM,编辑器里的播放器是节点视图。
|
|
91361
|
+
// 这些 DOM 即使不插入文档,带 src + preload=metadata 也会各自创建播放器,Chrome 每页上限 1000 个;
|
|
91362
|
+
// preload="none" 不创建播放器,点播放时照常加载(见 lib/lazy-media.ts)
|
|
91363
|
+
preload: "none",
|
|
90785
91364
|
src: node.attrs.src
|
|
90786
91365
|
};
|
|
90787
91366
|
if (node.attrs.title) attrs.title = node.attrs.title;
|
|
@@ -90795,18 +91374,19 @@ var Audio = Node3.create({
|
|
|
90795
91374
|
addNodeView() {
|
|
90796
91375
|
return ({ node, HTMLAttributes, editor }) => {
|
|
90797
91376
|
const dom = document.createElement("audio");
|
|
90798
|
-
const attrs = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
91377
|
+
const { src: _src, ...attrs } = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
90799
91378
|
controls: "true",
|
|
90800
91379
|
preload: "metadata",
|
|
90801
|
-
src: node.attrs.src,
|
|
90802
91380
|
...node.attrs.title ? { title: node.attrs.title } : {}
|
|
90803
91381
|
});
|
|
90804
91382
|
for (const [k, v] of Object.entries(attrs)) if (v != null && v !== false) dom.setAttribute(k, String(v));
|
|
90805
91383
|
if (!getDocPermissions(editor).download) dom.setAttribute("controlslist", "nodownload");
|
|
91384
|
+
const detach = attachLazyMedia(dom, node.attrs.src);
|
|
90806
91385
|
return {
|
|
90807
91386
|
dom,
|
|
90808
91387
|
stopEvent: () => !editor.isEditable,
|
|
90809
|
-
ignoreMutation: () => true
|
|
91388
|
+
ignoreMutation: () => true,
|
|
91389
|
+
destroy: detach
|
|
90810
91390
|
};
|
|
90811
91391
|
};
|
|
90812
91392
|
},
|
|
@@ -91184,10 +91764,10 @@ function FilePreview({
|
|
|
91184
91764
|
body = /* @__PURE__ */ jsx("img", { className: "tt-file-preview__media", src: file.src, alt: file.name });
|
|
91185
91765
|
} else if (kind === "video") {
|
|
91186
91766
|
sized = false;
|
|
91187
|
-
body = /* @__PURE__ */ jsx(
|
|
91767
|
+
body = /* @__PURE__ */ jsx(PreviewVideo, { src: file.src });
|
|
91188
91768
|
} else if (kind === "audio") {
|
|
91189
91769
|
sized = false;
|
|
91190
|
-
body = /* @__PURE__ */ jsx(
|
|
91770
|
+
body = /* @__PURE__ */ jsx(PreviewAudio, { src: file.src });
|
|
91191
91771
|
} else if (kind === "text") {
|
|
91192
91772
|
body = /* @__PURE__ */ jsx(TextPreview, { src: file.src, name: file.name });
|
|
91193
91773
|
} else {
|
|
@@ -91252,6 +91832,14 @@ function useFullscreen() {
|
|
|
91252
91832
|
}, []);
|
|
91253
91833
|
return on;
|
|
91254
91834
|
}
|
|
91835
|
+
function PreviewVideo({ src }) {
|
|
91836
|
+
const ref = useLazyMedia(src);
|
|
91837
|
+
return /* @__PURE__ */ jsx("video", { ref, className: "tt-file-preview__media", controls: true, preload: "metadata" });
|
|
91838
|
+
}
|
|
91839
|
+
function PreviewAudio({ src }) {
|
|
91840
|
+
const ref = useLazyMedia(src);
|
|
91841
|
+
return /* @__PURE__ */ jsx("audio", { ref, className: "tt-file-preview__audio", controls: true, preload: "metadata" });
|
|
91842
|
+
}
|
|
91255
91843
|
|
|
91256
91844
|
// src/components/tiptap-node/file-attachment-node/file-attachment-schema.ts
|
|
91257
91845
|
var FileAttachmentSchema = Node3.create({
|
|
@@ -96723,6 +97311,12 @@ function normalizeEditorContent(content, contentFormat, extensions, options = {}
|
|
|
96723
97311
|
}
|
|
96724
97312
|
return result.json;
|
|
96725
97313
|
}
|
|
97314
|
+
function resolveEditorContentUpdate(content, contentFormat, extensions, options = {}) {
|
|
97315
|
+
if (content === void 0) return { kind: "ignore" };
|
|
97316
|
+
if (content === null || content === "") return { kind: "clear" };
|
|
97317
|
+
const json = normalizeEditorContent(content, contentFormat, extensions, options);
|
|
97318
|
+
return json ? { kind: "set", json } : { kind: "ignore" };
|
|
97319
|
+
}
|
|
96726
97320
|
function defaultOnError(message) {
|
|
96727
97321
|
console.error(`[editor] 内容未载入:${message}`);
|
|
96728
97322
|
}
|
|
@@ -99576,6 +100170,9 @@ var useComposedRef = (libRef, userRef) => {
|
|
|
99576
100170
|
[libRef, userRef]
|
|
99577
100171
|
);
|
|
99578
100172
|
};
|
|
100173
|
+
function MenuProvider2({ ...props }) {
|
|
100174
|
+
return /* @__PURE__ */ jsx(Ariakit2.MenuProvider, { ...props });
|
|
100175
|
+
}
|
|
99579
100176
|
function Menu2({
|
|
99580
100177
|
children,
|
|
99581
100178
|
trigger,
|
|
@@ -99692,6 +100289,31 @@ function MenuGroupLabel2({
|
|
|
99692
100289
|
}
|
|
99693
100290
|
);
|
|
99694
100291
|
}
|
|
100292
|
+
function MenuSeparator2({
|
|
100293
|
+
className,
|
|
100294
|
+
...props
|
|
100295
|
+
}) {
|
|
100296
|
+
return /* @__PURE__ */ jsx(
|
|
100297
|
+
Ariakit2.MenuSeparator,
|
|
100298
|
+
{
|
|
100299
|
+
"data-slot": "tiptap-menu-separator",
|
|
100300
|
+
className: cn("tiptap-menu-separator", className),
|
|
100301
|
+
...props
|
|
100302
|
+
}
|
|
100303
|
+
);
|
|
100304
|
+
}
|
|
100305
|
+
function MenuItemCheck2({
|
|
100306
|
+
className,
|
|
100307
|
+
...props
|
|
100308
|
+
}) {
|
|
100309
|
+
return /* @__PURE__ */ jsx(
|
|
100310
|
+
Ariakit2.MenuItemCheck,
|
|
100311
|
+
{
|
|
100312
|
+
...props,
|
|
100313
|
+
className: cn("tiptap-menu-item-check", className)
|
|
100314
|
+
}
|
|
100315
|
+
);
|
|
100316
|
+
}
|
|
99695
100317
|
function MenuItemRadio2({
|
|
99696
100318
|
className,
|
|
99697
100319
|
...props
|
|
@@ -113178,90 +113800,200 @@ function CollabProvider({
|
|
|
113178
113800
|
);
|
|
113179
113801
|
return /* @__PURE__ */ jsx(CollabContext.Provider, { value, children });
|
|
113180
113802
|
}
|
|
113181
|
-
|
|
113182
|
-
|
|
113183
|
-
|
|
113184
|
-
|
|
113185
|
-
|
|
113186
|
-
|
|
113187
|
-
|
|
113188
|
-
|
|
113189
|
-
|
|
113190
|
-
|
|
113191
|
-
|
|
113192
|
-
|
|
113193
|
-
|
|
113194
|
-
|
|
113195
|
-
|
|
113196
|
-
|
|
113197
|
-
|
|
113198
|
-
|
|
113199
|
-
|
|
113200
|
-
|
|
113201
|
-
|
|
113202
|
-
|
|
113203
|
-
|
|
113204
|
-
|
|
113205
|
-
|
|
113206
|
-
|
|
113207
|
-
|
|
113208
|
-
|
|
113209
|
-
|
|
113210
|
-
|
|
113211
|
-
|
|
113212
|
-
|
|
113213
|
-
|
|
113214
|
-
|
|
113215
|
-
|
|
113216
|
-
|
|
113217
|
-
|
|
113218
|
-
|
|
113219
|
-
|
|
113220
|
-
|
|
113221
|
-
|
|
113222
|
-
|
|
113223
|
-
|
|
113224
|
-
|
|
113225
|
-
|
|
113226
|
-
|
|
113227
|
-
|
|
113228
|
-
|
|
113229
|
-
|
|
113230
|
-
|
|
113231
|
-
|
|
113232
|
-
|
|
113233
|
-
|
|
113234
|
-
|
|
113235
|
-
|
|
113236
|
-
|
|
113237
|
-
|
|
113238
|
-
|
|
113239
|
-
|
|
113240
|
-
|
|
113241
|
-
|
|
113242
|
-
|
|
113243
|
-
|
|
113244
|
-
|
|
113245
|
-
|
|
113246
|
-
|
|
113247
|
-
|
|
113248
|
-
|
|
113249
|
-
|
|
113250
|
-
)
|
|
113251
|
-
|
|
113252
|
-
|
|
113253
|
-
|
|
113254
|
-
|
|
113255
|
-
|
|
113803
|
+
|
|
113804
|
+
// src/components/tiptap-extension/comment-thread/comment-thread.style.ts
|
|
113805
|
+
var commentThreadFocusStyle = `
|
|
113806
|
+
[data-comment-thread-interactive]:focus-visible {
|
|
113807
|
+
outline: 2px solid var(--tt-brand-color-500, #3370ff);
|
|
113808
|
+
outline-offset: 2px;
|
|
113809
|
+
}
|
|
113810
|
+
`;
|
|
113811
|
+
|
|
113812
|
+
// src/components/tiptap-extension/comment-thread/comment-thread.ts
|
|
113813
|
+
var commentThreadInteractivityKey = new PluginKey(
|
|
113814
|
+
"commentThreadInteractivity"
|
|
113815
|
+
);
|
|
113816
|
+
function refreshCommentThreadInteractivity(editor, interactive) {
|
|
113817
|
+
if (editor.isDestroyed) return;
|
|
113818
|
+
editor.view.dispatch(
|
|
113819
|
+
editor.state.tr.setMeta(commentThreadInteractivityKey, interactive ?? true).setMeta("addToHistory", false)
|
|
113820
|
+
);
|
|
113821
|
+
}
|
|
113822
|
+
function getCommentSelection(state) {
|
|
113823
|
+
const { selection, doc: doc4 } = state;
|
|
113824
|
+
if (!(selection instanceof TextSelection) || selection.empty || selection.$from.parent.type.spec.code)
|
|
113825
|
+
return null;
|
|
113826
|
+
const { from: from2, to } = selection;
|
|
113827
|
+
const text = doc4.textBetween(from2, to, "\n");
|
|
113828
|
+
return text.trim() ? { from: from2, to, text } : null;
|
|
113829
|
+
}
|
|
113830
|
+
function canWriteComment(editor) {
|
|
113831
|
+
const storage = editor.storage;
|
|
113832
|
+
return editor.isEditable && !storage.readOnlyGuard?.locked;
|
|
113833
|
+
}
|
|
113834
|
+
var CommentThread = Mark2.create({
|
|
113835
|
+
name: "commentThread",
|
|
113836
|
+
priority: 1100,
|
|
113837
|
+
excludes: "",
|
|
113838
|
+
inclusive: false,
|
|
113839
|
+
addOptions() {
|
|
113840
|
+
return { onSelectThread: void 0, isInteractive: void 0 };
|
|
113841
|
+
},
|
|
113842
|
+
addAttributes() {
|
|
113843
|
+
return {
|
|
113844
|
+
threadId: {
|
|
113845
|
+
default: null,
|
|
113846
|
+
parseHTML: (element) => element.getAttribute("data-comment-thread"),
|
|
113847
|
+
renderHTML: (attributes) => ({ "data-comment-thread": attributes.threadId })
|
|
113848
|
+
}
|
|
113849
|
+
};
|
|
113850
|
+
},
|
|
113851
|
+
parseHTML() {
|
|
113852
|
+
return [
|
|
113853
|
+
{
|
|
113854
|
+
tag: "span[data-comment-thread]",
|
|
113855
|
+
getAttrs: (element) => element.getAttribute("data-comment-thread")?.trim() ? null : false
|
|
113856
|
+
}
|
|
113857
|
+
];
|
|
113858
|
+
},
|
|
113859
|
+
renderHTML({ HTMLAttributes }) {
|
|
113860
|
+
return [
|
|
113861
|
+
"span",
|
|
113862
|
+
{
|
|
113863
|
+
...HTMLAttributes,
|
|
113864
|
+
style: "background-color: var(--tt-color-highlight-yellow, rgba(255, 246, 122, 0.4)); border-radius: 2px; box-decoration-break: clone;"
|
|
113865
|
+
},
|
|
113866
|
+
0
|
|
113867
|
+
];
|
|
113868
|
+
},
|
|
113869
|
+
addCommands() {
|
|
113870
|
+
return {
|
|
113871
|
+
setCommentThread: (threadId) => ({ editor, tr: tr2, dispatch }) => {
|
|
113872
|
+
if (!canWriteComment(editor) || !threadId.trim()) return false;
|
|
113873
|
+
const selection = getCommentSelection(tr2);
|
|
113874
|
+
if (!selection) return false;
|
|
113875
|
+
let supported = false;
|
|
113876
|
+
tr2.doc.nodesBetween(selection.from, selection.to, (node, pos, parent) => {
|
|
113877
|
+
if (!node.isText || !parent?.type.allowsMarkType(this.type) || node.marks.some((mark) => mark.type.excludes(this.type)))
|
|
113878
|
+
return;
|
|
113879
|
+
supported = true;
|
|
113880
|
+
if (dispatch)
|
|
113881
|
+
tr2.addMark(
|
|
113882
|
+
Math.max(pos, selection.from),
|
|
113883
|
+
Math.min(pos + node.nodeSize, selection.to),
|
|
113884
|
+
this.type.create({ threadId })
|
|
113885
|
+
);
|
|
113886
|
+
});
|
|
113887
|
+
return supported;
|
|
113888
|
+
},
|
|
113889
|
+
unsetCommentThread: (threadId) => ({ editor, tr: tr2, dispatch }) => {
|
|
113890
|
+
if (!canWriteComment(editor) || !threadId.trim()) return false;
|
|
113891
|
+
const storedMarks = tr2.storedMarks;
|
|
113892
|
+
let found2 = Boolean(
|
|
113893
|
+
storedMarks?.some(
|
|
113894
|
+
(mark) => mark.type === this.type && mark.attrs.threadId === threadId
|
|
113895
|
+
)
|
|
113896
|
+
);
|
|
113897
|
+
tr2.doc.descendants((node, pos) => {
|
|
113898
|
+
for (const mark of node.marks) {
|
|
113899
|
+
if (mark.type !== this.type || mark.attrs.threadId !== threadId) continue;
|
|
113900
|
+
found2 = true;
|
|
113901
|
+
if (dispatch) tr2.removeMark(pos, pos + node.nodeSize, mark);
|
|
113256
113902
|
}
|
|
113903
|
+
});
|
|
113904
|
+
if (dispatch && storedMarks && found2)
|
|
113905
|
+
tr2.setStoredMarks(
|
|
113906
|
+
storedMarks.filter(
|
|
113907
|
+
(mark) => mark.type !== this.type || mark.attrs.threadId !== threadId
|
|
113908
|
+
)
|
|
113909
|
+
);
|
|
113910
|
+
return found2;
|
|
113911
|
+
}
|
|
113912
|
+
};
|
|
113913
|
+
},
|
|
113914
|
+
addProseMirrorPlugins() {
|
|
113915
|
+
const isInteractive = () => Boolean(this.options.onSelectThread) && (this.options.isInteractive?.() ?? true);
|
|
113916
|
+
const decorations = (state) => {
|
|
113917
|
+
if (!isInteractive()) return DecorationSet.empty;
|
|
113918
|
+
const ranges = [];
|
|
113919
|
+
state.doc.descendants((node, pos) => {
|
|
113920
|
+
if (!node.isText || node.marks.some((mark2) => mark2.type.name === "link")) return;
|
|
113921
|
+
const mark = node.marks.filter((mark2) => mark2.type === this.type).at(-1);
|
|
113922
|
+
const threadId = mark?.attrs.threadId;
|
|
113923
|
+
if (typeof threadId !== "string" || !threadId.trim()) return;
|
|
113924
|
+
const previous = ranges.at(-1);
|
|
113925
|
+
if (previous?.to === pos && previous.threadId === threadId) previous.to += node.nodeSize;
|
|
113926
|
+
else ranges.push({ from: pos, to: pos + node.nodeSize, threadId });
|
|
113927
|
+
});
|
|
113928
|
+
return DecorationSet.create(
|
|
113929
|
+
state.doc,
|
|
113930
|
+
ranges.map(
|
|
113931
|
+
({ from: from2, to, threadId }) => Decoration.inline(from2, to, {
|
|
113932
|
+
nodeName: "span",
|
|
113933
|
+
"data-comment-thread-interactive": threadId,
|
|
113934
|
+
role: "button",
|
|
113935
|
+
tabindex: "0",
|
|
113936
|
+
"aria-label": "查看评论"
|
|
113937
|
+
})
|
|
113257
113938
|
)
|
|
113258
|
-
|
|
113259
|
-
}
|
|
113260
|
-
|
|
113939
|
+
);
|
|
113940
|
+
};
|
|
113941
|
+
const threadTarget = (view, event) => {
|
|
113942
|
+
const element = event.target;
|
|
113943
|
+
if (element?.closest?.("a[href]")) return null;
|
|
113944
|
+
const target = element?.closest?.(
|
|
113945
|
+
"[data-comment-thread-interactive], span[data-comment-thread]"
|
|
113946
|
+
);
|
|
113947
|
+
return target && view.dom.contains(target) ? target : null;
|
|
113948
|
+
};
|
|
113949
|
+
return [
|
|
113950
|
+
new Plugin({
|
|
113951
|
+
key: commentThreadInteractivityKey,
|
|
113952
|
+
state: {
|
|
113953
|
+
init: (_config, state) => decorations(state),
|
|
113954
|
+
apply: (tr2, previous, _oldState, state) => tr2.docChanged || tr2.getMeta(commentThreadInteractivityKey) !== void 0 ? decorations(state) : previous
|
|
113955
|
+
},
|
|
113956
|
+
props: {
|
|
113957
|
+
decorations: (state) => commentThreadInteractivityKey.getState(state),
|
|
113958
|
+
handleClick: (view, _pos, event) => {
|
|
113959
|
+
if (!isInteractive() || event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || !view.state.selection.empty)
|
|
113960
|
+
return false;
|
|
113961
|
+
const target = threadTarget(view, event);
|
|
113962
|
+
const threadId = target?.getAttribute("data-comment-thread-interactive") ?? target?.getAttribute("data-comment-thread");
|
|
113963
|
+
if (!threadId?.trim()) return false;
|
|
113964
|
+
event.preventDefault();
|
|
113965
|
+
this.options.onSelectThread?.(threadId);
|
|
113966
|
+
return true;
|
|
113967
|
+
},
|
|
113968
|
+
handleDOMEvents: {
|
|
113969
|
+
keydown: (view, event) => {
|
|
113970
|
+
if (event.defaultPrevented || event.key !== "Enter" && event.key !== " " || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
|
113971
|
+
return false;
|
|
113972
|
+
const target = threadTarget(view, event);
|
|
113973
|
+
if (!target || target !== view.root.activeElement) return false;
|
|
113974
|
+
const threadId = target.getAttribute("data-comment-thread-interactive") ?? target.getAttribute("data-comment-thread");
|
|
113975
|
+
if (!threadId?.trim()) return false;
|
|
113976
|
+
event.preventDefault();
|
|
113977
|
+
if (isInteractive()) this.options.onSelectThread?.(threadId);
|
|
113978
|
+
return true;
|
|
113979
|
+
}
|
|
113980
|
+
}
|
|
113981
|
+
},
|
|
113982
|
+
view: (view) => {
|
|
113983
|
+
const style2 = view.dom.ownerDocument.createElement("style");
|
|
113984
|
+
style2.setAttribute("data-comment-thread-style", "");
|
|
113985
|
+
style2.textContent = commentThreadFocusStyle;
|
|
113986
|
+
const root = view.dom.getRootNode();
|
|
113987
|
+
const container = root.nodeType === 9 ? view.dom.ownerDocument.head : root;
|
|
113988
|
+
container.appendChild(style2);
|
|
113989
|
+
return { destroy: () => style2.remove() };
|
|
113990
|
+
}
|
|
113991
|
+
})
|
|
113992
|
+
];
|
|
113993
|
+
}
|
|
113261
113994
|
});
|
|
113262
|
-
|
|
113263
|
-
|
|
113264
|
-
return /* @__PURE__ */ jsxs(
|
|
113995
|
+
var MessageSquareIcon = memo(({ className, ...props }) => {
|
|
113996
|
+
return /* @__PURE__ */ jsx(
|
|
113265
113997
|
"svg",
|
|
113266
113998
|
{
|
|
113267
113999
|
width: "24",
|
|
@@ -113271,54 +114003,19 @@ var MoonStarIcon = memo(({ className, ...props }) => {
|
|
|
113271
114003
|
fill: "currentColor",
|
|
113272
114004
|
xmlns: "http://www.w3.org/2000/svg",
|
|
113273
114005
|
...props,
|
|
113274
|
-
children:
|
|
113275
|
-
|
|
113276
|
-
|
|
113277
|
-
|
|
113278
|
-
|
|
113279
|
-
|
|
113280
|
-
|
|
113281
|
-
|
|
113282
|
-
|
|
113283
|
-
),
|
|
113284
|
-
/* @__PURE__ */ jsx(
|
|
113285
|
-
"path",
|
|
113286
|
-
{
|
|
113287
|
-
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",
|
|
113288
|
-
fill: "currentColor"
|
|
113289
|
-
}
|
|
113290
|
-
)
|
|
113291
|
-
]
|
|
114006
|
+
children: /* @__PURE__ */ jsx(
|
|
114007
|
+
"path",
|
|
114008
|
+
{
|
|
114009
|
+
fillRule: "evenodd",
|
|
114010
|
+
clipRule: "evenodd",
|
|
114011
|
+
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",
|
|
114012
|
+
fill: "currentColor"
|
|
114013
|
+
}
|
|
114014
|
+
)
|
|
113292
114015
|
}
|
|
113293
114016
|
);
|
|
113294
114017
|
});
|
|
113295
|
-
|
|
113296
|
-
function ThemeToggle() {
|
|
113297
|
-
const [isDarkMode, setIsDarkMode] = useState(false);
|
|
113298
|
-
useEffect(() => {
|
|
113299
|
-
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
113300
|
-
const handleChange = () => setIsDarkMode(mediaQuery.matches);
|
|
113301
|
-
mediaQuery.addEventListener("change", handleChange);
|
|
113302
|
-
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
113303
|
-
}, []);
|
|
113304
|
-
useEffect(() => {
|
|
113305
|
-
const initialDarkMode = !!document.querySelector('meta[name="color-scheme"][content="dark"]') || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
113306
|
-
setIsDarkMode(initialDarkMode);
|
|
113307
|
-
}, []);
|
|
113308
|
-
useEffect(() => {
|
|
113309
|
-
document.documentElement.classList.toggle("dark", isDarkMode);
|
|
113310
|
-
}, [isDarkMode]);
|
|
113311
|
-
const toggleDarkMode = () => setIsDarkMode((isDark) => !isDark);
|
|
113312
|
-
return /* @__PURE__ */ jsx(
|
|
113313
|
-
Button,
|
|
113314
|
-
{
|
|
113315
|
-
onClick: toggleDarkMode,
|
|
113316
|
-
"aria-label": `Switch to ${isDarkMode ? "light" : "dark"} mode`,
|
|
113317
|
-
variant: "ghost",
|
|
113318
|
-
children: isDarkMode ? /* @__PURE__ */ jsx(MoonStarIcon, { className: "tiptap-button-icon" }) : /* @__PURE__ */ jsx(SunIcon, { className: "tiptap-button-icon" })
|
|
113319
|
-
}
|
|
113320
|
-
);
|
|
113321
|
-
}
|
|
114018
|
+
MessageSquareIcon.displayName = "MessageSquareIcon";
|
|
113322
114019
|
var PrinterIcon = memo(({ className, ...props }) => {
|
|
113323
114020
|
return /* @__PURE__ */ jsxs(
|
|
113324
114021
|
"svg",
|
|
@@ -113343,73 +114040,6 @@ var PrinterIcon = memo(({ className, ...props }) => {
|
|
|
113343
114040
|
);
|
|
113344
114041
|
});
|
|
113345
114042
|
PrinterIcon.displayName = "PrinterIcon";
|
|
113346
|
-
var PageWidthIcon = () => /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
113347
|
-
/* @__PURE__ */ jsx("path", { d: "M3 4v16M21 4v16" }),
|
|
113348
|
-
/* @__PURE__ */ jsx("path", { d: "M7 12h10M10 9l-3 3 3 3M14 9l3 3-3 3" })
|
|
113349
|
-
] });
|
|
113350
|
-
function WidthModeMenu(props = {}) {
|
|
113351
|
-
const ctx = useWidthMode();
|
|
113352
|
-
const mode = props.mode ?? ctx.mode;
|
|
113353
|
-
const setMode = props.onChange ?? ctx.setMode;
|
|
113354
|
-
const [open, setOpen] = useState(false);
|
|
113355
|
-
const ref = useRef(null);
|
|
113356
|
-
useEffect(() => {
|
|
113357
|
-
if (!open) return;
|
|
113358
|
-
const onDown = (e) => {
|
|
113359
|
-
if (!ref.current?.contains(e.target)) setOpen(false);
|
|
113360
|
-
};
|
|
113361
|
-
const onKey = (e) => {
|
|
113362
|
-
if (e.key === "Escape") setOpen(false);
|
|
113363
|
-
};
|
|
113364
|
-
document.addEventListener("mousedown", onDown);
|
|
113365
|
-
document.addEventListener("keydown", onKey);
|
|
113366
|
-
return () => {
|
|
113367
|
-
document.removeEventListener("mousedown", onDown);
|
|
113368
|
-
document.removeEventListener("keydown", onKey);
|
|
113369
|
-
};
|
|
113370
|
-
}, [open]);
|
|
113371
|
-
return /* @__PURE__ */ jsxs("div", { className: "tt-width-mode", ref, children: [
|
|
113372
|
-
/* @__PURE__ */ jsx(
|
|
113373
|
-
"button",
|
|
113374
|
-
{
|
|
113375
|
-
type: "button",
|
|
113376
|
-
className: "tt-width-mode__btn",
|
|
113377
|
-
"aria-label": WIDTH_MODE_MENU_TITLE,
|
|
113378
|
-
title: WIDTH_MODE_MENU_TITLE,
|
|
113379
|
-
"aria-haspopup": "menu",
|
|
113380
|
-
"aria-expanded": open,
|
|
113381
|
-
onClick: () => setOpen((o) => !o),
|
|
113382
|
-
children: /* @__PURE__ */ jsx(PageWidthIcon, {})
|
|
113383
|
-
}
|
|
113384
|
-
),
|
|
113385
|
-
open ? /* @__PURE__ */ jsxs("div", { className: "tt-width-mode__menu", role: "menu", "aria-label": WIDTH_MODE_MENU_TITLE, children: [
|
|
113386
|
-
/* @__PURE__ */ jsx("div", { className: "tt-width-mode__header", children: WIDTH_MODE_MENU_HEADER }),
|
|
113387
|
-
/* @__PURE__ */ jsx("div", { className: "tt-width-mode__items", children: WIDTH_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
|
|
113388
|
-
"button",
|
|
113389
|
-
{
|
|
113390
|
-
type: "button",
|
|
113391
|
-
role: "menuitemradio",
|
|
113392
|
-
"aria-checked": item.mode === mode,
|
|
113393
|
-
className: `tt-width-mode__item tt-width-mode__item--${item.mode}`,
|
|
113394
|
-
onClick: () => {
|
|
113395
|
-
setOpen(false);
|
|
113396
|
-
if (item.mode !== mode) setMode(item.mode);
|
|
113397
|
-
},
|
|
113398
|
-
children: [
|
|
113399
|
-
/* @__PURE__ */ jsxs("span", { className: "tt-width-mode__icon", "aria-hidden": "true", children: [
|
|
113400
|
-
/* @__PURE__ */ jsx("span", {}),
|
|
113401
|
-
/* @__PURE__ */ jsx("span", {}),
|
|
113402
|
-
/* @__PURE__ */ jsx("span", {}),
|
|
113403
|
-
/* @__PURE__ */ jsx("span", {})
|
|
113404
|
-
] }),
|
|
113405
|
-
/* @__PURE__ */ jsx("span", { className: "tt-width-mode__name", children: item.name })
|
|
113406
|
-
]
|
|
113407
|
-
},
|
|
113408
|
-
item.mode
|
|
113409
|
-
)) })
|
|
113410
|
-
] }) : null
|
|
113411
|
-
] });
|
|
113412
|
-
}
|
|
113413
114043
|
function HistoryShortcutBadge({
|
|
113414
114044
|
action,
|
|
113415
114045
|
shortcutKeys = UNDO_REDO_SHORTCUT_KEYS[action]
|
|
@@ -113763,40 +114393,199 @@ function CollaborationUsers() {
|
|
|
113763
114393
|
] }) }, user.id)) }) })
|
|
113764
114394
|
] });
|
|
113765
114395
|
}
|
|
113766
|
-
|
|
114396
|
+
var SAVE_STATE_LABELS = {
|
|
114397
|
+
unsaved: "未保存",
|
|
114398
|
+
saving: "正在保存",
|
|
114399
|
+
saved: "已保存",
|
|
114400
|
+
error: "保存失败",
|
|
114401
|
+
offline: "离线"
|
|
114402
|
+
};
|
|
114403
|
+
function DocumentViewModeMenu() {
|
|
114404
|
+
const { mode, canEdit, setMode } = useViewMode();
|
|
114405
|
+
const [open, setOpen] = useState(false);
|
|
114406
|
+
if (!canEdit) return null;
|
|
114407
|
+
const current = VIEW_MODE_ITEMS.find((item) => item.mode === mode) ?? VIEW_MODE_ITEMS[0];
|
|
114408
|
+
return /* @__PURE__ */ jsx(MenuProvider2, { placement: "bottom-start", open, setOpen, children: /* @__PURE__ */ jsxs(MenuContext.Provider, { value: { isRootMenu: true, open }, children: [
|
|
114409
|
+
/* @__PURE__ */ jsxs(
|
|
114410
|
+
MenuButton2,
|
|
114411
|
+
{
|
|
114412
|
+
render: /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost" }),
|
|
114413
|
+
"aria-label": `文档模式:${current.name}`,
|
|
114414
|
+
children: [
|
|
114415
|
+
/* @__PURE__ */ jsx("span", { children: current.name }),
|
|
114416
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: "tiptap-button-dropdown-small", "aria-hidden": "true" })
|
|
114417
|
+
]
|
|
114418
|
+
}
|
|
114419
|
+
),
|
|
114420
|
+
/* @__PURE__ */ jsx(
|
|
114421
|
+
MenuContent,
|
|
114422
|
+
{
|
|
114423
|
+
className: "notion-like-editor-menu",
|
|
114424
|
+
"aria-label": "文档模式",
|
|
114425
|
+
composite: true,
|
|
114426
|
+
modal: false,
|
|
114427
|
+
portal: true,
|
|
114428
|
+
preventBodyScroll: false,
|
|
114429
|
+
children: VIEW_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
|
|
114430
|
+
MenuItemRadio2,
|
|
114431
|
+
{
|
|
114432
|
+
className: "notion-like-editor-menu-item",
|
|
114433
|
+
name: "document-view-mode",
|
|
114434
|
+
value: item.mode,
|
|
114435
|
+
checked: item.mode === mode,
|
|
114436
|
+
"aria-label": item.name,
|
|
114437
|
+
hideOnClick: true,
|
|
114438
|
+
onClick: () => {
|
|
114439
|
+
if (item.mode !== mode) setMode(item.mode, "user");
|
|
114440
|
+
},
|
|
114441
|
+
children: [
|
|
114442
|
+
/* @__PURE__ */ jsx("span", { children: item.name }),
|
|
114443
|
+
/* @__PURE__ */ jsx(MenuItemCheck2, {})
|
|
114444
|
+
]
|
|
114445
|
+
},
|
|
114446
|
+
item.mode
|
|
114447
|
+
))
|
|
114448
|
+
}
|
|
114449
|
+
)
|
|
114450
|
+
] }) });
|
|
114451
|
+
}
|
|
114452
|
+
function DocumentMoreMenu() {
|
|
113767
114453
|
const { editor } = useTiptapEditor();
|
|
113768
|
-
|
|
113769
|
-
|
|
113770
|
-
|
|
113771
|
-
|
|
113772
|
-
|
|
113773
|
-
|
|
113774
|
-
|
|
113775
|
-
|
|
113776
|
-
|
|
113777
|
-
|
|
113778
|
-
|
|
113779
|
-
|
|
113780
|
-
|
|
113781
|
-
|
|
114454
|
+
const documentConfig = useEditorConfig()?.document;
|
|
114455
|
+
const { mode, setMode } = useWidthMode();
|
|
114456
|
+
const [open, setOpen] = useState(false);
|
|
114457
|
+
const theme = useTheme();
|
|
114458
|
+
const isDark = isDarkAntdToken(theme, theme.isDarkMode);
|
|
114459
|
+
return /* @__PURE__ */ jsx(MenuProvider2, { placement: "bottom-end", open, setOpen, children: /* @__PURE__ */ jsxs(MenuContext.Provider, { value: { isRootMenu: true, open }, children: [
|
|
114460
|
+
/* @__PURE__ */ jsx(MenuButton2, { render: /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost" }), "aria-label": "更多操作", children: /* @__PURE__ */ jsx(MoreVerticalIcon, { className: "tiptap-button-icon", "aria-hidden": "true" }) }),
|
|
114461
|
+
/* @__PURE__ */ jsxs(
|
|
114462
|
+
MenuContent,
|
|
114463
|
+
{
|
|
114464
|
+
className: "notion-like-editor-menu",
|
|
114465
|
+
"aria-label": "更多操作",
|
|
114466
|
+
composite: true,
|
|
114467
|
+
modal: false,
|
|
114468
|
+
portal: true,
|
|
114469
|
+
preventBodyScroll: false,
|
|
114470
|
+
children: [
|
|
114471
|
+
/* @__PURE__ */ jsxs(MenuGroup2, { children: [
|
|
114472
|
+
/* @__PURE__ */ jsx(MenuGroupLabel2, { children: "页宽设置" }),
|
|
114473
|
+
WIDTH_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
|
|
114474
|
+
MenuItemRadio2,
|
|
114475
|
+
{
|
|
114476
|
+
className: "notion-like-editor-menu-item",
|
|
114477
|
+
name: "document-width",
|
|
114478
|
+
value: item.mode,
|
|
114479
|
+
checked: item.mode === mode,
|
|
114480
|
+
hideOnClick: true,
|
|
114481
|
+
onClick: () => {
|
|
114482
|
+
if (item.mode !== mode) setMode(item.mode);
|
|
114483
|
+
},
|
|
114484
|
+
children: [
|
|
114485
|
+
/* @__PURE__ */ jsx("span", { children: item.name }),
|
|
114486
|
+
/* @__PURE__ */ jsx(MenuItemCheck2, {})
|
|
114487
|
+
]
|
|
114488
|
+
},
|
|
114489
|
+
item.mode
|
|
114490
|
+
))
|
|
114491
|
+
] }),
|
|
114492
|
+
editor && getDocPermissions(editor).print && typeof editor.commands.printDocument === "function" ? /* @__PURE__ */ jsxs(
|
|
114493
|
+
MenuItem3,
|
|
114494
|
+
{
|
|
114495
|
+
className: "notion-like-editor-menu-item",
|
|
114496
|
+
"aria-label": "打印",
|
|
114497
|
+
onClick: () => {
|
|
114498
|
+
if (getDocPermissions(editor).print) editor.commands.printDocument();
|
|
114499
|
+
},
|
|
114500
|
+
children: [
|
|
114501
|
+
/* @__PURE__ */ jsx(PrinterIcon, { className: "tiptap-button-icon", "aria-hidden": "true" }),
|
|
114502
|
+
/* @__PURE__ */ jsx("span", { children: "打印" })
|
|
114503
|
+
]
|
|
114504
|
+
}
|
|
114505
|
+
) : null,
|
|
114506
|
+
documentConfig?.onOpenHistory ? /* @__PURE__ */ jsx(
|
|
114507
|
+
MenuItem3,
|
|
114508
|
+
{
|
|
114509
|
+
className: "notion-like-editor-menu-item",
|
|
114510
|
+
onClick: documentConfig.onOpenHistory,
|
|
114511
|
+
children: "历史记录"
|
|
114512
|
+
}
|
|
114513
|
+
) : null,
|
|
114514
|
+
/* @__PURE__ */ jsx(MenuSeparator2, { className: "notion-like-editor-menu-separator" }),
|
|
114515
|
+
/* @__PURE__ */ jsxs("div", { className: "notion-like-editor-menu-note", children: [
|
|
114516
|
+
"主题:跟随宿主(",
|
|
114517
|
+
isDark ? "深色" : "浅色",
|
|
114518
|
+
")"
|
|
114519
|
+
] })
|
|
114520
|
+
]
|
|
114521
|
+
}
|
|
114522
|
+
)
|
|
114523
|
+
] }) });
|
|
113782
114524
|
}
|
|
113783
114525
|
function NotionEditorHeader() {
|
|
114526
|
+
const documentConfig = useEditorConfig()?.document;
|
|
114527
|
+
const saveState = documentConfig?.saveState;
|
|
114528
|
+
const commentCount = documentConfig?.commentCount;
|
|
113784
114529
|
return /* @__PURE__ */ jsxs("header", { className: "notion-like-editor-header", children: [
|
|
114530
|
+
saveState ? /* @__PURE__ */ jsxs("div", { className: "notion-like-editor-header-feedback", children: [
|
|
114531
|
+
/* @__PURE__ */ jsxs(
|
|
114532
|
+
"output",
|
|
114533
|
+
{
|
|
114534
|
+
className: "notion-like-editor-save-state",
|
|
114535
|
+
"data-save-state": saveState,
|
|
114536
|
+
"aria-live": "polite",
|
|
114537
|
+
"aria-atomic": "true",
|
|
114538
|
+
children: [
|
|
114539
|
+
/* @__PURE__ */ jsx("span", { className: "notion-like-editor-save-state-indicator", "aria-hidden": "true" }),
|
|
114540
|
+
/* @__PURE__ */ jsx("span", { children: SAVE_STATE_LABELS[saveState] })
|
|
114541
|
+
]
|
|
114542
|
+
}
|
|
114543
|
+
),
|
|
114544
|
+
saveState === "error" && documentConfig?.onRetrySave ? /* @__PURE__ */ jsx(
|
|
114545
|
+
Button,
|
|
114546
|
+
{
|
|
114547
|
+
type: "button",
|
|
114548
|
+
variant: "ghost",
|
|
114549
|
+
size: "small",
|
|
114550
|
+
"aria-label": "重试保存",
|
|
114551
|
+
onClick: documentConfig.onRetrySave,
|
|
114552
|
+
children: "重试"
|
|
114553
|
+
}
|
|
114554
|
+
) : null
|
|
114555
|
+
] }) : null,
|
|
113785
114556
|
/* @__PURE__ */ jsx(Spacer, {}),
|
|
113786
114557
|
/* @__PURE__ */ jsxs("div", { className: "notion-like-editor-header-actions", children: [
|
|
113787
|
-
/* @__PURE__ */ jsx(
|
|
113788
|
-
/* @__PURE__ */ jsx(Separator, {}),
|
|
114558
|
+
/* @__PURE__ */ jsx(DocumentViewModeMenu, {}),
|
|
113789
114559
|
/* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
113790
|
-
/* @__PURE__ */ jsx(
|
|
113791
|
-
/* @__PURE__ */ jsx(
|
|
114560
|
+
/* @__PURE__ */ jsx(UndoRedoButton, { action: "undo", tabIndex: 0 }),
|
|
114561
|
+
/* @__PURE__ */ jsx(UndoRedoButton, { action: "redo", tabIndex: 0 })
|
|
113792
114562
|
] }),
|
|
113793
114563
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
113794
|
-
/* @__PURE__ */ jsx(
|
|
113795
|
-
/* @__PURE__ */
|
|
113796
|
-
|
|
113797
|
-
|
|
113798
|
-
|
|
113799
|
-
|
|
114564
|
+
/* @__PURE__ */ jsx(CollaborationUsers, {}),
|
|
114565
|
+
documentConfig?.onOpenComments ? /* @__PURE__ */ jsxs(
|
|
114566
|
+
Button,
|
|
114567
|
+
{
|
|
114568
|
+
type: "button",
|
|
114569
|
+
variant: "ghost",
|
|
114570
|
+
"aria-label": commentCount === void 0 ? "评论" : `评论(${commentCount})`,
|
|
114571
|
+
onClick: documentConfig.onOpenComments,
|
|
114572
|
+
children: [
|
|
114573
|
+
/* @__PURE__ */ jsx(MessageSquareIcon, { className: "tiptap-button-icon", "aria-hidden": "true" }),
|
|
114574
|
+
commentCount !== void 0 ? /* @__PURE__ */ jsx("span", { className: "notion-like-editor-comment-count", "aria-hidden": "true", children: commentCount }) : null
|
|
114575
|
+
]
|
|
114576
|
+
}
|
|
114577
|
+
) : null,
|
|
114578
|
+
documentConfig?.onShare ? /* @__PURE__ */ jsx(
|
|
114579
|
+
Button,
|
|
114580
|
+
{
|
|
114581
|
+
type: "button",
|
|
114582
|
+
variant: "primary",
|
|
114583
|
+
className: "notion-like-editor-share",
|
|
114584
|
+
onClick: documentConfig.onShare,
|
|
114585
|
+
children: "分享"
|
|
114586
|
+
}
|
|
114587
|
+
) : null,
|
|
114588
|
+
/* @__PURE__ */ jsx(DocumentMoreMenu, {})
|
|
113800
114589
|
] })
|
|
113801
114590
|
] });
|
|
113802
114591
|
}
|
|
@@ -116796,9 +117585,33 @@ function MainToolbarContent({
|
|
|
116796
117585
|
toolbarViews,
|
|
116797
117586
|
onViewChange
|
|
116798
117587
|
}) {
|
|
117588
|
+
const comments = useEditorConfig()?.comments;
|
|
117589
|
+
const commentSelection = useEditorState({
|
|
117590
|
+
editor,
|
|
117591
|
+
selector: ({ editor: current }) => current ? getCommentSelection(current.state) : null
|
|
117592
|
+
});
|
|
117593
|
+
const commentSelectionRef = useRef(null);
|
|
116799
117594
|
const hasSelection2 = hasTextSelection(editor);
|
|
116800
117595
|
const hasContent = (editor?.getText().length ?? 0) > 0;
|
|
116801
117596
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
117597
|
+
comments && editor?.isEditable && commentSelection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
|
|
117598
|
+
Button,
|
|
117599
|
+
{
|
|
117600
|
+
type: "button",
|
|
117601
|
+
variant: "ghost",
|
|
117602
|
+
"aria-label": "添加评论",
|
|
117603
|
+
onMouseDown: (event) => {
|
|
117604
|
+
event.preventDefault();
|
|
117605
|
+
commentSelectionRef.current = getCommentSelection(editor.state);
|
|
117606
|
+
},
|
|
117607
|
+
onClick: () => {
|
|
117608
|
+
const selection = commentSelectionRef.current ?? commentSelection;
|
|
117609
|
+
commentSelectionRef.current = null;
|
|
117610
|
+
if (editor.isEditable && selection) comments.onCreateComment(selection);
|
|
117611
|
+
},
|
|
117612
|
+
children: "添加评论"
|
|
117613
|
+
}
|
|
117614
|
+
) }),
|
|
116802
117615
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
116803
117616
|
/* @__PURE__ */ jsx(SlashCommandTriggerButton, {}),
|
|
116804
117617
|
/* @__PURE__ */ jsx(MoreActionsDropdown, { editor }),
|
|
@@ -117416,6 +118229,12 @@ var AIButton = forwardRef(
|
|
|
117416
118229
|
AIButton.displayName = "AIButton";
|
|
117417
118230
|
function NotionToolbarFloating() {
|
|
117418
118231
|
const { editor } = useTiptapEditor();
|
|
118232
|
+
const comments = useEditorConfig()?.comments;
|
|
118233
|
+
const commentSelection = useEditorState({
|
|
118234
|
+
editor,
|
|
118235
|
+
selector: ({ editor: current }) => current ? getCommentSelection(current.state) : null
|
|
118236
|
+
});
|
|
118237
|
+
const commentSelectionRef = useRef(null);
|
|
117419
118238
|
const isMobile = useIsBreakpoint("max", 480);
|
|
117420
118239
|
const { lockDragHandle, commentInputVisible } = useUiEditorState(editor);
|
|
117421
118240
|
const linkPanelOpen = useEditorState({
|
|
@@ -117454,6 +118273,24 @@ function NotionToolbarFloating() {
|
|
|
117454
118273
|
/* @__PURE__ */ jsx(VideoNodeFloating, {})
|
|
117455
118274
|
] }),
|
|
117456
118275
|
/* @__PURE__ */ jsx(MoreOptions, { hideWhenUnavailable: true }),
|
|
118276
|
+
comments && editor?.isEditable && commentSelection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
|
|
118277
|
+
Button,
|
|
118278
|
+
{
|
|
118279
|
+
type: "button",
|
|
118280
|
+
variant: "ghost",
|
|
118281
|
+
"aria-label": "添加评论",
|
|
118282
|
+
onMouseDown: (event) => {
|
|
118283
|
+
event.preventDefault();
|
|
118284
|
+
commentSelectionRef.current = getCommentSelection(editor.state);
|
|
118285
|
+
},
|
|
118286
|
+
onClick: () => {
|
|
118287
|
+
const selection = commentSelectionRef.current ?? commentSelection;
|
|
118288
|
+
commentSelectionRef.current = null;
|
|
118289
|
+
if (editor.isEditable && selection) comments.onCreateComment(selection);
|
|
118290
|
+
},
|
|
118291
|
+
children: "添加评论"
|
|
118292
|
+
}
|
|
118293
|
+
) }),
|
|
117457
118294
|
editor?.isEditable && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
|
|
117458
118295
|
Button,
|
|
117459
118296
|
{
|
|
@@ -117628,6 +118465,13 @@ function TocSidebar({
|
|
|
117628
118465
|
}) {
|
|
117629
118466
|
const { tocContent, navigateToHeading, normalizeHeadingDepths: normalizeHeadingDepths2 } = useToc();
|
|
117630
118467
|
const hasRestoredHashRef = useRef(false);
|
|
118468
|
+
const navigationId = useId();
|
|
118469
|
+
const toggleRef = useRef(null);
|
|
118470
|
+
const [isPinned, setIsPinned] = useState(false);
|
|
118471
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
118472
|
+
const [hasFocus, setHasFocus] = useState(false);
|
|
118473
|
+
const [isDismissed, setIsDismissed] = useState(false);
|
|
118474
|
+
const isExpanded = !isDismissed && (isPinned || isHovered || hasFocus);
|
|
117631
118475
|
const lastClickTimeRef = useRef(null);
|
|
117632
118476
|
const [manualActiveId, setManualActiveId] = useState(null);
|
|
117633
118477
|
const headingList = useMemo(
|
|
@@ -117722,7 +118566,7 @@ function TocSidebar({
|
|
|
117722
118566
|
const popoverRef = useRef(null);
|
|
117723
118567
|
useEffect(() => {
|
|
117724
118568
|
if (!activeContentId) return;
|
|
117725
|
-
for (const box of [progressRef.current, popoverRef.current]) {
|
|
118569
|
+
for (const box of [isPinned ? null : progressRef.current, isExpanded ? popoverRef.current : null]) {
|
|
117726
118570
|
const el = box?.querySelector(`[data-toc-id="${CSS.escape(activeContentId)}"]`);
|
|
117727
118571
|
if (!box || !el) continue;
|
|
117728
118572
|
const top = el.offsetTop - box.offsetTop;
|
|
@@ -117730,60 +118574,154 @@ function TocSidebar({
|
|
|
117730
118574
|
if (top < box.scrollTop) box.scrollTop = top;
|
|
117731
118575
|
else if (bottom > box.scrollTop + box.clientHeight) box.scrollTop = bottom - box.clientHeight;
|
|
117732
118576
|
}
|
|
117733
|
-
}, [activeContentId]);
|
|
118577
|
+
}, [activeContentId, isExpanded, isPinned]);
|
|
117734
118578
|
const hasHeadings = headingList.length > 0;
|
|
117735
|
-
|
|
117736
|
-
|
|
117737
|
-
|
|
117738
|
-
|
|
117739
|
-
|
|
117740
|
-
|
|
118579
|
+
const closeSidebar = () => {
|
|
118580
|
+
setIsPinned(false);
|
|
118581
|
+
setIsDismissed(true);
|
|
118582
|
+
toggleRef.current?.focus({ preventScroll: true });
|
|
118583
|
+
};
|
|
118584
|
+
return /* @__PURE__ */ jsx(
|
|
118585
|
+
"div",
|
|
118586
|
+
{
|
|
118587
|
+
ref: sidebarRef,
|
|
118588
|
+
className: cn(
|
|
118589
|
+
"toc-sidebar",
|
|
118590
|
+
hasHeadings && isPinned && "toc-sidebar--pinned",
|
|
118591
|
+
hasHeadings && isExpanded && "toc-sidebar--expanded",
|
|
118592
|
+
className
|
|
118593
|
+
),
|
|
118594
|
+
...props,
|
|
118595
|
+
children: /* @__PURE__ */ jsx(
|
|
118596
|
+
"aside",
|
|
117741
118597
|
{
|
|
117742
|
-
"
|
|
117743
|
-
|
|
117744
|
-
|
|
117745
|
-
|
|
117746
|
-
|
|
117747
|
-
|
|
117748
|
-
|
|
117749
|
-
|
|
117750
|
-
|
|
117751
|
-
|
|
117752
|
-
|
|
117753
|
-
|
|
117754
|
-
|
|
117755
|
-
|
|
117756
|
-
|
|
117757
|
-
|
|
117758
|
-
|
|
117759
|
-
|
|
117760
|
-
|
|
117761
|
-
|
|
117762
|
-
|
|
117763
|
-
|
|
117764
|
-
|
|
117765
|
-
|
|
117766
|
-
|
|
117767
|
-
"
|
|
117768
|
-
|
|
117769
|
-
|
|
117770
|
-
|
|
117771
|
-
|
|
117772
|
-
"
|
|
117773
|
-
|
|
117774
|
-
|
|
117775
|
-
|
|
117776
|
-
|
|
117777
|
-
|
|
117778
|
-
|
|
117779
|
-
|
|
117780
|
-
|
|
117781
|
-
|
|
117782
|
-
|
|
117783
|
-
|
|
117784
|
-
|
|
117785
|
-
|
|
117786
|
-
|
|
118598
|
+
className: "toc-sidebar-wrapper",
|
|
118599
|
+
"aria-label": "文档目录",
|
|
118600
|
+
onMouseEnter: () => {
|
|
118601
|
+
setIsHovered(true);
|
|
118602
|
+
setIsDismissed(false);
|
|
118603
|
+
},
|
|
118604
|
+
onMouseLeave: () => setIsHovered(false),
|
|
118605
|
+
onFocusCapture: (event) => {
|
|
118606
|
+
setHasFocus(true);
|
|
118607
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setIsDismissed(false);
|
|
118608
|
+
},
|
|
118609
|
+
onBlurCapture: (event) => {
|
|
118610
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setHasFocus(false);
|
|
118611
|
+
},
|
|
118612
|
+
onKeyDownCapture: (event) => {
|
|
118613
|
+
if (event.key === "Escape" && isExpanded) {
|
|
118614
|
+
event.preventDefault();
|
|
118615
|
+
event.stopPropagation();
|
|
118616
|
+
closeSidebar();
|
|
118617
|
+
} else if (isDismissed && event.key === "Tab" && !event.shiftKey && event.target === toggleRef.current) {
|
|
118618
|
+
flushSync(() => setIsDismissed(false));
|
|
118619
|
+
}
|
|
118620
|
+
},
|
|
118621
|
+
children: /* @__PURE__ */ jsxs("div", { className: "toc-sidebar-inner", children: [
|
|
118622
|
+
hasHeadings && /* @__PURE__ */ jsxs(
|
|
118623
|
+
"button",
|
|
118624
|
+
{
|
|
118625
|
+
ref: toggleRef,
|
|
118626
|
+
type: "button",
|
|
118627
|
+
className: "toc-sidebar-toggle",
|
|
118628
|
+
"aria-label": isPinned ? "收起目录" : "固定目录",
|
|
118629
|
+
title: isPinned ? "收起目录" : "固定目录",
|
|
118630
|
+
"aria-controls": navigationId,
|
|
118631
|
+
"aria-pressed": isPinned,
|
|
118632
|
+
"aria-expanded": isExpanded,
|
|
118633
|
+
onClick: () => {
|
|
118634
|
+
if (isPinned) closeSidebar();
|
|
118635
|
+
else {
|
|
118636
|
+
setIsDismissed(false);
|
|
118637
|
+
setIsPinned(true);
|
|
118638
|
+
}
|
|
118639
|
+
},
|
|
118640
|
+
children: [
|
|
118641
|
+
/* @__PURE__ */ jsx(
|
|
118642
|
+
"svg",
|
|
118643
|
+
{
|
|
118644
|
+
width: "14",
|
|
118645
|
+
height: "14",
|
|
118646
|
+
viewBox: "0 0 24 24",
|
|
118647
|
+
fill: "none",
|
|
118648
|
+
stroke: "currentColor",
|
|
118649
|
+
strokeWidth: "1.8",
|
|
118650
|
+
"aria-hidden": "true",
|
|
118651
|
+
focusable: "false",
|
|
118652
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4 5h16M4 12h16M4 19h10" })
|
|
118653
|
+
}
|
|
118654
|
+
),
|
|
118655
|
+
isPinned ? "收起目录" : "目录"
|
|
118656
|
+
]
|
|
118657
|
+
}
|
|
118658
|
+
),
|
|
118659
|
+
/* @__PURE__ */ jsx(
|
|
118660
|
+
"div",
|
|
118661
|
+
{
|
|
118662
|
+
ref: progressRef,
|
|
118663
|
+
className: "toc-sidebar-progress",
|
|
118664
|
+
"aria-hidden": "true",
|
|
118665
|
+
tabIndex: -1,
|
|
118666
|
+
children: visibleHeadings.map((item) => {
|
|
118667
|
+
const depth = depthById.get(item.id) ?? 1;
|
|
118668
|
+
const isActive2 = activeContentId === item.id;
|
|
118669
|
+
return /* @__PURE__ */ jsx(
|
|
118670
|
+
"div",
|
|
118671
|
+
{
|
|
118672
|
+
"data-toc-id": item.id,
|
|
118673
|
+
className: cn(
|
|
118674
|
+
"toc-sidebar-progress-line",
|
|
118675
|
+
isActive2 && "toc-sidebar-progress-line--active"
|
|
118676
|
+
),
|
|
118677
|
+
"data-depth": depth,
|
|
118678
|
+
style: { "--toc-depth": depth }
|
|
118679
|
+
},
|
|
118680
|
+
item.id
|
|
118681
|
+
);
|
|
118682
|
+
})
|
|
118683
|
+
}
|
|
118684
|
+
),
|
|
118685
|
+
/* @__PURE__ */ jsx(
|
|
118686
|
+
"nav",
|
|
118687
|
+
{
|
|
118688
|
+
id: navigationId,
|
|
118689
|
+
className: cn(
|
|
118690
|
+
"toc-sidebar-nav",
|
|
118691
|
+
!hasHeadings && "toc-sidebar-nav--hidden"
|
|
118692
|
+
),
|
|
118693
|
+
"aria-label": "目录",
|
|
118694
|
+
"aria-hidden": !hasHeadings || !isExpanded,
|
|
118695
|
+
children: /* @__PURE__ */ jsx("div", { ref: popoverRef, className: "toc-sidebar-popover", tabIndex: -1, children: visibleHeadings.map((item) => {
|
|
118696
|
+
const depth = depthById.get(item.id) ?? 1;
|
|
118697
|
+
const isActive2 = activeContentId === item.id;
|
|
118698
|
+
return /* @__PURE__ */ jsx(
|
|
118699
|
+
"a",
|
|
118700
|
+
{
|
|
118701
|
+
"data-toc-id": item.id,
|
|
118702
|
+
title: item.textContent,
|
|
118703
|
+
href: `#${item.id}`,
|
|
118704
|
+
rel: "noopener noreferrer",
|
|
118705
|
+
className: cn(
|
|
118706
|
+
"toc-sidebar-item notranslate",
|
|
118707
|
+
isActive2 && "toc-sidebar-item--active"
|
|
118708
|
+
),
|
|
118709
|
+
"data-depth": depth,
|
|
118710
|
+
style: { "--toc-depth": depth },
|
|
118711
|
+
onClick: (e) => handleContentClick(e, item),
|
|
118712
|
+
"aria-current": isActive2 ? "location" : void 0,
|
|
118713
|
+
children: withOrder(item)
|
|
118714
|
+
},
|
|
118715
|
+
item.id
|
|
118716
|
+
);
|
|
118717
|
+
}) })
|
|
118718
|
+
}
|
|
118719
|
+
)
|
|
118720
|
+
] })
|
|
118721
|
+
}
|
|
118722
|
+
)
|
|
118723
|
+
}
|
|
118724
|
+
);
|
|
117787
118725
|
}
|
|
117788
118726
|
|
|
117789
118727
|
// src/components/tiptap-extension/list-normalization-extension.ts
|
|
@@ -118174,6 +119112,29 @@ function createRichMarkdownExtensions() {
|
|
|
118174
119112
|
return { MarkdownParagraph, MarkdownHeading };
|
|
118175
119113
|
}
|
|
118176
119114
|
|
|
119115
|
+
// src/lib/im-input.ts
|
|
119116
|
+
function createMessageInputKeyHandler({
|
|
119117
|
+
getEditor,
|
|
119118
|
+
getSendKey,
|
|
119119
|
+
onSend
|
|
119120
|
+
}) {
|
|
119121
|
+
return (view, event) => {
|
|
119122
|
+
if (!onSend || event.defaultPrevented || event.isComposing || event.keyCode === 229 || view.composing) {
|
|
119123
|
+
return false;
|
|
119124
|
+
}
|
|
119125
|
+
const editor = getEditor();
|
|
119126
|
+
if (!editor || editor.isDestroyed || !editor.isEditable) return false;
|
|
119127
|
+
if (event.key !== "Enter" || event.shiftKey || event.altKey) return false;
|
|
119128
|
+
const modifier = event.metaKey || event.ctrlKey;
|
|
119129
|
+
const sendKey = getSendKey();
|
|
119130
|
+
const shouldSend = sendKey === "enter" ? !modifier : sendKey === "mod-enter" ? modifier : false;
|
|
119131
|
+
if (!shouldSend) return false;
|
|
119132
|
+
event.preventDefault();
|
|
119133
|
+
onSend(editor);
|
|
119134
|
+
return true;
|
|
119135
|
+
};
|
|
119136
|
+
}
|
|
119137
|
+
|
|
118177
119138
|
// ../../node_modules/.pnpm/@tiptap+extension-highlight@3.30.0_@tiptap+core@3.30.0_@tiptap+pm@3.30.0_/node_modules/@tiptap/extension-highlight/dist/index.js
|
|
118178
119139
|
var inputRegex6 = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
|
|
118179
119140
|
var pasteRegex3 = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
|
|
@@ -118287,9 +119248,112 @@ var FeishuStrike = Strike.extend({
|
|
|
118287
119248
|
return { "Mod-Shift-x": () => this.editor.commands.toggleStrike() };
|
|
118288
119249
|
}
|
|
118289
119250
|
});
|
|
119251
|
+
function partialLinkRuns(block, start, code, link) {
|
|
119252
|
+
const out = [];
|
|
119253
|
+
let from2 = -1;
|
|
119254
|
+
let to = -1;
|
|
119255
|
+
let links = [];
|
|
119256
|
+
const flush = () => {
|
|
119257
|
+
const first2 = links[0];
|
|
119258
|
+
if (from2 >= 0 && links.some(Boolean) && !links.every((m) => m && first2 && m.eq(first2))) {
|
|
119259
|
+
out.push([from2, to]);
|
|
119260
|
+
}
|
|
119261
|
+
from2 = -1;
|
|
119262
|
+
links = [];
|
|
119263
|
+
};
|
|
119264
|
+
block.forEach((child, offset9) => {
|
|
119265
|
+
if (!child.isText || !code.isInSet(child.marks)) {
|
|
119266
|
+
flush();
|
|
119267
|
+
return;
|
|
119268
|
+
}
|
|
119269
|
+
if (from2 < 0) from2 = start + offset9;
|
|
119270
|
+
to = start + offset9 + child.nodeSize;
|
|
119271
|
+
links.push(link.isInSet(child.marks));
|
|
119272
|
+
});
|
|
119273
|
+
flush();
|
|
119274
|
+
return out;
|
|
119275
|
+
}
|
|
119276
|
+
function inlineCodeLinkPlugin() {
|
|
119277
|
+
return new Plugin({
|
|
119278
|
+
key: new PluginKey("inlineCodeLink"),
|
|
119279
|
+
appendTransaction(transactions, oldState, newState) {
|
|
119280
|
+
const { code, link } = newState.schema.marks;
|
|
119281
|
+
if (!code || !link || !transactions.some((tr3) => tr3.docChanged)) return null;
|
|
119282
|
+
const changed = getChangedRanges(combineTransactionSteps(oldState.doc, [...transactions]));
|
|
119283
|
+
const seen = /* @__PURE__ */ new Set();
|
|
119284
|
+
const ranges = [];
|
|
119285
|
+
for (const { newRange } of changed) {
|
|
119286
|
+
newState.doc.nodesBetween(newRange.from, newRange.to, (node, pos) => {
|
|
119287
|
+
if (!node.isTextblock) return true;
|
|
119288
|
+
if (!seen.has(pos)) {
|
|
119289
|
+
seen.add(pos);
|
|
119290
|
+
ranges.push(...partialLinkRuns(node, pos + 1, code, link));
|
|
119291
|
+
}
|
|
119292
|
+
return false;
|
|
119293
|
+
});
|
|
119294
|
+
}
|
|
119295
|
+
if (!ranges.length) return null;
|
|
119296
|
+
const tr2 = newState.tr;
|
|
119297
|
+
for (const [from2, to] of ranges) tr2.removeMark(from2, to, link);
|
|
119298
|
+
return tr2;
|
|
119299
|
+
}
|
|
119300
|
+
});
|
|
119301
|
+
}
|
|
118290
119302
|
var FeishuCode = Code.extend({
|
|
119303
|
+
excludes: "bold italic underline strike textStyle highlight superscript subscript code",
|
|
118291
119304
|
addKeyboardShortcuts() {
|
|
118292
119305
|
return { [isMac5() ? "Mod-Ctrl-c" : "Ctrl-Shift-c"]: () => this.editor.commands.toggleCode() };
|
|
119306
|
+
},
|
|
119307
|
+
addProseMirrorPlugins() {
|
|
119308
|
+
return [...this.parent?.() ?? [], inlineCodeLinkPlugin()];
|
|
119309
|
+
}
|
|
119310
|
+
});
|
|
119311
|
+
function selectionIsAllCode(state) {
|
|
119312
|
+
const { code } = state.schema.marks;
|
|
119313
|
+
const { from: from2, to, empty: empty2 } = state.selection;
|
|
119314
|
+
if (!code || empty2) return false;
|
|
119315
|
+
let hasText = false;
|
|
119316
|
+
let allCode = true;
|
|
119317
|
+
state.doc.nodesBetween(from2, to, (node) => {
|
|
119318
|
+
if (!node.isText) return true;
|
|
119319
|
+
hasText = true;
|
|
119320
|
+
if (!code.isInSet(node.marks)) allCode = false;
|
|
119321
|
+
return false;
|
|
119322
|
+
});
|
|
119323
|
+
return hasText && allCode;
|
|
119324
|
+
}
|
|
119325
|
+
var FeishuLink = Link.extend({
|
|
119326
|
+
addPasteRules() {
|
|
119327
|
+
return (this.parent?.() ?? []).map(
|
|
119328
|
+
(rule) => new PasteRule({
|
|
119329
|
+
find: rule.find,
|
|
119330
|
+
handler: (props) => {
|
|
119331
|
+
const { code } = props.state.schema.marks;
|
|
119332
|
+
if (code && props.state.doc.rangeHasMark(props.range.from, props.range.to, code)) {
|
|
119333
|
+
return null;
|
|
119334
|
+
}
|
|
119335
|
+
return rule.handler(props);
|
|
119336
|
+
}
|
|
119337
|
+
})
|
|
119338
|
+
);
|
|
119339
|
+
},
|
|
119340
|
+
// Link 的插件里只有「选中文字后粘贴网址 → 给选区加链接」这一个有 handlePaste。选中的全是行内代码时
|
|
119341
|
+
// 跳过它,按普通粘贴替换文字(放开链接之前就是这样),不给代码挂一个看不出来的链接
|
|
119342
|
+
addProseMirrorPlugins() {
|
|
119343
|
+
return (this.parent?.() ?? []).map((plugin) => {
|
|
119344
|
+
const handlePaste2 = plugin.props.handlePaste;
|
|
119345
|
+
if (!handlePaste2) return plugin;
|
|
119346
|
+
return new Plugin({
|
|
119347
|
+
...plugin.spec,
|
|
119348
|
+
props: {
|
|
119349
|
+
...plugin.spec.props,
|
|
119350
|
+
handlePaste(view, event, slice2) {
|
|
119351
|
+
if (selectionIsAllCode(view.state)) return false;
|
|
119352
|
+
return handlePaste2.call(this, view, event, slice2);
|
|
119353
|
+
}
|
|
119354
|
+
}
|
|
119355
|
+
});
|
|
119356
|
+
});
|
|
118293
119357
|
}
|
|
118294
119358
|
});
|
|
118295
119359
|
var FeishuBlockquote = Blockquote.extend({
|
|
@@ -118760,6 +119824,11 @@ function EditorProvider(props) {
|
|
|
118760
119824
|
hideFloatingToolbar = false,
|
|
118761
119825
|
embedded = false,
|
|
118762
119826
|
richMarkdown = false,
|
|
119827
|
+
sendKey,
|
|
119828
|
+
onSend,
|
|
119829
|
+
onUpdate,
|
|
119830
|
+
onSelectionUpdate,
|
|
119831
|
+
onEditorDestroy,
|
|
118763
119832
|
onEditorReady,
|
|
118764
119833
|
extensions: extraExtensions,
|
|
118765
119834
|
pageHeader = false,
|
|
@@ -118786,6 +119855,18 @@ function EditorProvider(props) {
|
|
|
118786
119855
|
return found2;
|
|
118787
119856
|
}, []);
|
|
118788
119857
|
const editorConfig = useEditorConfig();
|
|
119858
|
+
const editorConfigRef = useRef(editorConfig);
|
|
119859
|
+
editorConfigRef.current = editorConfig;
|
|
119860
|
+
const onSendRef = useRef(onSend);
|
|
119861
|
+
onSendRef.current = onSend;
|
|
119862
|
+
const sendKeyRef = useRef(sendKey);
|
|
119863
|
+
sendKeyRef.current = sendKey;
|
|
119864
|
+
const onUpdateRef = useRef(onUpdate);
|
|
119865
|
+
onUpdateRef.current = onUpdate;
|
|
119866
|
+
const onSelectionUpdateRef = useRef(onSelectionUpdate);
|
|
119867
|
+
onSelectionUpdateRef.current = onSelectionUpdate;
|
|
119868
|
+
const onEditorDestroyRef = useRef(onEditorDestroy);
|
|
119869
|
+
onEditorDestroyRef.current = onEditorDestroy;
|
|
118789
119870
|
const [mathBus] = useState(createMathEditBus);
|
|
118790
119871
|
const onUpload = editorConfig?.upload?.onUpload ?? handleImageUpload;
|
|
118791
119872
|
const onUploadError = editorConfig?.upload?.onError ?? // 宿主没给 onError 时按飞书弹提示(「上传图片大小不能超过 20 MB」「图片格式仅支持 …」等)
|
|
@@ -118815,7 +119896,8 @@ function EditorProvider(props) {
|
|
|
118815
119896
|
dropcursor: {
|
|
118816
119897
|
width: 2
|
|
118817
119898
|
},
|
|
118818
|
-
|
|
119899
|
+
// 换成粘贴规则跳过行内代码的版本(feishu-keymap 的 FeishuLink)
|
|
119900
|
+
link: false
|
|
118819
119901
|
}),
|
|
118820
119902
|
...richMarkdownExtensions ? [richMarkdownExtensions.MarkdownParagraph] : [],
|
|
118821
119903
|
// 代码块 / 分组 / 高亮 / Markdown / 直接输入:顺序固定,且在协同与 UniqueID 之前
|
|
@@ -118834,6 +119916,7 @@ function EditorProvider(props) {
|
|
|
118834
119916
|
richMarkdownExtensions ? richMarkdownExtensions.MarkdownHeading : Heading2,
|
|
118835
119917
|
FeishuStrike,
|
|
118836
119918
|
FeishuCode,
|
|
119919
|
+
FeishuLink.configure({ openOnClick: false }),
|
|
118837
119920
|
FeishuBlockquote,
|
|
118838
119921
|
// ⌘⌥S 分割线、⌘⌥H 套用上次颜色、Alt+C 切换待办(规格 §33)
|
|
118839
119922
|
FeishuKeymap,
|
|
@@ -118933,6 +120016,10 @@ function EditorProvider(props) {
|
|
|
118933
120016
|
FindReplace,
|
|
118934
120017
|
PrintDocument,
|
|
118935
120018
|
ReadOnlyGuard,
|
|
120019
|
+
CommentThread.configure({
|
|
120020
|
+
isInteractive: () => Boolean(editorConfigRef.current?.comments?.onSelectThread),
|
|
120021
|
+
onSelectThread: (threadId) => editorConfigRef.current?.comments?.onSelectThread?.(threadId)
|
|
120022
|
+
}),
|
|
118936
120023
|
Color,
|
|
118937
120024
|
FeishuTaskList,
|
|
118938
120025
|
TaskItem.configure({ nested: true }),
|
|
@@ -119038,6 +120125,7 @@ function EditorProvider(props) {
|
|
|
119038
120125
|
],
|
|
119039
120126
|
filterTransaction: (transaction) => !isChangeOrigin(transaction)
|
|
119040
120127
|
}),
|
|
120128
|
+
PasteNodeIds,
|
|
119041
120129
|
// 不挂 Typography:飞书没有任何排版替换(MD 规则全集 vT 里没有),它会把中文文档里的
|
|
119042
120130
|
// 引号、`--`、`1*2` 改写掉
|
|
119043
120131
|
UiState,
|
|
@@ -119050,6 +120138,14 @@ function EditorProvider(props) {
|
|
|
119050
120138
|
const [initialContent] = useState(
|
|
119051
120139
|
() => provider ? void 0 : normalizeEditorContent(content, contentFormat, extensions) ?? void 0
|
|
119052
120140
|
);
|
|
120141
|
+
const messageInputKeyHandler = useMemo(
|
|
120142
|
+
() => createMessageInputKeyHandler({
|
|
120143
|
+
getEditor: () => editorRef.current,
|
|
120144
|
+
getSendKey: () => sendKeyRef.current,
|
|
120145
|
+
onSend: (current) => onSendRef.current?.(current)
|
|
120146
|
+
}),
|
|
120147
|
+
[]
|
|
120148
|
+
);
|
|
119053
120149
|
const editor = useEditor({
|
|
119054
120150
|
immediatelyRender: false,
|
|
119055
120151
|
// 只读模式:禁用编辑。扩展集保持不变,自定义节点仍走各自 NodeView 渲染
|
|
@@ -119059,10 +120155,22 @@ function EditorProvider(props) {
|
|
|
119059
120155
|
editorProps: {
|
|
119060
120156
|
attributes: {
|
|
119061
120157
|
class: "notion-like-editor"
|
|
119062
|
-
}
|
|
120158
|
+
},
|
|
120159
|
+
handleKeyDown: messageInputKeyHandler
|
|
120160
|
+
},
|
|
120161
|
+
onUpdate: ({ editor: current }) => onUpdateRef.current?.(current),
|
|
120162
|
+
onSelectionUpdate: ({ editor: current }) => onSelectionUpdateRef.current?.(current),
|
|
120163
|
+
onDestroy: () => {
|
|
120164
|
+
const current = editorRef.current;
|
|
120165
|
+
if (current) onEditorDestroyRef.current?.(current);
|
|
119063
120166
|
},
|
|
119064
120167
|
extensions
|
|
119065
120168
|
});
|
|
120169
|
+
editorRef.current = editor;
|
|
120170
|
+
const canSelectComment = Boolean(editorConfig?.comments?.onSelectThread);
|
|
120171
|
+
useEffect(() => {
|
|
120172
|
+
if (editor) refreshCommentThreadInteractivity(editor, canSelectComment);
|
|
120173
|
+
}, [editor, canSelectComment]);
|
|
119066
120174
|
useEffect(() => {
|
|
119067
120175
|
if (!editor) return;
|
|
119068
120176
|
editorRef.current = editor;
|
|
@@ -119096,9 +120204,20 @@ function EditorProvider(props) {
|
|
|
119096
120204
|
useEffect(() => {
|
|
119097
120205
|
if (provider) return;
|
|
119098
120206
|
if (!editor) return;
|
|
119099
|
-
|
|
119100
|
-
|
|
119101
|
-
if (
|
|
120207
|
+
const update = resolveEditorContentUpdate(content, contentFormat, editor.extensionManager.extensions);
|
|
120208
|
+
if (update.kind === "ignore") return;
|
|
120209
|
+
if (update.kind === "clear") {
|
|
120210
|
+
if (editor.isEmpty) return;
|
|
120211
|
+
let cancelled2 = false;
|
|
120212
|
+
queueMicrotask(() => {
|
|
120213
|
+
if (cancelled2 || editor.isDestroyed) return;
|
|
120214
|
+
editor.commands.clearContent(false);
|
|
120215
|
+
});
|
|
120216
|
+
return () => {
|
|
120217
|
+
cancelled2 = true;
|
|
120218
|
+
};
|
|
120219
|
+
}
|
|
120220
|
+
const next = update.json;
|
|
119102
120221
|
if (isSameDocument(editor.getJSON(), next)) return;
|
|
119103
120222
|
let cancelled = false;
|
|
119104
120223
|
queueMicrotask(() => {
|
|
@@ -119214,6 +120333,11 @@ function NotionEditor({
|
|
|
119214
120333
|
hideFloatingToolbar = false,
|
|
119215
120334
|
embedded = false,
|
|
119216
120335
|
richMarkdown = false,
|
|
120336
|
+
sendKey,
|
|
120337
|
+
onSend,
|
|
120338
|
+
onUpdate,
|
|
120339
|
+
onSelectionUpdate,
|
|
120340
|
+
onEditorDestroy,
|
|
119217
120341
|
onEditorReady,
|
|
119218
120342
|
extensions,
|
|
119219
120343
|
pageHeader,
|
|
@@ -119241,6 +120365,11 @@ function NotionEditor({
|
|
|
119241
120365
|
hideFloatingToolbar,
|
|
119242
120366
|
embedded,
|
|
119243
120367
|
richMarkdown,
|
|
120368
|
+
sendKey,
|
|
120369
|
+
onSend,
|
|
120370
|
+
onUpdate,
|
|
120371
|
+
onSelectionUpdate,
|
|
120372
|
+
onEditorDestroy,
|
|
119244
120373
|
onEditorReady,
|
|
119245
120374
|
extensions,
|
|
119246
120375
|
pageHeader,
|
|
@@ -119265,6 +120394,11 @@ function NotionEditorContent({
|
|
|
119265
120394
|
hideFloatingToolbar = false,
|
|
119266
120395
|
embedded = false,
|
|
119267
120396
|
richMarkdown = false,
|
|
120397
|
+
sendKey,
|
|
120398
|
+
onSend,
|
|
120399
|
+
onUpdate,
|
|
120400
|
+
onSelectionUpdate,
|
|
120401
|
+
onEditorDestroy,
|
|
119268
120402
|
onEditorReady,
|
|
119269
120403
|
extensions,
|
|
119270
120404
|
pageHeader,
|
|
@@ -119297,6 +120431,11 @@ function NotionEditorContent({
|
|
|
119297
120431
|
hideFloatingToolbar,
|
|
119298
120432
|
embedded,
|
|
119299
120433
|
richMarkdown,
|
|
120434
|
+
sendKey,
|
|
120435
|
+
onSend,
|
|
120436
|
+
onUpdate,
|
|
120437
|
+
onSelectionUpdate,
|
|
120438
|
+
onEditorDestroy,
|
|
119300
120439
|
onEditorReady,
|
|
119301
120440
|
extensions,
|
|
119302
120441
|
pageHeader,
|
|
@@ -119336,6 +120475,27 @@ function ArticleViewer({
|
|
|
119336
120475
|
) })
|
|
119337
120476
|
] });
|
|
119338
120477
|
}
|
|
120478
|
+
function DocEditor(props) {
|
|
120479
|
+
return /* @__PURE__ */ jsx(NotionEditor, { ...props });
|
|
120480
|
+
}
|
|
120481
|
+
function MessageEditor({
|
|
120482
|
+
embedded = true,
|
|
120483
|
+
hideHeader = true,
|
|
120484
|
+
sendKey = "enter",
|
|
120485
|
+
placeholder = "发送消息...",
|
|
120486
|
+
...props
|
|
120487
|
+
}) {
|
|
120488
|
+
return /* @__PURE__ */ jsx(
|
|
120489
|
+
NotionEditor,
|
|
120490
|
+
{
|
|
120491
|
+
...props,
|
|
120492
|
+
embedded,
|
|
120493
|
+
hideHeader,
|
|
120494
|
+
sendKey,
|
|
120495
|
+
placeholder
|
|
120496
|
+
}
|
|
120497
|
+
);
|
|
120498
|
+
}
|
|
119339
120499
|
function useScrolling(target, options = {}) {
|
|
119340
120500
|
const { debounce = 150, fallbackToDocument = true } = options;
|
|
119341
120501
|
const [isScrolling, setIsScrolling] = useState(false);
|
|
@@ -119368,7 +120528,74 @@ function useScrolling(target, options = {}) {
|
|
|
119368
120528
|
}, [target, debounce, fallbackToDocument, isScrolling]);
|
|
119369
120529
|
return isScrolling;
|
|
119370
120530
|
}
|
|
120531
|
+
var PageWidthIcon = () => /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
120532
|
+
/* @__PURE__ */ jsx("path", { d: "M3 4v16M21 4v16" }),
|
|
120533
|
+
/* @__PURE__ */ jsx("path", { d: "M7 12h10M10 9l-3 3 3 3M14 9l3 3-3 3" })
|
|
120534
|
+
] });
|
|
120535
|
+
function WidthModeMenu(props = {}) {
|
|
120536
|
+
const ctx = useWidthMode();
|
|
120537
|
+
const mode = props.mode ?? ctx.mode;
|
|
120538
|
+
const setMode = props.onChange ?? ctx.setMode;
|
|
120539
|
+
const [open, setOpen] = useState(false);
|
|
120540
|
+
const ref = useRef(null);
|
|
120541
|
+
useEffect(() => {
|
|
120542
|
+
if (!open) return;
|
|
120543
|
+
const onDown = (e) => {
|
|
120544
|
+
if (!ref.current?.contains(e.target)) setOpen(false);
|
|
120545
|
+
};
|
|
120546
|
+
const onKey = (e) => {
|
|
120547
|
+
if (e.key === "Escape") setOpen(false);
|
|
120548
|
+
};
|
|
120549
|
+
document.addEventListener("mousedown", onDown);
|
|
120550
|
+
document.addEventListener("keydown", onKey);
|
|
120551
|
+
return () => {
|
|
120552
|
+
document.removeEventListener("mousedown", onDown);
|
|
120553
|
+
document.removeEventListener("keydown", onKey);
|
|
120554
|
+
};
|
|
120555
|
+
}, [open]);
|
|
120556
|
+
return /* @__PURE__ */ jsxs("div", { className: "tt-width-mode", ref, children: [
|
|
120557
|
+
/* @__PURE__ */ jsx(
|
|
120558
|
+
"button",
|
|
120559
|
+
{
|
|
120560
|
+
type: "button",
|
|
120561
|
+
className: "tt-width-mode__btn",
|
|
120562
|
+
"aria-label": WIDTH_MODE_MENU_TITLE,
|
|
120563
|
+
title: WIDTH_MODE_MENU_TITLE,
|
|
120564
|
+
"aria-haspopup": "menu",
|
|
120565
|
+
"aria-expanded": open,
|
|
120566
|
+
onClick: () => setOpen((o) => !o),
|
|
120567
|
+
children: /* @__PURE__ */ jsx(PageWidthIcon, {})
|
|
120568
|
+
}
|
|
120569
|
+
),
|
|
120570
|
+
open ? /* @__PURE__ */ jsxs("div", { className: "tt-width-mode__menu", role: "menu", "aria-label": WIDTH_MODE_MENU_TITLE, children: [
|
|
120571
|
+
/* @__PURE__ */ jsx("div", { className: "tt-width-mode__header", children: WIDTH_MODE_MENU_HEADER }),
|
|
120572
|
+
/* @__PURE__ */ jsx("div", { className: "tt-width-mode__items", children: WIDTH_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
|
|
120573
|
+
"button",
|
|
120574
|
+
{
|
|
120575
|
+
type: "button",
|
|
120576
|
+
role: "menuitemradio",
|
|
120577
|
+
"aria-checked": item.mode === mode,
|
|
120578
|
+
className: `tt-width-mode__item tt-width-mode__item--${item.mode}`,
|
|
120579
|
+
onClick: () => {
|
|
120580
|
+
setOpen(false);
|
|
120581
|
+
if (item.mode !== mode) setMode(item.mode);
|
|
120582
|
+
},
|
|
120583
|
+
children: [
|
|
120584
|
+
/* @__PURE__ */ jsxs("span", { className: "tt-width-mode__icon", "aria-hidden": "true", children: [
|
|
120585
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
120586
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
120587
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
120588
|
+
/* @__PURE__ */ jsx("span", {})
|
|
120589
|
+
] }),
|
|
120590
|
+
/* @__PURE__ */ jsx("span", { className: "tt-width-mode__name", children: item.name })
|
|
120591
|
+
]
|
|
120592
|
+
},
|
|
120593
|
+
item.mode
|
|
120594
|
+
)) })
|
|
120595
|
+
] }) : null
|
|
120596
|
+
] });
|
|
120597
|
+
}
|
|
119371
120598
|
|
|
119372
|
-
export { ApiParamExtension, ArticleViewer, Audio, Button, 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, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MAC_SYMBOLS, MAX_FILE_SIZE, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Popover, PopoverContent, PopoverTrigger, SR_ONLY, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WidthModeMenu, clamp2 as clamp, cn, countDocument, countRange, countText, defaultUiState, detectMediaKind, findNodeAtPosition, findNodePosition, findSelectionPosition, focusNextNode, formatShortcutKey, getAvatar, getDocPermissions, getEditorMarkdown, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, hasContentAbove, isAllowedUri2 as isAllowedUri, isExtensionAvailable, isMac4 as isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, markHideFloatingOnNext, parseEditorContent, parseShortcutKeys, pickFile, printDocument, removeEmptyParagraphs, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, sanitizeUrl, selectCurrentBlockContent, selectNodeAndHideFloating, selectionWithinConvertibleTypes, serializeEditorMarkdown, updateNodesAttr, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect2 as useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useScrolling, useThrottledCallback, useTiptapEditor, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize };
|
|
120599
|
+
export { ApiParamExtension, ArticleViewer, Audio, Button, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, CommentThread, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, DetailsExtension, DocEditor, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MAC_SYMBOLS, MAX_FILE_SIZE, MediaUploadButton, MediaUploadPlaceholder, MessageEditor, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Popover, PopoverContent, PopoverTrigger, SR_ONLY, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WidthModeMenu, clamp2 as clamp, cn, countDocument, countRange, countText, defaultUiState, detectMediaKind, findNodeAtPosition, findNodePosition, findSelectionPosition, focusNextNode, formatShortcutKey, getAvatar, getDocPermissions, getEditorMarkdown, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, hasContentAbove, isAllowedUri2 as isAllowedUri, isExtensionAvailable, isMac4 as isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, markHideFloatingOnNext, parseEditorContent, parseShortcutKeys, pickFile, printDocument, refreshCommentThreadInteractivity, removeEmptyParagraphs, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, sanitizeUrl, selectCurrentBlockContent, selectNodeAndHideFloating, selectionWithinConvertibleTypes, serializeEditorMarkdown, updateNodesAttr, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect2 as useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useScrolling, useThrottledCallback, useTiptapEditor, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize };
|
|
119373
120600
|
//# sourceMappingURL=doc-standalone.js.map
|
|
119374
120601
|
//# sourceMappingURL=doc-standalone.js.map
|