@4399ywkf/editor 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 缩进 + 灰色文字,块上下 16px */
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
- min-height: 53px;
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
- margin: 12px 0;
35268
- padding: 12px 16px;
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
- gap: 1rem;
35656
- margin: 0.5em 0;
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
- h1 {
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 notionLikeEditorStyles = ({ surface }) => `
40258
- /* 正文字体栈对齐飞书文档(feishu.cn 文章页实测值),纯系统字体、无外网字体依赖 */
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: "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;
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: "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;
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: 100vw;
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(100vh - 130px - 3rem);
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: -0.625rem;
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: all 0.15s ease;
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
- /* Pointer-hover devices */
44272
- @media (hover: hover) {
44273
- &-wrapper:hover &-nav {
44274
- pointer-events: auto;
44275
- transform: translateX(0);
44276
- opacity: 1;
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
- /* Touch devices */
44281
- @media (hover: none) {
44282
- &-nav {
44283
- pointer-events: auto;
44284
- transform: translateX(0);
44285
- opacity: 1;
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: "rgba(47, 50, 55, 0.2)",
45391
- // 迁移前 --tt-gray-light-a-300
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
- if (plain || !natural) return img();
75410
- const layout = frameLayout(natural, crop ?? [0, 0, 1, 1], rotation);
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) => onImageResize?.(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
- (editor?.isEditable ? shouldShowCaption : hasContent) && /* @__PURE__ */ jsx(
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 = buildImageHTMLAttributes({
75851
- src,
75852
- alt,
75853
- title,
75854
- width,
75855
- height
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,16 @@ 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
+ }
82525
83034
  function resolveMarkConflicts(nodes, schema) {
82526
83035
  return nodes.map((node) => {
82527
83036
  const out = { ...node };
@@ -82565,14 +83074,14 @@ function createCodeGroupInputPlugin(editor) {
82565
83074
  if (!data) return false;
82566
83075
  if (view.input?.shiftKey) return false;
82567
83076
  const text = containerPasteText(data, slice2, state.schema);
82568
- if (!text || !containsCompleteContainer(text)) return false;
83077
+ if (!text || !(containsCompleteContainer(text) || isMarkdownPaste(data, text))) return false;
82569
83078
  const manager = editor.markdown;
82570
83079
  if (!manager) return false;
82571
83080
  let content;
82572
83081
  try {
82573
83082
  const json = manager.parse(text.replace(/\r\n?/g, "\n"));
82574
83083
  if (!json.content?.length) return false;
82575
- content = resolveMarkConflicts(json.content, state.schema);
83084
+ content = withNodeIds(editor, resolveMarkConflicts(json.content, state.schema));
82576
83085
  } catch {
82577
83086
  return false;
82578
83087
  }
@@ -90579,6 +91088,48 @@ var ImageUploadNode2 = Node3.create({
90579
91088
  };
90580
91089
  }
90581
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
+ }
90582
91133
  var VIDEO_MIN_WIDTH = 200;
90583
91134
  var VIDEO_MAX_WIDTH = 800;
90584
91135
  function VideoPlayer({
@@ -90588,27 +91139,31 @@ function VideoPlayer({
90588
91139
  naturalSize,
90589
91140
  onNaturalSize,
90590
91141
  fillContainer,
90591
- noDownload
91142
+ noDownload,
91143
+ sizeHint
90592
91144
  }) {
91145
+ const size6 = naturalSize ?? sizeHint;
91146
+ const ratio = size6 ? `${size6.width} / ${size6.height}` : "16 / 9";
91147
+ const ref = useLazyMedia(src);
90593
91148
  return (
90594
91149
  // biome-ignore lint/a11y/useMediaCaption: 节点没有字幕字段,上传的视频也不带字幕文件;要加字幕时在这里补 <track>
90595
91150
  /* @__PURE__ */ jsx(
90596
91151
  "video",
90597
91152
  {
91153
+ ref,
90598
91154
  className: "tiptap-video-player",
90599
91155
  controls: true,
90600
91156
  controlsList: noDownload ? "nodownload" : void 0,
90601
91157
  preload: "metadata",
90602
- src,
90603
91158
  title,
90604
91159
  poster,
90605
- style: naturalSize ? {
90606
- aspectRatio: `${naturalSize.width} / ${naturalSize.height}`,
91160
+ style: {
91161
+ aspectRatio: ratio,
90607
91162
  // 没设宽度时按视频原始宽度显示。这个像素宽必须写在 <video> 上而不是外层 div:
90608
91163
  // 带百分比 max-width 的 video 是「可压缩替换元素」,算最小内容宽时按 0 计;
90609
91164
  // 写在 div 上会被当成最小宽度,把编辑器正文列(grid 轨道)整个撑宽、溢出外框。
90610
- width: fillContainer ? void 0 : `${naturalSize.width}px`
90611
- } : void 0,
91165
+ width: fillContainer || !size6 ? void 0 : `${size6.width}px`
91166
+ },
90612
91167
  onLoadedMetadata: (e) => {
90613
91168
  const { videoWidth, videoHeight } = e.currentTarget;
90614
91169
  if (videoWidth > 0 && videoHeight > 0) {
@@ -90621,6 +91176,7 @@ function VideoPlayer({
90621
91176
  }
90622
91177
  function VideoNodeView({ editor, node, getPos, updateAttributes: updateAttributes2 }) {
90623
91178
  const [naturalSize, setNaturalSize] = useState();
91179
+ const sizeHint = parseSizeHint(node.attrs.width, node.attrs.height);
90624
91180
  const align = node.attrs["data-align"] ?? "left";
90625
91181
  const canDownload = getDocPermissions(editor).download;
90626
91182
  const {
@@ -90639,8 +91195,8 @@ function VideoNodeView({ editor, node, getPos, updateAttributes: updateAttribute
90639
91195
  minWidth: VIDEO_MIN_WIDTH,
90640
91196
  maxWidth: VIDEO_MAX_WIDTH,
90641
91197
  align,
90642
- // 只存宽度,高度交给视频比例:清掉老数据里的 height,免得拖完画面被拉变形
90643
- onResize: (w) => updateAttributes2({ width: w, height: null })
91198
+ // height 只当宽高比用(不当像素高度,不会拉变形):按比例同步写回,下次打开视频加载前也能按真实比例占位
91199
+ onResize: (w) => updateAttributes2({ width: w, height: heightForWidth(w, naturalSize ?? sizeHint) })
90644
91200
  });
90645
91201
  return /* @__PURE__ */ jsx(
90646
91202
  NodeViewWrapper,
@@ -90665,6 +91221,7 @@ function VideoNodeView({ editor, node, getPos, updateAttributes: updateAttribute
90665
91221
  poster: node.attrs.poster ?? void 0,
90666
91222
  naturalSize,
90667
91223
  onNaturalSize: setNaturalSize,
91224
+ sizeHint,
90668
91225
  fillContainer: !!width,
90669
91226
  noDownload: !canDownload
90670
91227
  }
@@ -90732,7 +91289,10 @@ var Video = Node3.create({
90732
91289
  renderHTML({ node, HTMLAttributes }) {
90733
91290
  const attrs = {
90734
91291
  controls: "true",
90735
- preload: "metadata",
91292
+ // renderHTML 只用于序列化(getHTML、复制、导出)和 tiptap 卸载时的过渡 DOM,编辑器里的播放器是节点视图。
91293
+ // 这些 DOM 即使不插入文档,带 src + preload=metadata 也会各自创建播放器,Chrome 每页上限 1000 个;
91294
+ // preload="none" 不创建播放器,点播放时照常加载(见 lib/lazy-media.ts)
91295
+ preload: "none",
90736
91296
  src: node.attrs.src
90737
91297
  };
90738
91298
  if (node.attrs.title) attrs.title = node.attrs.title;
@@ -90797,7 +91357,10 @@ var Audio = Node3.create({
90797
91357
  renderHTML({ node, HTMLAttributes }) {
90798
91358
  const attrs = {
90799
91359
  controls: "true",
90800
- preload: "metadata",
91360
+ // renderHTML 只用于序列化(getHTML、复制、导出)和 tiptap 卸载时的过渡 DOM,编辑器里的播放器是节点视图。
91361
+ // 这些 DOM 即使不插入文档,带 src + preload=metadata 也会各自创建播放器,Chrome 每页上限 1000 个;
91362
+ // preload="none" 不创建播放器,点播放时照常加载(见 lib/lazy-media.ts)
91363
+ preload: "none",
90801
91364
  src: node.attrs.src
90802
91365
  };
90803
91366
  if (node.attrs.title) attrs.title = node.attrs.title;
@@ -90811,18 +91374,19 @@ var Audio = Node3.create({
90811
91374
  addNodeView() {
90812
91375
  return ({ node, HTMLAttributes, editor }) => {
90813
91376
  const dom = document.createElement("audio");
90814
- const attrs = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
91377
+ const { src: _src, ...attrs } = mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
90815
91378
  controls: "true",
90816
91379
  preload: "metadata",
90817
- src: node.attrs.src,
90818
91380
  ...node.attrs.title ? { title: node.attrs.title } : {}
90819
91381
  });
90820
91382
  for (const [k, v] of Object.entries(attrs)) if (v != null && v !== false) dom.setAttribute(k, String(v));
90821
91383
  if (!getDocPermissions(editor).download) dom.setAttribute("controlslist", "nodownload");
91384
+ const detach = attachLazyMedia(dom, node.attrs.src);
90822
91385
  return {
90823
91386
  dom,
90824
91387
  stopEvent: () => !editor.isEditable,
90825
- ignoreMutation: () => true
91388
+ ignoreMutation: () => true,
91389
+ destroy: detach
90826
91390
  };
90827
91391
  };
90828
91392
  },
@@ -91200,10 +91764,10 @@ function FilePreview({
91200
91764
  body = /* @__PURE__ */ jsx("img", { className: "tt-file-preview__media", src: file.src, alt: file.name });
91201
91765
  } else if (kind === "video") {
91202
91766
  sized = false;
91203
- body = /* @__PURE__ */ jsx("video", { className: "tt-file-preview__media", src: file.src, controls: true, preload: "metadata" });
91767
+ body = /* @__PURE__ */ jsx(PreviewVideo, { src: file.src });
91204
91768
  } else if (kind === "audio") {
91205
91769
  sized = false;
91206
- body = /* @__PURE__ */ jsx("audio", { className: "tt-file-preview__audio", src: file.src, controls: true, preload: "metadata" });
91770
+ body = /* @__PURE__ */ jsx(PreviewAudio, { src: file.src });
91207
91771
  } else if (kind === "text") {
91208
91772
  body = /* @__PURE__ */ jsx(TextPreview, { src: file.src, name: file.name });
91209
91773
  } else {
@@ -91268,6 +91832,14 @@ function useFullscreen() {
91268
91832
  }, []);
91269
91833
  return on;
91270
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
+ }
91271
91843
 
91272
91844
  // src/components/tiptap-node/file-attachment-node/file-attachment-schema.ts
91273
91845
  var FileAttachmentSchema = Node3.create({
@@ -99598,6 +100170,9 @@ var useComposedRef = (libRef, userRef) => {
99598
100170
  [libRef, userRef]
99599
100171
  );
99600
100172
  };
100173
+ function MenuProvider2({ ...props }) {
100174
+ return /* @__PURE__ */ jsx(Ariakit2.MenuProvider, { ...props });
100175
+ }
99601
100176
  function Menu2({
99602
100177
  children,
99603
100178
  trigger,
@@ -99714,6 +100289,31 @@ function MenuGroupLabel2({
99714
100289
  }
99715
100290
  );
99716
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
+ }
99717
100317
  function MenuItemRadio2({
99718
100318
  className,
99719
100319
  ...props
@@ -113200,90 +113800,200 @@ function CollabProvider({
113200
113800
  );
113201
113801
  return /* @__PURE__ */ jsx(CollabContext.Provider, { value, children });
113202
113802
  }
113203
- var SunIcon = memo(({ className, ...props }) => {
113204
- return /* @__PURE__ */ jsxs(
113205
- "svg",
113206
- {
113207
- width: "24",
113208
- height: "24",
113209
- className,
113210
- viewBox: "0 0 24 24",
113211
- fill: "currentColor",
113212
- xmlns: "http://www.w3.org/2000/svg",
113213
- ...props,
113214
- children: [
113215
- /* @__PURE__ */ jsx(
113216
- "path",
113217
- {
113218
- d: "M12 1C12.5523 1 13 1.44772 13 2V4C13 4.55228 12.5523 5 12 5C11.4477 5 11 4.55228 11 4V2C11 1.44772 11.4477 1 12 1Z",
113219
- fill: "currentColor"
113220
- }
113221
- ),
113222
- /* @__PURE__ */ jsx(
113223
- "path",
113224
- {
113225
- fillRule: "evenodd",
113226
- clipRule: "evenodd",
113227
- d: "M7 12C7 9.23858 9.23858 7 12 7C14.7614 7 17 9.23858 17 12C17 14.7614 14.7614 17 12 17C9.23858 17 7 14.7614 7 12ZM12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9Z",
113228
- fill: "currentColor"
113229
- }
113230
- ),
113231
- /* @__PURE__ */ jsx(
113232
- "path",
113233
- {
113234
- d: "M13 20C13 19.4477 12.5523 19 12 19C11.4477 19 11 19.4477 11 20V22C11 22.5523 11.4477 23 12 23C12.5523 23 13 22.5523 13 22V20Z",
113235
- fill: "currentColor"
113236
- }
113237
- ),
113238
- /* @__PURE__ */ jsx(
113239
- "path",
113240
- {
113241
- d: "M4.22282 4.22289C4.61335 3.83236 5.24651 3.83236 5.63704 4.22289L7.04704 5.63289C7.43756 6.02341 7.43756 6.65658 7.04704 7.0471C6.65651 7.43762 6.02335 7.43762 5.63283 7.0471L4.22282 5.6371C3.8323 5.24658 3.8323 4.61341 4.22282 4.22289Z",
113242
- fill: "currentColor"
113243
- }
113244
- ),
113245
- /* @__PURE__ */ jsx(
113246
- "path",
113247
- {
113248
- d: "M18.367 16.9529C17.9765 16.5623 17.3433 16.5623 16.9528 16.9529C16.5623 17.3434 16.5623 17.9766 16.9528 18.3671L18.3628 19.7771C18.7533 20.1676 19.3865 20.1676 19.777 19.7771C20.1675 19.3866 20.1675 18.7534 19.777 18.3629L18.367 16.9529Z",
113249
- fill: "currentColor"
113250
- }
113251
- ),
113252
- /* @__PURE__ */ jsx(
113253
- "path",
113254
- {
113255
- d: "M1 12C1 11.4477 1.44772 11 2 11H4C4.55228 11 5 11.4477 5 12C5 12.5523 4.55228 13 4 13H2C1.44772 13 1 12.5523 1 12Z",
113256
- fill: "currentColor"
113257
- }
113258
- ),
113259
- /* @__PURE__ */ jsx(
113260
- "path",
113261
- {
113262
- d: "M20 11C19.4477 11 19 11.4477 19 12C19 12.5523 19.4477 13 20 13H22C22.5523 13 23 12.5523 23 12C23 11.4477 22.5523 11 22 11H20Z",
113263
- fill: "currentColor"
113264
- }
113265
- ),
113266
- /* @__PURE__ */ jsx(
113267
- "path",
113268
- {
113269
- d: "M7.04704 16.9529C7.43756 17.3434 7.43756 17.9766 7.04704 18.3671L5.63704 19.7771C5.24651 20.1676 4.61335 20.1676 4.22282 19.7771C3.8323 19.3866 3.8323 18.7534 4.22283 18.3629L5.63283 16.9529C6.02335 16.5623 6.65651 16.5623 7.04704 16.9529Z",
113270
- fill: "currentColor"
113271
- }
113272
- ),
113273
- /* @__PURE__ */ jsx(
113274
- "path",
113275
- {
113276
- d: "M19.777 5.6371C20.1675 5.24657 20.1675 4.61341 19.777 4.22289C19.3865 3.83236 18.7533 3.83236 18.3628 4.22289L16.9528 5.63289C16.5623 6.02341 16.5623 6.65658 16.9528 7.0471C17.3433 7.43762 17.9765 7.43762 18.367 7.0471L19.777 5.6371Z",
113277
- fill: "currentColor"
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);
113278
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
+ })
113279
113938
  )
113280
- ]
113281
- }
113282
- );
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
+ }
113283
113994
  });
113284
- SunIcon.displayName = "SunIcon";
113285
- var MoonStarIcon = memo(({ className, ...props }) => {
113286
- return /* @__PURE__ */ jsxs(
113995
+ var MessageSquareIcon = memo(({ className, ...props }) => {
113996
+ return /* @__PURE__ */ jsx(
113287
113997
  "svg",
113288
113998
  {
113289
113999
  width: "24",
@@ -113293,54 +114003,19 @@ var MoonStarIcon = memo(({ className, ...props }) => {
113293
114003
  fill: "currentColor",
113294
114004
  xmlns: "http://www.w3.org/2000/svg",
113295
114005
  ...props,
113296
- children: [
113297
- /* @__PURE__ */ jsx(
113298
- "path",
113299
- {
113300
- fillRule: "evenodd",
113301
- clipRule: "evenodd",
113302
- d: "M12 2C10.0222 2 8.08879 2.58649 6.4443 3.6853C4.79981 4.78412 3.51809 6.3459 2.76121 8.17317C2.00433 10.0004 1.8063 12.0111 2.19215 13.9509C2.578 15.8907 3.53041 17.6725 4.92894 19.0711C6.32746 20.4696 8.10929 21.422 10.0491 21.8079C11.9889 22.1937 13.9996 21.9957 15.8268 21.2388C17.6541 20.4819 19.2159 19.2002 20.3147 17.5557C21.4135 15.9112 22 13.9778 22 12C22 11.5955 21.7564 11.2309 21.3827 11.0761C21.009 10.9213 20.5789 11.0069 20.2929 11.2929C19.287 12.2988 17.9226 12.864 16.5 12.864C15.0774 12.864 13.713 12.2988 12.7071 11.2929C11.7012 10.287 11.136 8.92261 11.136 7.5C11.136 6.07739 11.7012 4.71304 12.7071 3.70711C12.9931 3.42111 13.0787 2.99099 12.9239 2.61732C12.7691 2.24364 12.4045 2 12 2ZM7.55544 5.34824C8.27036 4.87055 9.05353 4.51389 9.87357 4.28778C9.39271 5.27979 9.13604 6.37666 9.13604 7.5C9.13604 9.45304 9.91189 11.3261 11.2929 12.7071C12.6739 14.0881 14.547 14.864 16.5 14.864C17.6233 14.864 18.7202 14.6073 19.7122 14.1264C19.4861 14.9465 19.1295 15.7296 18.6518 16.4446C17.7727 17.7602 16.5233 18.7855 15.0615 19.391C13.5997 19.9965 11.9911 20.155 10.4393 19.8463C8.88743 19.5376 7.46197 18.7757 6.34315 17.6569C5.22433 16.538 4.4624 15.1126 4.15372 13.5607C3.84504 12.0089 4.00347 10.4003 4.60897 8.93853C5.21447 7.47672 6.23985 6.22729 7.55544 5.34824Z",
113303
- fill: "currentColor"
113304
- }
113305
- ),
113306
- /* @__PURE__ */ jsx(
113307
- "path",
113308
- {
113309
- 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",
113310
- fill: "currentColor"
113311
- }
113312
- )
113313
- ]
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
+ )
113314
114015
  }
113315
114016
  );
113316
114017
  });
113317
- MoonStarIcon.displayName = "MoonStarIcon";
113318
- function ThemeToggle() {
113319
- const [isDarkMode, setIsDarkMode] = useState(false);
113320
- useEffect(() => {
113321
- const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
113322
- const handleChange = () => setIsDarkMode(mediaQuery.matches);
113323
- mediaQuery.addEventListener("change", handleChange);
113324
- return () => mediaQuery.removeEventListener("change", handleChange);
113325
- }, []);
113326
- useEffect(() => {
113327
- const initialDarkMode = !!document.querySelector('meta[name="color-scheme"][content="dark"]') || window.matchMedia("(prefers-color-scheme: dark)").matches;
113328
- setIsDarkMode(initialDarkMode);
113329
- }, []);
113330
- useEffect(() => {
113331
- document.documentElement.classList.toggle("dark", isDarkMode);
113332
- }, [isDarkMode]);
113333
- const toggleDarkMode = () => setIsDarkMode((isDark) => !isDark);
113334
- return /* @__PURE__ */ jsx(
113335
- Button,
113336
- {
113337
- onClick: toggleDarkMode,
113338
- "aria-label": `Switch to ${isDarkMode ? "light" : "dark"} mode`,
113339
- variant: "ghost",
113340
- children: isDarkMode ? /* @__PURE__ */ jsx(MoonStarIcon, { className: "tiptap-button-icon" }) : /* @__PURE__ */ jsx(SunIcon, { className: "tiptap-button-icon" })
113341
- }
113342
- );
113343
- }
114018
+ MessageSquareIcon.displayName = "MessageSquareIcon";
113344
114019
  var PrinterIcon = memo(({ className, ...props }) => {
113345
114020
  return /* @__PURE__ */ jsxs(
113346
114021
  "svg",
@@ -113365,73 +114040,6 @@ var PrinterIcon = memo(({ className, ...props }) => {
113365
114040
  );
113366
114041
  });
113367
114042
  PrinterIcon.displayName = "PrinterIcon";
113368
- 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: [
113369
- /* @__PURE__ */ jsx("path", { d: "M3 4v16M21 4v16" }),
113370
- /* @__PURE__ */ jsx("path", { d: "M7 12h10M10 9l-3 3 3 3M14 9l3 3-3 3" })
113371
- ] });
113372
- function WidthModeMenu(props = {}) {
113373
- const ctx = useWidthMode();
113374
- const mode = props.mode ?? ctx.mode;
113375
- const setMode = props.onChange ?? ctx.setMode;
113376
- const [open, setOpen] = useState(false);
113377
- const ref = useRef(null);
113378
- useEffect(() => {
113379
- if (!open) return;
113380
- const onDown = (e) => {
113381
- if (!ref.current?.contains(e.target)) setOpen(false);
113382
- };
113383
- const onKey = (e) => {
113384
- if (e.key === "Escape") setOpen(false);
113385
- };
113386
- document.addEventListener("mousedown", onDown);
113387
- document.addEventListener("keydown", onKey);
113388
- return () => {
113389
- document.removeEventListener("mousedown", onDown);
113390
- document.removeEventListener("keydown", onKey);
113391
- };
113392
- }, [open]);
113393
- return /* @__PURE__ */ jsxs("div", { className: "tt-width-mode", ref, children: [
113394
- /* @__PURE__ */ jsx(
113395
- "button",
113396
- {
113397
- type: "button",
113398
- className: "tt-width-mode__btn",
113399
- "aria-label": WIDTH_MODE_MENU_TITLE,
113400
- title: WIDTH_MODE_MENU_TITLE,
113401
- "aria-haspopup": "menu",
113402
- "aria-expanded": open,
113403
- onClick: () => setOpen((o) => !o),
113404
- children: /* @__PURE__ */ jsx(PageWidthIcon, {})
113405
- }
113406
- ),
113407
- open ? /* @__PURE__ */ jsxs("div", { className: "tt-width-mode__menu", role: "menu", "aria-label": WIDTH_MODE_MENU_TITLE, children: [
113408
- /* @__PURE__ */ jsx("div", { className: "tt-width-mode__header", children: WIDTH_MODE_MENU_HEADER }),
113409
- /* @__PURE__ */ jsx("div", { className: "tt-width-mode__items", children: WIDTH_MODE_ITEMS.map((item) => /* @__PURE__ */ jsxs(
113410
- "button",
113411
- {
113412
- type: "button",
113413
- role: "menuitemradio",
113414
- "aria-checked": item.mode === mode,
113415
- className: `tt-width-mode__item tt-width-mode__item--${item.mode}`,
113416
- onClick: () => {
113417
- setOpen(false);
113418
- if (item.mode !== mode) setMode(item.mode);
113419
- },
113420
- children: [
113421
- /* @__PURE__ */ jsxs("span", { className: "tt-width-mode__icon", "aria-hidden": "true", children: [
113422
- /* @__PURE__ */ jsx("span", {}),
113423
- /* @__PURE__ */ jsx("span", {}),
113424
- /* @__PURE__ */ jsx("span", {}),
113425
- /* @__PURE__ */ jsx("span", {})
113426
- ] }),
113427
- /* @__PURE__ */ jsx("span", { className: "tt-width-mode__name", children: item.name })
113428
- ]
113429
- },
113430
- item.mode
113431
- )) })
113432
- ] }) : null
113433
- ] });
113434
- }
113435
114043
  function HistoryShortcutBadge({
113436
114044
  action,
113437
114045
  shortcutKeys = UNDO_REDO_SHORTCUT_KEYS[action]
@@ -113785,40 +114393,199 @@ function CollaborationUsers() {
113785
114393
  ] }) }, user.id)) }) })
113786
114394
  ] });
113787
114395
  }
113788
- function PrintButton() {
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() {
113789
114453
  const { editor } = useTiptapEditor();
113790
- if (!editor || !getDocPermissions(editor).print) return null;
113791
- return /* @__PURE__ */ jsx(
113792
- Button,
113793
- {
113794
- type: "button",
113795
- variant: "ghost",
113796
- tabIndex: -1,
113797
- "aria-label": "打印",
113798
- tooltip: "打印",
113799
- shortcutKeys: "mod+p",
113800
- onClick: () => editor.commands.printDocument(),
113801
- children: /* @__PURE__ */ jsx(PrinterIcon, { className: "tiptap-button-icon" })
113802
- }
113803
- );
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
+ ] }) });
113804
114524
  }
113805
114525
  function NotionEditorHeader() {
114526
+ const documentConfig = useEditorConfig()?.document;
114527
+ const saveState = documentConfig?.saveState;
114528
+ const commentCount = documentConfig?.commentCount;
113806
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,
113807
114556
  /* @__PURE__ */ jsx(Spacer, {}),
113808
114557
  /* @__PURE__ */ jsxs("div", { className: "notion-like-editor-header-actions", children: [
113809
- /* @__PURE__ */ jsx(ViewModeSwitch, {}),
113810
- /* @__PURE__ */ jsx(Separator, {}),
114558
+ /* @__PURE__ */ jsx(DocumentViewModeMenu, {}),
113811
114559
  /* @__PURE__ */ jsxs(ButtonGroup, { children: [
113812
- /* @__PURE__ */ jsx(ButtonGroup, { children: /* @__PURE__ */ jsx(UndoRedoButton, { action: "undo" }) }),
113813
- /* @__PURE__ */ jsx(ButtonGroup, { children: /* @__PURE__ */ jsx(UndoRedoButton, { action: "redo" }) })
114560
+ /* @__PURE__ */ jsx(UndoRedoButton, { action: "undo", tabIndex: 0 }),
114561
+ /* @__PURE__ */ jsx(UndoRedoButton, { action: "redo", tabIndex: 0 })
113814
114562
  ] }),
113815
114563
  /* @__PURE__ */ jsx(Separator, {}),
113816
- /* @__PURE__ */ jsx(WidthModeMenu, {}),
113817
- /* @__PURE__ */ jsx(PrintButton, {}),
113818
- /* @__PURE__ */ jsx(Separator, {}),
113819
- /* @__PURE__ */ jsx(ThemeToggle, {}),
113820
- /* @__PURE__ */ jsx(Separator, {}),
113821
- /* @__PURE__ */ jsx(CollaborationUsers, {})
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, {})
113822
114589
  ] })
113823
114590
  ] });
113824
114591
  }
@@ -116818,9 +117585,33 @@ function MainToolbarContent({
116818
117585
  toolbarViews,
116819
117586
  onViewChange
116820
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);
116821
117594
  const hasSelection2 = hasTextSelection(editor);
116822
117595
  const hasContent = (editor?.getText().length ?? 0) > 0;
116823
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
+ ) }),
116824
117615
  /* @__PURE__ */ jsxs(ToolbarGroup, { children: [
116825
117616
  /* @__PURE__ */ jsx(SlashCommandTriggerButton, {}),
116826
117617
  /* @__PURE__ */ jsx(MoreActionsDropdown, { editor }),
@@ -117438,6 +118229,12 @@ var AIButton = forwardRef(
117438
118229
  AIButton.displayName = "AIButton";
117439
118230
  function NotionToolbarFloating() {
117440
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);
117441
118238
  const isMobile = useIsBreakpoint("max", 480);
117442
118239
  const { lockDragHandle, commentInputVisible } = useUiEditorState(editor);
117443
118240
  const linkPanelOpen = useEditorState({
@@ -117476,6 +118273,24 @@ function NotionToolbarFloating() {
117476
118273
  /* @__PURE__ */ jsx(VideoNodeFloating, {})
117477
118274
  ] }),
117478
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
+ ) }),
117479
118294
  editor?.isEditable && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(
117480
118295
  Button,
117481
118296
  {
@@ -117650,6 +118465,13 @@ function TocSidebar({
117650
118465
  }) {
117651
118466
  const { tocContent, navigateToHeading, normalizeHeadingDepths: normalizeHeadingDepths2 } = useToc();
117652
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);
117653
118475
  const lastClickTimeRef = useRef(null);
117654
118476
  const [manualActiveId, setManualActiveId] = useState(null);
117655
118477
  const headingList = useMemo(
@@ -117744,7 +118566,7 @@ function TocSidebar({
117744
118566
  const popoverRef = useRef(null);
117745
118567
  useEffect(() => {
117746
118568
  if (!activeContentId) return;
117747
- for (const box of [progressRef.current, popoverRef.current]) {
118569
+ for (const box of [isPinned ? null : progressRef.current, isExpanded ? popoverRef.current : null]) {
117748
118570
  const el = box?.querySelector(`[data-toc-id="${CSS.escape(activeContentId)}"]`);
117749
118571
  if (!box || !el) continue;
117750
118572
  const top = el.offsetTop - box.offsetTop;
@@ -117752,60 +118574,154 @@ function TocSidebar({
117752
118574
  if (top < box.scrollTop) box.scrollTop = top;
117753
118575
  else if (bottom > box.scrollTop + box.clientHeight) box.scrollTop = bottom - box.clientHeight;
117754
118576
  }
117755
- }, [activeContentId]);
118577
+ }, [activeContentId, isExpanded, isPinned]);
117756
118578
  const hasHeadings = headingList.length > 0;
117757
- return /* @__PURE__ */ jsx("div", { ref: sidebarRef, className: cn("toc-sidebar", className), ...props, children: /* @__PURE__ */ jsx("div", { className: "toc-sidebar-wrapper", children: /* @__PURE__ */ jsxs("div", { className: "toc-sidebar-inner", children: [
117758
- /* @__PURE__ */ jsx("div", { ref: progressRef, className: "toc-sidebar-progress", children: visibleHeadings.map((item) => {
117759
- const depth = depthById.get(item.id) ?? 1;
117760
- const isActive2 = activeContentId === item.id;
117761
- return /* @__PURE__ */ jsx(
117762
- "div",
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",
117763
118597
  {
117764
- "data-toc-id": item.id,
117765
- className: cn(
117766
- "toc-sidebar-progress-line",
117767
- isActive2 && "toc-sidebar-progress-line--active"
117768
- ),
117769
- "data-depth": depth,
117770
- style: { "--toc-depth": depth }
117771
- },
117772
- item.id
117773
- );
117774
- }) }),
117775
- /* @__PURE__ */ jsx(
117776
- "nav",
117777
- {
117778
- className: cn(
117779
- "toc-sidebar-nav",
117780
- !hasHeadings && "toc-sidebar-nav--hidden"
117781
- ),
117782
- "aria-label": "目录",
117783
- children: /* @__PURE__ */ jsx("div", { ref: popoverRef, className: "toc-sidebar-popover", children: visibleHeadings.map((item) => {
117784
- const depth = depthById.get(item.id) ?? 1;
117785
- const isActive2 = activeContentId === item.id;
117786
- return /* @__PURE__ */ jsx(
117787
- "a",
117788
- {
117789
- "data-toc-id": item.id,
117790
- title: item.textContent,
117791
- href: `#${item.id}`,
117792
- rel: "noopener noreferrer",
117793
- className: cn(
117794
- "toc-sidebar-item notranslate",
117795
- isActive2 && "toc-sidebar-item--active"
117796
- ),
117797
- "data-depth": depth,
117798
- style: { "--toc-depth": depth },
117799
- onClick: (e) => handleContentClick(e, item),
117800
- "aria-current": isActive2 ? "location" : void 0,
117801
- children: withOrder(item)
117802
- },
117803
- item.id
117804
- );
117805
- }) })
117806
- }
117807
- )
117808
- ] }) }) });
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
+ );
117809
118725
  }
117810
118726
 
117811
118727
  // src/components/tiptap-extension/list-normalization-extension.ts
@@ -118939,6 +119855,8 @@ function EditorProvider(props) {
118939
119855
  return found2;
118940
119856
  }, []);
118941
119857
  const editorConfig = useEditorConfig();
119858
+ const editorConfigRef = useRef(editorConfig);
119859
+ editorConfigRef.current = editorConfig;
118942
119860
  const onSendRef = useRef(onSend);
118943
119861
  onSendRef.current = onSend;
118944
119862
  const sendKeyRef = useRef(sendKey);
@@ -119098,6 +120016,10 @@ function EditorProvider(props) {
119098
120016
  FindReplace,
119099
120017
  PrintDocument,
119100
120018
  ReadOnlyGuard,
120019
+ CommentThread.configure({
120020
+ isInteractive: () => Boolean(editorConfigRef.current?.comments?.onSelectThread),
120021
+ onSelectThread: (threadId) => editorConfigRef.current?.comments?.onSelectThread?.(threadId)
120022
+ }),
119101
120023
  Color,
119102
120024
  FeishuTaskList,
119103
120025
  TaskItem.configure({ nested: true }),
@@ -119203,6 +120125,7 @@ function EditorProvider(props) {
119203
120125
  ],
119204
120126
  filterTransaction: (transaction) => !isChangeOrigin(transaction)
119205
120127
  }),
120128
+ PasteNodeIds,
119206
120129
  // 不挂 Typography:飞书没有任何排版替换(MD 规则全集 vT 里没有),它会把中文文档里的
119207
120130
  // 引号、`--`、`1*2` 改写掉
119208
120131
  UiState,
@@ -119244,6 +120167,10 @@ function EditorProvider(props) {
119244
120167
  extensions
119245
120168
  });
119246
120169
  editorRef.current = editor;
120170
+ const canSelectComment = Boolean(editorConfig?.comments?.onSelectThread);
120171
+ useEffect(() => {
120172
+ if (editor) refreshCommentThreadInteractivity(editor, canSelectComment);
120173
+ }, [editor, canSelectComment]);
119247
120174
  useEffect(() => {
119248
120175
  if (!editor) return;
119249
120176
  editorRef.current = editor;
@@ -119548,6 +120475,27 @@ function ArticleViewer({
119548
120475
  ) })
119549
120476
  ] });
119550
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
+ }
119551
120499
  function useScrolling(target, options = {}) {
119552
120500
  const { debounce = 150, fallbackToDocument = true } = options;
119553
120501
  const [isScrolling, setIsScrolling] = useState(false);
@@ -119580,7 +120528,74 @@ function useScrolling(target, options = {}) {
119580
120528
  }, [target, debounce, fallbackToDocument, isScrolling]);
119581
120529
  return isScrolling;
119582
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
+ }
119583
120598
 
119584
- 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 };
119585
120600
  //# sourceMappingURL=doc-standalone.js.map
119586
120601
  //# sourceMappingURL=doc-standalone.js.map