@atlaskit/editor-plugin-text-formatting 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +7 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE.md +13 -0
- package/README.md +9 -0
- package/dist/cjs/actions.js +188 -0
- package/dist/cjs/commands/clear-formatting.js +111 -0
- package/dist/cjs/commands/text-formatting.js +143 -0
- package/dist/cjs/commands/transform-to-code.js +68 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/plugin.js +133 -0
- package/dist/cjs/pm-plugins/clear-formatting-keymap.js +21 -0
- package/dist/cjs/pm-plugins/clear-formatting.js +36 -0
- package/dist/cjs/pm-plugins/cursor.js +55 -0
- package/dist/cjs/pm-plugins/input-rule.js +274 -0
- package/dist/cjs/pm-plugins/keymap.js +52 -0
- package/dist/cjs/pm-plugins/main.js +113 -0
- package/dist/cjs/pm-plugins/plugin-key.js +9 -0
- package/dist/cjs/pm-plugins/smart-input-rule.js +176 -0
- package/dist/cjs/ui/Toolbar/constants.js +19 -0
- package/dist/cjs/ui/Toolbar/dropdown-menu.js +86 -0
- package/dist/cjs/ui/Toolbar/hooks/clear-formatting-icon.js +55 -0
- package/dist/cjs/ui/Toolbar/hooks/formatting-icons.js +227 -0
- package/dist/cjs/ui/Toolbar/hooks/menu-state.js +23 -0
- package/dist/cjs/ui/Toolbar/hooks/responsive-toolbar-buttons.js +60 -0
- package/dist/cjs/ui/Toolbar/index.js +183 -0
- package/dist/cjs/ui/Toolbar/more-button.js +42 -0
- package/dist/cjs/ui/Toolbar/single-toolbar-buttons.js +49 -0
- package/dist/cjs/ui/Toolbar/types.js +17 -0
- package/dist/cjs/utils/cell-selection.js +12 -0
- package/dist/cjs/utils.js +86 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/actions.js +161 -0
- package/dist/es2019/commands/clear-formatting.js +105 -0
- package/dist/es2019/commands/text-formatting.js +144 -0
- package/dist/es2019/commands/transform-to-code.js +71 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/plugin.js +124 -0
- package/dist/es2019/pm-plugins/clear-formatting-keymap.js +10 -0
- package/dist/es2019/pm-plugins/clear-formatting.js +26 -0
- package/dist/es2019/pm-plugins/cursor.js +52 -0
- package/dist/es2019/pm-plugins/input-rule.js +242 -0
- package/dist/es2019/pm-plugins/keymap.js +43 -0
- package/dist/es2019/pm-plugins/main.js +110 -0
- package/dist/es2019/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/smart-input-rule.js +155 -0
- package/dist/es2019/ui/Toolbar/constants.js +20 -0
- package/dist/es2019/ui/Toolbar/dropdown-menu.js +66 -0
- package/dist/es2019/ui/Toolbar/hooks/clear-formatting-icon.js +44 -0
- package/dist/es2019/ui/Toolbar/hooks/formatting-icons.js +212 -0
- package/dist/es2019/ui/Toolbar/hooks/menu-state.js +11 -0
- package/dist/es2019/ui/Toolbar/hooks/responsive-toolbar-buttons.js +48 -0
- package/dist/es2019/ui/Toolbar/index.js +168 -0
- package/dist/es2019/ui/Toolbar/more-button.js +34 -0
- package/dist/es2019/ui/Toolbar/single-toolbar-buttons.js +39 -0
- package/dist/es2019/ui/Toolbar/types.js +10 -0
- package/dist/es2019/utils/cell-selection.js +5 -0
- package/dist/es2019/utils.js +74 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/actions.js +168 -0
- package/dist/esm/commands/clear-formatting.js +101 -0
- package/dist/esm/commands/text-formatting.js +134 -0
- package/dist/esm/commands/transform-to-code.js +61 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/plugin.js +125 -0
- package/dist/esm/pm-plugins/clear-formatting-keymap.js +10 -0
- package/dist/esm/pm-plugins/clear-formatting.js +28 -0
- package/dist/esm/pm-plugins/cursor.js +48 -0
- package/dist/esm/pm-plugins/input-rule.js +257 -0
- package/dist/esm/pm-plugins/keymap.js +43 -0
- package/dist/esm/pm-plugins/main.js +99 -0
- package/dist/esm/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/smart-input-rule.js +169 -0
- package/dist/esm/ui/Toolbar/constants.js +8 -0
- package/dist/esm/ui/Toolbar/dropdown-menu.js +75 -0
- package/dist/esm/ui/Toolbar/hooks/clear-formatting-icon.js +47 -0
- package/dist/esm/ui/Toolbar/hooks/formatting-icons.js +215 -0
- package/dist/esm/ui/Toolbar/hooks/menu-state.js +15 -0
- package/dist/esm/ui/Toolbar/hooks/responsive-toolbar-buttons.js +50 -0
- package/dist/esm/ui/Toolbar/index.js +174 -0
- package/dist/esm/ui/Toolbar/more-button.js +33 -0
- package/dist/esm/ui/Toolbar/single-toolbar-buttons.js +38 -0
- package/dist/esm/ui/Toolbar/types.js +10 -0
- package/dist/esm/utils/cell-selection.js +5 -0
- package/dist/esm/utils.js +75 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/actions.d.ts +22 -0
- package/dist/types/commands/clear-formatting.d.ts +6 -0
- package/dist/types/commands/text-formatting.d.ts +5 -0
- package/dist/types/commands/transform-to-code.d.ts +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/plugin.d.ts +17 -0
- package/dist/types/pm-plugins/clear-formatting-keymap.d.ts +4 -0
- package/dist/types/pm-plugins/clear-formatting.d.ts +8 -0
- package/dist/types/pm-plugins/cursor.d.ts +3 -0
- package/dist/types/pm-plugins/input-rule.d.ts +23 -0
- package/dist/types/pm-plugins/keymap.d.ts +4 -0
- package/dist/types/pm-plugins/main.d.ts +7 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/smart-input-rule.d.ts +3 -0
- package/dist/types/ui/Toolbar/constants.d.ts +6 -0
- package/dist/types/ui/Toolbar/dropdown-menu.d.ts +15 -0
- package/dist/types/ui/Toolbar/hooks/clear-formatting-icon.d.ts +7 -0
- package/dist/types/ui/Toolbar/hooks/formatting-icons.d.ts +14 -0
- package/dist/types/ui/Toolbar/hooks/menu-state.d.ts +1 -0
- package/dist/types/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +20 -0
- package/dist/types/ui/Toolbar/index.d.ts +25 -0
- package/dist/types/ui/Toolbar/more-button.d.ts +14 -0
- package/dist/types/ui/Toolbar/single-toolbar-buttons.d.ts +10 -0
- package/dist/types/ui/Toolbar/types.d.ts +32 -0
- package/dist/types/utils/cell-selection.d.ts +3 -0
- package/dist/types/utils.d.ts +11 -0
- package/dist/types-ts4.5/actions.d.ts +22 -0
- package/dist/types-ts4.5/commands/clear-formatting.d.ts +6 -0
- package/dist/types-ts4.5/commands/text-formatting.d.ts +5 -0
- package/dist/types-ts4.5/commands/transform-to-code.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +3 -0
- package/dist/types-ts4.5/plugin.d.ts +19 -0
- package/dist/types-ts4.5/pm-plugins/clear-formatting-keymap.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/clear-formatting.d.ts +8 -0
- package/dist/types-ts4.5/pm-plugins/cursor.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/input-rule.d.ts +23 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +7 -0
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/smart-input-rule.d.ts +3 -0
- package/dist/types-ts4.5/ui/Toolbar/constants.d.ts +6 -0
- package/dist/types-ts4.5/ui/Toolbar/dropdown-menu.d.ts +15 -0
- package/dist/types-ts4.5/ui/Toolbar/hooks/clear-formatting-icon.d.ts +7 -0
- package/dist/types-ts4.5/ui/Toolbar/hooks/formatting-icons.d.ts +14 -0
- package/dist/types-ts4.5/ui/Toolbar/hooks/menu-state.d.ts +5 -0
- package/dist/types-ts4.5/ui/Toolbar/hooks/responsive-toolbar-buttons.d.ts +20 -0
- package/dist/types-ts4.5/ui/Toolbar/index.d.ts +25 -0
- package/dist/types-ts4.5/ui/Toolbar/more-button.d.ts +14 -0
- package/dist/types-ts4.5/ui/Toolbar/single-toolbar-buttons.d.ts +10 -0
- package/dist/types-ts4.5/ui/Toolbar/types.d.ts +32 -0
- package/dist/types-ts4.5/utils/cell-selection.d.ts +3 -0
- package/dist/types-ts4.5/utils.d.ts +11 -0
- package/package.json +93 -0
- package/report.api.md +66 -0
- package/tmp/api-report-tmp.d.ts +39 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { MenuIconItem } from './types';
|
|
6
|
+
export declare const SingleToolbarButtons: React.MemoExoticComponent<({ items, isReducedSpacing, editorView, }: {
|
|
7
|
+
items: MenuIconItem[];
|
|
8
|
+
isReducedSpacing: boolean;
|
|
9
|
+
editorView: EditorView;
|
|
10
|
+
}) => jsx.JSX.Element>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
+
import type { TOOLBAR_ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
export declare enum IconTypes {
|
|
8
|
+
strong = "strong",
|
|
9
|
+
em = "em",
|
|
10
|
+
underline = "underline",
|
|
11
|
+
strike = "strike",
|
|
12
|
+
code = "code",
|
|
13
|
+
subscript = "subscript",
|
|
14
|
+
superscript = "superscript"
|
|
15
|
+
}
|
|
16
|
+
export interface MenuIconItem extends MenuItem {
|
|
17
|
+
command: Command;
|
|
18
|
+
iconMark?: IconTypes;
|
|
19
|
+
tooltipElement?: React.ReactElement;
|
|
20
|
+
iconElement?: React.ReactElement;
|
|
21
|
+
buttonId?: TOOLBAR_ACTION_SUBJECT_ID;
|
|
22
|
+
}
|
|
23
|
+
export type MenuIconState = {
|
|
24
|
+
isActive: boolean;
|
|
25
|
+
isDisabled: boolean;
|
|
26
|
+
isHidden: boolean;
|
|
27
|
+
hasSchemaMark: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type IconHookProps = {
|
|
30
|
+
isToolbarDisabled?: boolean;
|
|
31
|
+
editorState: EditorState;
|
|
32
|
+
} & WrappedComponentProps;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
|
+
export declare const cellSelectionNodesBetween: (selection: CellSelection, doc: Node, f: (node: Node, pos: number, parent: Node | null, index: number) => void | boolean, startPos?: number) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Mark as PMMark } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { MenuIconItem } from './ui/Toolbar/types';
|
|
4
|
+
export declare const hasCode: (state: EditorState, pos: number) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Determine if a mark (with specific attribute values) exists anywhere in the selection.
|
|
7
|
+
*/
|
|
8
|
+
export declare const markActive: (state: EditorState, mark: PMMark) => boolean;
|
|
9
|
+
export declare const checkFormattingIsPresent: (state: EditorState) => boolean;
|
|
10
|
+
export declare const compareItemsArrays: (items: MenuIconItem[], prevItems: MenuIconItem[]) => MenuIconItem[];
|
|
11
|
+
export declare const isArrayContainsContent: (items: MenuIconItem[], content: string) => boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, InputMethodBasic } from '@atlaskit/editor-common/types';
|
|
3
|
+
type ToggleMarkCommand = () => Command;
|
|
4
|
+
export type ToggleMarkWithAnalyticsCommand = (analyticsMetadata: {
|
|
5
|
+
inputMethod: InputMethodBasic;
|
|
6
|
+
}) => Command;
|
|
7
|
+
type ToggleMarkWithAnalyticsFactory = (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => ToggleMarkWithAnalyticsCommand;
|
|
8
|
+
export declare const toggleEm: ToggleMarkCommand;
|
|
9
|
+
export declare const toggleEmWithAnalytics: ToggleMarkWithAnalyticsFactory;
|
|
10
|
+
export declare const toggleStrike: ToggleMarkCommand;
|
|
11
|
+
export declare const toggleStrikeWithAnalytics: ToggleMarkWithAnalyticsFactory;
|
|
12
|
+
export declare const toggleStrong: ToggleMarkCommand;
|
|
13
|
+
export declare const toggleStrongWithAnalytics: ToggleMarkWithAnalyticsFactory;
|
|
14
|
+
export declare const toggleUnderline: ToggleMarkCommand;
|
|
15
|
+
export declare const toggleUnderlineWithAnalytics: ToggleMarkWithAnalyticsFactory;
|
|
16
|
+
export declare const toggleSuperscript: ToggleMarkCommand;
|
|
17
|
+
export declare const toggleSuperscriptWithAnalytics: ToggleMarkWithAnalyticsFactory;
|
|
18
|
+
export declare const toggleSubscript: ToggleMarkCommand;
|
|
19
|
+
export declare const toggleSubscriptWithAnalytics: ToggleMarkWithAnalyticsFactory;
|
|
20
|
+
export declare const toggleCode: ToggleMarkCommand;
|
|
21
|
+
export declare const toggleCodeWithAnalytics: ToggleMarkWithAnalyticsFactory;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
3
|
+
export declare const FORMATTING_NODE_TYPES: string[];
|
|
4
|
+
export declare const FORMATTING_MARK_TYPES: string[];
|
|
5
|
+
export declare function clearFormattingWithAnalytics(inputMethod: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): Command;
|
|
6
|
+
export declare function clearFormatting(inputMethod?: INPUT_METHOD.TOOLBAR | INPUT_METHOD.SHORTCUT, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined): Command;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
3
|
+
export declare const moveRight: () => Command;
|
|
4
|
+
export declare const moveLeft: () => Command;
|
|
5
|
+
export declare const createInlineCodeFromTextInputWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (from: number, to: number, text: string) => Command;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NextEditorPlugin, OptionalPlugin, TextFormattingOptions } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { ToggleMarkWithAnalyticsCommand } from './actions';
|
|
4
|
+
export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
|
|
5
|
+
pluginConfiguration: TextFormattingOptions | undefined;
|
|
6
|
+
dependencies: [
|
|
7
|
+
OptionalPlugin<typeof analyticsPlugin>
|
|
8
|
+
];
|
|
9
|
+
actions: {
|
|
10
|
+
toggleSuperscript: ToggleMarkWithAnalyticsCommand;
|
|
11
|
+
toggleSubscript: ToggleMarkWithAnalyticsCommand;
|
|
12
|
+
toggleStrike: ToggleMarkWithAnalyticsCommand;
|
|
13
|
+
toggleCode: ToggleMarkWithAnalyticsCommand;
|
|
14
|
+
toggleUnderline: ToggleMarkWithAnalyticsCommand;
|
|
15
|
+
toggleEm: ToggleMarkWithAnalyticsCommand;
|
|
16
|
+
toggleStrong: ToggleMarkWithAnalyticsCommand;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export declare const textFormattingPlugin: TextFormattingPlugin;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
export declare function keymapPlugin(editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin;
|
|
4
|
+
export default keymapPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
export interface ClearFormattingState {
|
|
5
|
+
formattingIsPresent?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const pluginKey: PluginKey<ClearFormattingState>;
|
|
8
|
+
export declare const plugin: (dispatch: Dispatch) => SafePlugin<ClearFormattingState>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
declare enum ValidAutoformatChars {
|
|
5
|
+
STRONG = "__",
|
|
6
|
+
STRIKE = "~~",
|
|
7
|
+
STRONG_MARKDOWN = "**",
|
|
8
|
+
ITALIC_MARKDOWN = "*",
|
|
9
|
+
ITALIC = "_",
|
|
10
|
+
CODE = "`"
|
|
11
|
+
}
|
|
12
|
+
export declare const ValidCombinations: Record<ValidAutoformatChars, string[]>;
|
|
13
|
+
declare class ReverseRegexExp extends RegExp {
|
|
14
|
+
exec(str: string): RegExpExecArray | null;
|
|
15
|
+
}
|
|
16
|
+
export declare const strongRegex1: ReverseRegexExp;
|
|
17
|
+
export declare const strongRegex2: ReverseRegexExp;
|
|
18
|
+
export declare const italicRegex1: ReverseRegexExp;
|
|
19
|
+
export declare const italicRegex2: ReverseRegexExp;
|
|
20
|
+
export declare const strikeRegex: ReverseRegexExp;
|
|
21
|
+
export declare const codeRegex: ReverseRegexExp;
|
|
22
|
+
export declare function inputRulePlugin(schema: Schema, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
23
|
+
export default inputRulePlugin;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
+
export default function keymapPlugin(schema: Schema, editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { TextFormattingState } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { pluginKey } from './plugin-key';
|
|
6
|
+
export { pluginKey };
|
|
7
|
+
export declare const plugin: (dispatch: Dispatch, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => SafePlugin<TextFormattingState>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { IconTypes } from './types';
|
|
3
|
+
export declare const DefaultButtonsToolbar: IconTypes[];
|
|
4
|
+
export declare const DefaultButtonsMenu: IconTypes[];
|
|
5
|
+
export declare const ResponsiveCustomButtonToolbar: Record<ToolbarSize, IconTypes[]>;
|
|
6
|
+
export declare const ResponsiveCustomMenu: Record<ToolbarSize, IconTypes[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
import type { MenuIconItem } from './types';
|
|
4
|
+
type DropdownMenuProps = {
|
|
5
|
+
editorView: EditorView;
|
|
6
|
+
isReducedSpacing: boolean;
|
|
7
|
+
items: Array<MenuIconItem>;
|
|
8
|
+
moreButtonLabel: string;
|
|
9
|
+
hasFormattingActive: boolean;
|
|
10
|
+
popupsBoundariesElement?: HTMLElement;
|
|
11
|
+
popupsMountPoint?: HTMLElement;
|
|
12
|
+
popupsScrollableElement?: HTMLElement;
|
|
13
|
+
};
|
|
14
|
+
export declare const FormattingTextDropdownMenu: React.MemoExoticComponent<({ editorView, moreButtonLabel, isReducedSpacing, items, hasFormattingActive, popupsBoundariesElement, popupsMountPoint, popupsScrollableElement, }: DropdownMenuProps) => JSX.Element>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { IconHookProps, MenuIconItem } from '../types';
|
|
3
|
+
interface ClearIconHookProps extends IconHookProps {
|
|
4
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare const useClearIcon: ({ intl, editorState, editorAnalyticsAPI, }: ClearIconHookProps) => MenuIconItem | null;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { IconHookProps, MenuIconItem } from '../types';
|
|
4
|
+
import { IconTypes } from '../types';
|
|
5
|
+
interface FormattingIconHookProps extends IconHookProps {
|
|
6
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const useFormattingIcons: ({ isToolbarDisabled, editorState, intl, editorAnalyticsAPI, }: FormattingIconHookProps) => Array<MenuIconItem | null>;
|
|
9
|
+
type Props = {
|
|
10
|
+
editorState: EditorState;
|
|
11
|
+
iconTypeList: IconTypes[];
|
|
12
|
+
};
|
|
13
|
+
export declare const useHasFormattingActived: ({ editorState, iconTypeList, }: Props) => boolean;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { MenuIconItem } from '../types';
|
|
3
|
+
export declare const useResponsiveIconTypeButtons: ({ toolbarSize, responsivenessEnabled, }: {
|
|
4
|
+
toolbarSize: ToolbarSize;
|
|
5
|
+
responsivenessEnabled: boolean;
|
|
6
|
+
}) => import("../types").IconTypes[];
|
|
7
|
+
export declare const useResponsiveIconTypeMenu: ({ toolbarSize, responsivenessEnabled, }: {
|
|
8
|
+
toolbarSize: ToolbarSize;
|
|
9
|
+
responsivenessEnabled: boolean;
|
|
10
|
+
}) => import("../types").IconTypes[];
|
|
11
|
+
type IconsPositions = {
|
|
12
|
+
dropdownItems: Array<MenuIconItem>;
|
|
13
|
+
singleItems: Array<MenuIconItem>;
|
|
14
|
+
};
|
|
15
|
+
export declare const useResponsiveToolbarButtons: ({ icons, toolbarSize, responsivenessEnabled, }: {
|
|
16
|
+
responsivenessEnabled: boolean;
|
|
17
|
+
toolbarSize: ToolbarSize;
|
|
18
|
+
icons: Array<MenuIconItem | null>;
|
|
19
|
+
}) => IconsPositions;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
export type ToolbarFormattingProps = {
|
|
8
|
+
editorView: EditorView;
|
|
9
|
+
isToolbarDisabled: boolean;
|
|
10
|
+
toolbarSize: ToolbarSize;
|
|
11
|
+
isReducedSpacing: boolean;
|
|
12
|
+
shouldUseResponsiveToolbar: boolean;
|
|
13
|
+
popupsMountPoint?: HTMLElement;
|
|
14
|
+
popupsBoundariesElement?: HTMLElement;
|
|
15
|
+
popupsScrollableElement?: HTMLElement;
|
|
16
|
+
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<ToolbarFormattingProps & WrappedComponentProps<"intl"> & {
|
|
19
|
+
editorState: EditorState;
|
|
20
|
+
}>> & {
|
|
21
|
+
WrappedComponent: import("react").ComponentType<ToolbarFormattingProps & WrappedComponentProps<"intl"> & {
|
|
22
|
+
editorState: EditorState;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
type MoreButtonProps = {
|
|
5
|
+
label: string;
|
|
6
|
+
isReducedSpacing: boolean;
|
|
7
|
+
isSelected: boolean;
|
|
8
|
+
isDisabled: boolean;
|
|
9
|
+
'aria-expanded': React.AriaAttributes['aria-expanded'];
|
|
10
|
+
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
11
|
+
onKeyDown?: (event: React.KeyboardEvent) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const MoreButton: React.MemoExoticComponent<({ label, "aria-expanded": ariaExpanded, isReducedSpacing, isSelected, isDisabled, onClick, onKeyDown, }: MoreButtonProps) => jsx.JSX.Element>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
5
|
+
import type { MenuIconItem } from './types';
|
|
6
|
+
export declare const SingleToolbarButtons: React.MemoExoticComponent<({ items, isReducedSpacing, editorView, }: {
|
|
7
|
+
items: MenuIconItem[];
|
|
8
|
+
isReducedSpacing: boolean;
|
|
9
|
+
editorView: EditorView;
|
|
10
|
+
}) => jsx.JSX.Element>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
|
+
import type { TOOLBAR_ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
6
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
export declare enum IconTypes {
|
|
8
|
+
strong = "strong",
|
|
9
|
+
em = "em",
|
|
10
|
+
underline = "underline",
|
|
11
|
+
strike = "strike",
|
|
12
|
+
code = "code",
|
|
13
|
+
subscript = "subscript",
|
|
14
|
+
superscript = "superscript"
|
|
15
|
+
}
|
|
16
|
+
export interface MenuIconItem extends MenuItem {
|
|
17
|
+
command: Command;
|
|
18
|
+
iconMark?: IconTypes;
|
|
19
|
+
tooltipElement?: React.ReactElement;
|
|
20
|
+
iconElement?: React.ReactElement;
|
|
21
|
+
buttonId?: TOOLBAR_ACTION_SUBJECT_ID;
|
|
22
|
+
}
|
|
23
|
+
export type MenuIconState = {
|
|
24
|
+
isActive: boolean;
|
|
25
|
+
isDisabled: boolean;
|
|
26
|
+
isHidden: boolean;
|
|
27
|
+
hasSchemaMark: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type IconHookProps = {
|
|
30
|
+
isToolbarDisabled?: boolean;
|
|
31
|
+
editorState: EditorState;
|
|
32
|
+
} & WrappedComponentProps;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
|
+
export declare const cellSelectionNodesBetween: (selection: CellSelection, doc: Node, f: (node: Node, pos: number, parent: Node | null, index: number) => void | boolean, startPos?: number) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Mark as PMMark } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { MenuIconItem } from './ui/Toolbar/types';
|
|
4
|
+
export declare const hasCode: (state: EditorState, pos: number) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Determine if a mark (with specific attribute values) exists anywhere in the selection.
|
|
7
|
+
*/
|
|
8
|
+
export declare const markActive: (state: EditorState, mark: PMMark) => boolean;
|
|
9
|
+
export declare const checkFormattingIsPresent: (state: EditorState) => boolean;
|
|
10
|
+
export declare const compareItemsArrays: (items: MenuIconItem[], prevItems: MenuIconItem[]) => MenuIconItem[];
|
|
11
|
+
export declare const isArrayContainsContent: (items: MenuIconItem[], content: string) => boolean;
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-plugin-text-formatting",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Text-formatting plugin for @atlaskit/editor-core",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"atlassian": {
|
|
11
|
+
"team": "Editor",
|
|
12
|
+
"singleton": true,
|
|
13
|
+
"releaseModel": "continuous"
|
|
14
|
+
},
|
|
15
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
16
|
+
"main": "dist/cjs/index.js",
|
|
17
|
+
"module": "dist/esm/index.js",
|
|
18
|
+
"module:es2019": "dist/es2019/index.js",
|
|
19
|
+
"types": "dist/types/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
">=4.5 <4.9": {
|
|
22
|
+
"*": [
|
|
23
|
+
"dist/types-ts4.5/*",
|
|
24
|
+
"dist/types-ts4.5/index.d.ts"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"atlaskit:src": "src/index.ts",
|
|
30
|
+
"af:exports": {
|
|
31
|
+
".": "./src/index.ts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@atlaskit/adf-schema": "^28.0.0",
|
|
35
|
+
"@atlaskit/editor-common": "^74.36.0",
|
|
36
|
+
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
37
|
+
"@atlaskit/editor-shared-styles": "^2.5.0",
|
|
38
|
+
"@atlaskit/editor-tables": "^2.3.0",
|
|
39
|
+
"@atlaskit/icon": "^21.12.0",
|
|
40
|
+
"@atlaskit/prosemirror-input-rules": "^2.4.0",
|
|
41
|
+
"@babel/runtime": "^7.0.0",
|
|
42
|
+
"@emotion/react": "^11.7.1",
|
|
43
|
+
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": "^16.8.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@atlaskit/editor-plugin-analytics": "^0.1.0",
|
|
50
|
+
"@atlaskit/editor-plugin-decorations": "^0.1.0",
|
|
51
|
+
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
52
|
+
"@atlaskit/editor-test-helpers": "^18.10.0",
|
|
53
|
+
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
54
|
+
"@testing-library/react": "^12.1.5",
|
|
55
|
+
"typescript": "~4.9.5"
|
|
56
|
+
},
|
|
57
|
+
"techstack": {
|
|
58
|
+
"@atlassian/frontend": {
|
|
59
|
+
"import-structure": [
|
|
60
|
+
"atlassian-conventions"
|
|
61
|
+
],
|
|
62
|
+
"circular-dependencies": [
|
|
63
|
+
"file-and-folder-level"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"@repo/internal": {
|
|
67
|
+
"dom-events": "use-bind-event-listener",
|
|
68
|
+
"analytics": [
|
|
69
|
+
"analytics-next"
|
|
70
|
+
],
|
|
71
|
+
"design-tokens": [
|
|
72
|
+
"color"
|
|
73
|
+
],
|
|
74
|
+
"theming": [
|
|
75
|
+
"react-context"
|
|
76
|
+
],
|
|
77
|
+
"ui-components": [
|
|
78
|
+
"lite-mode"
|
|
79
|
+
],
|
|
80
|
+
"deprecation": [
|
|
81
|
+
"no-deprecated-imports"
|
|
82
|
+
],
|
|
83
|
+
"styling": [
|
|
84
|
+
"static",
|
|
85
|
+
"emotion"
|
|
86
|
+
],
|
|
87
|
+
"imports": [
|
|
88
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
93
|
+
}
|
package/report.api.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!-- API Report Version: 2.3 -->
|
|
2
|
+
|
|
3
|
+
## API Report File for "@atlaskit/editor-plugin-text-formatting"
|
|
4
|
+
|
|
5
|
+
> Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
|
|
6
|
+
> [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
7
|
+
|
|
8
|
+
### Table of contents
|
|
9
|
+
|
|
10
|
+
- [Main Entry Types](#main-entry-types)
|
|
11
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
12
|
+
|
|
13
|
+
### Main Entry Types
|
|
14
|
+
|
|
15
|
+
<!--SECTION START: Main Entry Types-->
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
19
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
20
|
+
import type { InputMethodBasic } from '@atlaskit/editor-common/types';
|
|
21
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
22
|
+
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
23
|
+
import type { TextFormattingOptions } from '@atlaskit/editor-common/types';
|
|
24
|
+
|
|
25
|
+
// @public (undocumented)
|
|
26
|
+
export type TextFormattingPlugin = NextEditorPlugin<
|
|
27
|
+
'textFormatting',
|
|
28
|
+
{
|
|
29
|
+
pluginConfiguration: TextFormattingOptions | undefined;
|
|
30
|
+
dependencies: [OptionalPlugin<typeof analyticsPlugin>];
|
|
31
|
+
actions: {
|
|
32
|
+
toggleSuperscript: ToggleMarkWithAnalyticsCommand;
|
|
33
|
+
toggleSubscript: ToggleMarkWithAnalyticsCommand;
|
|
34
|
+
toggleStrike: ToggleMarkWithAnalyticsCommand;
|
|
35
|
+
toggleCode: ToggleMarkWithAnalyticsCommand;
|
|
36
|
+
toggleUnderline: ToggleMarkWithAnalyticsCommand;
|
|
37
|
+
toggleEm: ToggleMarkWithAnalyticsCommand;
|
|
38
|
+
toggleStrong: ToggleMarkWithAnalyticsCommand;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
// @public (undocumented)
|
|
44
|
+
export const textFormattingPlugin: TextFormattingPlugin;
|
|
45
|
+
|
|
46
|
+
// @public (undocumented)
|
|
47
|
+
export type ToggleMarkWithAnalyticsCommand = (analyticsMetadata: {
|
|
48
|
+
inputMethod: InputMethodBasic;
|
|
49
|
+
}) => Command;
|
|
50
|
+
|
|
51
|
+
// (No @packageDocumentation comment for this package)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<!--SECTION END: Main Entry Types-->
|
|
55
|
+
|
|
56
|
+
### Peer Dependencies
|
|
57
|
+
|
|
58
|
+
<!--SECTION START: Peer Dependencies-->
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"react": "^16.8.0"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
<!--SECTION END: Peer Dependencies-->
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/editor-plugin-text-formatting"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
8
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
9
|
+
import type { InputMethodBasic } from '@atlaskit/editor-common/types';
|
|
10
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
11
|
+
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
12
|
+
import type { TextFormattingOptions } from '@atlaskit/editor-common/types';
|
|
13
|
+
|
|
14
|
+
// @public (undocumented)
|
|
15
|
+
export type TextFormattingPlugin = NextEditorPlugin<'textFormatting', {
|
|
16
|
+
pluginConfiguration: TextFormattingOptions | undefined;
|
|
17
|
+
dependencies: [OptionalPlugin<typeof analyticsPlugin>];
|
|
18
|
+
actions: {
|
|
19
|
+
toggleSuperscript: ToggleMarkWithAnalyticsCommand;
|
|
20
|
+
toggleSubscript: ToggleMarkWithAnalyticsCommand;
|
|
21
|
+
toggleStrike: ToggleMarkWithAnalyticsCommand;
|
|
22
|
+
toggleCode: ToggleMarkWithAnalyticsCommand;
|
|
23
|
+
toggleUnderline: ToggleMarkWithAnalyticsCommand;
|
|
24
|
+
toggleEm: ToggleMarkWithAnalyticsCommand;
|
|
25
|
+
toggleStrong: ToggleMarkWithAnalyticsCommand;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
// @public (undocumented)
|
|
30
|
+
export const textFormattingPlugin: TextFormattingPlugin;
|
|
31
|
+
|
|
32
|
+
// @public (undocumented)
|
|
33
|
+
export type ToggleMarkWithAnalyticsCommand = (analyticsMetadata: {
|
|
34
|
+
inputMethod: InputMethodBasic;
|
|
35
|
+
}) => Command;
|
|
36
|
+
|
|
37
|
+
// (No @packageDocumentation comment for this package)
|
|
38
|
+
|
|
39
|
+
```
|