Skip to content

Commit

Permalink
Merge branch 'MarkBind:master' into fix-scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
jingting1412 authored Apr 4, 2024
2 parents 6ca8a70 + 69ec838 commit 625134d
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 87 deletions.
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ packages/core/src/Site/*.js
packages/core/src/utils/*.js
packages/core/src/variables/*.js
packages/core/test/unit/**/*.js

# TODO: remove when migrated to TS
!markdown-it-icons.test.js
packages/core/index.js

# Rules for pure JS files
packages/core/src/lib/markdown-it/patches/*
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ packages/core/src/Site/*.js
packages/core/src/utils/*.js
packages/core/src/variables/*.js
packages/core/test/unit/**/*.js

# TODO: remove when migrated to TS
!markdown-it-icons.test.js
packages/core/index.js

# --- packages/core end ---
2 changes: 1 addition & 1 deletion packages/cli/src/cmd/build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');

const { Site } = require('@markbind/core').Site;
const { Site } = require('@markbind/core');

const cliUtil = require('../util/cliUtil');
const logger = require('../util/logger');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cmd/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');

const { Site } = require('@markbind/core').Site;
const { Site } = require('@markbind/core');

const cliUtil = require('../util/cliUtil');
const logger = require('../util/logger');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cmd/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const chokidar = require('chokidar');
const path = require('path');
const readline = require('readline');

const { Site } = require('@markbind/core').Site;
const { Site } = require('@markbind/core');
const { pageVueServerRenderer } = require('@markbind/core/src/Page/PageVueServerRenderer');

const fsUtil = require('@markbind/core/src/utils/fsUtil');
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/test/functional/test_site/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ <h2 id="panel-header-inside-unexpanded-panel-should-not-appear-in-search-data">P
Some text some text some text some text some text some text some text. Some text some text some text some text some text some text some text. Some text some text some text some text some text some text some text some text some text some text some text some text some text some text. Some text some text some text some text some text some text. Some text some text some text some text some text some text some text.
</panel>
</div>
<p><strong>Test popover has no stray space</strong>
(<popover><template #content>content</template>There should be no stray space before this</popover>)</p>
<p><strong>Test tooltip has no stray space</strong>
(<tooltip><template #content>content</template>There should be no stray space before this</tooltip>)</p>
<p><strong>Test search indexing</strong></p>
<p><strong>Test PlantUML live reload without include</strong></p>
<pic src="/test_site/diagrams/activity.png" alt="activity diagram"></pic>
Expand Down

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions packages/cli/test/functional/test_site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ and **this**.
**Test panel closing transitions**
<include src="testPanelsClosingTransition.md" />

**Test popover has no stray space**
(<popover content="content">There should be no stray space before this</popover>)

**Test tooltip has no stray space**
(<tooltip content="content">There should be no stray space before this</tooltip>)

**Test search indexing**

Expand Down
7 changes: 0 additions & 7 deletions packages/core/index.js

This file was deleted.

4 changes: 4 additions & 0 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Site } from './src/Site';
import { Template } from './src/Site/template';

export { Site, Template };
89 changes: 51 additions & 38 deletions packages/core/test/unit/html/NodeProcessor.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,6 @@ export const PROCESS_PANEL_ATTRIBUTES_EXPECTED = `
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY = `
<panel header="# Lorem ipsum">
<div slot="header">
This existing header slot should be preserved in favour over header attribute, with a logger warning for repeated attributes.
</div>
Header attribute should be ignored and deleted while header slot is reserved.
</panel>
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<panel>
<template #header><div>
This existing header slot should be preserved in favour over header attribute, with a logger warning for repeated attributes.
</div></template>
Header attribute should be ignored and deleted while header slot is reserved.
</panel>
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "panel has a header slot, 'header' attribute has no effect.";

export const PROCESS_PANEL_HEADER_NO_OVERRIDE = `
<panel header="# Lorem ipsum" alt="**strong alt**">
<div slot="header">
This existing header slot should be preserved in favour over header attribute.
Expand All @@ -49,7 +29,7 @@ export const PROCESS_PANEL_HEADER_NO_OVERRIDE = `
</panel>
`;

export const PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED = `
export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<panel><template #_alt><p><strong>strong alt</strong></p>
</template>
<template #header><div>
Expand All @@ -61,6 +41,8 @@ export const PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED = `
</panel>
`;

export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "panel has a header slot, 'header' attribute has no effect.";

// Post Process

export const POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT = `
Expand Down Expand Up @@ -92,18 +74,38 @@ export const PROCESS_QUESTION_ATTRIBUTES_EXPECTED = `
</question>
`;

export const PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE = `
<question header="**header**" hint="**hint**" answer="**answer**">
export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY = `
<question header="**lorem ipsum**">
<template slot="header"></template>
<template slot="hint"></template>
<template slot="answer"></template>
</question>
`;

export const PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<question>
<template #header></template>
</question>
`;

export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY = `
<question hint="**lorem ipsum**">
<template slot="hint"></template>
</question>
`;

export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED = `
<question>
<template #hint></template>
</question>
`;

export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY = `
<question answer="**lorem ipsum**">
<template slot="answer"></template>
</question>
`;

export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED = `
<question>
<template #answer></template>
</question>
`;
Expand All @@ -119,13 +121,13 @@ export const PROCESS_QOPTION_ATTRIBUTES_EXPECTED = `
</q-option>
`;

export const PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE = `
export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY = `
<q-option reason="**lorem ipsum**">
<template slot="reason"></template>
</q-option>
`;

export const PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED = `
<q-option>
<template #reason></template>
</q-option>
Expand All @@ -142,13 +144,13 @@ export const PROCESS_QUIZ_ATTRIBUTES_EXPECTED = `
</quiz>
`;

export const PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE = `
export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY = `
<quiz intro="**lorem ipsum**">
<template slot="intro"></template>
</quiz>
`;

export const PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED = `
<quiz>
<template #intro></template>
</quiz>
Expand All @@ -171,24 +173,35 @@ export const PROCESS_POPOVER_ATTRIBUTES_EXPECTED = `
</popover>
`;

export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE = `
<popover content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel tellus elit."
header="_Lorem ipsum_">
export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY = `
<popover header="_Lorem ipsum_">
<div slot="header">Some header slot content that should not be overwritten</div>
<div slot="content">Some content slot that should not be overwritten</div>
Content and header attributes should not be inserted under panel as slots, but should be deleted.
Header attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;

export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED = `
export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = `
<popover>
<template #header><div>Some header slot content that should not be overwritten</div></template>
<template #content><div>Some content slot that should not be overwritten</div></template>
Content and header attributes should not be inserted under panel as slots, but should be deleted.
Header attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;

export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG = "popover has a header slot, 'header' attribute has no effect.";

export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY = `
<popover content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel tellus elit.">
<div slot="content">Some content slot that should not be overwritten</div>
Content attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;

export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED = `
<popover>
<template #content><div>Some content slot that should not be overwritten</div></template>
Content attribute should not be inserted under panel as slot, but should be deleted.
</popover>
`;
export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG = "popover has a content slot, 'content' attribute has no effect.";

/*
Expand Down
25 changes: 14 additions & 11 deletions packages/core/test/unit/html/NodeProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,42 @@ test('processNode processes panel attributes and inserts into dom as slots corre
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG);
processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_NO_OVERRIDE,
testData.PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG);
});

test('processNode processes question attributes and inserts into dom as slots correctly', () => {
processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES,
testData.PROCESS_QUESTION_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED);
});

test('processNode processes q-option attributes and inserts into dom as slots correctly', () => {
processAndVerifyTemplate(testData.PROCESS_QOPTION_ATTRIBUTES,
testData.PROCESS_QOPTION_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY,
testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED);
});

test('processNode processes quiz attributes and inserts into dom as slots correctly', () => {
processAndVerifyTemplate(testData.PROCESS_QUIZ_ATTRIBUTES,
testData.PROCESS_QUIZ_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY,
testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED);
});

test('processNode processes popover attributes and inserts into dom as slots correctly', () => {
const warnSpy = jest.spyOn(logger, 'warn');
processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES,
testData.PROCESS_POPOVER_ATTRIBUTES_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE,
testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED);
processAndVerifyTemplate(testData.PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY,
testData.PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG);
processAndVerifyTemplate(testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY,
testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED);
expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const expectedOcticon = require('@primer/octicons')['git-pull-request'].toSVG();
import octicons from '@primer/octicons';
import markdownIt from '../../src/lib/markdown-it';

const markdownIt = require('../../src/lib/markdown-it');
const expectedOcticon = octicons['git-pull-request'].toSVG();

test('markdown-it-icons renders icon syntax correctly', () => {
const source = ':fab-font-awesome: :glyphicon-home: :octicon-git-pull-request: :mit-task-alt:';
Expand Down
5 changes: 2 additions & 3 deletions packages/vue-components/src/Popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
<div class="popover-body">
<slot name="content"></slot>
</div>
</portal>

<v-popover
</portal><!-- do not delete this comment, it is for the stray space issue (#2419)
--><v-popover
v-if="isMounted"
:auto-hide="!isInput"
:triggers="triggers"
Expand Down
10 changes: 4 additions & 6 deletions packages/vue-components/src/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
>
<portal v-if="targetEl.id" :to="'tooltip:' + targetEl.id">
<slot name="content"></slot>
</portal>

<v-tooltip
</portal><!-- do not delete this comment, it is for the stray space issue (#2419)
--><v-tooltip
v-if="isMounted"
:auto-hide="!isInput"
:triggers="triggers"
Expand All @@ -20,9 +19,8 @@
>
<template #popper>
<slot name="content"></slot>
</template>

<span v-if="!isInput" @click.stop>
</template><!-- do not delete this comment, it is for the stray space issue (#2419)
--><span v-if="!isInput" @click.stop>
<slot></slot>
</span>
<slot v-else></slot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports[`Popover should not be shown until triggered 1`] = `
tabindex="0"
>
<!---->
<!---->
</span>
`;
Expand All @@ -21,7 +20,6 @@ exports[`Popover should not show header when no header is given 1`] = `
tabindex="0"
>
<!---->
<v-popover-stub
auto-hide="true"
delay="0"
Expand All @@ -47,7 +45,6 @@ exports[`Popover should respect the placement attribute 1`] = `
tabindex="0"
>
<!---->
<v-popover-stub
auto-hide="true"
delay="0"
Expand All @@ -73,7 +70,6 @@ exports[`Popover should show header and content 1`] = `
tabindex="0"
>
<!---->
<v-popover-stub
auto-hide="true"
delay="0"
Expand All @@ -97,7 +93,6 @@ exports[`Popover should show header and content slots correctly 1`] = `
tabindex="0"
>
<!---->
<v-popover-stub
auto-hide="true"
delay="0"
Expand Down
Loading

0 comments on commit 625134d

Please sign in to comment.