@prosekit/basic 0.6.1 → 0.6.3
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/prosekit-basic.d.ts +35 -34
- package/dist/prosekit-basic.d.ts.map +1 -0
- package/dist/prosekit-basic.js +2 -1
- package/dist/prosekit-basic.js.map +1 -0
- package/dist/style.css +2 -0
- package/dist/style.css.map +1 -0
- package/dist/style.js +1 -0
- package/dist/typography.css +3 -1
- package/dist/typography.css.map +1 -0
- package/dist/typography.js +1 -0
- package/package.json +11 -10
- package/src/index.spec.ts +57 -0
- package/src/index.ts +187 -0
- package/src/node.spec.ts +120 -0
- package/src/style.css +7 -0
- package/src/typography.css +223 -0
package/dist/prosekit-basic.d.ts
CHANGED
|
@@ -23,41 +23,42 @@ import { VirtualSelectionExtension } from "@prosekit/extensions/virtual-selectio
|
|
|
23
23
|
//#region src/index.d.ts
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
28
|
type BasicExtension = Union<[DocExtension, TextExtension, ParagraphExtension, HeadingExtension, ListExtension, BlockquoteExtension, ImageExtension, HorizontalRuleExtension, HardBreakExtension, TableExtension, CodeBlockExtension, ItalicExtension, BoldExtension, UnderlineExtension, StrikeExtension, CodeExtension, LinkExtension, BaseKeymapExtension, BaseCommandsExtension, HistoryExtension, GapCursorExtension, VirtualSelectionExtension, ModClickPreventionExtension]>;
|
|
29
29
|
/**
|
|
30
|
-
* Define a basic extension that includes some common functionality. You can
|
|
31
|
-
* copy this function and customize it to your needs.
|
|
32
|
-
*
|
|
33
|
-
* It's a combination of the following extension functions:
|
|
34
|
-
*
|
|
35
|
-
* - {@link defineDoc}
|
|
36
|
-
* - {@link defineText}
|
|
37
|
-
* - {@link defineParagraph}
|
|
38
|
-
* - {@link defineHeading}
|
|
39
|
-
* - {@link defineList}
|
|
40
|
-
* - {@link defineBlockquote}
|
|
41
|
-
* - {@link defineImage}
|
|
42
|
-
* - {@link defineHorizontalRule}
|
|
43
|
-
* - {@link defineHardBreak}
|
|
44
|
-
* - {@link defineTable}
|
|
45
|
-
* - {@link defineCodeBlock}
|
|
46
|
-
* - {@link defineItalic}
|
|
47
|
-
* - {@link defineBold}
|
|
48
|
-
* - {@link defineUnderline}
|
|
49
|
-
* - {@link defineStrike}
|
|
50
|
-
* - {@link defineCode}
|
|
51
|
-
* - {@link defineLink}
|
|
52
|
-
* - {@link defineBaseKeymap}
|
|
53
|
-
* - {@link defineBaseCommands}
|
|
54
|
-
* - {@link defineHistory}
|
|
55
|
-
* - {@link defineGapCursor}
|
|
56
|
-
* - {@link defineVirtualSelection}
|
|
57
|
-
* - {@link defineModClickPrevention}
|
|
58
|
-
*
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
30
|
+
* Define a basic extension that includes some common functionality. You can
|
|
31
|
+
* copy this function and customize it to your needs.
|
|
32
|
+
*
|
|
33
|
+
* It's a combination of the following extension functions:
|
|
34
|
+
*
|
|
35
|
+
* - {@link defineDoc}
|
|
36
|
+
* - {@link defineText}
|
|
37
|
+
* - {@link defineParagraph}
|
|
38
|
+
* - {@link defineHeading}
|
|
39
|
+
* - {@link defineList}
|
|
40
|
+
* - {@link defineBlockquote}
|
|
41
|
+
* - {@link defineImage}
|
|
42
|
+
* - {@link defineHorizontalRule}
|
|
43
|
+
* - {@link defineHardBreak}
|
|
44
|
+
* - {@link defineTable}
|
|
45
|
+
* - {@link defineCodeBlock}
|
|
46
|
+
* - {@link defineItalic}
|
|
47
|
+
* - {@link defineBold}
|
|
48
|
+
* - {@link defineUnderline}
|
|
49
|
+
* - {@link defineStrike}
|
|
50
|
+
* - {@link defineCode}
|
|
51
|
+
* - {@link defineLink}
|
|
52
|
+
* - {@link defineBaseKeymap}
|
|
53
|
+
* - {@link defineBaseCommands}
|
|
54
|
+
* - {@link defineHistory}
|
|
55
|
+
* - {@link defineGapCursor}
|
|
56
|
+
* - {@link defineVirtualSelection}
|
|
57
|
+
* - {@link defineModClickPrevention}
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
61
|
declare function defineBasicExtension(): BasicExtension;
|
|
62
62
|
//#endregion
|
|
63
|
-
export { BasicExtension, defineBasicExtension };
|
|
63
|
+
export { BasicExtension, defineBasicExtension };
|
|
64
|
+
//# sourceMappingURL=prosekit-basic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-basic.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA;AAA0B,KAAd,cAAA,GAAiB,KAAH,CAAA,CAGtB,YAAA,EACA,aAAA,EACA,kBAAA,EACA,gBAAA,EACA,aAAA,EACA,mBAAA,EACA,cAAA,EACA,uBAAA,EACA,kBAAA,EACA,cAAA,EACA,kBAAA,EAEA,eAAA,EACA,aAAA,EACA,kBAAA,EACA,eAAA,EACA,aAAA,EACA,aAAA,EAEA,mBAAA,EACA,qBAAA,EACA,gBAAA,EACA,kBAAA,EACA,yBAAA,EACA,2BAAA;;AAoCJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,oBAAA,CAAA,GAAwB"}
|
package/dist/prosekit-basic.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prosekit-basic.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n defineBaseCommands,\n defineBaseKeymap,\n defineHistory,\n union,\n type BaseCommandsExtension,\n type BaseKeymapExtension,\n type HistoryExtension,\n type Union,\n} from '@prosekit/core'\nimport {\n defineBlockquote,\n type BlockquoteExtension,\n} from '@prosekit/extensions/blockquote'\nimport {\n defineBold,\n type BoldExtension,\n} from '@prosekit/extensions/bold'\nimport {\n defineCode,\n type CodeExtension,\n} from '@prosekit/extensions/code'\nimport {\n defineCodeBlock,\n type CodeBlockExtension,\n} from '@prosekit/extensions/code-block'\nimport {\n defineDoc,\n type DocExtension,\n} from '@prosekit/extensions/doc'\nimport {\n defineGapCursor,\n type GapCursorExtension,\n} from '@prosekit/extensions/gap-cursor'\nimport {\n defineHardBreak,\n type HardBreakExtension,\n} from '@prosekit/extensions/hard-break'\nimport {\n defineHeading,\n type HeadingExtension,\n} from '@prosekit/extensions/heading'\nimport {\n defineHorizontalRule,\n type HorizontalRuleExtension,\n} from '@prosekit/extensions/horizontal-rule'\nimport {\n defineImage,\n type ImageExtension,\n} from '@prosekit/extensions/image'\nimport {\n defineItalic,\n type ItalicExtension,\n} from '@prosekit/extensions/italic'\nimport {\n defineLink,\n type LinkExtension,\n} from '@prosekit/extensions/link'\nimport {\n defineList,\n type ListExtension,\n} from '@prosekit/extensions/list'\nimport {\n defineModClickPrevention,\n type ModClickPreventionExtension,\n} from '@prosekit/extensions/mod-click-prevention'\nimport {\n defineParagraph,\n type ParagraphExtension,\n} from '@prosekit/extensions/paragraph'\nimport {\n defineStrike,\n type StrikeExtension,\n} from '@prosekit/extensions/strike'\nimport {\n defineTable,\n type TableExtension,\n} from '@prosekit/extensions/table'\nimport {\n defineText,\n type TextExtension,\n} from '@prosekit/extensions/text'\nimport {\n defineUnderline,\n type UnderlineExtension,\n} from '@prosekit/extensions/underline'\nimport {\n defineVirtualSelection,\n type VirtualSelectionExtension,\n} from '@prosekit/extensions/virtual-selection'\n\n/**\n * @internal\n */\nexport type BasicExtension = Union<\n [\n // Nodes\n DocExtension,\n TextExtension,\n ParagraphExtension,\n HeadingExtension,\n ListExtension,\n BlockquoteExtension,\n ImageExtension,\n HorizontalRuleExtension,\n HardBreakExtension,\n TableExtension,\n CodeBlockExtension,\n // Marks\n ItalicExtension,\n BoldExtension,\n UnderlineExtension,\n StrikeExtension,\n CodeExtension,\n LinkExtension,\n // Others\n BaseKeymapExtension,\n BaseCommandsExtension,\n HistoryExtension,\n GapCursorExtension,\n VirtualSelectionExtension,\n ModClickPreventionExtension,\n ]\n>\n\n/**\n * Define a basic extension that includes some common functionality. You can\n * copy this function and customize it to your needs.\n *\n * It's a combination of the following extension functions:\n *\n * - {@link defineDoc}\n * - {@link defineText}\n * - {@link defineParagraph}\n * - {@link defineHeading}\n * - {@link defineList}\n * - {@link defineBlockquote}\n * - {@link defineImage}\n * - {@link defineHorizontalRule}\n * - {@link defineHardBreak}\n * - {@link defineTable}\n * - {@link defineCodeBlock}\n * - {@link defineItalic}\n * - {@link defineBold}\n * - {@link defineUnderline}\n * - {@link defineStrike}\n * - {@link defineCode}\n * - {@link defineLink}\n * - {@link defineBaseKeymap}\n * - {@link defineBaseCommands}\n * - {@link defineHistory}\n * - {@link defineGapCursor}\n * - {@link defineVirtualSelection}\n * - {@link defineModClickPrevention}\n *\n * @public\n */\nexport function defineBasicExtension(): BasicExtension {\n return union(\n // Nodes\n defineDoc(),\n defineText(),\n defineParagraph(),\n defineHeading(),\n defineList(),\n defineBlockquote(),\n defineImage(),\n defineHorizontalRule(),\n defineHardBreak(),\n defineTable(),\n defineCodeBlock(),\n // Marks\n defineItalic(),\n defineBold(),\n defineUnderline(),\n defineStrike(),\n defineCode(),\n defineLink(),\n // Others\n defineBaseKeymap(),\n defineBaseCommands(),\n defineHistory(),\n defineGapCursor(),\n defineVirtualSelection(),\n defineModClickPrevention(),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JA,SAAgB,uBAAuC;AACrD,QAAO,MAEL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EAEjB,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,CAC3B"}
|
package/dist/style.css
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.css","names":[],"sources":["../../../node_modules/.pnpm/prosemirror-view@1.41.3/node_modules/prosemirror-view/style/prosemirror.css","../../pm/src/view/style/prosemirror.css","../../extensions/src/list/style.css","../../extensions/src/table/style.css","../../extensions/src/placeholder/style.css","../../extensions/src/virtual-selection/style.css","../../extensions/src/commit/style.css","../../extensions/src/gap-cursor/style.css","../src/style.css"],"sourcesContent":[".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\n.ProseMirror li {\n position: relative;\n}\n\n.ProseMirror-hideselection *::selection { background: transparent; }\n.ProseMirror-hideselection *::-moz-selection { background: transparent; }\n.ProseMirror-hideselection { caret-color: transparent; }\n\n/* See https://github.com/ProseMirror/prosemirror/issues/1421#issuecomment-1759320191 */\n.ProseMirror [draggable][contenteditable=false] { user-select: text }\n\n.ProseMirror-selectednode {\n outline: 2px solid #8cf;\n}\n\n/* Make sure li selections wrap around markers */\n\nli.ProseMirror-selectednode {\n outline: none;\n}\n\nli.ProseMirror-selectednode:after {\n content: \"\";\n position: absolute;\n left: -32px;\n right: -2px; top: -2px; bottom: -2px;\n border: 2px solid #8cf;\n pointer-events: none;\n}\n\n/* Protect against generic img rules */\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n}\n","@import \"prosemirror-view/style/prosemirror.css\";\n",":root {\n --prosekit-list-bullet-icon: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='2.5' fill='currentColor'/%3E%3C/svg%3E\");\n --prosekit-list-toggle-open-icon: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='8,10 12,14 16,10' fill='currentColor'/%3E%3C/svg%3E\");\n --prosekit-list-toggle-closed-icon: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='10,8 14,12 10,16' fill='currentColor'/%3E%3C/svg%3E\");\n}\n\n.prosemirror-flat-list {\n & {\n position: relative;\n margin: 0;\n padding: 0;\n list-style: none;\n }\n\n & > .list-marker {\n position: absolute;\n left: 0;\n width: 1.5em;\n width: 1lh;\n height: 1.5em;\n height: 1lh;\n text-align: center;\n }\n\n & > .list-content {\n margin-left: 1.5em;\n margin-left: 1lh;\n }\n\n &[data-list-kind=\"bullet\"] > .list-marker,\n &[data-list-kind=\"toggle\"] > .list-marker {\n background-color: currentColor;\n mask-position: center;\n mask-repeat: no-repeat;\n mask-size: contain;\n }\n\n &[data-list-kind=\"bullet\"] {\n & > .list-marker {\n mask-image: var(--prosekit-list-bullet-icon);\n }\n }\n\n &[data-list-kind=\"toggle\"] {\n & > .list-marker {\n mask-image: var(--prosekit-list-toggle-open-icon);\n }\n\n &[data-list-collapsable][data-list-collapsed] > .list-marker {\n mask-image: var(--prosekit-list-toggle-closed-icon);\n }\n }\n\n &[data-list-kind=\"ordered\"] {\n /*\n Ensure that the counters in children don't escape, so that the sub lists\n won't affect the counter of the parent list.\n \n See also https://github.com/ocavue/prosemirror-flat-list/issues/23\n */\n & > * {\n contain: style;\n }\n\n &::before {\n position: absolute;\n right: calc(100% - 1.5em);\n right: calc(100% - 1lh);\n content: counter(prosemirror-flat-list-counter, decimal) \". \";\n font-variant-numeric: tabular-nums;\n }\n counter-increment: prosemirror-flat-list-counter;\n\n /* \n Reset the counter for the first list node in the sequence.\n */\n &:first-child,\n :not(&) + & {\n counter-reset: prosemirror-flat-list-counter;\n\n /* \n If the first list node has a custom order number, set the counter to that value.\n */\n &[data-list-order] {\n @supports (counter-set: prosemirror-flat-list-counter 1) {\n counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);\n }\n\n /* \n Safari older than version 17.2 doesn't support `counter-set` \n */\n @supports not (counter-set: prosemirror-flat-list-counter 1) {\n counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);\n }\n }\n }\n }\n\n &[data-list-kind=\"task\"] {\n & > .list-marker {\n &,\n & * {\n /* Make sure that the checkbox is at the center */\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n padding: 0;\n cursor: pointer;\n }\n }\n }\n\n &[data-list-kind=\"toggle\"] {\n &[data-list-collapsable] > .list-marker {\n cursor: pointer;\n }\n &:not([data-list-collapsable]) > .list-marker {\n opacity: 40%;\n pointer-events: none;\n }\n\n /* If collapsed, hide the second and futher children */\n &[data-list-collapsable][data-list-collapsed] > .list-content > *:nth-child(n+2) {\n display: none;\n }\n }\n}\n",".ProseMirror .tableWrapper {\n overflow-x: auto;\n}\n.ProseMirror table {\n width: 100%;\n overflow: hidden;\n border-collapse: collapse;\n table-layout: fixed;\n}\n.ProseMirror td,\n.ProseMirror th {\n box-sizing: border-box;\n position: relative;\n padding-right: 0.75rem;\n padding-left: 0.75rem;\n border-width: 1px;\n vertical-align: top;\n}\n\nprosekit-table-handle-drop-indicator {\n background-color: HighlightText;\n}\n\n.ProseMirror .column-resize-handle {\n z-index: 20;\n position: absolute;\n top: 0;\n right: -2px;\n bottom: 0;\n width: 4px;\n background-color: HighlightText;\n pointer-events: none;\n}\n.ProseMirror.resize-cursor {\n cursor: ew-resize;\n cursor: col-resize;\n}\n.ProseMirror .selectedCell {\n --color: 210, 100%, 56%;\n border: 1px double hsl(var(--color));\n background-color: hsla(var(--color), 20%);\n}\n",".prosekit-placeholder::before {\n position: absolute;\n height: 0;\n content: attr(data-placeholder);\n opacity: 30%;\n pointer-events: none;\n}\n",".prosekit-virtual-selection {\n border-radius: 2px;\n background-color: #8888884d;\n box-shadow: 0 0 0 2px #8888884d;\n}\n",".prosekit-commit-deletion {\n background-color: #e5534b80;\n text-decoration: line-through;\n}\n.prosekit-commit-addition {\n background-color: #53e54b80;\n}\n",".ProseMirror-gapcursor {\n display: none;\n position: relative;\n pointer-events: none;\n}\n\n.ProseMirror-gapcursor:after {\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid currentColor;\n content: \"\";\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n","@import \"@prosekit/pm/view/style/prosemirror.css\";\n@import \"@prosekit/extensions/list/style.css\";\n@import \"@prosekit/extensions/table/style.css\";\n@import \"@prosekit/extensions/placeholder/style.css\";\n@import \"@prosekit/extensions/virtual-selection/style.css\";\n@import \"@prosekit/extensions/commit/style.css\";\n@import \"@prosekit/extensions/gap-cursor/style.css\";\n"],"x_google_ignoreList":[0],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;;AErDA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzCA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACA;AACA;AACA;AACA;;ACJA;AACA;AACA;AACA;AACA;AACA;AACA;;ACNA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA"}
|
package/dist/style.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/typography.css
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography.css","names":[],"sources":["../src/typography.css"],"sourcesContent":[":root {\n --prosekit-node-selection-color: rgba(57, 136, 255, 0.2);\n}\n\n.ProseMirror {\n & {\n /* Disable margin collapsing */\n display: flex;\n flex-direction: column;\n }\n\n & {\n /* Set the default line height as same as block handle's height */\n line-height: 1.5;\n }\n\n & p:first-child,\n & h1:first-child,\n & h2:first-child,\n & h3:first-child,\n & h4:first-child,\n & h5:first-child,\n & h6:first-child {\n margin-top: 0;\n }\n\n & p:last-child,\n & h1:last-child,\n & h2:last-child,\n & h3:last-child,\n & h4:last-child,\n & h5:last-child,\n & h6:last-child {\n margin-bottom: 0;\n }\n\n & h1,\n & h2,\n & h3,\n & h4,\n & h5,\n & h6 {\n padding-top: 0;\n padding-bottom: 0;\n border-style: none;\n font-weight: 600;\n line-height: 1.25;\n }\n\n & a {\n font-weight: 500;\n text-decoration: underline;\n }\n\n & p,\n & ul,\n & ol,\n & pre {\n margin: 0;\n padding: 0.5rem 0;\n line-height: 1.5;\n }\n\n & blockquote {\n padding-left: 1em;\n border-left: 0.25em solid hsl(0 0% 60% / 0.4);\n }\n\n & h1 {\n margin: 1rem 0;\n font-size: 2.25em;\n }\n\n & h2 {\n margin: 1.75em 0 0.5em;\n font-size: 1.75em;\n }\n\n & h3 {\n margin: 1.5em 0 0.5em;\n font-size: 1.375em;\n }\n\n & h4 {\n margin: 1em 0;\n font-size: 1.125em;\n }\n\n & h5 {\n margin: 0.5em 0;\n }\n\n & h6 {\n opacity: 0.8;\n }\n\n & img,\n & video {\n width: min-content;\n max-width: 100%;\n margin: 0.5em 0;\n }\n\n & code {\n font-weight: 600;\n font-size: 0.875em;\n }\n\n & pre {\n margin: 0.5rem 0;\n padding: 2rem 2rem;\n overflow-x: auto;\n border: 1px solid hsl(0 0% 50% / 0.2);\n border-radius: 0.375rem;\n /* CSS variables `prosemirror-highlight` and `prosemirror-highlight-bg` are set by package `prosemirror-highlight` */\n background-color: var(--prosemirror-highlight-bg, inherit);\n color: var(--prosemirror-highlight, inherit);\n }\n\n & pre,\n & code {\n white-space: pre;\n word-break: normal;\n word-spacing: normal;\n word-wrap: normal;\n hyphens: none;\n tab-size: 4;\n }\n\n & pre code {\n font-weight: inherit;\n }\n\n & hr {\n margin: 2em 0;\n border-width: 1px;\n }\n\n & .prosekit-horizontal-rule {\n margin: 1em 0;\n padding: 1em 0;\n /* Set a small line-height so that the block handle can align to the middle\n of the horizontal rule */\n line-height: 1px;\n\n & hr {\n margin: 0;\n }\n }\n\n & .tableWrapper {\n margin-top: 0.5em;\n margin-bottom: 1em;\n }\n\n & .prosemirror-flat-list {\n /* Use the same line-height as <p> */\n line-height: 1.5;\n\n &::before,\n & > .list-marker {\n /* Use the same padding as <p> */\n top: 0.5rem;\n }\n\n &:has(> div.list-content > h1) {\n &::before,\n & > .list-marker {\n top: 0.75em;\n }\n }\n &:has(> div.list-content > h2) {\n &::before,\n & > .list-marker {\n top: 0.5em;\n }\n }\n &:has(> div.list-content > h3) {\n &::before,\n & > .list-marker {\n top: 0.25em;\n }\n }\n &:has(> div.list-content > h4) {\n &::before,\n & > .list-marker {\n top: 0;\n }\n }\n &:has(> div.list-content > h5) {\n &::before,\n & > .list-marker {\n top: -0.2em;\n }\n }\n &:has(> div.list-content > h6) {\n &::before,\n & > .list-marker {\n top: -0.3em;\n }\n }\n }\n\n /*\n Don't generate box for node view wrapper. This make it easier to style\n the node views.\n */\n div[data-node-view-root=\"true\"] {\n display: contents;\n }\n\n & .ProseMirror-selectednode {\n border-radius: 0.2rem;\n outline-color: var(--prosekit-node-selection-color);\n outline-style: solid;\n outline-width: 0.3rem;\n background-color: var(--prosekit-node-selection-color);\n }\n\n &.prosekit-dragging {\n --prosekit-node-selection-color: transparent;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA"}
|
package/dist/typography.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosekit/basic",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "A quick starter for ProseKit",
|
|
7
7
|
"author": {
|
|
@@ -38,19 +38,20 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
|
-
"dist"
|
|
41
|
+
"dist",
|
|
42
|
+
"src"
|
|
42
43
|
],
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@prosekit/core": "^0.8.
|
|
45
|
-
"@prosekit/pm": "^0.1.
|
|
46
|
-
"@prosekit/extensions": "^0.11.
|
|
45
|
+
"@prosekit/core": "^0.8.4",
|
|
46
|
+
"@prosekit/pm": "^0.1.12",
|
|
47
|
+
"@prosekit/extensions": "^0.11.7"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@types/jsdom": "^
|
|
50
|
-
"happy-dom": "^
|
|
51
|
-
"jsdom": "^
|
|
52
|
-
"tsdown": "^0.
|
|
53
|
-
"typescript": "~5.
|
|
50
|
+
"@types/jsdom": "^27.0.0",
|
|
51
|
+
"happy-dom": "^20.0.0",
|
|
52
|
+
"jsdom": "^27.0.0",
|
|
53
|
+
"tsdown": "^0.15.6",
|
|
54
|
+
"typescript": "~5.9.2",
|
|
54
55
|
"vitest": "^3.2.4",
|
|
55
56
|
"@prosekit/config-tsdown": "0.0.0",
|
|
56
57
|
"@prosekit/config-vitest": "0.0.0"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createEditor,
|
|
3
|
+
union,
|
|
4
|
+
} from '@prosekit/core'
|
|
5
|
+
import {
|
|
6
|
+
describe,
|
|
7
|
+
expect,
|
|
8
|
+
it,
|
|
9
|
+
} from 'vitest'
|
|
10
|
+
|
|
11
|
+
import { defineBasicExtension } from './index'
|
|
12
|
+
|
|
13
|
+
describe('defineBasicExtension', () => {
|
|
14
|
+
it('can add nodes and marks', () => {
|
|
15
|
+
const extension = union(defineBasicExtension())
|
|
16
|
+
const editor = createEditor({ extension })
|
|
17
|
+
const schema = editor.schema
|
|
18
|
+
const nodes = Object.keys(schema.nodes).sort()
|
|
19
|
+
const marks = Object.keys(schema.marks).sort()
|
|
20
|
+
|
|
21
|
+
expect(nodes).toContain('heading')
|
|
22
|
+
expect(nodes).toContain('list')
|
|
23
|
+
expect(nodes).toContain('paragraph')
|
|
24
|
+
expect(nodes).toContain('text')
|
|
25
|
+
expect(nodes).toContain('doc')
|
|
26
|
+
|
|
27
|
+
expect(marks).toContain('italic')
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
describe('BasicExtension', () => {
|
|
32
|
+
const extension = defineBasicExtension()
|
|
33
|
+
const editor = createEditor({ extension })
|
|
34
|
+
|
|
35
|
+
it('can throw TypeScript error for non existing command', () => {
|
|
36
|
+
expect(() => {
|
|
37
|
+
// @ts-expect-error: expected to throw
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
39
|
+
editor.commands.this_command_does_not_exit()
|
|
40
|
+
}).toThrow()
|
|
41
|
+
|
|
42
|
+
expect(() => {
|
|
43
|
+
editor.commands.insertNode({ type: 'heading' })
|
|
44
|
+
}).not.toThrow()
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('can throw TypeScript error for incorrect command arguments', () => {
|
|
48
|
+
expect(() => {
|
|
49
|
+
// @ts-expect-error: expected to throw
|
|
50
|
+
editor.commands.insertNode({ this_argument_does_not_exist: true })
|
|
51
|
+
}).toThrow()
|
|
52
|
+
|
|
53
|
+
expect(() => {
|
|
54
|
+
editor.commands.insertNode({ type: 'heading' })
|
|
55
|
+
}).not.toThrow()
|
|
56
|
+
})
|
|
57
|
+
})
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineBaseCommands,
|
|
3
|
+
defineBaseKeymap,
|
|
4
|
+
defineHistory,
|
|
5
|
+
union,
|
|
6
|
+
type BaseCommandsExtension,
|
|
7
|
+
type BaseKeymapExtension,
|
|
8
|
+
type HistoryExtension,
|
|
9
|
+
type Union,
|
|
10
|
+
} from '@prosekit/core'
|
|
11
|
+
import {
|
|
12
|
+
defineBlockquote,
|
|
13
|
+
type BlockquoteExtension,
|
|
14
|
+
} from '@prosekit/extensions/blockquote'
|
|
15
|
+
import {
|
|
16
|
+
defineBold,
|
|
17
|
+
type BoldExtension,
|
|
18
|
+
} from '@prosekit/extensions/bold'
|
|
19
|
+
import {
|
|
20
|
+
defineCode,
|
|
21
|
+
type CodeExtension,
|
|
22
|
+
} from '@prosekit/extensions/code'
|
|
23
|
+
import {
|
|
24
|
+
defineCodeBlock,
|
|
25
|
+
type CodeBlockExtension,
|
|
26
|
+
} from '@prosekit/extensions/code-block'
|
|
27
|
+
import {
|
|
28
|
+
defineDoc,
|
|
29
|
+
type DocExtension,
|
|
30
|
+
} from '@prosekit/extensions/doc'
|
|
31
|
+
import {
|
|
32
|
+
defineGapCursor,
|
|
33
|
+
type GapCursorExtension,
|
|
34
|
+
} from '@prosekit/extensions/gap-cursor'
|
|
35
|
+
import {
|
|
36
|
+
defineHardBreak,
|
|
37
|
+
type HardBreakExtension,
|
|
38
|
+
} from '@prosekit/extensions/hard-break'
|
|
39
|
+
import {
|
|
40
|
+
defineHeading,
|
|
41
|
+
type HeadingExtension,
|
|
42
|
+
} from '@prosekit/extensions/heading'
|
|
43
|
+
import {
|
|
44
|
+
defineHorizontalRule,
|
|
45
|
+
type HorizontalRuleExtension,
|
|
46
|
+
} from '@prosekit/extensions/horizontal-rule'
|
|
47
|
+
import {
|
|
48
|
+
defineImage,
|
|
49
|
+
type ImageExtension,
|
|
50
|
+
} from '@prosekit/extensions/image'
|
|
51
|
+
import {
|
|
52
|
+
defineItalic,
|
|
53
|
+
type ItalicExtension,
|
|
54
|
+
} from '@prosekit/extensions/italic'
|
|
55
|
+
import {
|
|
56
|
+
defineLink,
|
|
57
|
+
type LinkExtension,
|
|
58
|
+
} from '@prosekit/extensions/link'
|
|
59
|
+
import {
|
|
60
|
+
defineList,
|
|
61
|
+
type ListExtension,
|
|
62
|
+
} from '@prosekit/extensions/list'
|
|
63
|
+
import {
|
|
64
|
+
defineModClickPrevention,
|
|
65
|
+
type ModClickPreventionExtension,
|
|
66
|
+
} from '@prosekit/extensions/mod-click-prevention'
|
|
67
|
+
import {
|
|
68
|
+
defineParagraph,
|
|
69
|
+
type ParagraphExtension,
|
|
70
|
+
} from '@prosekit/extensions/paragraph'
|
|
71
|
+
import {
|
|
72
|
+
defineStrike,
|
|
73
|
+
type StrikeExtension,
|
|
74
|
+
} from '@prosekit/extensions/strike'
|
|
75
|
+
import {
|
|
76
|
+
defineTable,
|
|
77
|
+
type TableExtension,
|
|
78
|
+
} from '@prosekit/extensions/table'
|
|
79
|
+
import {
|
|
80
|
+
defineText,
|
|
81
|
+
type TextExtension,
|
|
82
|
+
} from '@prosekit/extensions/text'
|
|
83
|
+
import {
|
|
84
|
+
defineUnderline,
|
|
85
|
+
type UnderlineExtension,
|
|
86
|
+
} from '@prosekit/extensions/underline'
|
|
87
|
+
import {
|
|
88
|
+
defineVirtualSelection,
|
|
89
|
+
type VirtualSelectionExtension,
|
|
90
|
+
} from '@prosekit/extensions/virtual-selection'
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export type BasicExtension = Union<
|
|
96
|
+
[
|
|
97
|
+
// Nodes
|
|
98
|
+
DocExtension,
|
|
99
|
+
TextExtension,
|
|
100
|
+
ParagraphExtension,
|
|
101
|
+
HeadingExtension,
|
|
102
|
+
ListExtension,
|
|
103
|
+
BlockquoteExtension,
|
|
104
|
+
ImageExtension,
|
|
105
|
+
HorizontalRuleExtension,
|
|
106
|
+
HardBreakExtension,
|
|
107
|
+
TableExtension,
|
|
108
|
+
CodeBlockExtension,
|
|
109
|
+
// Marks
|
|
110
|
+
ItalicExtension,
|
|
111
|
+
BoldExtension,
|
|
112
|
+
UnderlineExtension,
|
|
113
|
+
StrikeExtension,
|
|
114
|
+
CodeExtension,
|
|
115
|
+
LinkExtension,
|
|
116
|
+
// Others
|
|
117
|
+
BaseKeymapExtension,
|
|
118
|
+
BaseCommandsExtension,
|
|
119
|
+
HistoryExtension,
|
|
120
|
+
GapCursorExtension,
|
|
121
|
+
VirtualSelectionExtension,
|
|
122
|
+
ModClickPreventionExtension,
|
|
123
|
+
]
|
|
124
|
+
>
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Define a basic extension that includes some common functionality. You can
|
|
128
|
+
* copy this function and customize it to your needs.
|
|
129
|
+
*
|
|
130
|
+
* It's a combination of the following extension functions:
|
|
131
|
+
*
|
|
132
|
+
* - {@link defineDoc}
|
|
133
|
+
* - {@link defineText}
|
|
134
|
+
* - {@link defineParagraph}
|
|
135
|
+
* - {@link defineHeading}
|
|
136
|
+
* - {@link defineList}
|
|
137
|
+
* - {@link defineBlockquote}
|
|
138
|
+
* - {@link defineImage}
|
|
139
|
+
* - {@link defineHorizontalRule}
|
|
140
|
+
* - {@link defineHardBreak}
|
|
141
|
+
* - {@link defineTable}
|
|
142
|
+
* - {@link defineCodeBlock}
|
|
143
|
+
* - {@link defineItalic}
|
|
144
|
+
* - {@link defineBold}
|
|
145
|
+
* - {@link defineUnderline}
|
|
146
|
+
* - {@link defineStrike}
|
|
147
|
+
* - {@link defineCode}
|
|
148
|
+
* - {@link defineLink}
|
|
149
|
+
* - {@link defineBaseKeymap}
|
|
150
|
+
* - {@link defineBaseCommands}
|
|
151
|
+
* - {@link defineHistory}
|
|
152
|
+
* - {@link defineGapCursor}
|
|
153
|
+
* - {@link defineVirtualSelection}
|
|
154
|
+
* - {@link defineModClickPrevention}
|
|
155
|
+
*
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
export function defineBasicExtension(): BasicExtension {
|
|
159
|
+
return union(
|
|
160
|
+
// Nodes
|
|
161
|
+
defineDoc(),
|
|
162
|
+
defineText(),
|
|
163
|
+
defineParagraph(),
|
|
164
|
+
defineHeading(),
|
|
165
|
+
defineList(),
|
|
166
|
+
defineBlockquote(),
|
|
167
|
+
defineImage(),
|
|
168
|
+
defineHorizontalRule(),
|
|
169
|
+
defineHardBreak(),
|
|
170
|
+
defineTable(),
|
|
171
|
+
defineCodeBlock(),
|
|
172
|
+
// Marks
|
|
173
|
+
defineItalic(),
|
|
174
|
+
defineBold(),
|
|
175
|
+
defineUnderline(),
|
|
176
|
+
defineStrike(),
|
|
177
|
+
defineCode(),
|
|
178
|
+
defineLink(),
|
|
179
|
+
// Others
|
|
180
|
+
defineBaseKeymap(),
|
|
181
|
+
defineBaseCommands(),
|
|
182
|
+
defineHistory(),
|
|
183
|
+
defineGapCursor(),
|
|
184
|
+
defineVirtualSelection(),
|
|
185
|
+
defineModClickPrevention(),
|
|
186
|
+
)
|
|
187
|
+
}
|
package/src/node.spec.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
|
|
3
|
+
import { createEditor } from '@prosekit/core'
|
|
4
|
+
import {
|
|
5
|
+
describe,
|
|
6
|
+
expect,
|
|
7
|
+
it,
|
|
8
|
+
} from 'vitest'
|
|
9
|
+
|
|
10
|
+
import { defineBasicExtension } from './index'
|
|
11
|
+
|
|
12
|
+
describe('Node.js environment', () => {
|
|
13
|
+
it('is not a browser environment', () => {
|
|
14
|
+
expect(typeof window).toBe('undefined')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('can create an editor', () => {
|
|
18
|
+
const extension = defineBasicExtension()
|
|
19
|
+
const editor = createEditor({ extension })
|
|
20
|
+
|
|
21
|
+
expect(editor).toBeDefined()
|
|
22
|
+
expect(editor.mounted).toBe(false)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('can call editor.setContent() with a JSON object', () => {
|
|
26
|
+
const extension = defineBasicExtension()
|
|
27
|
+
const editor = createEditor({ extension })
|
|
28
|
+
|
|
29
|
+
// Set the document
|
|
30
|
+
editor.setContent({
|
|
31
|
+
type: 'doc',
|
|
32
|
+
content: [
|
|
33
|
+
{ type: 'paragraph', content: [{ type: 'text', text: 'Hello, world!' }] },
|
|
34
|
+
],
|
|
35
|
+
})
|
|
36
|
+
expect(editor.getDocJSON()).toMatchInlineSnapshot(`
|
|
37
|
+
{
|
|
38
|
+
"content": [
|
|
39
|
+
{
|
|
40
|
+
"content": [
|
|
41
|
+
{
|
|
42
|
+
"text": "Hello, world!",
|
|
43
|
+
"type": "text",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
"type": "paragraph",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
"type": "doc",
|
|
50
|
+
}
|
|
51
|
+
`)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('can execute a command', () => {
|
|
55
|
+
const extension = defineBasicExtension()
|
|
56
|
+
const editor = createEditor({ extension })
|
|
57
|
+
|
|
58
|
+
// Execute a command
|
|
59
|
+
editor.commands.insertImage({ src: 'https://example.com/image.png', width: 100, height: 100 })
|
|
60
|
+
expect(editor.state.doc.toJSON()).toMatchInlineSnapshot(`
|
|
61
|
+
{
|
|
62
|
+
"content": [
|
|
63
|
+
{
|
|
64
|
+
"attrs": {
|
|
65
|
+
"height": 100,
|
|
66
|
+
"src": "https://example.com/image.png",
|
|
67
|
+
"width": 100,
|
|
68
|
+
},
|
|
69
|
+
"type": "image",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "paragraph",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
"type": "doc",
|
|
76
|
+
}
|
|
77
|
+
`)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('cannot call HTML APIs by default', () => {
|
|
81
|
+
const extension = defineBasicExtension()
|
|
82
|
+
const editor = createEditor({ extension })
|
|
83
|
+
|
|
84
|
+
expect(() => editor.setContent('<p>Hello World</p>')).toThrow()
|
|
85
|
+
expect(() => editor.getDocHTML()).toThrow()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('can call HTML APIs using jsdom', async () => {
|
|
89
|
+
const extension = defineBasicExtension()
|
|
90
|
+
const editor = createEditor({ extension })
|
|
91
|
+
|
|
92
|
+
const { JSDOM } = await import('jsdom')
|
|
93
|
+
const dom = new JSDOM('')
|
|
94
|
+
const document: Document = dom.window.document
|
|
95
|
+
|
|
96
|
+
editor.setContent({
|
|
97
|
+
type: 'doc',
|
|
98
|
+
content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Foo' }] }],
|
|
99
|
+
})
|
|
100
|
+
editor.commands.insertText({ text: 'Bar' })
|
|
101
|
+
expect(editor.getDocHTML({ document })).toMatchInlineSnapshot(`"<div><p>BarFoo</p></div>"`)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('can call HTML APIs using happy-dom', async () => {
|
|
105
|
+
const extension = defineBasicExtension()
|
|
106
|
+
const editor = createEditor({ extension })
|
|
107
|
+
|
|
108
|
+
const { Window } = await import('happy-dom')
|
|
109
|
+
const window = new Window()
|
|
110
|
+
// @ts-expect-error - happy-dom types are not compatible with DOM types
|
|
111
|
+
const document: Document = window.document
|
|
112
|
+
|
|
113
|
+
editor.setContent({
|
|
114
|
+
type: 'doc',
|
|
115
|
+
content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Foo' }] }],
|
|
116
|
+
})
|
|
117
|
+
editor.commands.insertText({ text: 'Bar' })
|
|
118
|
+
expect(editor.getDocHTML({ document })).toMatchInlineSnapshot(`"<div><p>BarFoo</p></div>"`)
|
|
119
|
+
})
|
|
120
|
+
})
|
package/src/style.css
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@import "@prosekit/pm/view/style/prosemirror.css";
|
|
2
|
+
@import "@prosekit/extensions/list/style.css";
|
|
3
|
+
@import "@prosekit/extensions/table/style.css";
|
|
4
|
+
@import "@prosekit/extensions/placeholder/style.css";
|
|
5
|
+
@import "@prosekit/extensions/virtual-selection/style.css";
|
|
6
|
+
@import "@prosekit/extensions/commit/style.css";
|
|
7
|
+
@import "@prosekit/extensions/gap-cursor/style.css";
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--prosekit-node-selection-color: rgba(57, 136, 255, 0.2);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.ProseMirror {
|
|
6
|
+
& {
|
|
7
|
+
/* Disable margin collapsing */
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
& {
|
|
13
|
+
/* Set the default line height as same as block handle's height */
|
|
14
|
+
line-height: 1.5;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
& p:first-child,
|
|
18
|
+
& h1:first-child,
|
|
19
|
+
& h2:first-child,
|
|
20
|
+
& h3:first-child,
|
|
21
|
+
& h4:first-child,
|
|
22
|
+
& h5:first-child,
|
|
23
|
+
& h6:first-child {
|
|
24
|
+
margin-top: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
& p:last-child,
|
|
28
|
+
& h1:last-child,
|
|
29
|
+
& h2:last-child,
|
|
30
|
+
& h3:last-child,
|
|
31
|
+
& h4:last-child,
|
|
32
|
+
& h5:last-child,
|
|
33
|
+
& h6:last-child {
|
|
34
|
+
margin-bottom: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
& h1,
|
|
38
|
+
& h2,
|
|
39
|
+
& h3,
|
|
40
|
+
& h4,
|
|
41
|
+
& h5,
|
|
42
|
+
& h6 {
|
|
43
|
+
padding-top: 0;
|
|
44
|
+
padding-bottom: 0;
|
|
45
|
+
border-style: none;
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
line-height: 1.25;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
& a {
|
|
51
|
+
font-weight: 500;
|
|
52
|
+
text-decoration: underline;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
& p,
|
|
56
|
+
& ul,
|
|
57
|
+
& ol,
|
|
58
|
+
& pre {
|
|
59
|
+
margin: 0;
|
|
60
|
+
padding: 0.5rem 0;
|
|
61
|
+
line-height: 1.5;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
& blockquote {
|
|
65
|
+
padding-left: 1em;
|
|
66
|
+
border-left: 0.25em solid hsl(0 0% 60% / 0.4);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
& h1 {
|
|
70
|
+
margin: 1rem 0;
|
|
71
|
+
font-size: 2.25em;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
& h2 {
|
|
75
|
+
margin: 1.75em 0 0.5em;
|
|
76
|
+
font-size: 1.75em;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
& h3 {
|
|
80
|
+
margin: 1.5em 0 0.5em;
|
|
81
|
+
font-size: 1.375em;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
& h4 {
|
|
85
|
+
margin: 1em 0;
|
|
86
|
+
font-size: 1.125em;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
& h5 {
|
|
90
|
+
margin: 0.5em 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
& h6 {
|
|
94
|
+
opacity: 0.8;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
& img,
|
|
98
|
+
& video {
|
|
99
|
+
width: min-content;
|
|
100
|
+
max-width: 100%;
|
|
101
|
+
margin: 0.5em 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
& code {
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
font-size: 0.875em;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
& pre {
|
|
110
|
+
margin: 0.5rem 0;
|
|
111
|
+
padding: 2rem 2rem;
|
|
112
|
+
overflow-x: auto;
|
|
113
|
+
border: 1px solid hsl(0 0% 50% / 0.2);
|
|
114
|
+
border-radius: 0.375rem;
|
|
115
|
+
/* CSS variables `prosemirror-highlight` and `prosemirror-highlight-bg` are set by package `prosemirror-highlight` */
|
|
116
|
+
background-color: var(--prosemirror-highlight-bg, inherit);
|
|
117
|
+
color: var(--prosemirror-highlight, inherit);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
& pre,
|
|
121
|
+
& code {
|
|
122
|
+
white-space: pre;
|
|
123
|
+
word-break: normal;
|
|
124
|
+
word-spacing: normal;
|
|
125
|
+
word-wrap: normal;
|
|
126
|
+
hyphens: none;
|
|
127
|
+
tab-size: 4;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
& pre code {
|
|
131
|
+
font-weight: inherit;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
& hr {
|
|
135
|
+
margin: 2em 0;
|
|
136
|
+
border-width: 1px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
& .prosekit-horizontal-rule {
|
|
140
|
+
margin: 1em 0;
|
|
141
|
+
padding: 1em 0;
|
|
142
|
+
/* Set a small line-height so that the block handle can align to the middle
|
|
143
|
+
of the horizontal rule */
|
|
144
|
+
line-height: 1px;
|
|
145
|
+
|
|
146
|
+
& hr {
|
|
147
|
+
margin: 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
& .tableWrapper {
|
|
152
|
+
margin-top: 0.5em;
|
|
153
|
+
margin-bottom: 1em;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
& .prosemirror-flat-list {
|
|
157
|
+
/* Use the same line-height as <p> */
|
|
158
|
+
line-height: 1.5;
|
|
159
|
+
|
|
160
|
+
&::before,
|
|
161
|
+
& > .list-marker {
|
|
162
|
+
/* Use the same padding as <p> */
|
|
163
|
+
top: 0.5rem;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&:has(> div.list-content > h1) {
|
|
167
|
+
&::before,
|
|
168
|
+
& > .list-marker {
|
|
169
|
+
top: 0.75em;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
&:has(> div.list-content > h2) {
|
|
173
|
+
&::before,
|
|
174
|
+
& > .list-marker {
|
|
175
|
+
top: 0.5em;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
&:has(> div.list-content > h3) {
|
|
179
|
+
&::before,
|
|
180
|
+
& > .list-marker {
|
|
181
|
+
top: 0.25em;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
&:has(> div.list-content > h4) {
|
|
185
|
+
&::before,
|
|
186
|
+
& > .list-marker {
|
|
187
|
+
top: 0;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
&:has(> div.list-content > h5) {
|
|
191
|
+
&::before,
|
|
192
|
+
& > .list-marker {
|
|
193
|
+
top: -0.2em;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
&:has(> div.list-content > h6) {
|
|
197
|
+
&::before,
|
|
198
|
+
& > .list-marker {
|
|
199
|
+
top: -0.3em;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/*
|
|
205
|
+
Don't generate box for node view wrapper. This make it easier to style
|
|
206
|
+
the node views.
|
|
207
|
+
*/
|
|
208
|
+
div[data-node-view-root="true"] {
|
|
209
|
+
display: contents;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
& .ProseMirror-selectednode {
|
|
213
|
+
border-radius: 0.2rem;
|
|
214
|
+
outline-color: var(--prosekit-node-selection-color);
|
|
215
|
+
outline-style: solid;
|
|
216
|
+
outline-width: 0.3rem;
|
|
217
|
+
background-color: var(--prosekit-node-selection-color);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
&.prosekit-dragging {
|
|
221
|
+
--prosekit-node-selection-color: transparent;
|
|
222
|
+
}
|
|
223
|
+
}
|