Skip to content
Merged
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
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
"npm-run-all": "^4.1.5",
"path-browserify": "1.0.1",
"postcss": "8.5.6",
"prettier": "3.1.1",
"prettier": "3.7.4",
"process": "0.11.10",
"prosemirror-dev-toolkit": "1.1.8",
"react": "18.2.0",
Expand Down
132 changes: 51 additions & 81 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import config from '@gravity-ui/prettier-config';

/**
* @see https://prettier.io/docs/configuration
* @type {import("prettier").Config}
*/
export default config;
6 changes: 1 addition & 5 deletions src/bundle/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
export type ToolbarActionData = {
editorMode: EditorMode;
id: string;
attrs?: {[key: string]: any};

Check warning on line 43 in src/bundle/Editor.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Unexpected any. Specify a different type
};

export interface EventMap {
Expand Down Expand Up @@ -71,17 +71,13 @@

moveCursor(position: 'start' | 'end' | {line: number}): void;

/** @internal used in demo for dev-tools */

Check warning on line 74 in src/bundle/Editor.ts

View workflow job for this annotation

GitHub Actions / Verify Files

@internal should be empty
readonly _wysiwygView?: PMEditorView;
}

/** @internal */
export interface EditorInt
extends CommonEditor,
Emitter<EventMapInt>,
Receiver<EventMapInt>,
ActionStorage,
CodeEditor {
extends CommonEditor, Emitter<EventMapInt>, Receiver<EventMapInt>, ActionStorage, CodeEditor {
readonly logger: Logger2.ILogger;
readonly currentMode: EditorMode;
readonly toolbarVisible: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/bundle/HorizontalDrag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const useColResize = ({onStart, onMove, onEnd}: UseDragHandlersParams) => {

const handleMove = useCallback(
(e: MouseEvent | TouchEvent) => {
const currentX = 'touches' in e ? e.touches[0]?.clientX ?? 0 : e.clientX;
const currentX = 'touches' in e ? (e.touches[0]?.clientX ?? 0) : e.clientX;

if (currentXPosition.current === currentX) {
return;
Expand All @@ -40,7 +40,7 @@ const useColResize = ({onStart, onMove, onEnd}: UseDragHandlersParams) => {

document.body.style.removeProperty('user-select');

const currentX = 'touches' in e ? e.touches[0]?.clientX ?? 0 : e.clientX;
const currentX = 'touches' in e ? (e.touches[0]?.clientX ?? 0) : e.clientX;
const delta = initialXPosition.current - currentX;

onEnd(delta);
Expand All @@ -50,7 +50,7 @@ const useColResize = ({onStart, onMove, onEnd}: UseDragHandlersParams) => {

const handleStart: React.EventHandler<React.MouseEvent | React.TouchEvent> = useCallback(
(e) => {
const currentX = 'touches' in e ? e.touches[0]?.clientX ?? 0 : e.clientX;
const currentX = 'touches' in e ? (e.touches[0]?.clientX ?? 0) : e.clientX;
initialXPosition.current = currentX;
currentXPosition.current = currentX;

Expand Down
16 changes: 8 additions & 8 deletions src/bundle/toolbar/utils/toolbarsConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ interface GetToolbarsConfigsArgs {
export const getToolbarsConfigs = ({toolbarsPreset, props, preset}: GetToolbarsConfigsArgs) => {
const wysiwygToolbarConfig = toolbarsPreset
? createToolbarConfig<WToolbarData>('wysiwyg', toolbarsPreset, ToolbarName.wysiwygMain)
: props.wysiwygToolbarConfig ??
createToolbarConfig<WToolbarData>('wysiwyg', preset, ToolbarName.wysiwygMain);
: (props.wysiwygToolbarConfig ??
createToolbarConfig<WToolbarData>('wysiwyg', preset, ToolbarName.wysiwygMain));

const markupToolbarConfig = toolbarsPreset
? createToolbarConfig<MToolbarData>('markup', toolbarsPreset, ToolbarName.markupMain)
: props.markupToolbarConfig ??
createToolbarConfig<MToolbarData>('markup', preset, ToolbarName.markupMain);
: (props.markupToolbarConfig ??
createToolbarConfig<MToolbarData>('markup', preset, ToolbarName.markupMain));

const wysiwygHiddenActionsConfig = toolbarsPreset
? flattenPreset(
Expand All @@ -125,19 +125,19 @@ export const getToolbarsConfigs = ({toolbarsPreset, props, preset}: GetToolbarsC
ToolbarName.wysiwygHidden,
),
)
: props.wysiwygHiddenActionsConfig ??
: (props.wysiwygHiddenActionsConfig ??
flattenPreset(
createToolbarConfig<WToolbarData>('wysiwyg', preset, ToolbarName.wysiwygHidden),
);
));

const markupHiddenActionsConfig = toolbarsPreset
? flattenPreset(
createToolbarConfig<MToolbarData>('markup', toolbarsPreset, ToolbarName.markupHidden),
)
: props.markupHiddenActionsConfig ??
: (props.markupHiddenActionsConfig ??
flattenPreset(
createToolbarConfig<MToolbarData>('markup', preset, ToolbarName.markupHidden),
);
));

return {
wysiwygToolbarConfig,
Expand Down
19 changes: 8 additions & 11 deletions src/bundle/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ export type ParseInsertedUrlAsImage = (text: string) => {imageUrl: string; title

export type WysiwygPlaceholderOptions = {
value?: string | (() => string);
/** Default – empty-doc
Values:
- 'empty-doc' – The placeholder will only be shown when the document is completely empty;
- 'empty-row-top-level' – The placeholder will be displayed in an empty line that is at the top level of the document structure;
- 'empty-row' – The placeholder will be shown in any empty line within the document, regardless of its nesting level.
*/
/**
* Default – empty-doc.
*
* Values:
* - 'empty-doc' – The placeholder will only be shown when the document is completely empty;
* - 'empty-row-top-level' – The placeholder will be displayed in an empty line that is at the top level of the document structure;
* - 'empty-row' – The placeholder will be shown in any empty line within the document, regardless of its nesting level.
*/
behavior?: 'empty-doc' | 'empty-row-top-level' | 'empty-row';
};

Expand Down Expand Up @@ -67,13 +69,11 @@ export type MarkdownEditorHandlers = {
export type MarkdownEditorExperimentalOptions = {
/**
* If we need to set dimensions for uploaded images
*
* @default false
*/
needToSetDimensionsForUploadedImages?: boolean;
/**
* If we need to enable new image size calculations
*
* @default false
*/
enableNewImageSizeCalculation?: boolean;
Expand Down Expand Up @@ -107,7 +107,6 @@ export type MarkdownEditorExperimentalOptions = {
directiveSyntax?: DirectiveSyntaxOption;
/**
* If we need support for empty strings
*
* @default false
*/
preserveEmptyRows?: boolean;
Expand All @@ -118,7 +117,6 @@ export type MarkdownEditorExperimentalOptions = {
* **Use case:** Maintain consistent markup when switching modes
*
* **Note:** Applies to tracked blocks: `yfm_table`
*
* @default false
*/
preserveMarkupFormatting?: boolean;
Expand Down Expand Up @@ -200,7 +198,6 @@ export type MarkdownEditorWysiwygConfig = {
export type MarkdownEditorOptions = {
/**
* A set of plug-in extensions.
*
* @default 'full'
*/
preset?: MarkdownEditorPreset;
Expand Down
3 changes: 1 addition & 2 deletions src/bundle/wysiwyg-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export type BundlePresetOptions = ExtensionsOptions &
placeholderOptions?: WysiwygPlaceholderOptions;
/**
* If we need to set dimensions for uploaded images
*
* @default false
*/
needToSetDimensionsForUploadedImages?: boolean;
Expand Down Expand Up @@ -97,7 +96,7 @@ export const BundlePreset: ExtensionAuto<BundlePresetOptions> = (builder, opts)

return typeof value === 'function'
? value()
: value ?? i18nPlaceholder(opts.mobile ? 'doc_empty_mobile' : 'doc_empty');
: (value ?? i18nPlaceholder(opts.mobile ? 'doc_empty_mobile' : 'doc_empty'));
},
preserveEmptyRows: opts.preserveEmptyRows,
...opts.baseSchema,
Expand Down
1 change: 0 additions & 1 deletion src/core/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export class WysiwygEditor implements CommonEditor, ActionStorage {

declare global {
namespace WysiwygEditor {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Actions {}
}
}
4 changes: 1 addition & 3 deletions src/core/ExtensionBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type MarkdownIt from 'markdown-it';
import OrderedMap from 'orderedmap'; // eslint-disable-line import/no-extraneous-dependencies
import OrderedMap from 'orderedmap';
import {inputRules} from 'prosemirror-inputrules';
import {keymap} from 'prosemirror-keymap';
import type {Plugin} from 'prosemirror-state';
Expand All @@ -22,13 +22,11 @@ type ExtensionWithParams = (builder: ExtensionBuilder, ...params: any[]) => void
type ConfigureMdParams = {
/**
* Apply this configurtion to text parser
*
* @default true
*/
text?: boolean;
/**
* Apply this configurtion to markup parser
*
* @default true
*/
markup?: boolean;
Expand Down
4 changes: 1 addition & 3 deletions src/extensions/additional/GPT/gptExtension/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export type GptWidgetDecoViewParams<
export class GptWidgetDecoView<
AnswerData extends CommonAnswer = CommonAnswer,
PromptData extends unknown = unknown,
> implements Required<PluginView>
{
> implements Required<PluginView> {
private readonly _view;
private readonly _renderer;

Expand Down Expand Up @@ -216,7 +215,6 @@ export class GptWidgetDecoView<
return this._getPluginState()?.find(
undefined,
undefined,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
(spec) => spec[WIDGET_DECO_SPEC_FLAG],
)[0];
}
Expand Down
1 change: 0 additions & 1 deletion src/extensions/additional/Mermaid/MermaidSpecs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import {transform} from '@diplodoc/mermaid-extension';

import type {ExtensionAuto, ExtensionNodeSpec} from '#core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {YfmHtmlBlockConsts, defaultYfmHtmlBlockEntityId} from './const';

export {yfmHtmlBlockNodeName, YfmHtmlBlockConsts} from './const';

export interface YfmHtmlBlockSpecsOptions
extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle' | 'embeddingMode'> {
export interface YfmHtmlBlockSpecsOptions extends Omit<
PluginOptions,
'runtimeJsPath' | 'containerClasses' | 'bundle' | 'embeddingMode'
> {
nodeView?: ExtensionNodeSpec['view'];
}

Expand Down
6 changes: 4 additions & 2 deletions src/extensions/additional/YfmHtmlBlock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import {YfmHtmlBlockSpecs} from './YfmHtmlBlockSpecs';
import {YfmHtmlBlockAction} from './YfmHtmlBlockSpecs/const';
import {addYfmHtmlBlock} from './actions';

export interface YfmHtmlBlockOptions
extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle' | 'embeddingMode'> {
export interface YfmHtmlBlockOptions extends Omit<
PluginOptions,
'runtimeJsPath' | 'containerClasses' | 'bundle' | 'embeddingMode'
> {
useConfig?: () => IHTMLIFrameElementConfig | undefined;
autoSave?: {
enabled: boolean;
Expand Down
6 changes: 4 additions & 2 deletions src/extensions/behavior/Autocomplete/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export type {

export {ActionKind as AutocompleteActionKind} from 'prosemirror-autocomplete';

export interface AutocompleteHandler
extends Pick<Options, 'onArrow' | 'onClose' | 'onEnter' | 'onFilter' | 'onOpen'> {
export interface AutocompleteHandler extends Pick<
Options,
'onArrow' | 'onClose' | 'onEnter' | 'onFilter' | 'onOpen'
> {
onDestroy?: () => void;
}

Expand Down
2 changes: 0 additions & 2 deletions src/extensions/behavior/SelectionContext/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ export type SelectionContextOptions = {
config?: ContextConfig;
/**
* Placement of context popup
*
* @default 'bottom'
*/
placement?: 'top' | 'bottom';
/**
* Prevents context popup from overflowing
*
* @default false
*/
flip?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/behavior/SelectionContext/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {VirtualElement} from '@floating-ui/react'; // eslint-disable-line import/no-extraneous-dependencies
import type {VirtualElement} from '@floating-ui/react';
import {Popup, type PopupPlacement, type PopupProps} from '@gravity-ui/uikit';
import type {EditorState} from 'prosemirror-state';
import type {EditorView} from 'prosemirror-view';
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/markdown/Deflist/DeflistSpecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const defDescType = nodeTypeFactory(DeflistNode.Desc);

export type DeflistSpecsOptions = {
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
deflistTermPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
deflistDescPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
};
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/markdown/Heading/HeadingSpecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const DEFAULT_PLACEHOLDER = (node: Node) => 'Heading ' + node.attrs[headingLevel

export type HeadingSpecsOptions = {
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
headingPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
};
Expand Down
1 change: 0 additions & 1 deletion src/extensions/markdown/Lists/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import ist from 'ist';
import type {Node} from 'prosemirror-model';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/yfm/Checkbox/CheckboxSpecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export {

export type CheckboxSpecsOptions = {
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
checkboxLabelPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
inputView?: ExtensionNodeSpec['view'];
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/yfm/ImgSize/ImgSizeSpecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export {ImgSizeAttr};

export type ImgSizeSpecsOptions = {
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
placeholder?: NodeSpec['placeholder'];
};
Expand Down
1 change: 0 additions & 1 deletion src/extensions/yfm/ImgSize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {imgSizeNodeViewPlugin} from './plugins/ImgSizeNodeView';
export type ImgSizeOptions = ImgSizeSpecsOptions & {
/**
* If we need to set dimensions for uploaded images
*
* @default false
*/
needToSetDimensionsForUploadedImages?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/yfm/YfmCut/YfmCutSpecs/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {CutAttr, CutNode, YfmCutClassName} from './const';

export type YfmCutSchemaOptions = {
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
yfmCutTitlePlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
yfmCutContentPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
};
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/yfm/YfmNote/YfmNoteSpecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export {noteType, noteTitleType} from './utils';

export type YfmNoteSpecsOptions = {
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
yfmNoteTitlePlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
};
Expand Down
2 changes: 0 additions & 2 deletions src/extensions/yfm/YfmTable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ export {
export type YfmTableOptions = YfmTableSpecsOptions & {
/**
* Enables floating controls for table.
*
* @default true
*/
controls?: boolean;
/**
* Enables drag-d-drop rows and columns in table.
* The `controls` property must also be `true`.
*
* @default true
*/
dnd?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import {forwardRef, useEffect, useImperativeHandle, useMemo} from 'react';

// eslint-disable-next-line import/no-extraneous-dependencies
import {
FloatingNode,
FloatingTree,
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/yfm/YfmTabs/YfmTabsSpecs/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DEFAULT_PLACEHOLDERS = {

export type YfmTabsSchemaOptions = {
/**
* @deprecated: use placeholder option in BehaviorPreset instead.
* @deprecated use placeholder option in BehaviorPreset instead.
*/
tabPlaceholder?: NonNullable<NodeSpec['placeholder']>['content'];
};
Expand Down
Loading
Loading