@4399ywkf/editor 0.10.1 → 0.11.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,4 +1,4 @@
1
- import { EditorConfigProvider, NotionEditor } from './chunk-ABXCS4IZ.js';
1
+ import { EditorConfigProvider, NotionEditor } from './chunk-6MZAYCF6.js';
2
2
  import './chunk-MGSVKKK7.js';
3
3
  import './chunk-UD6MDBTN.js';
4
4
  import './chunk-ABMZOL26.js';
@@ -18,5 +18,5 @@ function DocView({ content, contentFormat, readOnly, room, className, onReady })
18
18
  }
19
19
 
20
20
  export { DocView as default };
21
- //# sourceMappingURL=DocView-HCBFGLWI.js.map
22
- //# sourceMappingURL=DocView-HCBFGLWI.js.map
21
+ //# sourceMappingURL=DocView-KUVYBQ66.js.map
22
+ //# sourceMappingURL=DocView-KUVYBQ66.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;;;;AAMe,SAAR,OAAA,CAAyB,EAAE,OAAA,EAAS,aAAA,EAAe,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AACjH,EAAA,2BACG,KAAA,EAAA,EAAI,SAAA,EACH,8BAAC,oBAAA,EAAA,EAAqB,MAAA,EAAQ,EAAC,EAC7B,QAAA,kBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,MAAM,IAAA,IAAQ,SAAA;AAAA,MACd,OAAA;AAAA,MACA,aAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-HCBFGLWI.js","sourcesContent":["import type { Editor } from \"@tiptap/react\"\nimport { EditorConfigProvider } from \"../contexts/editor-config-context\"\nimport { NotionEditor } from \"../components/tiptap-templates/notion-like/notion-like-editor\"\nimport type { DocumentViewProps } from \"../registry\"\n\n/** doc 通道:云文档与本地 doc 是同一套 tiptap,不做区分 */\nexport default function DocView({ content, contentFormat, readOnly, room, className, onReady }: DocumentViewProps) {\n return (\n <div className={className}>\n <EditorConfigProvider config={{}}>\n <NotionEditor\n room={room ?? \"default\"}\n content={content as string}\n contentFormat={contentFormat}\n readOnly={readOnly}\n onEditorReady={(editor: Editor) => onReady?.(editor)}\n />\n </EditorConfigProvider>\n </div>\n )\n}\n"]}
1
+ {"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;;;;AAMe,SAAR,OAAA,CAAyB,EAAE,OAAA,EAAS,aAAA,EAAe,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AACjH,EAAA,2BACG,KAAA,EAAA,EAAI,SAAA,EACH,8BAAC,oBAAA,EAAA,EAAqB,MAAA,EAAQ,EAAC,EAC7B,QAAA,kBAAA,GAAA;AAAA,IAAC,YAAA;AAAA,IAAA;AAAA,MACC,MAAM,IAAA,IAAQ,SAAA;AAAA,MACd,OAAA;AAAA,MACA,aAAA;AAAA,MACA,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-KUVYBQ66.js","sourcesContent":["import type { Editor } from \"@tiptap/react\"\nimport { EditorConfigProvider } from \"../contexts/editor-config-context\"\nimport { NotionEditor } from \"../components/tiptap-templates/notion-like/notion-like-editor\"\nimport type { DocumentViewProps } from \"../registry\"\n\n/** doc 通道:云文档与本地 doc 是同一套 tiptap,不做区分 */\nexport default function DocView({ content, contentFormat, readOnly, room, className, onReady }: DocumentViewProps) {\n return (\n <div className={className}>\n <EditorConfigProvider config={{}}>\n <NotionEditor\n room={room ?? \"default\"}\n content={content as string}\n contentFormat={contentFormat}\n readOnly={readOnly}\n onEditorReady={(editor: Editor) => onReady?.(editor)}\n />\n </EditorConfigProvider>\n </div>\n )\n}\n"]}
@@ -5,9 +5,9 @@ import * as React from 'react';
5
5
  import { createContext, memo, forwardRef, useState, useCallback, useRef, useEffect, useMemo, lazy, useLayoutEffect, Suspense, useContext, useReducer, Children, isValidElement, cloneElement } from 'react';
6
6
  import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
7
7
  import { createPortal } from 'react-dom';
8
- import { Extension, Node as Node$2, mergeAttributes as mergeAttributes$1, textblockTypeInputRule, InputRule, getChangedRanges, getTextSerializersFromSchema, generateJSON, generateHTML } from '@tiptap/core';
8
+ import { Extension, Node as Node$2, mergeAttributes as mergeAttributes$1, textblockTypeInputRule, InputRule, getChangedRanges, getTextSerializersFromSchema, getTextBetween, generateJSON, generateHTML } from '@tiptap/core';
9
9
  import { isChangeOrigin, Collaboration } from '@tiptap/extension-collaboration';
10
- import { Fragment, Slice, Mark } from '@tiptap/pm/model';
10
+ import { Fragment, Slice, Mark, DOMSerializer } from '@tiptap/pm/model';
11
11
  import { PluginKey, Plugin, TextSelection, Selection, NodeSelection, SelectionRange } from '@tiptap/pm/state';
12
12
  import { createGlobalStyle, useTheme } from 'antd-style';
13
13
  import { serialize, compile, stringify } from 'stylis';
@@ -50,6 +50,7 @@ import '@base-ui/react/use-render';
50
50
  import { cva } from 'class-variance-authority';
51
51
  import { exitSuggestion, SuggestionPluginKey, Suggestion } from '@tiptap/suggestion';
52
52
  import { DragHandle } from '@tiptap/extension-drag-handle-react';
53
+ import { Paragraph } from '@tiptap/extension-paragraph';
53
54
  import { Blockquote } from '@tiptap/extension-blockquote';
54
55
  import { Code } from '@tiptap/extension-code';
55
56
  import { Highlight } from '@tiptap/extension-highlight';
@@ -9925,7 +9926,7 @@ var paragraphNodeStyles = ({ isDark }) => `
9925
9926
  .is-empty.with-slash[data-placeholder]:has(
9926
9927
  > .ProseMirror-trailingBreak:only-child
9927
9928
  )::before {
9928
- content: "Write, type '/' for commands…";
9929
+ content: attr(data-placeholder);
9929
9930
  font-style: italic;
9930
9931
  }
9931
9932
 
@@ -13684,7 +13685,7 @@ function getAnchorNodeAndPos(editor, allowEmptySelection = true) {
13684
13685
  return { node, pos };
13685
13686
  }
13686
13687
  function getEditorExtension(editor, extensionName) {
13687
- if (!editor) return null;
13688
+ if (!editor || editor.isDestroyed || !editor.extensionManager) return null;
13688
13689
  const extension = editor.extensionManager.extensions.find(
13689
13690
  (ext) => ext.name === extensionName
13690
13691
  );
@@ -21173,7 +21174,7 @@ function useScrollToHash(config = {}) {
21173
21174
  onTargetNotFoundRef.current = onTargetNotFound;
21174
21175
  const scrollToNode = useCallback(
21175
21176
  (hash) => {
21176
- if (!editor) return false;
21177
+ if (!editor || editor.isDestroyed) return false;
21177
21178
  const attributeName = getEditorExtension(editor, "uniqueID")?.options?.attributeName ?? "data-id";
21178
21179
  const anchor2 = parseAnchorHash(hash);
21179
21180
  if (!anchor2) return false;
@@ -22420,67 +22421,74 @@ var NodeAlignment = Extension.create({
22420
22421
  types: ["paragraph", "heading", "blockquote", "tableCell", "tableHeader"],
22421
22422
  useStyle: true,
22422
22423
  textAlignValues: ["left", "center", "right", "justify"],
22423
- verticalAlignValues: ["top", "middle", "bottom"]
22424
+ verticalAlignValues: ["top", "middle", "bottom"],
22425
+ textAlignHandledTypes: []
22424
22426
  };
22425
22427
  },
22426
22428
  addGlobalAttributes() {
22429
+ const attributes = {
22430
+ nodeTextAlign: {
22431
+ default: null,
22432
+ parseHTML: (element) => {
22433
+ const styleAlign = element.style?.textAlign;
22434
+ if (styleAlign && this.options.textAlignValues.includes(styleAlign)) {
22435
+ return styleAlign;
22436
+ }
22437
+ const dataAlign = element.getAttribute("data-node-text-align");
22438
+ if (dataAlign && this.options.textAlignValues.includes(dataAlign)) {
22439
+ return dataAlign;
22440
+ }
22441
+ return null;
22442
+ },
22443
+ renderHTML: (attributes2) => {
22444
+ const align = attributes2.nodeTextAlign;
22445
+ if (!align || !this.options.textAlignValues.includes(align))
22446
+ return {};
22447
+ if (this.options.useStyle) {
22448
+ return { style: `text-align: ${align}` };
22449
+ } else {
22450
+ return { "data-node-text-align": align };
22451
+ }
22452
+ }
22453
+ },
22454
+ nodeVerticalAlign: {
22455
+ default: null,
22456
+ parseHTML: (element) => {
22457
+ const styleVAlign = element.style?.verticalAlign;
22458
+ if (styleVAlign && this.options.verticalAlignValues.includes(styleVAlign)) {
22459
+ return styleVAlign;
22460
+ }
22461
+ const dataVAlign = element.getAttribute(
22462
+ "data-node-vertical-align"
22463
+ );
22464
+ if (dataVAlign && this.options.verticalAlignValues.includes(dataVAlign)) {
22465
+ return dataVAlign;
22466
+ }
22467
+ return null;
22468
+ },
22469
+ renderHTML: (attributes2) => {
22470
+ const vAlign = attributes2.nodeVerticalAlign;
22471
+ if (!vAlign || !this.options.verticalAlignValues.includes(vAlign))
22472
+ return {};
22473
+ if (this.options.useStyle) {
22474
+ return { style: `vertical-align: ${vAlign}` };
22475
+ } else {
22476
+ return { "data-node-vertical-align": vAlign };
22477
+ }
22478
+ }
22479
+ }
22480
+ };
22481
+ const handled = new Set(this.options.textAlignHandledTypes);
22427
22482
  return [
22483
+ { types: this.options.types.filter((type) => !handled.has(type)), attributes },
22428
22484
  {
22429
- types: this.options.types,
22485
+ types: this.options.types.filter((type) => handled.has(type)),
22430
22486
  attributes: {
22431
- nodeTextAlign: {
22432
- default: null,
22433
- parseHTML: (element) => {
22434
- const styleAlign = element.style?.textAlign;
22435
- if (styleAlign && this.options.textAlignValues.includes(styleAlign)) {
22436
- return styleAlign;
22437
- }
22438
- const dataAlign = element.getAttribute("data-node-text-align");
22439
- if (dataAlign && this.options.textAlignValues.includes(dataAlign)) {
22440
- return dataAlign;
22441
- }
22442
- return null;
22443
- },
22444
- renderHTML: (attributes) => {
22445
- const align = attributes.nodeTextAlign;
22446
- if (!align || !this.options.textAlignValues.includes(align))
22447
- return {};
22448
- if (this.options.useStyle) {
22449
- return { style: `text-align: ${align}` };
22450
- } else {
22451
- return { "data-node-text-align": align };
22452
- }
22453
- }
22454
- },
22455
- nodeVerticalAlign: {
22456
- default: null,
22457
- parseHTML: (element) => {
22458
- const styleVAlign = element.style?.verticalAlign;
22459
- if (styleVAlign && this.options.verticalAlignValues.includes(styleVAlign)) {
22460
- return styleVAlign;
22461
- }
22462
- const dataVAlign = element.getAttribute(
22463
- "data-node-vertical-align"
22464
- );
22465
- if (dataVAlign && this.options.verticalAlignValues.includes(dataVAlign)) {
22466
- return dataVAlign;
22467
- }
22468
- return null;
22469
- },
22470
- renderHTML: (attributes) => {
22471
- const vAlign = attributes.nodeVerticalAlign;
22472
- if (!vAlign || !this.options.verticalAlignValues.includes(vAlign))
22473
- return {};
22474
- if (this.options.useStyle) {
22475
- return { style: `vertical-align: ${vAlign}` };
22476
- } else {
22477
- return { "data-node-vertical-align": vAlign };
22478
- }
22479
- }
22480
- }
22487
+ ...attributes,
22488
+ nodeTextAlign: { default: null, parseHTML: () => null, renderHTML: () => ({}) }
22481
22489
  }
22482
22490
  }
22483
- ];
22491
+ ].filter((group) => group.types.length > 0);
22484
22492
  },
22485
22493
  addCommands() {
22486
22494
  const executeAlignmentCommand = (attributeName, getTargetValue) => {
@@ -26564,6 +26572,33 @@ function convertCodeGroupDraft(view, draft) {
26564
26572
  dispatchAsOwnUndoStep(view, tr.scrollIntoView());
26565
26573
  return true;
26566
26574
  }
26575
+ function isPlainLineSlice(slice) {
26576
+ if (slice.content.childCount === 0) return false;
26577
+ let plain = true;
26578
+ slice.content.descendants((node) => {
26579
+ if (!plain) return false;
26580
+ if (node.isInline || node.type.name === "paragraph") return true;
26581
+ plain = false;
26582
+ return false;
26583
+ });
26584
+ return plain;
26585
+ }
26586
+ function sliceLines(slice, schema) {
26587
+ const container = schema.topNodeType.create(null, slice.content);
26588
+ return getTextBetween(
26589
+ container,
26590
+ { from: 0, to: container.content.size },
26591
+ { blockSeparator: "\n", textSerializers: getTextSerializersFromSchema(schema) }
26592
+ );
26593
+ }
26594
+ function containerPasteText(data, slice, schema) {
26595
+ const text = data.getData("text/plain");
26596
+ const html = data.getData("text/html");
26597
+ if (!html) return text || null;
26598
+ if (!isPlainLineSlice(slice)) return null;
26599
+ if (/\sdata-pm-slice=/.test(html)) return sliceLines(slice, schema);
26600
+ return text || null;
26601
+ }
26567
26602
  function isComposing(view, event) {
26568
26603
  if (event?.isComposing) return true;
26569
26604
  return Boolean(view.composing);
@@ -26590,14 +26625,13 @@ function createCodeGroupInputPlugin(editor) {
26590
26625
  }
26591
26626
  return editor.commands.splitBlock();
26592
26627
  },
26593
- handlePaste(view, event) {
26628
+ handlePaste(view, event, slice) {
26594
26629
  const { state } = view;
26595
26630
  if (state.selection.$from.parent.type.name === "codeBlock") return false;
26596
26631
  const data = event.clipboardData;
26597
26632
  if (!data) return false;
26598
26633
  if (view.input?.shiftKey) return false;
26599
- if (data.getData("text/html")) return false;
26600
- const text = data.getData("text/plain");
26634
+ const text = containerPasteText(data, slice, state.schema);
26601
26635
  if (!text || !containsCompleteContainer(text)) return false;
26602
26636
  const manager = editor.markdown;
26603
26637
  if (!manager) return false;
@@ -38749,7 +38783,8 @@ var TableActionMenu = () => {
38749
38783
  {
38750
38784
  autoFocusOnShow: true,
38751
38785
  autoFocusOnHide: false,
38752
- modal: true,
38786
+ portal: true,
38787
+ preventBodyScroll: true,
38753
38788
  onClose: resetMenu,
38754
38789
  children: [
38755
38790
  /* @__PURE__ */ jsx(Combobox2, { style: SR_ONLY }),
@@ -39467,21 +39502,24 @@ var TableActionItem2 = ({ action }) => {
39467
39502
  var TableActionMenu2 = ({ onClose }) => {
39468
39503
  const { mergeAction, splitAction, clearAction } = useTableActions();
39469
39504
  const hasMergeOrSplit = mergeAction.isAvailable || splitAction.isAvailable;
39470
- return /* @__PURE__ */ jsxs(MenuContent, { autoFocusOnShow: true, modal: true, onClose, children: [
39471
- /* @__PURE__ */ jsx(Combobox2, { style: SR_ONLY }),
39472
- /* @__PURE__ */ jsxs(ComboboxList2, { style: { minWidth: "15rem" }, children: [
39473
- hasMergeOrSplit && /* @__PURE__ */ jsxs(MenuGroup2, { children: [
39474
- mergeAction.isAvailable && /* @__PURE__ */ jsx(TableActionItem2, { action: mergeAction }),
39475
- splitAction.isAvailable && /* @__PURE__ */ jsx(TableActionItem2, { action: splitAction }),
39476
- /* @__PURE__ */ jsx(Separator, { orientation: "horizontal" })
39477
- ] }),
39478
- /* @__PURE__ */ jsxs(MenuGroup2, { children: [
39479
- /* @__PURE__ */ jsx(ColorMenu, {}),
39480
- /* @__PURE__ */ jsx(TableAlignMenu, {}),
39481
- clearAction.isAvailable && /* @__PURE__ */ jsx(TableActionItem2, { action: clearAction })
39505
+ return (
39506
+ // 不用 modal,原因同 table-handle-menu:modal 会改写编辑器 DOM,选区被 ProseMirror 重置
39507
+ /* @__PURE__ */ jsxs(MenuContent, { autoFocusOnShow: true, portal: true, preventBodyScroll: true, onClose, children: [
39508
+ /* @__PURE__ */ jsx(Combobox2, { style: SR_ONLY }),
39509
+ /* @__PURE__ */ jsxs(ComboboxList2, { style: { minWidth: "15rem" }, children: [
39510
+ hasMergeOrSplit && /* @__PURE__ */ jsxs(MenuGroup2, { children: [
39511
+ mergeAction.isAvailable && /* @__PURE__ */ jsx(TableActionItem2, { action: mergeAction }),
39512
+ splitAction.isAvailable && /* @__PURE__ */ jsx(TableActionItem2, { action: splitAction }),
39513
+ /* @__PURE__ */ jsx(Separator, { orientation: "horizontal" })
39514
+ ] }),
39515
+ /* @__PURE__ */ jsxs(MenuGroup2, { children: [
39516
+ /* @__PURE__ */ jsx(ColorMenu, {}),
39517
+ /* @__PURE__ */ jsx(TableAlignMenu, {}),
39518
+ clearAction.isAvailable && /* @__PURE__ */ jsx(TableActionItem2, { action: clearAction })
39519
+ ] })
39482
39520
  ] })
39483
39521
  ] })
39484
- ] });
39522
+ );
39485
39523
  };
39486
39524
  var TableCellHandleMenu = forwardRef(({ editor: providedEditor, onOpenChange, className, ...props }, ref) => {
39487
39525
  const { editor } = useTiptapEditor(providedEditor);
@@ -50620,6 +50658,98 @@ var Indent = Extension.create({
50620
50658
  };
50621
50659
  }
50622
50660
  });
50661
+ var SAFE_COLOR = /^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%deg]+\)|[a-z]{3,20})$/i;
50662
+ var HTML_ONLY_MARKS = /* @__PURE__ */ new Set(["textStyle", "highlight", "underline", "superscript", "subscript"]);
50663
+ function markdownColor(value) {
50664
+ if (typeof value !== "string") return null;
50665
+ const resolved = resolveColorToHex(value);
50666
+ if (resolved) return resolved;
50667
+ const trimmed = value.trim();
50668
+ return SAFE_COLOR.test(trimmed) ? trimmed : null;
50669
+ }
50670
+ function escapeMarkdownAttribute(value) {
50671
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
50672
+ }
50673
+ function blockStyles(attrs) {
50674
+ const align = ["center", "right"].includes(String(attrs?.textAlign)) ? String(attrs?.textAlign) : null;
50675
+ const indent = Math.max(0, Math.min(30, Math.trunc(Number(attrs?.indent) || 0)));
50676
+ const background = markdownColor(attrs?.backgroundColor);
50677
+ return [
50678
+ align ? `text-align: ${align}` : null,
50679
+ indent ? `margin-left: ${indent * 24}px` : null,
50680
+ background ? `background-color: ${background}` : null
50681
+ ].filter((style) => Boolean(style));
50682
+ }
50683
+ function hasHtmlOnlyMark(content) {
50684
+ return (content ?? []).some(
50685
+ (child) => child.marks?.some((mark) => HTML_ONLY_MARKS.has(mark.type)) || hasHtmlOnlyMark(child.content)
50686
+ );
50687
+ }
50688
+ function hasSignificantWhitespace(content) {
50689
+ const text = (content ?? []).map((child) => child.text ?? "").join("");
50690
+ return /\s{2}|^\s|\s$|\t/.test(text);
50691
+ }
50692
+ function needsHtmlBlock(node) {
50693
+ return blockStyles(node.attrs).length > 0 || hasHtmlOnlyMark(node.content);
50694
+ }
50695
+ function serializeInlineHTML(node, schema) {
50696
+ if (!schema || typeof document === "undefined") return null;
50697
+ try {
50698
+ const pmNode = schema.nodeFromJSON(node);
50699
+ const container = document.createElement("div");
50700
+ container.appendChild(
50701
+ DOMSerializer.fromSchema(schema).serializeFragment(pmNode.content, { document })
50702
+ );
50703
+ return container.innerHTML.replace(/\n/g, "&#10;");
50704
+ } catch {
50705
+ return null;
50706
+ }
50707
+ }
50708
+ function htmlBlock(node, tag, inner, extraAttrs = {}) {
50709
+ const styles = blockStyles(node.attrs);
50710
+ if (hasSignificantWhitespace(node.content)) styles.push("white-space: pre-wrap");
50711
+ const attrs = Object.entries(extraAttrs).map(
50712
+ ([key, value]) => ` ${key}="${escapeMarkdownAttribute(value)}"`
50713
+ );
50714
+ if (styles.length) attrs.push(` style="${escapeMarkdownAttribute(styles.join("; "))}"`);
50715
+ return `<${tag}${attrs.join("")}>${inner}</${tag}>`;
50716
+ }
50717
+ function createRichMarkdownExtensions() {
50718
+ const ref = { schema: null };
50719
+ const MarkdownParagraph = Paragraph.extend({
50720
+ onBeforeCreate() {
50721
+ ref.schema = this.editor.schema;
50722
+ },
50723
+ renderMarkdown(node, helpers, context) {
50724
+ const renderBase = Paragraph.config.renderMarkdown;
50725
+ if (!needsHtmlBlock(node)) return renderBase(node, helpers, context);
50726
+ const inner = serializeInlineHTML(node, ref.schema);
50727
+ return inner === null ? renderBase(node, helpers, context) : htmlBlock(node, "p", inner);
50728
+ }
50729
+ });
50730
+ const MarkdownHeading = Heading.extend({
50731
+ // extend() 会把 Heading 的 config 拷进来:不覆写的话,拷过来的函数里 `...this.parent()` 又调一遍
50732
+ // Heading 自己的同一个函数,数组被加两份(headingNumbering 是带 key 的插件,直接抛错)
50733
+ addExtensions() {
50734
+ return this.parent?.() ?? [];
50735
+ },
50736
+ addInputRules() {
50737
+ return this.parent?.() ?? [];
50738
+ },
50739
+ addProseMirrorPlugins() {
50740
+ return this.parent?.() ?? [];
50741
+ },
50742
+ renderMarkdown(node, helpers, context) {
50743
+ const renderBase = Heading.config.renderMarkdown;
50744
+ const level = Math.min(9, Math.max(1, Math.trunc(Number(node.attrs?.level) || 1)));
50745
+ if (level <= 6 && !needsHtmlBlock(node)) return renderBase(node, helpers, context);
50746
+ const inner = serializeInlineHTML(node, ref.schema);
50747
+ if (inner === null) return renderBase(node, helpers, context);
50748
+ return level <= 6 ? htmlBlock(node, `h${level}`, inner) : htmlBlock(node, "div", inner, { "data-heading-level": String(level) });
50749
+ }
50750
+ });
50751
+ return { MarkdownParagraph, MarkdownHeading };
50752
+ }
50623
50753
  var isMac3 = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform);
50624
50754
  var FeishuStrike = Strike.extend({
50625
50755
  addKeyboardShortcuts() {
@@ -51026,6 +51156,7 @@ var CopyLink = Extension.create({
51026
51156
  };
51027
51157
  }
51028
51158
  });
51159
+ var TEXT_ALIGN_TYPES = ["heading", "paragraph"];
51029
51160
  function LoadingSpinner({ text = "Connecting..." }) {
51030
51161
  return /* @__PURE__ */ jsx("div", { className: "spinner-container", children: /* @__PURE__ */ jsxs("div", { className: "spinner-content", children: [
51031
51162
  /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
@@ -51035,7 +51166,7 @@ function LoadingSpinner({ text = "Connecting..." }) {
51035
51166
  /* @__PURE__ */ jsx("div", { className: "spinner-loading-text", children: text })
51036
51167
  ] }) });
51037
51168
  }
51038
- function EditorContentArea() {
51169
+ function EditorContentArea({ hideFloatingToolbar = false }) {
51039
51170
  const { editor } = useContext(EditorContext);
51040
51171
  useScrollToHash();
51041
51172
  if (!editor) {
@@ -51065,7 +51196,7 @@ function EditorContentArea() {
51065
51196
  /* @__PURE__ */ jsx(EmojiDropdownMenu, {}),
51066
51197
  /* @__PURE__ */ jsx(MentionDropdownMenu, {}),
51067
51198
  /* @__PURE__ */ jsx(SlashDropdownMenu, {}),
51068
- /* @__PURE__ */ jsx(NotionToolbarFloating, {}),
51199
+ !hideFloatingToolbar && /* @__PURE__ */ jsx(NotionToolbarFloating, {}),
51069
51200
  /* @__PURE__ */ jsx(MathEditorPopover, { editor }),
51070
51201
  /* @__PURE__ */ jsx(LinkPastePanel, { editor }),
51071
51202
  /* @__PURE__ */ jsx(LinkEditPanel, { editor }),
@@ -51091,7 +51222,9 @@ function EditorProvider(props) {
51091
51222
  readOnly = false,
51092
51223
  permissions,
51093
51224
  hideHeader = false,
51225
+ hideFloatingToolbar = false,
51094
51226
  embedded = false,
51227
+ richMarkdown = false,
51095
51228
  onEditorReady,
51096
51229
  extensions: extraExtensions,
51097
51230
  pageHeader = false,
@@ -51127,9 +51260,14 @@ function EditorProvider(props) {
51127
51260
  const videoMaxSize = resolveMaxSize("video", editorConfig?.upload);
51128
51261
  const audioMaxSize = resolveMaxSize("audio", editorConfig?.upload);
51129
51262
  const fileMaxSize = resolveMaxSize("file", editorConfig?.upload);
51263
+ const richMarkdownExtensions = useMemo(
51264
+ () => richMarkdown ? createRichMarkdownExtensions() : null,
51265
+ [richMarkdown]
51266
+ );
51130
51267
  const extensions = [
51131
51268
  StarterKit.configure({
51132
51269
  undoRedo: false,
51270
+ paragraph: richMarkdownExtensions ? false : void 0,
51133
51271
  horizontalRule: false,
51134
51272
  // 换成 1–9 级 + 折叠的版本(heading-node-extension)
51135
51273
  heading: false,
@@ -51144,6 +51282,7 @@ function EditorProvider(props) {
51144
51282
  },
51145
51283
  link: { openOnClick: false }
51146
51284
  }),
51285
+ ...richMarkdownExtensions ? [richMarkdownExtensions.MarkdownParagraph] : [],
51147
51286
  // 代码块 / 分组 / 高亮 / Markdown / 直接输入:顺序固定,且在协同与 UniqueID 之前
51148
51287
  CodeBlockExtension,
51149
51288
  CodeGroupExtension,
@@ -51157,7 +51296,7 @@ function EditorProvider(props) {
51157
51296
  ApiParamExtension,
51158
51297
  ContainerInput,
51159
51298
  HorizontalRule,
51160
- Heading,
51299
+ richMarkdownExtensions ? richMarkdownExtensions.MarkdownHeading : Heading,
51161
51300
  FeishuStrike,
51162
51301
  FeishuCode,
51163
51302
  FeishuBlockquote,
@@ -51170,7 +51309,7 @@ function EditorProvider(props) {
51170
51309
  // 文档页头:节点始终注册(协同各端 schema 要一致),是否自动补由 pageHeader 决定
51171
51310
  PageHeader.configure({ autoInsert: pageHeader }),
51172
51311
  // 飞书只有左 / 中 / 右(对齐枚举里没有两端对齐),也就没有 ⌘⇧J
51173
- TextAlign.configure({ types: ["heading", "paragraph"], alignments: ["left", "center", "right"] }),
51312
+ TextAlign.configure({ types: TEXT_ALIGN_TYPES, alignments: ["left", "center", "right"] }),
51174
51313
  // Collaboration 可以无 provider 运行(仅操作本地 yjs doc),CollaborationCaret
51175
51314
  // 强依赖 provider.awareness,没 provider 时不挂以避免 runtime 崩。
51176
51315
  Collaboration.configure({ document: ydoc }),
@@ -51232,7 +51371,8 @@ function EditorProvider(props) {
51232
51371
  "tocNode"
51233
51372
  ]
51234
51373
  }),
51235
- NodeAlignment,
51374
+ // 段落 / 标题的 text-align 归 TextAlign,NodeAlignment 不再抢(见 textAlignHandledTypes)
51375
+ NodeAlignment.configure({ textAlignHandledTypes: TEXT_ALIGN_TYPES }),
51236
51376
  // 行距 / 段前段后距:Word 把它们挂在每个段落上,导入时没有对应属性就会
51237
51377
  // 整篇塌回编辑器的统一边距,原文的疏密节奏全丢。
51238
51378
  BlockSpacing.configure({
@@ -51506,7 +51646,7 @@ function EditorProvider(props) {
51506
51646
  /* @__PURE__ */ jsx(ReadModeSelectionBar, { editor }),
51507
51647
  !readOnly && !hideHeader && /* @__PURE__ */ jsx(NotionEditorHeader, {}),
51508
51648
  /* @__PURE__ */ jsxs("div", { className: "notion-like-editor-layout", "data-width-mode": widthModeValue, children: [
51509
- /* @__PURE__ */ jsx(EditorContentArea, {}),
51649
+ /* @__PURE__ */ jsx(EditorContentArea, { hideFloatingToolbar }),
51510
51650
  !embedded && /* @__PURE__ */ jsx(TocSidebar, { topOffset: 48 })
51511
51651
  ] }),
51512
51652
  isEditable && /* @__PURE__ */ jsxs(Fragment$1, { children: [
@@ -51536,6 +51676,9 @@ function NotionEditor({
51536
51676
  codeBlock,
51537
51677
  readOnly = false,
51538
51678
  hideHeader = false,
51679
+ hideFloatingToolbar = false,
51680
+ embedded = false,
51681
+ richMarkdown = false,
51539
51682
  onEditorReady,
51540
51683
  extensions,
51541
51684
  pageHeader,
@@ -51560,6 +51703,9 @@ function NotionEditor({
51560
51703
  readOnly,
51561
51704
  permissions,
51562
51705
  hideHeader,
51706
+ hideFloatingToolbar,
51707
+ embedded,
51708
+ richMarkdown,
51563
51709
  onEditorReady,
51564
51710
  extensions,
51565
51711
  pageHeader,
@@ -51581,6 +51727,9 @@ function NotionEditorContent({
51581
51727
  readOnly = false,
51582
51728
  permissions,
51583
51729
  hideHeader = false,
51730
+ hideFloatingToolbar = false,
51731
+ embedded = false,
51732
+ richMarkdown = false,
51584
51733
  onEditorReady,
51585
51734
  extensions,
51586
51735
  pageHeader,
@@ -51610,6 +51759,9 @@ function NotionEditorContent({
51610
51759
  readOnly,
51611
51760
  permissions,
51612
51761
  hideHeader,
51762
+ hideFloatingToolbar,
51763
+ embedded,
51764
+ richMarkdown,
51613
51765
  onEditorReady,
51614
51766
  extensions,
51615
51767
  pageHeader,
@@ -51651,5 +51803,5 @@ function ArticleViewer({
51651
51803
  }
51652
51804
 
51653
51805
  export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, DetailsExtension, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorProvider, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WidthModeMenu, countDocument, countRange, countText, defaultUiState, detectMediaKind, findSelectionPosition, getDocPermissions, getEditorMarkdown, hasContentAbove, markHideFloatingOnNext, parseEditorContent, pickFile, printDocument, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, serializeEditorMarkdown, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize, use_ui_editor_state_default };
51654
- //# sourceMappingURL=chunk-ABXCS4IZ.js.map
51655
- //# sourceMappingURL=chunk-ABXCS4IZ.js.map
51806
+ //# sourceMappingURL=chunk-6MZAYCF6.js.map
51807
+ //# sourceMappingURL=chunk-6MZAYCF6.js.map