Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 18:09:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 18:09:08 +0300
commitcc1066db64a2a283a3d229b9bbb67c01716ca871 (patch)
treec5a518fabe9bb87b17a1f99b6c2616144170ebeb /app/assets/javascripts/content_editor
parent5c5d24f032b67d98452f391192386e330a0f880c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/content_editor')
-rw-r--r--app/assets/javascripts/content_editor/services/hast_to_prosemirror_converter.js25
-rw-r--r--app/assets/javascripts/content_editor/services/remark_markdown_deserializer.js18
2 files changed, 9 insertions, 34 deletions
diff --git a/app/assets/javascripts/content_editor/services/hast_to_prosemirror_converter.js b/app/assets/javascripts/content_editor/services/hast_to_prosemirror_converter.js
index 6544cd192f9..312ab88de4a 100644
--- a/app/assets/javascripts/content_editor/services/hast_to_prosemirror_converter.js
+++ b/app/assets/javascripts/content_editor/services/hast_to_prosemirror_converter.js
@@ -21,7 +21,6 @@
import { Mark } from 'prosemirror-model';
import { visitParents, SKIP } from 'unist-util-visit-parents';
-import { toString } from 'hast-util-to-string';
import { isFunction, isString, noop } from 'lodash';
const NO_ATTRIBUTES = {};
@@ -357,15 +356,6 @@ const createProseMirrorNodeFactories = (schema, proseMirrorFactorySpecs, markdow
state.closeUntil(parent);
state.openNode(nodeType, hastNode, getAttrs(factory, hastNode, parent, markdown), factory);
-
- /**
- * If a getContent function is provided, we immediately close
- * the node to delegate content processing to this function.
- * */
- if (isFunction(factory.getContent)) {
- state.addText(schema, factory.getContent({ hastNode, hastNodeText: toString(hastNode) }));
- state.closeNode();
- }
};
} else if (factory.type === 'inline') {
const nodeType = schema.nodeType(proseMirrorName);
@@ -571,19 +561,6 @@ const wrapInlineElements = (nodes, wrappableTags) =>
* it allows applying a processing function to that text. This is useful when
* you can transform the text node, i.e trim(), substring(), etc.
*
- * **skipChildren**
- *
- * Skips a hast node’s children while traversing the tree.
- *
- * **getContent**
- *
- * Allows to pass a custom function that returns the content of a block node. The
- * Content is limited to a single text node therefore the function should return
- * a String value.
- *
- * Use this property along skipChildren to provide custom processing of child nodes
- * for a block node.
- *
* **parent**
*
* Specifies what is the node’s parent. This is useful when the node’s parent is not
@@ -634,7 +611,7 @@ export const createProseMirrorDocFromMdastTree = ({
factory.handle(state, hastNode, parent);
- return factory.skipChildren === true ? SKIP : true;
+ return true;
});
return state.buildDoc();
diff --git a/app/assets/javascripts/content_editor/services/remark_markdown_deserializer.js b/app/assets/javascripts/content_editor/services/remark_markdown_deserializer.js
index b3815262639..8e2c066e011 100644
--- a/app/assets/javascripts/content_editor/services/remark_markdown_deserializer.js
+++ b/app/assets/javascripts/content_editor/services/remark_markdown_deserializer.js
@@ -1,4 +1,3 @@
-import { isString } from 'lodash';
import { render } from '~/lib/gfm';
import { createProseMirrorDocFromMdastTree } from './hast_to_prosemirror_converter';
@@ -45,15 +44,8 @@ const factorySpecs = {
},
codeBlock: {
type: 'block',
- skipChildren: true,
- selector: 'pre',
- getContent: ({ hastNodeText }) => hastNodeText.replace(/\n$/, ''),
- getAttrs: (hastNode) => {
- const languageClass = hastNode.children[0]?.properties.className?.[0];
- const language = isString(languageClass) ? languageClass.replace('language-', '') : null;
-
- return { language };
- },
+ selector: 'codeblock',
+ getAttrs: (hastNode) => ({ ...hastNode.properties }),
},
horizontalRule: {
type: 'block',
@@ -123,6 +115,11 @@ const factorySpecs = {
selector: 'footnotedefinition',
getAttrs: (hastNode) => hastNode.properties,
},
+ pre: {
+ type: 'block',
+ selector: 'pre',
+ wrapInParagraph: true,
+ },
image: {
type: 'inline',
selector: 'img',
@@ -188,6 +185,7 @@ export default () => {
wrappableTags,
markdown,
}),
+ skipRendering: ['footnoteReference', 'footnoteDefinition', 'code'],
});
return { document };