Commit 5f675418 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'move-render-gfm' into 'master'

Move render gfm to commons and update imports

See merge request gitlab-org/gitlab-ce!15993
parents 956bd6a4 c1708514
import './autosize'; import './autosize';
import './bind_in_out'; import './bind_in_out';
import initCopyAsGFM from './copy_as_gfm'; import './markdown/render_gfm';
import initCopyAsGFM from './markdown/copy_as_gfm';
import initCopyToClipboard from './copy_to_clipboard'; import initCopyToClipboard from './copy_to_clipboard';
import './details_behavior'; import './details_behavior';
import installGlEmojiElement from './gl_emoji'; import installGlEmojiElement from './gl_emoji';
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
import { insertText, getSelectedFragment, nodeMatchesSelector } from '../lib/utils/common_utils'; import { insertText, getSelectedFragment, nodeMatchesSelector } from '~/lib/utils/common_utils';
import { placeholderImage } from '../lazy_loader'; import { placeholderImage } from '~/lazy_loader';
const gfmRules = { const gfmRules = {
// The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert // The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert
......
import $ from 'jquery'; import $ from 'jquery';
import syntaxHighlight from '~/syntax_highlight';
import renderMath from './render_math'; import renderMath from './render_math';
import renderMermaid from './render_mermaid'; import renderMermaid from './render_mermaid';
import syntaxHighlight from './syntax_highlight';
// Render Gitlab flavoured Markdown // Render Gitlab flavoured Markdown
// //
......
import $ from 'jquery'; import $ from 'jquery';
import { __ } from './locale'; import { __ } from '~/locale';
import flash from './flash'; import flash from '~/flash';
// Renders math using KaTeX in any element with the // Renders math using KaTeX in any element with the
// `js-render-math` class // `js-render-math` class
......
import flash from '~/flash';
// Renders diagrams and flowcharts from text using Mermaid in any element with the // Renders diagrams and flowcharts from text using Mermaid in any element with the
// `js-render-mermaid` class. // `js-render-mermaid` class.
// //
...@@ -12,8 +14,6 @@ ...@@ -12,8 +14,6 @@
// </pre> // </pre>
// //
import Flash from './flash';
export default function renderMermaid($els) { export default function renderMermaid($els) {
if (!$els.length) return; if (!$els.length) return;
...@@ -52,6 +52,6 @@ export default function renderMermaid($els) { ...@@ -52,6 +52,6 @@ export default function renderMermaid($els) {
}); });
}); });
}).catch((err) => { }).catch((err) => {
Flash(`Can't load mermaid module: ${err}`); flash(`Can't load mermaid module: ${err}`);
}); });
} }
...@@ -32,7 +32,6 @@ import LazyLoader from './lazy_loader'; ...@@ -32,7 +32,6 @@ import LazyLoader from './lazy_loader';
import initLogoAnimation from './logo'; import initLogoAnimation from './logo';
import './milestone_select'; import './milestone_select';
import './projects_dropdown'; import './projects_dropdown';
import './render_gfm';
import initBreadcrumbs from './breadcrumb'; import initBreadcrumbs from './breadcrumb';
import initDispatcher from './dispatcher'; import initDispatcher from './dispatcher';
......
...@@ -3,7 +3,7 @@ import Mousetrap from 'mousetrap'; ...@@ -3,7 +3,7 @@ import Mousetrap from 'mousetrap';
import _ from 'underscore'; import _ from 'underscore';
import Sidebar from './right_sidebar'; import Sidebar from './right_sidebar';
import Shortcuts from './shortcuts'; import Shortcuts from './shortcuts';
import { CopyAsGFM } from './behaviors/copy_as_gfm'; import { CopyAsGFM } from './behaviors/markdown/copy_as_gfm';
export default class ShortcutsIssuable extends Shortcuts { export default class ShortcutsIssuable extends Shortcuts {
constructor(isMergeRequest) { constructor(isMergeRequest) {
......
...@@ -2,10 +2,10 @@ module Banzai ...@@ -2,10 +2,10 @@ module Banzai
module Pipeline module Pipeline
class GfmPipeline < BasePipeline class GfmPipeline < BasePipeline
# These filters convert GitLab Flavored Markdown (GFM) to HTML. # These filters convert GitLab Flavored Markdown (GFM) to HTML.
# The handlers defined in app/assets/javascripts/copy_as_gfm.js # The handlers defined in app/assets/javascripts/behaviors/markdown/copy_as_gfm.js
# consequently convert that same HTML to GFM to be copied to the clipboard. # consequently convert that same HTML to GFM to be copied to the clipboard.
# Every filter that generates HTML from GFM should have a handler in # Every filter that generates HTML from GFM should have a handler in
# app/assets/javascripts/copy_as_gfm.js, in reverse order. # app/assets/javascripts/behaviors/markdown/copy_as_gfm.js, in reverse order.
# The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb. # The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.
def self.filters def self.filters
@filters ||= FilterArray[ @filters ||= FilterArray[
......
...@@ -20,7 +20,7 @@ describe 'Copy as GFM', :js do ...@@ -20,7 +20,7 @@ describe 'Copy as GFM', :js do
end end
# The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert GitLab Flavored Markdown (GFM) to HTML. # The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert GitLab Flavored Markdown (GFM) to HTML.
# The handlers defined in app/assets/javascripts/copy_as_gfm.js consequently convert that same HTML to GFM. # The handlers defined in app/assets/javascripts/behaviors/markdown/copy_as_gfm.js consequently convert that same HTML to GFM.
# To make sure these filters and handlers are properly aligned, this spec tests the GFM-to-HTML-to-GFM cycle # To make sure these filters and handlers are properly aligned, this spec tests the GFM-to-HTML-to-GFM cycle
# by verifying (`html_to_gfm(gfm_to_html(gfm)) == gfm`) for a number of examples of GFM for every filter, using the `verify` helper. # by verifying (`html_to_gfm(gfm_to_html(gfm)) == gfm`) for a number of examples of GFM for every filter, using the `verify` helper.
......
import { CopyAsGFM } from '~/behaviors/copy_as_gfm'; import { CopyAsGFM } from '~/behaviors/markdown/copy_as_gfm';
describe('CopyAsGFM', () => { describe('CopyAsGFM', () => {
describe('CopyAsGFM.pasteGFM', () => { describe('CopyAsGFM.pasteGFM', () => {
......
import Vue from 'vue'; import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import '~/render_math'; import '~/behaviors/markdown/render_gfm';
import '~/render_gfm';
import * as urlUtils from '~/lib/utils/url_utility'; import * as urlUtils from '~/lib/utils/url_utility';
import issuableApp from '~/issue_show/components/app.vue'; import issuableApp from '~/issue_show/components/app.vue';
import eventHub from '~/issue_show/event_hub'; import eventHub from '~/issue_show/event_hub';
......
...@@ -3,8 +3,7 @@ import _ from 'underscore'; ...@@ -3,8 +3,7 @@ import _ from 'underscore';
import 'autosize'; import 'autosize';
import '~/gl_form'; import '~/gl_form';
import '~/lib/utils/text_utility'; import '~/lib/utils/text_utility';
import '~/render_gfm'; import '~/behaviors/markdown/render_gfm';
import '~/render_math';
import Notes from '~/notes'; import Notes from '~/notes';
const upArrowKeyCode = 38; const upArrowKeyCode = 38;
......
...@@ -3,7 +3,7 @@ import _ from 'underscore'; ...@@ -3,7 +3,7 @@ import _ from 'underscore';
import Vue from 'vue'; import Vue from 'vue';
import notesApp from '~/notes/components/notes_app.vue'; import notesApp from '~/notes/components/notes_app.vue';
import service from '~/notes/services/notes_service'; import service from '~/notes/services/notes_service';
import '~/render_gfm'; import '~/behaviors/markdown/render_gfm';
import * as mockData from '../mock_data'; import * as mockData from '../mock_data';
const vueMatchers = { const vueMatchers = {
......
...@@ -7,7 +7,7 @@ import * as urlUtils from '~/lib/utils/url_utility'; ...@@ -7,7 +7,7 @@ import * as urlUtils from '~/lib/utils/url_utility';
import 'autosize'; import 'autosize';
import '~/gl_form'; import '~/gl_form';
import '~/lib/utils/text_utility'; import '~/lib/utils/text_utility';
import '~/render_gfm'; import '~/behaviors/markdown/render_gfm';
import Notes from '~/notes'; import Notes from '~/notes';
import timeoutPromise from './helpers/set_timeout_promise_helper'; import timeoutPromise from './helpers/set_timeout_promise_helper';
......
import $ from 'jquery'; import $ from 'jquery';
import initCopyAsGFM from '~/behaviors/copy_as_gfm'; import initCopyAsGFM from '~/behaviors/markdown/copy_as_gfm';
import ShortcutsIssuable from '~/shortcuts_issuable'; import ShortcutsIssuable from '~/shortcuts_issuable';
initCopyAsGFM(); initCopyAsGFM();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment