mirror of
https://github.com/discourse/discourse.git
synced 2026-08-04 02:13:26 -05:00
FEATURE: enforce prosemirror-gapcursor on additional block nodes (#35415)
Enforces the gap cursor using the new `createGapCursor: true` node spec prop to the following block nodes: - `blockquote` - `quote` - `code_block` - `html_block` - `spoiler`
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { setBlockType, toggleMark } from "prosemirror-commands";
|
||||
import { highlightPlugin } from "prosemirror-highlightjs";
|
||||
import { schema as markdownSchema } from "prosemirror-markdown";
|
||||
import { TextSelection } from "prosemirror-state";
|
||||
import { ensureHighlightJs } from "discourse/lib/highlight-syntax";
|
||||
|
||||
@@ -153,6 +154,12 @@ function convertSelectionToCodeBlock(schema) {
|
||||
|
||||
/** @type {RichEditorExtension} */
|
||||
const extension = {
|
||||
nodeSpec: {
|
||||
code_block: {
|
||||
createGapCursor: true,
|
||||
...markdownSchema.nodes.code_block.spec,
|
||||
},
|
||||
},
|
||||
nodeViews: { code_block: CodeBlockWithLangSelectorNodeView },
|
||||
commands: ({ schema }) => ({
|
||||
formatCode() {
|
||||
|
||||
@@ -4,6 +4,7 @@ const extension = {
|
||||
html_block: {
|
||||
attrs: { params: { default: "html" } },
|
||||
group: "block",
|
||||
createGapCursor: true,
|
||||
content: "text*",
|
||||
code: true,
|
||||
defining: true,
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { schema } from "prosemirror-markdown";
|
||||
|
||||
/** @type {RichEditorExtension} */
|
||||
const extension = {
|
||||
nodeSpec: {
|
||||
blockquote: {
|
||||
createGapCursor: true,
|
||||
...schema.nodes.blockquote.spec,
|
||||
},
|
||||
quote: {
|
||||
content: "block+",
|
||||
group: "block",
|
||||
createGapCursor: true,
|
||||
defining: true,
|
||||
attrs: {
|
||||
username: { default: null },
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
"prosemirror-codemark": "^0.4.2",
|
||||
"prosemirror-commands": "^1.7.1",
|
||||
"prosemirror-dropcursor": "^1.8.2",
|
||||
"prosemirror-gapcursor": "^1.3.2",
|
||||
"prosemirror-gapcursor": "^1.4.0",
|
||||
"prosemirror-highlightjs": "^0.9.1",
|
||||
"prosemirror-history": "^1.4.1",
|
||||
"prosemirror-inputrules": "^1.5.0",
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
const extension = {
|
||||
nodeSpec: {
|
||||
details: {
|
||||
allowGapCursor: true,
|
||||
attrs: { open: { default: true } },
|
||||
content: "summary block+",
|
||||
group: "block",
|
||||
|
||||
@@ -9,6 +9,7 @@ const extension = {
|
||||
attrs: { blurred: { default: true } },
|
||||
group: "block",
|
||||
content: "block+",
|
||||
createGapCursor: true,
|
||||
parseDOM: [{ tag: "div.spoiled" }],
|
||||
toDOM: () => ["div", { class: "spoiled" }, 0],
|
||||
},
|
||||
|
||||
Generated
+5
-5
@@ -351,8 +351,8 @@ importers:
|
||||
specifier: ^1.8.2
|
||||
version: 1.8.2
|
||||
prosemirror-gapcursor:
|
||||
specifier: ^1.3.2
|
||||
version: 1.3.2
|
||||
specifier: ^1.4.0
|
||||
version: 1.4.0
|
||||
prosemirror-highlightjs:
|
||||
specifier: ^0.9.1
|
||||
version: 0.9.1(highlight.js@11.11.1)(prosemirror-model@1.25.3)(prosemirror-state@1.4.3)(prosemirror-view@1.41.3)
|
||||
@@ -7557,8 +7557,8 @@ packages:
|
||||
prosemirror-dropcursor@1.8.2:
|
||||
resolution: {integrity: sha512-CCk6Gyx9+Tt2sbYk5NK0nB1ukHi2ryaRgadV/LvyNuO3ena1payM2z6Cg0vO1ebK8cxbzo41ku2DE5Axj1Zuiw==}
|
||||
|
||||
prosemirror-gapcursor@1.3.2:
|
||||
resolution: {integrity: sha512-wtjswVBd2vaQRrnYZaBCbyDqr232Ed4p2QPtRIUK5FuqHYKGWkEwl08oQM4Tw7DOR0FsasARV5uJFvMZWxdNxQ==}
|
||||
prosemirror-gapcursor@1.4.0:
|
||||
resolution: {integrity: sha512-z00qvurSdCEWUIulij/isHaqu4uLS8r/Fi61IbjdIPJEonQgggbJsLnstW7Lgdk4zQ68/yr6B6bf7sJXowIgdQ==}
|
||||
|
||||
prosemirror-highlightjs@0.9.1:
|
||||
resolution: {integrity: sha512-aqcXUCM4Dbc+0DoORrmF4MWrdIJuaJKUpZvzi1xy0HEx06J5vTlnwR25xCUIbxD3ilOtkabB36QqY3WQ03OuzQ==}
|
||||
@@ -17186,7 +17186,7 @@ snapshots:
|
||||
prosemirror-transform: 1.10.4
|
||||
prosemirror-view: 1.41.3
|
||||
|
||||
prosemirror-gapcursor@1.3.2:
|
||||
prosemirror-gapcursor@1.4.0:
|
||||
dependencies:
|
||||
prosemirror-keymap: 1.2.3
|
||||
prosemirror-model: 1.25.3
|
||||
|
||||
Reference in New Issue
Block a user