@atlaskit/editor-core 190.1.9 → 190.1.12
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/CHANGELOG.md +15 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/ui/ConfigPanel/utils.js +4 -3
- package/dist/cjs/ui/ContentStyles/code-block.js +2 -2
- package/dist/cjs/ui/ContentStyles/expand.js +10 -45
- package/dist/cjs/ui/ContentStyles/index.js +3 -3
- package/dist/cjs/ui/ContentStyles/panel.js +2 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/ui/ConfigPanel/utils.js +5 -2
- package/dist/es2019/ui/ContentStyles/code-block.js +2 -2
- package/dist/es2019/ui/ContentStyles/expand.js +19 -64
- package/dist/es2019/ui/ContentStyles/index.js +8 -8
- package/dist/es2019/ui/ContentStyles/panel.js +2 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/ui/ConfigPanel/utils.js +3 -2
- package/dist/esm/ui/ContentStyles/code-block.js +2 -2
- package/dist/esm/ui/ContentStyles/expand.js +10 -46
- package/dist/esm/ui/ContentStyles/index.js +3 -3
- package/dist/esm/ui/ContentStyles/panel.js +2 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/ui/ConfigPanel/utils.d.ts +1 -0
- package/dist/types/ui/ContentStyles/code-block.d.ts +1 -2
- package/dist/types/ui/ContentStyles/expand.d.ts +1 -2
- package/dist/types/ui/ContentStyles/panel.d.ts +1 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/ConfigPanel/utils.d.ts +1 -0
- package/dist/types-ts4.5/ui/ContentStyles/code-block.d.ts +1 -2
- package/dist/types-ts4.5/ui/ContentStyles/expand.d.ts +1 -2
- package/dist/types-ts4.5/ui/ContentStyles/panel.d.ts +1 -2
- package/package.json +3 -2
- package/dist/cjs/plugins/custom-autoformat/doc.js +0 -91
- package/dist/cjs/plugins/custom-autoformat/index.js +0 -131
- package/dist/cjs/plugins/custom-autoformat/input-rules.js +0 -35
- package/dist/cjs/plugins/custom-autoformat/reducers.js +0 -56
- package/dist/cjs/plugins/custom-autoformat/types.js +0 -5
- package/dist/cjs/plugins/custom-autoformat/utils.js +0 -14
- package/dist/es2019/plugins/custom-autoformat/doc.js +0 -71
- package/dist/es2019/plugins/custom-autoformat/index.js +0 -101
- package/dist/es2019/plugins/custom-autoformat/input-rules.js +0 -31
- package/dist/es2019/plugins/custom-autoformat/reducers.js +0 -40
- package/dist/es2019/plugins/custom-autoformat/types.js +0 -1
- package/dist/es2019/plugins/custom-autoformat/utils.js +0 -6
- package/dist/esm/plugins/custom-autoformat/doc.js +0 -84
- package/dist/esm/plugins/custom-autoformat/index.js +0 -124
- package/dist/esm/plugins/custom-autoformat/input-rules.js +0 -29
- package/dist/esm/plugins/custom-autoformat/reducers.js +0 -49
- package/dist/esm/plugins/custom-autoformat/types.js +0 -1
- package/dist/esm/plugins/custom-autoformat/utils.js +0 -8
- package/dist/types/plugins/custom-autoformat/doc.d.ts +0 -6
- package/dist/types/plugins/custom-autoformat/index.d.ts +0 -6
- package/dist/types/plugins/custom-autoformat/input-rules.d.ts +0 -9
- package/dist/types/plugins/custom-autoformat/reducers.d.ts +0 -4
- package/dist/types/plugins/custom-autoformat/types.d.ts +0 -31
- package/dist/types/plugins/custom-autoformat/utils.d.ts +0 -6
- package/dist/types-ts4.5/plugins/custom-autoformat/doc.d.ts +0 -6
- package/dist/types-ts4.5/plugins/custom-autoformat/index.d.ts +0 -6
- package/dist/types-ts4.5/plugins/custom-autoformat/input-rules.d.ts +0 -9
- package/dist/types-ts4.5/plugins/custom-autoformat/reducers.d.ts +0 -4
- package/dist/types-ts4.5/plugins/custom-autoformat/types.d.ts +0 -31
- package/dist/types-ts4.5/plugins/custom-autoformat/utils.d.ts +0 -6
|
@@ -1,61 +1,25 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject, _templateObject2;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import {
|
|
5
|
-
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
6
|
-
import { themed } from '@atlaskit/theme/components';
|
|
4
|
+
import { N40A, N50A, N80A, R300, R50 } from '@atlaskit/theme/colors';
|
|
7
5
|
import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
|
|
8
6
|
import { sharedExpandStyles } from '@atlaskit/editor-common/ui';
|
|
9
7
|
import { akEditorSelectedNodeClassName, akLayoutGutterOffset, getSelectionStyles, SelectionStyle } from '@atlaskit/editor-shared-styles';
|
|
10
8
|
import { expandClassNames } from '@atlaskit/editor-common/styles';
|
|
11
|
-
var EXPAND_SELECTED_BACKGROUND =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
17
|
-
var EXPAND_ICON_COLOR = function EXPAND_ICON_COLOR(props) {
|
|
18
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n"])), themed({
|
|
19
|
-
light: "var(--ds-icon-subtle, ".concat(N80A, ")"),
|
|
20
|
-
dark: "var(--ds-icon-subtle, #d9dde3)"
|
|
21
|
-
})(props));
|
|
9
|
+
var EXPAND_SELECTED_BACKGROUND = "var(--ds-background-neutral-subtle, rgba(255, 255, 255, 0.6))";
|
|
10
|
+
var EXPAND_ICON_COLOR = function EXPAND_ICON_COLOR() {
|
|
11
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon-subtle, ".concat(N80A, ")"));
|
|
22
12
|
};
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
var ACTIVE_STATE_BORDER = themed({
|
|
27
|
-
dark: "1px solid ".concat("var(--ds-border-selected, ".concat("#4794ff4B", ")"))
|
|
28
|
-
});
|
|
29
|
-
var ACTIVE_STATE_BORDER_RADIUS = themed({
|
|
30
|
-
dark: '3px'
|
|
31
|
-
});
|
|
32
|
-
var DANGER_STATE_BACKGROUND_COLOR = themed({
|
|
33
|
-
light: "var(--ds-background-danger, ".concat(R50, ")"),
|
|
34
|
-
dark: "var(--ds-background-danger, #441C13)"
|
|
35
|
-
});
|
|
36
|
-
var DANGER_STATE_BORDER = themed({
|
|
37
|
-
dark: "1px solid ".concat("var(--ds-border-danger, ".concat(R200, ")"))
|
|
38
|
-
});
|
|
39
|
-
var DANGER_STATE_BORDER_COLOR = themed({
|
|
40
|
-
light: "var(--ds-border-danger, ".concat(R300, ")")
|
|
41
|
-
});
|
|
42
|
-
var DANGER_STATE_BORDER_RADIUS = themed({
|
|
43
|
-
dark: '3px'
|
|
44
|
-
});
|
|
13
|
+
var DANGER_STATE_BACKGROUND_COLOR = "var(--ds-background-danger, ".concat(R50, ")");
|
|
14
|
+
var DANGER_STATE_BORDER_COLOR = "var(--ds-border-danger, ".concat(R300, ")");
|
|
45
15
|
|
|
46
16
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
47
|
-
export var expandStyles = function expandStyles(
|
|
48
|
-
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " > div {\n display: flex;\n }\n\n .", " {\n ", "\n overflow: hidden;\n cursor: pointer;\n box-sizing: border-box;\n\n td > & {\n margin-top: 0;\n }\n\n .", " svg {\n ", ";\n transform: rotate(90deg);\n }\n\n &.", ":not(.danger) {\n ", "\n
|
|
17
|
+
export var expandStyles = function expandStyles() {
|
|
18
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", " > div {\n display: flex;\n }\n\n .", " {\n ", "\n overflow: hidden;\n cursor: pointer;\n box-sizing: border-box;\n\n td > & {\n margin-top: 0;\n }\n\n .", " svg {\n ", ";\n transform: rotate(90deg);\n }\n\n &.", ":not(.danger) {\n ", "\n }\n\n &.danger {\n background: ", ";\n border-color: ", ";\n }\n }\n\n .ProseMirror\n > .", ",\n .", "\n > .", " {\n margin-left: -", "px;\n margin-right: -", "px;\n }\n\n .", " {\n ", "\n cursor: text;\n padding-top: 0px;\n }\n\n .", " {\n ", "\n }\n\n .", " {\n ", ";\n align-items: center;\n overflow: visible;\n }\n\n .", " {\n background: ", ";\n border-color: ", ";\n\n .", " {\n padding-top: ", ";\n }\n }\n\n .", " {\n width: 100%;\n }\n\n /* stylelint-disable property-no-unknown, value-keyword-case */\n .", ":(.", ") {\n .expand-content-wrapper {\n height: auto;\n }\n }\n /* stylelint-enable property-no-unknown, value-keyword-case */\n\n .", ":not(.", ") {\n .ak-editor-expand__content {\n position: absolute;\n height: 1px;\n width: 1px;\n overflow: hidden;\n clip: rect(1px, 1px, 1px, 1px);\n white-space: nowrap;\n }\n\n .", " svg {\n ", ";\n transform: rotate(0deg);\n }\n\n &:not(.", "):not(.danger) {\n background: transparent;\n border-color: transparent;\n\n &:hover {\n border-color: ", ";\n background: ", ";\n }\n }\n }\n"])), expandClassNames.icon, expandClassNames.prefix, sharedExpandStyles.containerStyles({
|
|
49
19
|
expanded: false,
|
|
50
20
|
focused: false
|
|
51
|
-
})(
|
|
21
|
+
})(), expandClassNames.iconContainer, EXPAND_ICON_COLOR(), akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.Blanket, SelectionStyle.Border]), DANGER_STATE_BACKGROUND_COLOR, DANGER_STATE_BORDER_COLOR, expandClassNames.type('expand'), BreakoutCssClassName.BREAKOUT_MARK_DOM, expandClassNames.type('expand'), akLayoutGutterOffset, akLayoutGutterOffset, expandClassNames.content, sharedExpandStyles.contentStyles({
|
|
52
22
|
expanded: false,
|
|
53
23
|
focused: false
|
|
54
|
-
})(
|
|
55
|
-
light: "var(--ds-border, ".concat(N40A, ")"),
|
|
56
|
-
dark: "var(--ds-border, ".concat(DN50, ")")
|
|
57
|
-
})(props), expandClassNames.content, "var(--ds-space-100, 8px)", expandClassNames.inputContainer, expandClassNames.prefix, expandClassNames.expanded, expandClassNames.prefix, expandClassNames.expanded, expandClassNames.iconContainer, EXPAND_ICON_COLOR(props), akEditorSelectedNodeClassName, themed({
|
|
58
|
-
light: "var(--ds-border, ".concat(N50A, ")"),
|
|
59
|
-
dark: "var(--ds-border, ".concat(DN50, ")")
|
|
60
|
-
})(props), EXPAND_SELECTED_BACKGROUND(props));
|
|
24
|
+
})(), expandClassNames.titleInput, sharedExpandStyles.titleInputStyles(), expandClassNames.titleContainer, sharedExpandStyles.titleContainerStyles(), expandClassNames.expanded, EXPAND_SELECTED_BACKGROUND, "var(--ds-border, ".concat(N40A, ")"), expandClassNames.content, "var(--ds-space-100, 8px)", expandClassNames.inputContainer, expandClassNames.prefix, expandClassNames.expanded, expandClassNames.prefix, expandClassNames.expanded, expandClassNames.iconContainer, EXPAND_ICON_COLOR(), akEditorSelectedNodeClassName, "var(--ds-border, ".concat(N50A, ")"), EXPAND_SELECTED_BACKGROUND);
|
|
61
25
|
};
|
|
@@ -29,8 +29,8 @@ import { EmojiSharedCssClassName } from '@atlaskit/editor-common/emoji';
|
|
|
29
29
|
import { N500, N30A, N200 } from '@atlaskit/theme/colors';
|
|
30
30
|
import { gapCursorStyles } from '@atlaskit/editor-common/selection';
|
|
31
31
|
export var linkStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n ", "\n }\n"])), linkSharedStyle);
|
|
32
|
-
var ruleStyles = function ruleStyles(
|
|
33
|
-
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ProseMirror {\n ", ";\n\n hr {\n cursor: pointer;\n padding: ", " 0;\n margin: calc(", "em - 4px) 0;\n background-clip: content-box;\n\n &.", " {\n outline: none;\n background-color: ", ";\n }\n }\n }\n"])), ruleSharedStyles(
|
|
32
|
+
var ruleStyles = function ruleStyles() {
|
|
33
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .ProseMirror {\n ", ";\n\n hr {\n cursor: pointer;\n padding: ", " 0;\n margin: calc(", "em - 4px) 0;\n background-clip: content-box;\n\n &.", " {\n outline: none;\n background-color: ", ";\n }\n }\n }\n"])), ruleSharedStyles(), "var(--ds-space-050, 4px)", akEditorLineHeight, akEditorSelectedNodeClassName, "var(--ds-border-selected, ".concat(akEditorSelectedBorderColor, ")"));
|
|
34
34
|
};
|
|
35
35
|
var mentionsStyles = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .", " {\n &.", " [data-mention-id] > span {\n ", "\n\n /* need to specify dark text colour because personal mentions\n (in dark blue) have white text by default */\n color: ", ";\n }\n }\n\n .danger {\n .", ".", "\n > span\n > span\n > span {\n box-shadow: 0 0 0 ", "px ", ";\n background-color: ", ";\n }\n .", " > span > span > span {\n background-color: ", ";\n color: ", ";\n }\n }\n"])), MentionSharedCssClassName.MENTION_CONTAINER, akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Background]), "var(--ds-text-subtle, ".concat(N500, ")"), MentionSharedCssClassName.MENTION_CONTAINER, akEditorSelectedNodeClassName, akEditorSelectedBorderSize, akEditorDeleteBorder, "var(--ds-background-danger, ".concat(akEditorDeleteBackgroundWithOpacity, ")"), MentionSharedCssClassName.MENTION_CONTAINER, "var(--ds-background-neutral, ".concat(N30A, ")"), "var(--ds-text-subtle, ".concat(N500, ")"));
|
|
36
36
|
var listsStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n .ProseMirror {\n li {\n position: relative;\n\n > p:not(:first-child) {\n margin: ", " 0 0 0;\n }\n\n // In SSR the above rule will apply to all p tags because first-child would be a style tag.\n // The following rule resets the first p tag back to its original margin\n // defined in packages/editor/editor-common/src/styles/shared/paragraph.ts\n > style:first-child + p {\n margin-top: ", ";\n }\n }\n\n &:not([data-node-type='decisionList']) > li,\n // This prevents https://product-fabric.atlassian.net/browse/ED-20924\n &:not(.", ") > li {\n ", "\n }\n }\n"])), "var(--ds-space-050, 4px)", blockNodesVerticalMargin, SmartCardSharedCssClassName.BLOCK_CARD_CONTAINER, browser.safari ? codeBlockInListSafariFix : '');
|
|
@@ -39,7 +39,7 @@ export var placeholderStyles = css(_templateObject6 || (_templateObject6 = _tagg
|
|
|
39
39
|
var contentStyles = function contentStyles(props) {
|
|
40
40
|
return css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n .ProseMirror {\n outline: none;\n font-size: ", "px;\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n }\n\n .ProseMirror[contenteditable='false'] .taskItemView-content-wrap {\n pointer-events: none;\n opacity: 0.7;\n }\n\n .ProseMirror-hideselection *::selection {\n background: transparent;\n }\n\n .ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n }\n\n .ProseMirror-selectednode {\n outline: none;\n }\n\n .ProseMirror-selectednode:empty {\n outline: 2px solid ", ";\n }\n\n ", "\n ", "\n ", "\n\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", ";\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n ", "\n\n .panelView-content-wrap {\n box-sizing: border-box;\n }\n\n .mediaGroupView-content-wrap ul {\n padding: 0;\n }\n\n /** Needed to override any cleared floats, e.g. image wrapping */\n\n div.fabric-editor-block-mark[class^='fabric-editor-align'] {\n clear: none !important;\n }\n\n .fabric-editor-align-end {\n text-align: right;\n }\n\n .fabric-editor-align-start {\n text-align: left;\n }\n\n .fabric-editor-align-center {\n text-align: center;\n }\n\n .pm-table-header-content-wrap :not(.fabric-editor-alignment),\n .pm-table-header-content-wrap\n :not(p, .fabric-editor-block-mark)\n + div.fabric-editor-block-mark,\n .pm-table-cell-content-wrap\n :not(p, .fabric-editor-block-mark)\n + div.fabric-editor-block-mark {\n p:first-of-type {\n margin-top: 0;\n }\n }\n\n .hyperlink-floating-toolbar,\n .", " {\n padding: 0;\n }\n\n /* Link icon in the Atlaskit package\n is bigger than the others\n */\n .hyperlink-open-link {\n svg {\n max-width: 18px;\n }\n &[href] {\n padding: 0 4px;\n }\n }\n"])), editorFontSize({
|
|
41
41
|
theme: props.theme
|
|
42
|
-
}), whitespaceSharedStyles, paragraphSharedStyles, listsSharedStyles, indentationSharedStyles, shadowSharedStyle, InlineNodeViewSharedStyles, "var(--ds-border-focused, #8cf)", placeholderTextStyles, placeholderStyles, codeBlockStyles(
|
|
42
|
+
}), whitespaceSharedStyles, paragraphSharedStyles, listsSharedStyles, indentationSharedStyles, shadowSharedStyle, InlineNodeViewSharedStyles, "var(--ds-border-focused, #8cf)", placeholderTextStyles, placeholderStyles, codeBlockStyles(), blocktypeStyles(), codeMarkSharedStyles(), textColorStyles, listsStyles, ruleStyles(), mediaStyles, layoutStyles(props), telepointerStyle, gapCursorStyles, tableStyles(props), panelStyles(), mentionsStyles, emojiStyles, tasksAndDecisionsStyles, gridStyles, linkStyles, blockMarksSharedStyles, dateSharedStyle, extensionStyles, expandStyles(), findReplaceStyles, textHighlightStyle, taskDecisionStyles, statusStyles, annotationSharedStyles(), smartCardStyles, smartCardSharedStyles, dateStyles, embedCardStyles, unsupportedStyles, resizerStyles, MediaSharedClassNames.FLOATING_TOOLBAR_COMPONENT);
|
|
43
43
|
};
|
|
44
44
|
export var createEditorContentStyle = function createEditorContentStyle(styles) {
|
|
45
45
|
return /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
@@ -3,6 +3,6 @@ var _templateObject;
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { panelSharedStyles, PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
|
|
5
5
|
import { SelectionStyle, getSelectionStyles, akEditorDeleteBackground, akEditorDeleteBackgroundWithOpacity, akEditorDeleteBorder, akEditorSelectedBorderSize, akEditorDeleteIconColor, akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles';
|
|
6
|
-
export var panelStyles = function panelStyles(
|
|
7
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n .", " {\n cursor: pointer;\n\n /* Danger when top level node */\n &.danger {\n box-shadow: 0 0 0 ", "px\n ", ";\n background-color: ", " !important;\n\n .", " {\n color: ", " !important;\n }\n }\n }\n\n .", " {\n cursor: text;\n }\n\n /* Danger when nested node */\n .danger .", " {\n &[data-panel-type] {\n background-color: ", ";\n\n .", " {\n color: ", ";\n }\n }\n }\n\n ", ";\n }\n\n .", ".", ":not(.danger) {\n ", "\n }\n"])), PanelSharedCssClassName.prefix, akEditorSelectedBorderSize, akEditorDeleteBorder, "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), PanelSharedCssClassName.icon, "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), PanelSharedCssClassName.content, PanelSharedCssClassName.prefix, "var(--ds-blanket-danger, ".concat(akEditorDeleteBackgroundWithOpacity, ")"), PanelSharedCssClassName.icon, "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), panelSharedStyles(
|
|
6
|
+
export var panelStyles = function panelStyles() {
|
|
7
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .ProseMirror {\n .", " {\n cursor: pointer;\n\n /* Danger when top level node */\n &.danger {\n box-shadow: 0 0 0 ", "px\n ", ";\n background-color: ", " !important;\n\n .", " {\n color: ", " !important;\n }\n }\n }\n\n .", " {\n cursor: text;\n }\n\n /* Danger when nested node */\n .danger .", " {\n &[data-panel-type] {\n background-color: ", ";\n\n .", " {\n color: ", ";\n }\n }\n }\n\n ", ";\n }\n\n .", ".", ":not(.danger) {\n ", "\n }\n"])), PanelSharedCssClassName.prefix, akEditorSelectedBorderSize, akEditorDeleteBorder, "var(--ds-background-danger, ".concat(akEditorDeleteBackground, ")"), PanelSharedCssClassName.icon, "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), PanelSharedCssClassName.content, PanelSharedCssClassName.prefix, "var(--ds-blanket-danger, ".concat(akEditorDeleteBackgroundWithOpacity, ")"), PanelSharedCssClassName.icon, "var(--ds-icon-danger, ".concat(akEditorDeleteIconColor, ")"), panelSharedStyles(), PanelSharedCssClassName.prefix, akEditorSelectedNodeClassName, getSelectionStyles([SelectionStyle.BoxShadow, SelectionStyle.Blanket]));
|
|
8
8
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "190.1.
|
|
2
|
+
export var version = "190.1.12";
|
|
@@ -4,7 +4,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
|
|
|
4
4
|
export { default as pastePlugin } from './paste';
|
|
5
5
|
export { default as breakoutPlugin } from './breakout';
|
|
6
6
|
export { default as annotationPlugin } from './annotation';
|
|
7
|
-
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
8
7
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
9
8
|
export { default as findReplacePlugin } from './find-replace';
|
|
10
9
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
@@ -11,5 +11,6 @@ export declare const getOptionFromValue: (options: Option[] | GroupBase<Option>[
|
|
|
11
11
|
export declare const getSafeParentedName: (name: string, parentName?: string) => string;
|
|
12
12
|
export declare const isDuplicateField: (key: string) => boolean;
|
|
13
13
|
export declare const getNameFromDuplicateField: (key: string) => string;
|
|
14
|
+
export declare const parseParamType: (paramValue: any, paramField?: FieldDefinition) => any;
|
|
14
15
|
export declare const getLoggedParameters: (macroKey: string, currentParams: Parameters, macroFields?: FieldDefinition[]) => {};
|
|
15
16
|
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const codeBlockStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
1
|
+
export declare const codeBlockStyles: () => import("@emotion/react").SerializedStyles;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const expandStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
1
|
+
export declare const expandStyles: () => import("@emotion/react").SerializedStyles;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const panelStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
1
|
+
export declare const panelStyles: () => import("@emotion/react").SerializedStyles;
|
|
@@ -4,7 +4,6 @@ export { default as jiraIssuePlugin } from './jira-issue';
|
|
|
4
4
|
export { default as pastePlugin } from './paste';
|
|
5
5
|
export { default as breakoutPlugin } from './breakout';
|
|
6
6
|
export { default as annotationPlugin } from './annotation';
|
|
7
|
-
export { default as customAutoformatPlugin } from './custom-autoformat';
|
|
8
7
|
export { default as feedbackDialogPlugin } from './feedback-dialog';
|
|
9
8
|
export { default as findReplacePlugin } from './find-replace';
|
|
10
9
|
export { default as undoRedoPlugin } from './undo-redo';
|
|
@@ -11,5 +11,6 @@ export declare const getOptionFromValue: (options: Option[] | GroupBase<Option>[
|
|
|
11
11
|
export declare const getSafeParentedName: (name: string, parentName?: string) => string;
|
|
12
12
|
export declare const isDuplicateField: (key: string) => boolean;
|
|
13
13
|
export declare const getNameFromDuplicateField: (key: string) => string;
|
|
14
|
+
export declare const parseParamType: (paramValue: any, paramField?: FieldDefinition) => any;
|
|
14
15
|
export declare const getLoggedParameters: (macroKey: string, currentParams: Parameters, macroFields?: FieldDefinition[]) => {};
|
|
15
16
|
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const codeBlockStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
1
|
+
export declare const codeBlockStyles: () => import("@emotion/react").SerializedStyles;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const expandStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
1
|
+
export declare const expandStyles: () => import("@emotion/react").SerializedStyles;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const panelStyles: (props: ThemeProps) => import("@emotion/react").SerializedStyles;
|
|
1
|
+
export declare const panelStyles: () => import("@emotion/react").SerializedStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "190.1.
|
|
3
|
+
"version": "190.1.12",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.4",
|
|
71
71
|
"@atlaskit/editor-plugin-context-panel": "^0.2.0",
|
|
72
72
|
"@atlaskit/editor-plugin-copy-button": "^1.0.0",
|
|
73
|
+
"@atlaskit/editor-plugin-custom-autoformat": "^0.1.0",
|
|
73
74
|
"@atlaskit/editor-plugin-data-consumer": "^0.1.0",
|
|
74
75
|
"@atlaskit/editor-plugin-date": "^0.2.0",
|
|
75
76
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
@@ -142,7 +143,7 @@
|
|
|
142
143
|
"@atlaskit/textfield": "^6.0.0",
|
|
143
144
|
"@atlaskit/theme": "^12.6.0",
|
|
144
145
|
"@atlaskit/toggle": "^13.0.0",
|
|
145
|
-
"@atlaskit/tokens": "^1.
|
|
146
|
+
"@atlaskit/tokens": "^1.31.0",
|
|
146
147
|
"@atlaskit/tooltip": "^18.1.0",
|
|
147
148
|
"@atlaskit/ufo": "^0.2.0",
|
|
148
149
|
"@atlaskit/width-detector": "^4.1.0",
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.completeReplacements = exports.buildHandler = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
11
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
|
-
var _utils2 = require("./utils");
|
|
13
|
-
var buildHandler = exports.buildHandler = function buildHandler(_regex, handler) {
|
|
14
|
-
return /*#__PURE__*/function () {
|
|
15
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(view, match, start, end) {
|
|
16
|
-
var replacementPromise, replacementData, replacementNode;
|
|
17
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
18
|
-
while (1) switch (_context.prev = _context.next) {
|
|
19
|
-
case 0:
|
|
20
|
-
replacementPromise = handler(match.slice(1, match.length - 1)); // queue the position and match pair so that we can remap across transactions
|
|
21
|
-
// while we wait for the replacmentPromise to resolve
|
|
22
|
-
view.dispatch((0, _utils2.autoformatAction)(view.state.tr, {
|
|
23
|
-
action: 'matched',
|
|
24
|
-
match: match,
|
|
25
|
-
start: start,
|
|
26
|
-
end: end
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
// ask the provider to give us an ADF node to replace the text with
|
|
30
|
-
_context.next = 4;
|
|
31
|
-
return replacementPromise;
|
|
32
|
-
case 4:
|
|
33
|
-
replacementData = _context.sent;
|
|
34
|
-
replacementNode = (0, _utils.processRawValue)(view.state.schema, replacementData);
|
|
35
|
-
view.dispatch((0, _utils2.autoformatAction)(view.state.tr, {
|
|
36
|
-
action: 'resolved',
|
|
37
|
-
matchString: match[0],
|
|
38
|
-
replacement: replacementNode
|
|
39
|
-
}));
|
|
40
|
-
return _context.abrupt("return", replacementData);
|
|
41
|
-
case 8:
|
|
42
|
-
case "end":
|
|
43
|
-
return _context.stop();
|
|
44
|
-
}
|
|
45
|
-
}, _callee);
|
|
46
|
-
}));
|
|
47
|
-
return function (_x, _x2, _x3, _x4) {
|
|
48
|
-
return _ref.apply(this, arguments);
|
|
49
|
-
};
|
|
50
|
-
}();
|
|
51
|
-
};
|
|
52
|
-
var completeReplacements = exports.completeReplacements = function completeReplacements(view, state) {
|
|
53
|
-
var inlineCard = view.state.schema.nodes.inlineCard;
|
|
54
|
-
state.matches.forEach(function (completedMatch) {
|
|
55
|
-
var matchingRequests = state.resolving.filter(function (candidate) {
|
|
56
|
-
return candidate.match[0] === completedMatch.matchString;
|
|
57
|
-
});
|
|
58
|
-
var tr = view.state.tr;
|
|
59
|
-
matchingRequests.forEach(function (request) {
|
|
60
|
-
var match = request.match,
|
|
61
|
-
start = request.start,
|
|
62
|
-
end = request.end;
|
|
63
|
-
var replacement = completedMatch.replacement;
|
|
64
|
-
var prefix = match[1];
|
|
65
|
-
var suffix = match[match.length - 1];
|
|
66
|
-
var matchEndPos = end + suffix.length;
|
|
67
|
-
|
|
68
|
-
// only permit inlineCard as replacement target for now
|
|
69
|
-
if (!replacement || replacement.type !== inlineCard && !replacement.isText) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// get the current document text, adding # or | if we cross node boundaries
|
|
74
|
-
var docText = view.state.doc.textBetween(start, matchEndPos, '#', '|');
|
|
75
|
-
|
|
76
|
-
// only replace if text still remains the same as when typed at the start
|
|
77
|
-
if (docText === match[0]) {
|
|
78
|
-
tr = tr.replaceWith(tr.mapping.map(start + prefix.length), tr.mapping.map(end, -1), replacement);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// clear this match from plugin state now that we've processed it
|
|
83
|
-
tr = (0, _utils2.autoformatAction)(tr, {
|
|
84
|
-
action: 'finish',
|
|
85
|
-
matchString: completedMatch.matchString
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// and dispatch the replacement, closing history for cmd+z to allow undo separately
|
|
89
|
-
view.dispatch((0, _history.closeHistory)(tr));
|
|
90
|
-
});
|
|
91
|
-
};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.createPMPlugin = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
13
|
-
var _reducers = _interopRequireDefault(require("./reducers"));
|
|
14
|
-
var _inputRules = require("./input-rules");
|
|
15
|
-
var _doc = require("./doc");
|
|
16
|
-
var _utils = require("./utils");
|
|
17
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
-
var createPMPlugin = exports.createPMPlugin = function createPMPlugin(_ref) {
|
|
20
|
-
var providerFactory = _ref.providerFactory;
|
|
21
|
-
var rules = [];
|
|
22
|
-
return new _safePlugin.SafePlugin({
|
|
23
|
-
state: {
|
|
24
|
-
init: function init() {
|
|
25
|
-
return {
|
|
26
|
-
resolving: [],
|
|
27
|
-
matches: []
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
apply: function apply(tr, prevPluginState) {
|
|
31
|
-
if (!prevPluginState) {
|
|
32
|
-
return prevPluginState;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// remap positions
|
|
36
|
-
var remappedPluginState = _objectSpread(_objectSpread({}, prevPluginState), {}, {
|
|
37
|
-
resolving: prevPluginState.resolving.map(function (candidate) {
|
|
38
|
-
return _objectSpread(_objectSpread({}, candidate), {}, {
|
|
39
|
-
start: tr.mapping.map(candidate.start),
|
|
40
|
-
end: tr.mapping.map(candidate.end, -1)
|
|
41
|
-
});
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
var meta = tr.getMeta(_utils.pluginKey);
|
|
45
|
-
if (!meta) {
|
|
46
|
-
return remappedPluginState;
|
|
47
|
-
}
|
|
48
|
-
return (0, _reducers.default)(remappedPluginState, meta);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
props: {
|
|
52
|
-
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
53
|
-
(0, _inputRules.triggerInputRule)(view, rules, from, to, text);
|
|
54
|
-
return false;
|
|
55
|
-
},
|
|
56
|
-
handleKeyDown: (0, _keymap.keydownHandler)({
|
|
57
|
-
Enter: function Enter(_state, _dispatch, view) {
|
|
58
|
-
if (view) {
|
|
59
|
-
(0, _inputRules.triggerInputRule)(view, rules, view.state.selection.from, view.state.selection.to, '');
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
},
|
|
65
|
-
view: function view() {
|
|
66
|
-
var handleProvider = function handleProvider(name, provider) {
|
|
67
|
-
if (name !== 'autoformattingProvider' || !provider) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
provider.then( /*#__PURE__*/function () {
|
|
71
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(autoformattingProvider) {
|
|
72
|
-
var ruleset;
|
|
73
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
74
|
-
while (1) switch (_context.prev = _context.next) {
|
|
75
|
-
case 0:
|
|
76
|
-
_context.next = 2;
|
|
77
|
-
return autoformattingProvider.getRules();
|
|
78
|
-
case 2:
|
|
79
|
-
ruleset = _context.sent;
|
|
80
|
-
Object.keys(ruleset).forEach(function (rule) {
|
|
81
|
-
var inputRule = {
|
|
82
|
-
matchTyping: new RegExp('(\\s+|^)' + rule + '(\\s|,|\\.)$'),
|
|
83
|
-
matchEnter: new RegExp('(\\s+|^)' + rule + '()$'),
|
|
84
|
-
handler: (0, _doc.buildHandler)(rule, ruleset[rule])
|
|
85
|
-
};
|
|
86
|
-
rules.push(inputRule);
|
|
87
|
-
});
|
|
88
|
-
case 4:
|
|
89
|
-
case "end":
|
|
90
|
-
return _context.stop();
|
|
91
|
-
}
|
|
92
|
-
}, _callee);
|
|
93
|
-
}));
|
|
94
|
-
return function (_x) {
|
|
95
|
-
return _ref2.apply(this, arguments);
|
|
96
|
-
};
|
|
97
|
-
}());
|
|
98
|
-
};
|
|
99
|
-
providerFactory.subscribe('autoformattingProvider', handleProvider);
|
|
100
|
-
return {
|
|
101
|
-
update: function update(view) {
|
|
102
|
-
var currentState = (0, _utils.getPluginState)(view.state);
|
|
103
|
-
if (!currentState) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// make replacements in document for finished autoformats
|
|
108
|
-
if (currentState.matches) {
|
|
109
|
-
(0, _doc.completeReplacements)(view, currentState);
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
destroy: function destroy() {
|
|
113
|
-
providerFactory.unsubscribe('autoformattingProvider', handleProvider);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
key: _utils.pluginKey
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
var customAutoformatPlugin = function customAutoformatPlugin() {
|
|
121
|
-
return {
|
|
122
|
-
name: 'customAutoformat',
|
|
123
|
-
pmPlugins: function pmPlugins() {
|
|
124
|
-
return [{
|
|
125
|
-
name: 'customAutoformat',
|
|
126
|
-
plugin: createPMPlugin
|
|
127
|
-
}];
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
var _default = exports.default = customAutoformatPlugin;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.triggerInputRule = void 0;
|
|
7
|
-
var MAX_MATCH = 500;
|
|
8
|
-
|
|
9
|
-
// this is a modified version of
|
|
10
|
-
// https://github.com/ProseMirror/prosemirror-inputrules/blob/master/src/inputrules.js#L53
|
|
11
|
-
var triggerInputRule = exports.triggerInputRule = function triggerInputRule(view, rules, from, to, text) {
|
|
12
|
-
var state = view.state;
|
|
13
|
-
var $from = state.doc.resolve(from);
|
|
14
|
-
if ($from.parent.type.spec.code) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
var textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset, undefined, "\uFFFC") + text;
|
|
18
|
-
|
|
19
|
-
// loop through rules trying to find one that matches
|
|
20
|
-
for (var i = 0; i < rules.length; i++) {
|
|
21
|
-
var _match = void 0;
|
|
22
|
-
if (text.length) {
|
|
23
|
-
_match = rules[i].matchTyping.exec(textBefore);
|
|
24
|
-
} else {
|
|
25
|
-
_match = rules[i].matchEnter.exec(textBefore);
|
|
26
|
-
}
|
|
27
|
-
if (_match) {
|
|
28
|
-
// kick off the handler
|
|
29
|
-
var pos = from - (_match[0].length - text.length);
|
|
30
|
-
rules[i].handler(view, _match, pos, to);
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
// queues a match at a given position in the document
|
|
13
|
-
var matched = function matched(state, action) {
|
|
14
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
15
|
-
resolving: [].concat((0, _toConsumableArray2.default)(state.resolving), [{
|
|
16
|
-
start: action.start,
|
|
17
|
-
end: action.end,
|
|
18
|
-
match: action.match
|
|
19
|
-
}])
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// store the replacement for a match
|
|
24
|
-
var resolved = function resolved(state, action) {
|
|
25
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
26
|
-
matches: [].concat((0, _toConsumableArray2.default)(state.matches), [{
|
|
27
|
-
replacement: action.replacement,
|
|
28
|
-
matchString: action.matchString
|
|
29
|
-
}])
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// indicates a replacement in the document has been completed, and removes the match from both resolving and matches
|
|
34
|
-
var finish = function finish(state, action) {
|
|
35
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
36
|
-
resolving: state.resolving.filter(function (resolving) {
|
|
37
|
-
return resolving.match[0] !== action.matchString;
|
|
38
|
-
}),
|
|
39
|
-
matches: state.matches.filter(function (matching) {
|
|
40
|
-
return matching.matchString !== action.matchString;
|
|
41
|
-
})
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
var reduce = function reduce(state, action) {
|
|
45
|
-
switch (action.action) {
|
|
46
|
-
case 'matched':
|
|
47
|
-
return matched(state, action);
|
|
48
|
-
case 'resolved':
|
|
49
|
-
return resolved(state, action);
|
|
50
|
-
case 'finish':
|
|
51
|
-
return finish(state, action);
|
|
52
|
-
default:
|
|
53
|
-
return state;
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var _default = exports.default = reduce;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pluginKey = exports.getPluginState = exports.autoformatAction = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var pluginKey = exports.pluginKey = new _state.PluginKey('customAutoformatPlugin');
|
|
9
|
-
var getPluginState = exports.getPluginState = function getPluginState(editorState) {
|
|
10
|
-
return pluginKey.getState(editorState);
|
|
11
|
-
};
|
|
12
|
-
var autoformatAction = exports.autoformatAction = function autoformatAction(tr, action) {
|
|
13
|
-
return tr.setMeta(pluginKey, action);
|
|
14
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
2
|
-
import { processRawValue } from '@atlaskit/editor-common/utils';
|
|
3
|
-
import { autoformatAction } from './utils';
|
|
4
|
-
export const buildHandler = (_regex, handler) => {
|
|
5
|
-
return async (view, match, start, end) => {
|
|
6
|
-
const replacementPromise = handler(match.slice(1, match.length - 1));
|
|
7
|
-
|
|
8
|
-
// queue the position and match pair so that we can remap across transactions
|
|
9
|
-
// while we wait for the replacmentPromise to resolve
|
|
10
|
-
view.dispatch(autoformatAction(view.state.tr, {
|
|
11
|
-
action: 'matched',
|
|
12
|
-
match: match,
|
|
13
|
-
start,
|
|
14
|
-
end
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
// ask the provider to give us an ADF node to replace the text with
|
|
18
|
-
const replacementData = await replacementPromise;
|
|
19
|
-
const replacementNode = processRawValue(view.state.schema, replacementData);
|
|
20
|
-
view.dispatch(autoformatAction(view.state.tr, {
|
|
21
|
-
action: 'resolved',
|
|
22
|
-
matchString: match[0],
|
|
23
|
-
replacement: replacementNode
|
|
24
|
-
}));
|
|
25
|
-
return replacementData;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export const completeReplacements = (view, state) => {
|
|
29
|
-
const {
|
|
30
|
-
inlineCard
|
|
31
|
-
} = view.state.schema.nodes;
|
|
32
|
-
state.matches.forEach(completedMatch => {
|
|
33
|
-
const matchingRequests = state.resolving.filter(candidate => candidate.match[0] === completedMatch.matchString);
|
|
34
|
-
let tr = view.state.tr;
|
|
35
|
-
matchingRequests.forEach(request => {
|
|
36
|
-
const {
|
|
37
|
-
match,
|
|
38
|
-
start,
|
|
39
|
-
end
|
|
40
|
-
} = request;
|
|
41
|
-
const {
|
|
42
|
-
replacement
|
|
43
|
-
} = completedMatch;
|
|
44
|
-
const prefix = match[1];
|
|
45
|
-
const suffix = match[match.length - 1];
|
|
46
|
-
const matchEndPos = end + suffix.length;
|
|
47
|
-
|
|
48
|
-
// only permit inlineCard as replacement target for now
|
|
49
|
-
if (!replacement || replacement.type !== inlineCard && !replacement.isText) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// get the current document text, adding # or | if we cross node boundaries
|
|
54
|
-
const docText = view.state.doc.textBetween(start, matchEndPos, '#', '|');
|
|
55
|
-
|
|
56
|
-
// only replace if text still remains the same as when typed at the start
|
|
57
|
-
if (docText === match[0]) {
|
|
58
|
-
tr = tr.replaceWith(tr.mapping.map(start + prefix.length), tr.mapping.map(end, -1), replacement);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// clear this match from plugin state now that we've processed it
|
|
63
|
-
tr = autoformatAction(tr, {
|
|
64
|
-
action: 'finish',
|
|
65
|
-
matchString: completedMatch.matchString
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// and dispatch the replacement, closing history for cmd+z to allow undo separately
|
|
69
|
-
view.dispatch(closeHistory(tr));
|
|
70
|
-
});
|
|
71
|
-
};
|