Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I9421 v-pkp-allowed-html #320

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import Tab from '@/components/Tabs/Tab.vue';
import Tabs from '@/components/Tabs/Tabs.vue';
import FloatingVue from 'floating-vue';

// Directives
import {allowedHtmlDirective} from '@/directive/allowedHtml.js';

import PkpDialog from '@/components/Modal/Dialog.vue';

import VueScrollTo from 'vue-scrollto';
Expand Down Expand Up @@ -51,6 +54,10 @@ initialize({

setup((app) => {
app.use(pinia);

// directives
app.directive('pkp-allowed-html', allowedHtmlDirective);

app.mixin(GlobalMixins);

app.use(FloatingVue, {
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"chart.js": "^4.3.3",
"clone-deep": "^4.0.1",
"debounce": "^1.2.0",
"dompurify": "^3.0.8",
"dropzone-vue3": "^1.0.2",
"element-resize-event": "^3.0.6",
"floating-vue": "^2.0.0-beta.24",
Expand Down
5 changes: 5 additions & 0 deletions public/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* are not part of the UI Library's responsibilities
*/
window.pkp = {
serverContext: {
configAllowedHtml:
'a[href|target|title],em,strong,cite,code,ul,ol,li[class],dl,dt,dd,b,i,u,img[src|alt],sup,sub,br,p',
apiBaseUrl: 'https://mock/index.php/publicknowledge/api/v1/',
},
/**
* Event bus. This will be a Vue instance but must be registered in main.js
* where Vue can be imported
Expand Down
6 changes: 3 additions & 3 deletions src/components/Container/SubmissionWizardPage.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const SubmissionWizardPageWithDataAndTemplate = {
<panel-section v-for="section in step.sections" :key="section.id">
<template #header>
<h2>{{ section.name }}</h2>
<div v-html="section.description" />
<div v-pkp-allowed-html="section.description" />
</template>
<pkp-form
v-if="section.type === 'form'"
Expand Down Expand Up @@ -243,7 +243,7 @@ const SubmissionWizardPageWithDataAndTemplate = {
</h4>
<div
class="submissionWizard__reviewPanel__item__value"
v-html="localize(publication.title)"
v-pkp-allowed-html="localize(publication.title)"
/>
</div>
<div class="submissionWizard__reviewPanel__item">
Expand All @@ -262,7 +262,7 @@ const SubmissionWizardPageWithDataAndTemplate = {
</h4>
<div
class="submissionWizard__reviewPanel__item__value"
v-html="localize(publication.abstract)"
v-pkp-allowed-html="localize(publication.abstract)"
/>
</div>
<div
Expand Down
4 changes: 2 additions & 2 deletions src/components/DateRange/DateRange.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="pkpDateRange">
<span class="-screenReader">{{ dateRangeLabel }}</span>
<span class="pkpDateRange__current" v-html="currentRange" />
<span v-pkp-allowed-html="currentRange" class="pkpDateRange__current" />
<button
ref="toggleButton"
class="pkpDateRange__button"
Expand Down Expand Up @@ -63,7 +63,7 @@
<pkp-button @click="applyCustomRange">{{ applyLabel }}</pkp-button>
<div v-if="errorMessage" class="pkpDateRange__error">
<icon icon="exclamation-triangle" :inline="true" />
<span v-html="errorMessage" />
<span v-pkp-allowed-html="errorMessage" />
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileAttacher/FileAttacher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
:key="key"
>
<h2>{{ attacher.label }}</h2>
<p v-html="attacher.description" />
<p v-pkp-allowed-html="attacher.description" />
<template #actions>
<pkp-button
:aria-describedby="'attacher' + key"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/FieldError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class="pkpFieldError__message"
>
<icon icon="exclamation-triangle" :inline="true" />
<span v-html="message" />
<span v-pkp-allowed-html="message" />
</div>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/FormGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<legend class="pkpFormGroup__legend">{{ label }}</legend>
<div
v-if="description"
v-pkp-allowed-html="description"
class="pkpFormGroup__description"
v-html="description"
></div>
</div>
<div class="pkpFormGroup__fields">
Expand Down
6 changes: 3 additions & 3 deletions src/components/Form/fields/FieldArchivingPn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<span
v-if="tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="helpTopic"
Expand All @@ -33,13 +33,13 @@
<div
v-if="description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description pkpFormField--options__description"
v-html="description"
/>
<div
v-if="terms && value"
v-pkp-allowed-html="terms"
class="pkpFormField__description pkpFormField--options__description pkpFormField--archivingPn__terms"
v-html="terms"
/>
<field-error
v-if="errors && errors.length"
Expand Down
6 changes: 3 additions & 3 deletions src/components/Form/fields/FieldBaseAutosuggest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<span
v-if="tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="helpTopic"
Expand All @@ -33,8 +33,8 @@
<div
v-if="isPrimaryLocale && description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description"
v-html="description"
/>
<div class="pkpFormField__control pkpAutosuggest__control">
<div
Expand Down Expand Up @@ -67,8 +67,8 @@
<span
v-if="tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="helpTopic"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/fields/FieldColor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<span
v-if="isPrimaryLocale && tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="isPrimaryLocale && helpTopic"
Expand All @@ -35,8 +35,8 @@
<div
v-if="isPrimaryLocale && description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description"
v-html="description"
/>
<div class="pkpFormField__control">
<color-picker
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/fields/FieldHtml.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{ label }}
</span>
<tooltip v-if="tooltip" aria-hidden="true" :tooltip="tooltip" label="" />
<span v-if="tooltip" class="-screenReader" v-html="tooltip" />
<span v-if="tooltip" v-pkp-allowed-html="tooltip" class="-screenReader" />
<help-button
v-if="helpTopic"
:topic="helpTopic"
Expand All @@ -14,8 +14,8 @@
/>
</div>
<div
v-pkp-allowed-html="description"
class="pkpFormField__control pkpFormField__control--html"
v-html="description"
/>
</div>
</template>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Form/fields/FieldMetadataSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<span
v-if="tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="helpTopic"
Expand All @@ -20,8 +20,8 @@
<div
v-if="description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description pkpFormField--options__description"
v-html="description"
/>
<field-error
v-if="errors && errors.length"
Expand All @@ -44,8 +44,8 @@
:disabled="option.disabled"
/>
<span
v-pkp-allowed-html="option.label"
class="pkpFormField--options__optionLabel"
v-html="option.label"
/>
</label>
<div v-if="isEnabled" class="pkpFormField--metadata__submissionOptions">
Expand All @@ -63,8 +63,8 @@
:disabled="option.disabled"
/>
<span
v-pkp-allowed-html="option.label"
class="pkpFormField--options__optionLabel"
v-html="option.label"
/>
</label>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Form/fields/FieldOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<span
v-if="isPrimaryLocale && tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="isPrimaryLocale && helpTopic"
Expand All @@ -35,8 +35,8 @@
<div
v-if="isPrimaryLocale && description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description pkpFormField--options__description"
v-html="description"
/>
<div class="pkpFormField__control">
<VueDraggable
Expand Down Expand Up @@ -79,8 +79,8 @@
:disabled="option.disabled"
/>
<span
v-pkp-allowed-html="option.label"
class="pkpFormField--options__optionLabel"
v-html="option.label"
/>
<orderer
v-if="isOrderable"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/fields/FieldPubId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<span
v-if="tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="helpTopic"
Expand All @@ -25,8 +25,8 @@
<div
v-if="description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description"
v-html="description"
/>
<div class="pkpFormField__control">
<input
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/fields/FieldRadioInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<span
v-if="isPrimaryLocale && tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="isPrimaryLocale && helpTopic"
Expand All @@ -35,8 +35,8 @@
<div
v-if="isPrimaryLocale && description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description pkpFormField--options__description"
v-html="description"
/>
<field-error
v-if="errors && errors.length"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/fields/FieldRichTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<span
v-if="isPrimaryLocale && tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="isPrimaryLocale && helpTopic"
Expand All @@ -35,8 +35,8 @@
<div
v-if="isPrimaryLocale && description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description"
v-html="description"
/>
<div
class="pkpFormField__control pkpFormField--richTextarea__control"
Expand Down
4 changes: 2 additions & 2 deletions src/components/Form/fields/FieldSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<span
v-if="tooltip"
:id="describedByTooltipId"
v-pkp-allowed-html="tooltip"
class="-screenReader"
v-html="tooltip"
/>
<help-button
v-if="helpTopic"
Expand All @@ -27,8 +27,8 @@
<div
v-if="isPrimaryLocale && description"
:id="describedByDescriptionId"
v-pkp-allowed-html="description"
class="pkpFormField__description"
v-html="description"
/>
<div
class="pkpFormField__control"
Expand Down
Loading