@4399ywkf/editor 0.2.0 → 0.3.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-3GZSG6KH.js';
1
+ import { EditorConfigProvider, NotionEditor } from './chunk-ZRFOS52C.js';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
 
4
4
  function DocView({ content, readOnly, room, className, onReady }) {
@@ -14,5 +14,5 @@ function DocView({ content, readOnly, room, className, onReady }) {
14
14
  }
15
15
 
16
16
  export { DocView as default };
17
- //# sourceMappingURL=DocView-BPODKQ57.js.map
18
- //# sourceMappingURL=DocView-BPODKQ57.js.map
17
+ //# sourceMappingURL=DocView-GDN5CZCJ.js.map
18
+ //# sourceMappingURL=DocView-GDN5CZCJ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/views/DocView.tsx"],"names":[],"mappings":";;;AAMe,SAAR,QAAyB,EAAE,OAAA,EAAS,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AAClG,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,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-BPODKQ57.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, 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 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,QAAyB,EAAE,OAAA,EAAS,UAAU,IAAA,EAAM,SAAA,EAAW,SAAQ,EAAsB;AAClG,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,QAAA;AAAA,MACA,aAAA,EAAe,CAAC,MAAA,KAAmB,OAAA,GAAU,MAAM;AAAA;AAAA,KAEvD,CAAA,EACF,CAAA;AAEJ","file":"DocView-GDN5CZCJ.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, 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 readOnly={readOnly}\n onEditorReady={(editor: Editor) => onReady?.(editor)}\n />\n </EditorConfigProvider>\n </div>\n )\n}\n"]}
@@ -17,7 +17,7 @@ import { CodeBlockLowlight } from '@tiptap/extension-code-block-lowlight';
17
17
  import { createLowlight, common } from 'lowlight';
18
18
  import { Mention } from '@tiptap/extension-mention';
19
19
  import { TaskList, TaskItem } from '@tiptap/extension-list';
20
- import { TextStyle, Color } from '@tiptap/extension-text-style';
20
+ import { TextStyle, FontSize, FontFamily, Color } from '@tiptap/extension-text-style';
21
21
  import { Selection as Selection$1, Placeholder } from '@tiptap/extensions';
22
22
  import { Collaboration, isChangeOrigin } from '@tiptap/extension-collaboration';
23
23
  import { CollaborationCaret } from '@tiptap/extension-collaboration-caret';
@@ -4110,6 +4110,72 @@ var NodeAlignment = Extension.create({
4110
4110
  };
4111
4111
  }
4112
4112
  });
4113
+ var BlockSpacing = Extension.create({
4114
+ name: "blockSpacing",
4115
+ addOptions() {
4116
+ return {
4117
+ types: ["paragraph", "heading", "blockquote"]
4118
+ };
4119
+ },
4120
+ addGlobalAttributes() {
4121
+ return [
4122
+ {
4123
+ types: this.options.types,
4124
+ attributes: {
4125
+ lineHeight: {
4126
+ default: null,
4127
+ parseHTML: (element) => element.style?.lineHeight || null,
4128
+ renderHTML: (attributes) => {
4129
+ const v = attributes.lineHeight;
4130
+ return v ? { style: `line-height: ${v}` } : {};
4131
+ }
4132
+ },
4133
+ spaceBefore: {
4134
+ default: null,
4135
+ parseHTML: (element) => element.style?.marginTop || null,
4136
+ renderHTML: (attributes) => {
4137
+ const v = attributes.spaceBefore;
4138
+ return v ? { style: `margin-top: ${v}` } : {};
4139
+ }
4140
+ },
4141
+ spaceAfter: {
4142
+ default: null,
4143
+ parseHTML: (element) => element.style?.marginBottom || null,
4144
+ renderHTML: (attributes) => {
4145
+ const v = attributes.spaceAfter;
4146
+ return v ? { style: `margin-bottom: ${v}` } : {};
4147
+ }
4148
+ }
4149
+ }
4150
+ }
4151
+ ];
4152
+ },
4153
+ addCommands() {
4154
+ const apply = (patch) => ({ state, tr }) => {
4155
+ const targets = getSelectedNodesOfType(
4156
+ state.selection,
4157
+ this.options.types
4158
+ );
4159
+ if (targets.length === 0) return false;
4160
+ let changed = false;
4161
+ for (const [name, value] of Object.entries(patch)) {
4162
+ if (updateNodesAttr(tr, targets, name, value)) changed = true;
4163
+ }
4164
+ return changed;
4165
+ };
4166
+ return {
4167
+ setLineHeight: (lineHeight) => apply({ lineHeight }),
4168
+ unsetLineHeight: () => apply({ lineHeight: null }),
4169
+ setBlockSpacing: (spaceBefore, spaceAfter) => {
4170
+ const patch = {};
4171
+ if (spaceBefore !== void 0) patch.spaceBefore = spaceBefore;
4172
+ if (spaceAfter !== void 0) patch.spaceAfter = spaceAfter;
4173
+ return apply(patch);
4174
+ },
4175
+ unsetBlockSpacing: () => apply({ spaceBefore: null, spaceAfter: null })
4176
+ };
4177
+ }
4178
+ });
4113
4179
  var TocContext = createContext(void 0);
4114
4180
  function normalizeHeadingDepths(items) {
4115
4181
  if (items.length === 0) return [];
@@ -21645,7 +21711,17 @@ function EditorProvider(props) {
21645
21711
  ]
21646
21712
  }),
21647
21713
  NodeAlignment,
21714
+ // 行距 / 段前段后距:Word 把它们挂在每个段落上,导入时没有对应属性就会
21715
+ // 整篇塌回编辑器的统一边距,原文的疏密节奏全丢。
21716
+ BlockSpacing.configure({
21717
+ types: ["paragraph", "heading", "blockquote"]
21718
+ }),
21648
21719
  TextStyle,
21720
+ // 字号与字体是 textStyle 上的属性。不注册这两个扩展,schema 里就没有
21721
+ // fontSize / fontFamily,ProseMirror 会**静默丢弃**这两个属性 ——
21722
+ // 表现是 docx 导入后全文一个字号(见 docx/parse.ts 的 fmtToMarks)。
21723
+ FontSize,
21724
+ FontFamily,
21649
21725
  Mathematics,
21650
21726
  Superscript,
21651
21727
  Subscript,
@@ -21861,5 +21937,5 @@ function ArticleViewer({ content, placeholder = "" }) {
21861
21937
  }
21862
21938
 
21863
21939
  export { ArticleViewer, Audio, Button, CollabContext, CollabProvider, Column, Columns, DEFAULT_MAX_FILE_SIZES, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorProvider, FileAttachment, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MAC_SYMBOLS, MAX_FILE_SIZE, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, PasteDropMedia, Popover, PopoverContent, PopoverTrigger, SR_ONLY, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, Video, clamp, cn, defaultUiState, detectMediaKind, findNodeAtPosition, findNodePosition, findSelectionPosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, hasContentAbove, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, markHideFloatingOnNext, parseShortcutKeys, pickFile, removeEmptyParagraphs, resolveMaxSize, runMediaUpload, sanitizeUrl, selectCurrentBlockContent, selectNodeAndHideFloating, selectionWithinConvertibleTypes, updateNodesAttr, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useTiptapEditor, useUiEditorState, useUnmount, useUser, useWindowSize, use_ui_editor_state_default };
21864
- //# sourceMappingURL=chunk-3GZSG6KH.js.map
21865
- //# sourceMappingURL=chunk-3GZSG6KH.js.map
21940
+ //# sourceMappingURL=chunk-ZRFOS52C.js.map
21941
+ //# sourceMappingURL=chunk-ZRFOS52C.js.map