@atlaskit/editor-core 189.3.23 → 189.3.25

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/index.js +0 -7
  3. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +2 -13
  4. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -3
  5. package/dist/cjs/presets/universal.js +2 -1
  6. package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +3 -43
  7. package/dist/cjs/version-wrapper.js +1 -1
  8. package/dist/es2019/plugins/index.js +0 -1
  9. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +2 -11
  10. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -2
  11. package/dist/es2019/presets/universal.js +2 -1
  12. package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +1 -42
  13. package/dist/es2019/version-wrapper.js +1 -1
  14. package/dist/esm/plugins/index.js +0 -1
  15. package/dist/esm/plugins/toolbar-lists-indentation/index.js +2 -11
  16. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -2
  17. package/dist/esm/presets/universal.js +2 -1
  18. package/dist/esm/ui/ConfigPanel/ConfigPanel.js +2 -42
  19. package/dist/esm/version-wrapper.js +1 -1
  20. package/dist/types/plugins/index.d.ts +0 -1
  21. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +1 -3
  22. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -2
  23. package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +4 -3
  24. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  25. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +1 -3
  26. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -2
  27. package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +4 -3
  28. package/package.json +2 -1
  29. package/dist/cjs/plugins/indentation/commands/index.js +0 -140
  30. package/dist/cjs/plugins/indentation/commands/utils.js +0 -92
  31. package/dist/cjs/plugins/indentation/getAttrsWithChangesRecorder.js +0 -38
  32. package/dist/cjs/plugins/indentation/index.js +0 -54
  33. package/dist/cjs/plugins/indentation/pm-plugins/keymap.js +0 -26
  34. package/dist/es2019/plugins/indentation/commands/index.js +0 -130
  35. package/dist/es2019/plugins/indentation/commands/utils.js +0 -89
  36. package/dist/es2019/plugins/indentation/getAttrsWithChangesRecorder.js +0 -32
  37. package/dist/es2019/plugins/indentation/index.js +0 -55
  38. package/dist/es2019/plugins/indentation/pm-plugins/keymap.js +0 -21
  39. package/dist/esm/plugins/indentation/commands/index.js +0 -133
  40. package/dist/esm/plugins/indentation/commands/utils.js +0 -85
  41. package/dist/esm/plugins/indentation/getAttrsWithChangesRecorder.js +0 -32
  42. package/dist/esm/plugins/indentation/index.js +0 -48
  43. package/dist/esm/plugins/indentation/pm-plugins/keymap.js +0 -19
  44. package/dist/types/plugins/indentation/commands/index.d.ts +0 -8
  45. package/dist/types/plugins/indentation/commands/utils.d.ts +0 -37
  46. package/dist/types/plugins/indentation/getAttrsWithChangesRecorder.d.ts +0 -23
  47. package/dist/types/plugins/indentation/index.d.ts +0 -18
  48. package/dist/types/plugins/indentation/pm-plugins/keymap.d.ts +0 -4
  49. package/dist/types-ts4.5/plugins/indentation/commands/index.d.ts +0 -8
  50. package/dist/types-ts4.5/plugins/indentation/commands/utils.d.ts +0 -37
  51. package/dist/types-ts4.5/plugins/indentation/getAttrsWithChangesRecorder.d.ts +0 -23
  52. package/dist/types-ts4.5/plugins/indentation/index.d.ts +0 -20
  53. package/dist/types-ts4.5/plugins/indentation/pm-plugins/keymap.d.ts +0 -4
@@ -1,21 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, findShortcutByKeymap, outdent, indent, backspace } from '@atlaskit/editor-common/keymaps';
3
- import { isTextSelection } from '@atlaskit/editor-common/utils';
4
- import { getIndentCommand, getOutdentCommand } from '../commands';
5
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
- export function keymapPlugin(editorAnalyticsAPI) {
7
- const list = {};
8
- bindKeymapWithCommand(findShortcutByKeymap(indent), getIndentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), list);
9
- bindKeymapWithCommand(findShortcutByKeymap(outdent), getOutdentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), list);
10
- bindKeymapWithCommand(findShortcutByKeymap(backspace), (state, dispatch) => {
11
- const {
12
- selection
13
- } = state;
14
- if (isTextSelection(selection) && selection.$cursor && selection.$cursor.parentOffset === 0) {
15
- return dispatch ? getOutdentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)(state, dispatch) : false;
16
- }
17
- return false;
18
- }, list);
19
- return keymap(list);
20
- }
21
- export default keymapPlugin;
@@ -1,133 +0,0 @@
1
- import { toggleBlockMark } from '@atlaskit/editor-common/commands';
2
- import { createAnalyticsDispatch } from './utils';
3
- import { INDENT_DIRECTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import getAttrsWithChangesRecorder from '../getAttrsWithChangesRecorder';
5
- import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
6
- export var isIndentationAllowed = function isIndentationAllowed(schema, node) {
7
- var _schema$nodes = schema.nodes,
8
- paragraph = _schema$nodes.paragraph,
9
- heading = _schema$nodes.heading,
10
- alignment = schema.marks.alignment;
11
- if ([paragraph, heading].indexOf(node.type) > -1) {
12
- if (alignment) {
13
- var hasAlignment = node.marks.filter(function (mark) {
14
- return mark.type === alignment;
15
- })[0];
16
- return !hasAlignment;
17
- }
18
- return true;
19
- }
20
- return false;
21
- };
22
-
23
- /**
24
- * Create new indentation command (Either indent or outdent depend of getArgsFn)
25
- * @param getNewIndentationAttrs Function to handle new indentation level
26
- */
27
- function createIndentationCommand(getNewIndentationAttrs) {
28
- return function (state, dispatch) {
29
- var indentation = state.schema.marks.indentation;
30
- return toggleBlockMark(indentation, getNewIndentationAttrs, isIndentationAllowed)(state, dispatch);
31
- };
32
- }
33
- function createIndentationCommandWithAnalytics(_ref) {
34
- var getNewIndentationAttrs = _ref.getNewIndentationAttrs,
35
- direction = _ref.direction,
36
- inputMethod = _ref.inputMethod,
37
- editorAnalyticsAPI = _ref.editorAnalyticsAPI;
38
- // Create a new getAttrs function to record the changes
39
- var _getAttrsWithChangesR = getAttrsWithChangesRecorder(getNewIndentationAttrs, {
40
- direction: direction
41
- }),
42
- getAttrs = _getAttrsWithChangesR.getAttrs,
43
- getAndResetAttrsChanges = _getAttrsWithChangesR.getAndResetAttrsChanges;
44
-
45
- // Use new getAttrs wrapper
46
- var indentationCommand = createIndentationCommand(getAttrs);
47
-
48
- // Return a new command where we change dispatch for our analytics dispatch
49
- return function (state, dispatch) {
50
- return indentationCommand(state, createAnalyticsDispatch({
51
- getAttrsChanges: getAndResetAttrsChanges,
52
- inputMethod: inputMethod,
53
- editorAnalyticsAPI: editorAnalyticsAPI,
54
- state: state,
55
- dispatch: dispatch
56
- }));
57
- };
58
- }
59
-
60
- /**
61
- * Get new level for outdent
62
- * @param oldAttr Old attributes for the mark, undefined if the mark doesn't exit
63
- * @returns - undefined; No change required
64
- * - false; Remove the mark
65
- * - object; Update attributes
66
- */
67
- var getIndentAttrs = function getIndentAttrs(oldAttr) {
68
- if (!oldAttr) {
69
- return {
70
- level: 1
71
- }; // No mark exist, create a new one with level 1
72
- }
73
-
74
- var level = oldAttr.level;
75
- if (level >= MAX_INDENTATION_LEVEL) {
76
- return undefined; // Max indentation level reached, do nothing.
77
- }
78
-
79
- return {
80
- level: level + 1
81
- }; // Otherwise, increase the level by one
82
- };
83
-
84
- export var getIndentCommand = function getIndentCommand(editorAnalyticsAPI) {
85
- return function () {
86
- var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.KEYBOARD;
87
- return createIndentationCommandWithAnalytics({
88
- getNewIndentationAttrs: getIndentAttrs,
89
- direction: INDENT_DIRECTION.INDENT,
90
- inputMethod: inputMethod,
91
- editorAnalyticsAPI: editorAnalyticsAPI
92
- });
93
- };
94
- };
95
-
96
- /**
97
- * Get new level for outdent
98
- * @param oldAttr Old attributes for the mark, undefined if the mark doesn't exit
99
- * @returns - undefined; No change required
100
- * - false; Remove the mark
101
- * - object; Update attributes
102
- */
103
- var getOutdentAttrs = function getOutdentAttrs(oldAttr) {
104
- if (!oldAttr) {
105
- return undefined; // Do nothing;
106
- }
107
-
108
- var level = oldAttr.level;
109
- if (level <= 1) {
110
- return false; // Remove the mark
111
- }
112
-
113
- return {
114
- level: level - 1
115
- }; // Decrease the level on other cases
116
- };
117
-
118
- export var getOutdentCommand = function getOutdentCommand(editorAnalyticsAPI) {
119
- return function () {
120
- var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.KEYBOARD;
121
- return createIndentationCommandWithAnalytics({
122
- getNewIndentationAttrs: getOutdentAttrs,
123
- direction: INDENT_DIRECTION.OUTDENT,
124
- inputMethod: inputMethod,
125
- editorAnalyticsAPI: editorAnalyticsAPI
126
- });
127
- };
128
- };
129
- export var removeIndentation = function removeIndentation(state, dispatch) {
130
- return toggleBlockMark(state.schema.marks.indentation, function () {
131
- return false;
132
- })(state, dispatch);
133
- };
@@ -1,85 +0,0 @@
1
- import { INDENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
-
3
- // Analytics GAS v3 Utils
4
-
5
- var indentTypes = {
6
- paragraph: INDENT_TYPE.PARAGRAPH,
7
- heading: INDENT_TYPE.HEADING
8
- };
9
-
10
- /**
11
- * Get the current indentation level given prev and new attributes
12
- * @param prevAttrs - Previous attributes from indentation
13
- * @param newAttrs - New attributes from indentation
14
- */
15
- export function getNewIndentLevel(prevAttrs, newAttrs) {
16
- if (newAttrs === undefined) {
17
- return getPrevIndentLevel(prevAttrs);
18
- } else if (newAttrs === false) {
19
- return 0;
20
- }
21
- return newAttrs.level;
22
- }
23
-
24
- /**
25
- * Get the previous indentation level prev attributes
26
- * @param prevAttrs - Previous attributes from indentation
27
- */
28
- export function getPrevIndentLevel(prevAttrs) {
29
- if (prevAttrs === undefined) {
30
- return 0;
31
- }
32
- return prevAttrs.level;
33
- }
34
-
35
- /**
36
- * Create a new dispatch function who add analytics events given a list of attributes changes
37
- *
38
- * @export
39
- * @param {*} getAttrsChanges
40
- * @param {*} state
41
- * @param dispatch
42
- * @returns
43
- */
44
- export function createAnalyticsDispatch(_ref) {
45
- var getAttrsChanges = _ref.getAttrsChanges,
46
- inputMethod = _ref.inputMethod,
47
- editorAnalyticsAPI = _ref.editorAnalyticsAPI,
48
- state = _ref.state,
49
- dispatch = _ref.dispatch;
50
- return function (tr) {
51
- var currentTr = tr;
52
- var changes = getAttrsChanges(); // Get all attributes changes
53
-
54
- // Add analytics event for each change stored.
55
- changes.forEach(function (_ref2) {
56
- var node = _ref2.node,
57
- prevAttrs = _ref2.prevAttrs,
58
- newAttrs = _ref2.newAttrs,
59
- direction = _ref2.options.direction;
60
- var indentType = indentTypes[node.type.name];
61
- if (!indentType) {
62
- return; // If no valid indent type continue
63
- }
64
-
65
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
66
- action: ACTION.FORMATTED,
67
- actionSubject: ACTION_SUBJECT.TEXT,
68
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
69
- eventType: EVENT_TYPE.TRACK,
70
- attributes: {
71
- inputMethod: inputMethod,
72
- previousIndentationLevel: getPrevIndentLevel(prevAttrs),
73
- newIndentLevel: getNewIndentLevel(prevAttrs, newAttrs),
74
- direction: direction,
75
- indentType: indentType
76
- }
77
- })(currentTr);
78
- });
79
-
80
- // Dispatch analytics if exist
81
- if (dispatch) {
82
- dispatch(tr);
83
- }
84
- };
85
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Create a new getAttrs handler who will wrap the original function,
3
- * and store the changes internally to be used for other
4
- * tools like Analytics later in the code.
5
- *
6
- * @param getAttrs - Function who gets the new attributes
7
- * @return object
8
- * @property handler - New handler to get indentation attributes (It wraps the original)
9
- * @property getChanges - Return all the stored changes.
10
- * @property clear - Clear the changes
11
- */
12
- export default function getAttrsWithChangesRecorder(getAttrs, options) {
13
- var changes = [];
14
- function getAttrsWithChangesRecorder(prevAttrs, node) {
15
- var newAttrs = getAttrs(prevAttrs, node);
16
- changes.push({
17
- node: node,
18
- prevAttrs: prevAttrs,
19
- newAttrs: newAttrs,
20
- options: options
21
- });
22
- return newAttrs;
23
- }
24
- return {
25
- getAttrs: getAttrsWithChangesRecorder,
26
- getAndResetAttrsChanges: function getAndResetAttrsChanges() {
27
- var oldChanges = changes;
28
- changes = [];
29
- return oldChanges;
30
- }
31
- };
32
- }
@@ -1,48 +0,0 @@
1
- import { indentation } from '@atlaskit/adf-schema';
2
- import { keymapPlugin } from './pm-plugins/keymap';
3
- import { getOutdentCommand, getIndentCommand, isIndentationAllowed } from './commands';
4
- import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
5
- var indentationPlugin = function indentationPlugin(_ref) {
6
- var _api$analytics, _api$analytics2;
7
- var api = _ref.api;
8
- return {
9
- name: 'indentation',
10
- marks: function marks() {
11
- return [{
12
- name: 'indentation',
13
- mark: indentation
14
- }];
15
- },
16
- actions: {
17
- indentParagraphOrHeading: getIndentCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
18
- outdentParagraphOrHeading: getOutdentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
19
- },
20
- getSharedState: function getSharedState(editorState) {
21
- var _ref2;
22
- if (!editorState) {
23
- return undefined;
24
- }
25
- var selection = editorState.tr.selection,
26
- indentation = editorState.schema.marks.indentation;
27
- var node = selection.$from.node();
28
- var indentationMark = node.marks.find(function (mark) {
29
- return mark.type === indentation;
30
- });
31
- return {
32
- isIndentationAllowed: isIndentationAllowed(editorState.schema, node),
33
- indentDisabled: (_ref2 = (indentationMark === null || indentationMark === void 0 ? void 0 : indentationMark.attrs.level) >= MAX_INDENTATION_LEVEL) !== null && _ref2 !== void 0 ? _ref2 : false,
34
- outdentDisabled: !indentationMark
35
- };
36
- },
37
- pmPlugins: function pmPlugins() {
38
- return [{
39
- name: 'indentationKeymap',
40
- plugin: function plugin() {
41
- var _api$analytics3;
42
- return keymapPlugin(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
43
- }
44
- }];
45
- }
46
- };
47
- };
48
- export default indentationPlugin;
@@ -1,19 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, findShortcutByKeymap, outdent, indent, backspace } from '@atlaskit/editor-common/keymaps';
3
- import { isTextSelection } from '@atlaskit/editor-common/utils';
4
- import { getIndentCommand, getOutdentCommand } from '../commands';
5
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
- export function keymapPlugin(editorAnalyticsAPI) {
7
- var list = {};
8
- bindKeymapWithCommand(findShortcutByKeymap(indent), getIndentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), list);
9
- bindKeymapWithCommand(findShortcutByKeymap(outdent), getOutdentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), list);
10
- bindKeymapWithCommand(findShortcutByKeymap(backspace), function (state, dispatch) {
11
- var selection = state.selection;
12
- if (isTextSelection(selection) && selection.$cursor && selection.$cursor.parentOffset === 0) {
13
- return dispatch ? getOutdentCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD)(state, dispatch) : false;
14
- }
15
- return false;
16
- }, list);
17
- return keymap(list);
18
- }
19
- export default keymapPlugin;
@@ -1,8 +0,0 @@
1
- import type { Node as PmNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import type { Command } from '@atlaskit/editor-common/types';
4
- import type { IndentationInputMethod } from './utils';
5
- export declare const isIndentationAllowed: (schema: Schema, node: PmNode) => boolean;
6
- export declare const getIndentCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod?: IndentationInputMethod) => Command;
7
- export declare const getOutdentCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod?: IndentationInputMethod) => Command;
8
- export declare const removeIndentation: Command;
@@ -1,37 +0,0 @@
1
- import type { IndentationMarkAttributes } from '@atlaskit/adf-schema';
2
- import type { INDENT_DIRECTION, INPUT_METHOD, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import type { GetAttrsChange } from '../getAttrsWithChangesRecorder';
5
- export type PrevAttributes = IndentationMarkAttributes | undefined;
6
- export type NewAttributes = IndentationMarkAttributes | undefined | false;
7
- export type IndentationChangesOptions = {
8
- direction: INDENT_DIRECTION;
9
- };
10
- export type IndentationInputMethod = INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR;
11
- /**
12
- * Get the current indentation level given prev and new attributes
13
- * @param prevAttrs - Previous attributes from indentation
14
- * @param newAttrs - New attributes from indentation
15
- */
16
- export declare function getNewIndentLevel(prevAttrs: PrevAttributes, newAttrs: NewAttributes): number;
17
- /**
18
- * Get the previous indentation level prev attributes
19
- * @param prevAttrs - Previous attributes from indentation
20
- */
21
- export declare function getPrevIndentLevel(prevAttrs: PrevAttributes): number;
22
- /**
23
- * Create a new dispatch function who add analytics events given a list of attributes changes
24
- *
25
- * @export
26
- * @param {*} getAttrsChanges
27
- * @param {*} state
28
- * @param dispatch
29
- * @returns
30
- */
31
- export declare function createAnalyticsDispatch({ getAttrsChanges, inputMethod, editorAnalyticsAPI, state, dispatch, }: {
32
- getAttrsChanges: () => GetAttrsChange<IndentationMarkAttributes, IndentationChangesOptions>[];
33
- inputMethod: IndentationInputMethod;
34
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
35
- state: EditorState;
36
- dispatch?: (tr: Transaction) => void;
37
- }): (tr: Transaction) => void;
@@ -1,23 +0,0 @@
1
- import type { Node } from '@atlaskit/editor-prosemirror/model';
2
- export interface GetAttrsChange<T, V> {
3
- node: Node;
4
- prevAttrs?: T;
5
- newAttrs: T | false | undefined;
6
- options: V;
7
- }
8
- export type GetAttrsWithChangesRecorder<T, V> = {
9
- getAttrs(prevAttrs?: T | undefined, node?: Node): T | false | undefined;
10
- getAndResetAttrsChanges(): GetAttrsChange<T, V>[];
11
- };
12
- /**
13
- * Create a new getAttrs handler who will wrap the original function,
14
- * and store the changes internally to be used for other
15
- * tools like Analytics later in the code.
16
- *
17
- * @param getAttrs - Function who gets the new attributes
18
- * @return object
19
- * @property handler - New handler to get indentation attributes (It wraps the original)
20
- * @property getChanges - Return all the stored changes.
21
- * @property clear - Clear the changes
22
- */
23
- export default function getAttrsWithChangesRecorder<T, V>(getAttrs: (prevAttrs?: T, node?: Node) => T | false | undefined, options: V): GetAttrsWithChangesRecorder<T, V>;
@@ -1,18 +0,0 @@
1
- import type { NextEditorPlugin, OptionalPlugin, Command } from '@atlaskit/editor-common/types';
2
- import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
- import type { IndentationInputMethod } from './commands/utils';
4
- type IndentationPluginSharedState = {
5
- isIndentationAllowed: boolean;
6
- indentDisabled: boolean;
7
- outdentDisabled: boolean;
8
- };
9
- export type IndentationPlugin = NextEditorPlugin<'indentation', {
10
- dependencies: [OptionalPlugin<AnalyticsPlugin>];
11
- actions: {
12
- indentParagraphOrHeading: (inputMethod: IndentationInputMethod) => Command;
13
- outdentParagraphOrHeading: (inputMethod: IndentationInputMethod) => Command;
14
- };
15
- sharedState: IndentationPluginSharedState | undefined;
16
- }>;
17
- declare const indentationPlugin: IndentationPlugin;
18
- export default indentationPlugin;
@@ -1,4 +0,0 @@
1
- import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- export declare function keymapPlugin(editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
4
- export default keymapPlugin;
@@ -1,8 +0,0 @@
1
- import type { Node as PmNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import type { Command } from '@atlaskit/editor-common/types';
4
- import type { IndentationInputMethod } from './utils';
5
- export declare const isIndentationAllowed: (schema: Schema, node: PmNode) => boolean;
6
- export declare const getIndentCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod?: IndentationInputMethod) => Command;
7
- export declare const getOutdentCommand: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputMethod?: IndentationInputMethod) => Command;
8
- export declare const removeIndentation: Command;
@@ -1,37 +0,0 @@
1
- import type { IndentationMarkAttributes } from '@atlaskit/adf-schema';
2
- import type { INDENT_DIRECTION, INPUT_METHOD, EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
4
- import type { GetAttrsChange } from '../getAttrsWithChangesRecorder';
5
- export type PrevAttributes = IndentationMarkAttributes | undefined;
6
- export type NewAttributes = IndentationMarkAttributes | undefined | false;
7
- export type IndentationChangesOptions = {
8
- direction: INDENT_DIRECTION;
9
- };
10
- export type IndentationInputMethod = INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR;
11
- /**
12
- * Get the current indentation level given prev and new attributes
13
- * @param prevAttrs - Previous attributes from indentation
14
- * @param newAttrs - New attributes from indentation
15
- */
16
- export declare function getNewIndentLevel(prevAttrs: PrevAttributes, newAttrs: NewAttributes): number;
17
- /**
18
- * Get the previous indentation level prev attributes
19
- * @param prevAttrs - Previous attributes from indentation
20
- */
21
- export declare function getPrevIndentLevel(prevAttrs: PrevAttributes): number;
22
- /**
23
- * Create a new dispatch function who add analytics events given a list of attributes changes
24
- *
25
- * @export
26
- * @param {*} getAttrsChanges
27
- * @param {*} state
28
- * @param dispatch
29
- * @returns
30
- */
31
- export declare function createAnalyticsDispatch({ getAttrsChanges, inputMethod, editorAnalyticsAPI, state, dispatch, }: {
32
- getAttrsChanges: () => GetAttrsChange<IndentationMarkAttributes, IndentationChangesOptions>[];
33
- inputMethod: IndentationInputMethod;
34
- editorAnalyticsAPI: EditorAnalyticsAPI | undefined;
35
- state: EditorState;
36
- dispatch?: (tr: Transaction) => void;
37
- }): (tr: Transaction) => void;
@@ -1,23 +0,0 @@
1
- import type { Node } from '@atlaskit/editor-prosemirror/model';
2
- export interface GetAttrsChange<T, V> {
3
- node: Node;
4
- prevAttrs?: T;
5
- newAttrs: T | false | undefined;
6
- options: V;
7
- }
8
- export type GetAttrsWithChangesRecorder<T, V> = {
9
- getAttrs(prevAttrs?: T | undefined, node?: Node): T | false | undefined;
10
- getAndResetAttrsChanges(): GetAttrsChange<T, V>[];
11
- };
12
- /**
13
- * Create a new getAttrs handler who will wrap the original function,
14
- * and store the changes internally to be used for other
15
- * tools like Analytics later in the code.
16
- *
17
- * @param getAttrs - Function who gets the new attributes
18
- * @return object
19
- * @property handler - New handler to get indentation attributes (It wraps the original)
20
- * @property getChanges - Return all the stored changes.
21
- * @property clear - Clear the changes
22
- */
23
- export default function getAttrsWithChangesRecorder<T, V>(getAttrs: (prevAttrs?: T, node?: Node) => T | false | undefined, options: V): GetAttrsWithChangesRecorder<T, V>;
@@ -1,20 +0,0 @@
1
- import type { NextEditorPlugin, OptionalPlugin, Command } from '@atlaskit/editor-common/types';
2
- import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
- import type { IndentationInputMethod } from './commands/utils';
4
- type IndentationPluginSharedState = {
5
- isIndentationAllowed: boolean;
6
- indentDisabled: boolean;
7
- outdentDisabled: boolean;
8
- };
9
- export type IndentationPlugin = NextEditorPlugin<'indentation', {
10
- dependencies: [
11
- OptionalPlugin<AnalyticsPlugin>
12
- ];
13
- actions: {
14
- indentParagraphOrHeading: (inputMethod: IndentationInputMethod) => Command;
15
- outdentParagraphOrHeading: (inputMethod: IndentationInputMethod) => Command;
16
- };
17
- sharedState: IndentationPluginSharedState | undefined;
18
- }>;
19
- declare const indentationPlugin: IndentationPlugin;
20
- export default indentationPlugin;
@@ -1,4 +0,0 @@
1
- import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
- export declare function keymapPlugin(editorAnalyticsAPI: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
4
- export default keymapPlugin;