kopia lustrzana https://github.com/wagtail/wagtail
eslint - update lines-between-class-members & format
- allow single line members to be compactpull/8736/head
rodzic
f10eb48ae3
commit
75d2f063a2
|
@ -10,7 +10,6 @@ const legacyCode = {
|
||||||
'jsx-a11y/interactive-supports-focus': 'off',
|
'jsx-a11y/interactive-supports-focus': 'off',
|
||||||
'jsx-a11y/no-noninteractive-element-interactions': 'off',
|
'jsx-a11y/no-noninteractive-element-interactions': 'off',
|
||||||
'jsx-a11y/role-supports-aria-props': 'off',
|
'jsx-a11y/role-supports-aria-props': 'off',
|
||||||
'lines-between-class-members': 'off',
|
|
||||||
'max-classes-per-file': 'off',
|
'max-classes-per-file': 'off',
|
||||||
'no-await-in-loop': 'off',
|
'no-await-in-loop': 'off',
|
||||||
'no-continue': 'off',
|
'no-continue': 'off',
|
||||||
|
@ -73,6 +72,12 @@ module.exports = {
|
||||||
],
|
],
|
||||||
// does not align with the majority of legacy and newer code, some use named others use default exports
|
// does not align with the majority of legacy and newer code, some use named others use default exports
|
||||||
'import/prefer-default-export': 'off',
|
'import/prefer-default-export': 'off',
|
||||||
|
// allow no lines between single line members (e.g. static declarations)
|
||||||
|
'lines-between-class-members': [
|
||||||
|
'error',
|
||||||
|
'always',
|
||||||
|
{ exceptAfterSingleLine: true },
|
||||||
|
],
|
||||||
// note you must disable the base rule as it can report incorrect errors
|
// note you must disable the base rule as it can report incorrect errors
|
||||||
'no-use-before-define': 'off',
|
'no-use-before-define': 'off',
|
||||||
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
|
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
|
||||||
|
|
|
@ -47,9 +47,11 @@ export class Chooser {
|
||||||
getState() {
|
getState() {
|
||||||
return this.state;
|
return this.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
getValue() {
|
getValue() {
|
||||||
return this.state && this.state.id;
|
return this.state && this.state.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(newState) {
|
setState(newState) {
|
||||||
this.state = newState;
|
this.state = newState;
|
||||||
if (newState) {
|
if (newState) {
|
||||||
|
@ -58,13 +60,16 @@ export class Chooser {
|
||||||
this.renderEmptyState();
|
this.renderEmptyState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.setState(null);
|
this.setState(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderEmptyState() {
|
renderEmptyState() {
|
||||||
this.input.setAttribute('value', '');
|
this.input.setAttribute('value', '');
|
||||||
this.chooserElement.classList.add('blank');
|
this.chooserElement.classList.add('blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
renderState(newState) {
|
renderState(newState) {
|
||||||
this.input.setAttribute('value', newState.id);
|
this.input.setAttribute('value', newState.id);
|
||||||
this.titleElement.innerText = newState.title;
|
this.titleElement.innerText = newState.title;
|
||||||
|
@ -80,6 +85,7 @@ export class Chooser {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
this.chooserElement.querySelector('.action-choose').focus();
|
this.chooserElement.querySelector('.action-choose').focus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,11 +105,14 @@ function renderCommentsUi(
|
||||||
|
|
||||||
export class CommentApp {
|
export class CommentApp {
|
||||||
store: Store;
|
store: Store;
|
||||||
|
|
||||||
layout: LayoutController;
|
layout: LayoutController;
|
||||||
|
|
||||||
utils = {
|
utils = {
|
||||||
selectCommentsForContentPathFactory,
|
selectCommentsForContentPathFactory,
|
||||||
selectCommentFactory,
|
selectCommentFactory,
|
||||||
};
|
};
|
||||||
|
|
||||||
selectors = {
|
selectors = {
|
||||||
selectComments,
|
selectComments,
|
||||||
selectEnabled,
|
selectEnabled,
|
||||||
|
@ -117,6 +120,7 @@ export class CommentApp {
|
||||||
selectIsDirty,
|
selectIsDirty,
|
||||||
selectCommentCount,
|
selectCommentCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
actions = commentActionFunctions;
|
actions = commentActionFunctions;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -136,19 +140,23 @@ export class CommentApp {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAnnotation(annotation: Annotation, commentId: number) {
|
updateAnnotation(annotation: Annotation, commentId: number) {
|
||||||
this.attachAnnotationLayout(annotation, commentId);
|
this.attachAnnotationLayout(annotation, commentId);
|
||||||
this.store.dispatch(updateComment(commentId, { annotation: annotation }));
|
this.store.dispatch(updateComment(commentId, { annotation: annotation }));
|
||||||
}
|
}
|
||||||
|
|
||||||
attachAnnotationLayout(annotation: Annotation, commentId: number) {
|
attachAnnotationLayout(annotation: Annotation, commentId: number) {
|
||||||
// Attach an annotation to an existing comment in the layout
|
// Attach an annotation to an existing comment in the layout
|
||||||
|
|
||||||
// const layout engine know the annotation so it would position the comment correctly
|
// const layout engine know the annotation so it would position the comment correctly
|
||||||
this.layout.setCommentAnnotation(commentId, annotation);
|
this.layout.setCommentAnnotation(commentId, annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentTab(tab: string | null) {
|
setCurrentTab(tab: string | null) {
|
||||||
this.store.dispatch(updateGlobalSettings({ currentTab: tab }));
|
this.store.dispatch(updateGlobalSettings({ currentTab: tab }));
|
||||||
}
|
}
|
||||||
|
|
||||||
makeComment(annotation: Annotation, contentpath: string, position = '') {
|
makeComment(annotation: Annotation, contentpath: string, position = '') {
|
||||||
const commentId = getNextCommentId();
|
const commentId = getNextCommentId();
|
||||||
|
|
||||||
|
@ -180,6 +188,7 @@ export class CommentApp {
|
||||||
);
|
);
|
||||||
return commentId;
|
return commentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisible(visible: boolean) {
|
setVisible(visible: boolean) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
updateGlobalSettings({
|
updateGlobalSettings({
|
||||||
|
@ -187,15 +196,18 @@ export class CommentApp {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidateContentPath(contentPath: string) {
|
invalidateContentPath(contentPath: string) {
|
||||||
// Called when a given content path on the form is no longer valid (eg, a block has been deleted)
|
// Called when a given content path on the form is no longer valid (eg, a block has been deleted)
|
||||||
this.store.dispatch(invalidateContentPath(contentPath));
|
this.store.dispatch(invalidateContentPath(contentPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateContentPath(commentId: number, newContentPath: string) {
|
updateContentPath(commentId: number, newContentPath: string) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
updateComment(commentId, { contentpath: newContentPath }),
|
updateComment(commentId, { contentpath: newContentPath }),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderApp(
|
renderApp(
|
||||||
element: HTMLElement,
|
element: HTMLElement,
|
||||||
outputElement: HTMLElement,
|
outputElement: HTMLElement,
|
||||||
|
|
|
@ -75,27 +75,32 @@ export class DraftailInlineAnnotation implements Annotation {
|
||||||
this.focusedBlockKey = '';
|
this.focusedBlockKey = '';
|
||||||
this.cachedMedianRef = null;
|
this.cachedMedianRef = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
addDecoratorRef(ref: DecoratorRef, blockKey: BlockKey) {
|
addDecoratorRef(ref: DecoratorRef, blockKey: BlockKey) {
|
||||||
this.decoratorRefs.set(ref, blockKey);
|
this.decoratorRefs.set(ref, blockKey);
|
||||||
|
|
||||||
// We're adding a ref, so remove the cached median refs - this needs to be recalculated
|
// We're adding a ref, so remove the cached median refs - this needs to be recalculated
|
||||||
this.cachedMedianRef = null;
|
this.cachedMedianRef = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeDecoratorRef(ref: DecoratorRef) {
|
removeDecoratorRef(ref: DecoratorRef) {
|
||||||
this.decoratorRefs.delete(ref);
|
this.decoratorRefs.delete(ref);
|
||||||
|
|
||||||
// We're deleting a ref, so remove the cached median refs - this needs to be recalculated
|
// We're deleting a ref, so remove the cached median refs - this needs to be recalculated
|
||||||
this.cachedMedianRef = null;
|
this.cachedMedianRef = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFocusedBlockKey(blockKey: BlockKey) {
|
setFocusedBlockKey(blockKey: BlockKey) {
|
||||||
this.focusedBlockKey = blockKey;
|
this.focusedBlockKey = blockKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getHeightForRef(ref: DecoratorRef) {
|
static getHeightForRef(ref: DecoratorRef) {
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
return ref.current.getBoundingClientRect().top;
|
return ref.current.getBoundingClientRect().top;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getMedianRef(refArray: Array<DecoratorRef>) {
|
static getMedianRef(refArray: Array<DecoratorRef>) {
|
||||||
const refs = refArray.sort(
|
const refs = refArray.sort(
|
||||||
(firstRef, secondRef) =>
|
(firstRef, secondRef) =>
|
||||||
|
@ -107,9 +112,11 @@ export class DraftailInlineAnnotation implements Annotation {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTab() {
|
getTab() {
|
||||||
return this.field.closest('[role="tabpanel"]')?.getAttribute('id');
|
return this.field.closest('[role="tabpanel"]')?.getAttribute('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnchorNode(focused = false) {
|
getAnchorNode(focused = false) {
|
||||||
// The comment should always aim to float by an annotation, rather than between them
|
// The comment should always aim to float by an annotation, rather than between them
|
||||||
// so calculate which annotation is the median one by height and float the comment by that
|
// so calculate which annotation is the median one by height and float the comment by that
|
||||||
|
|
|
@ -51,6 +51,7 @@ class ActionButton {
|
||||||
enable() {
|
enable() {
|
||||||
this.dom.removeAttr('disabled');
|
this.dom.removeAttr('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
this.dom.attr('disabled', 'true');
|
this.dom.attr('disabled', 'true');
|
||||||
}
|
}
|
||||||
|
@ -258,31 +259,38 @@ export class BaseSequenceChild extends EventEmitter {
|
||||||
this.block.setCapabilityOptions('duplicate', { enabled: true });
|
this.block.setCapabilityOptions('duplicate', { enabled: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disableDuplication() {
|
disableDuplication() {
|
||||||
this.emit('disableDuplication');
|
this.emit('disableDuplication');
|
||||||
if (this.block && this.block.setCapabilityOptions) {
|
if (this.block && this.block.setCapabilityOptions) {
|
||||||
this.block.setCapabilityOptions('duplicate', { enabled: false });
|
this.block.setCapabilityOptions('duplicate', { enabled: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enableSplit() {
|
enableSplit() {
|
||||||
if (this.block && this.block.setCapabilityOptions) {
|
if (this.block && this.block.setCapabilityOptions) {
|
||||||
this.block.setCapabilityOptions('split', { enabled: true });
|
this.block.setCapabilityOptions('split', { enabled: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disableSplit() {
|
disableSplit() {
|
||||||
if (this.block && this.block.setCapabilityOptions) {
|
if (this.block && this.block.setCapabilityOptions) {
|
||||||
this.block.setCapabilityOptions('split', { enabled: false });
|
this.block.setCapabilityOptions('split', { enabled: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enableMoveUp() {
|
enableMoveUp() {
|
||||||
this.emit('enableMoveUp');
|
this.emit('enableMoveUp');
|
||||||
}
|
}
|
||||||
|
|
||||||
disableMoveUp() {
|
disableMoveUp() {
|
||||||
this.emit('disableMoveUp');
|
this.emit('disableMoveUp');
|
||||||
}
|
}
|
||||||
|
|
||||||
enableMoveDown() {
|
enableMoveDown() {
|
||||||
this.emit('enableMoveDown');
|
this.emit('enableMoveDown');
|
||||||
}
|
}
|
||||||
|
|
||||||
disableMoveDown() {
|
disableMoveDown() {
|
||||||
this.emit('disableMoveDown');
|
this.emit('disableMoveDown');
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,6 +173,7 @@ class StreamBlockMenu extends BaseInsertionControl {
|
||||||
this.open({ animate: true });
|
this.open({ animate: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open(opts) {
|
open(opts) {
|
||||||
if (!this.canAddBlock) {
|
if (!this.canAddBlock) {
|
||||||
return;
|
return;
|
||||||
|
@ -188,6 +189,7 @@ class StreamBlockMenu extends BaseInsertionControl {
|
||||||
this.outerContainer.attr('aria-hidden', 'false');
|
this.outerContainer.attr('aria-hidden', 'false');
|
||||||
this.isOpen = true;
|
this.isOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(opts) {
|
close(opts) {
|
||||||
if (opts && opts.animate) {
|
if (opts && opts.animate) {
|
||||||
this.outerContainer.slideUp();
|
this.outerContainer.slideUp();
|
||||||
|
|
|
@ -8,15 +8,19 @@ class BoundWidget {
|
||||||
this.setState(initialState);
|
this.setState(initialState);
|
||||||
this.parentCapabilities = parentCapabilities || new Map();
|
this.parentCapabilities = parentCapabilities || new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
getValue() {
|
getValue() {
|
||||||
return this.input.val();
|
return this.input.val();
|
||||||
}
|
}
|
||||||
|
|
||||||
getState() {
|
getState() {
|
||||||
return this.input.val();
|
return this.input.val();
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(state) {
|
setState(state) {
|
||||||
this.input.val(state);
|
this.input.val(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTextLabel(opts) {
|
getTextLabel(opts) {
|
||||||
const val = this.getValue();
|
const val = this.getValue();
|
||||||
if (typeof val !== 'string') return null;
|
if (typeof val !== 'string') return null;
|
||||||
|
@ -26,9 +30,11 @@ class BoundWidget {
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
this.input.focus();
|
this.input.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
setCapabilityOptions(capability, options) {
|
setCapabilityOptions(capability, options) {
|
||||||
Object.assign(this.parentCapabilities.get(capability), options);
|
Object.assign(this.parentCapabilities.get(capability), options);
|
||||||
}
|
}
|
||||||
|
@ -63,9 +69,11 @@ class BoundCheckboxInput extends BoundWidget {
|
||||||
getValue() {
|
getValue() {
|
||||||
return this.input.is(':checked');
|
return this.input.is(':checked');
|
||||||
}
|
}
|
||||||
|
|
||||||
getState() {
|
getState() {
|
||||||
return this.input.is(':checked');
|
return this.input.is(':checked');
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(state) {
|
setState(state) {
|
||||||
// if false, set attribute value to null to remove it
|
// if false, set attribute value to null to remove it
|
||||||
this.input.attr('checked', state || null);
|
this.input.attr('checked', state || null);
|
||||||
|
@ -85,15 +93,19 @@ class BoundRadioSelect {
|
||||||
this.selector = 'input[name="' + name + '"]:checked';
|
this.selector = 'input[name="' + name + '"]:checked';
|
||||||
this.setState(initialState);
|
this.setState(initialState);
|
||||||
}
|
}
|
||||||
|
|
||||||
getValue() {
|
getValue() {
|
||||||
return this.element.find(this.selector).val();
|
return this.element.find(this.selector).val();
|
||||||
}
|
}
|
||||||
|
|
||||||
getState() {
|
getState() {
|
||||||
return this.element.find(this.selector).val();
|
return this.element.find(this.selector).val();
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(state) {
|
setState(state) {
|
||||||
this.element.find('input[name="' + this.name + '"]').val([state]);
|
this.element.find('input[name="' + this.name + '"]').val([state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
this.element.find('input[name="' + this.name + '"]').focus();
|
this.element.find('input[name="' + this.name + '"]').focus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,10 +153,12 @@ export class TypedTableBlock {
|
||||||
this.addColumnMenu.show();
|
this.addColumnMenu.show();
|
||||||
this.addColumnCallback = callback;
|
this.addColumnCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
hideAddColumnMenu() {
|
hideAddColumnMenu() {
|
||||||
this.addColumnMenu.hide();
|
this.addColumnMenu.hide();
|
||||||
this.addColumnMenuBaseElement = null;
|
this.addColumnMenuBaseElement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleAddColumnMenu(baseElement, callback) {
|
toggleAddColumnMenu(baseElement, callback) {
|
||||||
if (this.addColumnMenuBaseElement === baseElement) {
|
if (this.addColumnMenuBaseElement === baseElement) {
|
||||||
this.hideAddColumnMenu();
|
this.hideAddColumnMenu();
|
||||||
|
@ -164,6 +166,7 @@ export class TypedTableBlock {
|
||||||
this.showAddColumnMenu(baseElement, callback);
|
this.showAddColumnMenu(baseElement, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
// reset to initial empty state with no rows or columns
|
// reset to initial empty state with no rows or columns
|
||||||
this.columns = [];
|
this.columns = [];
|
||||||
|
@ -192,6 +195,7 @@ export class TypedTableBlock {
|
||||||
this.tbody.replaceChildren();
|
this.tbody.replaceChildren();
|
||||||
this.addRowButton.hide();
|
this.addRowButton.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
insertColumn(index, blockDef, opts) {
|
insertColumn(index, blockDef, opts) {
|
||||||
const column = {
|
const column = {
|
||||||
blockDef,
|
blockDef,
|
||||||
|
|
Ładowanie…
Reference in New Issue