@4399ywkf/editor 0.1.2 → 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.
- package/dist/{DocView-5KS7B4DA.js → DocView-GDN5CZCJ.js} +3 -3
- package/dist/{DocView-5KS7B4DA.js.map → DocView-GDN5CZCJ.js.map} +1 -1
- package/dist/{chunk-G6WM2PSU.js → chunk-ZRFOS52C.js} +111 -8
- package/dist/chunk-ZRFOS52C.js.map +1 -0
- package/dist/doc-runtime.d.ts +358 -0
- package/dist/doc-runtime.js +774 -0
- package/dist/doc-runtime.js.map +1 -0
- package/dist/doc.js +1 -1
- package/dist/docx.d.ts +121 -6
- package/dist/docx.js +421 -40
- package/dist/docx.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/style.css +22 -0
- package/package.json +15 -11
- package/dist/chunk-G6WM2PSU.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorConfigProvider, NotionEditor } from './chunk-
|
|
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-
|
|
18
|
-
//# sourceMappingURL=DocView-
|
|
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-
|
|
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,
|
|
@@ -21692,16 +21768,43 @@ function EditorProvider(props) {
|
|
|
21692
21768
|
onRehostProgress
|
|
21693
21769
|
}),
|
|
21694
21770
|
UniqueID.configure({
|
|
21771
|
+
/**
|
|
21772
|
+
* 带稳定 id 的节点类型 —— 也就是 AI 能直接寻址的那些(见 doc-runtime)。
|
|
21773
|
+
*
|
|
21774
|
+
* 原本只配了上面 9 种块级类型,于是 listItem / taskItem / tableCell /
|
|
21775
|
+
* columns / column / image 这些**结构**节点全都没 id:AI 能读到它们,
|
|
21776
|
+
* 却没法指着其中一个说「改这个」。doc_modify_nodes 的 modify 要求
|
|
21777
|
+
* litexml 带 id,所以「把第 3 个列表项加粗」「把这张图换掉」
|
|
21778
|
+
* 「改这个单元格的底色」在旧配置下根本表达不出来。
|
|
21779
|
+
*
|
|
21780
|
+
* 代价是每个此类节点在文档里多一个 id 属性(大表格尤其明显)。
|
|
21781
|
+
* 拿可寻址性换体积,这笔是划算的 —— 寻址不了的能力等于没有。
|
|
21782
|
+
*/
|
|
21695
21783
|
types: [
|
|
21696
|
-
|
|
21784
|
+
// 块级容器
|
|
21697
21785
|
"paragraph",
|
|
21698
|
-
"bulletList",
|
|
21699
|
-
"orderedList",
|
|
21700
|
-
"taskList",
|
|
21701
21786
|
"heading",
|
|
21702
21787
|
"blockquote",
|
|
21703
21788
|
"codeBlock",
|
|
21704
|
-
"tocNode"
|
|
21789
|
+
"tocNode",
|
|
21790
|
+
// 列表:容器和条目都要,否则改不了单条
|
|
21791
|
+
"bulletList",
|
|
21792
|
+
"orderedList",
|
|
21793
|
+
"listItem",
|
|
21794
|
+
"taskList",
|
|
21795
|
+
"taskItem",
|
|
21796
|
+
// 表格:结构性改动走 (tableId,row,col),但改单元格属性只能靠 id
|
|
21797
|
+
"table",
|
|
21798
|
+
"tableCell",
|
|
21799
|
+
"tableHeader",
|
|
21800
|
+
// 分栏
|
|
21801
|
+
"columns",
|
|
21802
|
+
"column",
|
|
21803
|
+
// 媒体
|
|
21804
|
+
"image",
|
|
21805
|
+
"video",
|
|
21806
|
+
"audio",
|
|
21807
|
+
"fileAttachment"
|
|
21705
21808
|
],
|
|
21706
21809
|
filterTransaction: (transaction) => !isChangeOrigin(transaction)
|
|
21707
21810
|
}),
|
|
@@ -21834,5 +21937,5 @@ function ArticleViewer({ content, placeholder = "" }) {
|
|
|
21834
21937
|
}
|
|
21835
21938
|
|
|
21836
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 };
|
|
21837
|
-
//# sourceMappingURL=chunk-
|
|
21838
|
-
//# sourceMappingURL=chunk-
|
|
21940
|
+
//# sourceMappingURL=chunk-ZRFOS52C.js.map
|
|
21941
|
+
//# sourceMappingURL=chunk-ZRFOS52C.js.map
|