@atlaskit/adf-schema 25.4.0 → 25.5.1
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 +17 -0
- package/dist/cjs/schema/jira-schema.js +4 -0
- package/dist/cjs/schema/marks/alignment.js +4 -0
- package/dist/cjs/schema/marks/annotation.js +8 -8
- package/dist/cjs/schema/marks/border.js +6 -0
- package/dist/cjs/schema/marks/breakout.js +5 -0
- package/dist/cjs/schema/marks/code.js +4 -0
- package/dist/cjs/schema/marks/data-consumer.js +17 -0
- package/dist/cjs/schema/marks/em.js +4 -0
- package/dist/cjs/schema/marks/fragment.js +6 -0
- package/dist/cjs/schema/marks/indentation.js +4 -0
- package/dist/cjs/schema/marks/link.js +4 -0
- package/dist/cjs/schema/marks/strike.js +4 -0
- package/dist/cjs/schema/marks/strong.js +4 -0
- package/dist/cjs/schema/marks/subsup.js +4 -0
- package/dist/cjs/schema/marks/text-color.js +4 -0
- package/dist/cjs/schema/marks/underline.js +4 -0
- package/dist/cjs/schema/nodes/bodied-extension.js +8 -0
- package/dist/cjs/schema/nodes/code-block.js +12 -0
- package/dist/cjs/schema/nodes/decision-item.js +4 -0
- package/dist/cjs/schema/nodes/decision-list.js +4 -0
- package/dist/cjs/schema/nodes/emoji.js +4 -0
- package/dist/cjs/schema/nodes/extension.js +8 -0
- package/dist/cjs/schema/nodes/inline-extension.js +8 -0
- package/dist/cjs/schema/nodes/media-inline.js +4 -0
- package/dist/cjs/schema/nodes/media.js +4 -0
- package/dist/cjs/schema/nodes/mention.js +7 -4
- package/dist/cjs/schema/nodes/panel.js +7 -4
- package/dist/cjs/schema/nodes/paragraph.js +0 -3
- package/dist/cjs/schema/nodes/status.js +4 -0
- package/dist/cjs/schema/nodes/tableNodes.js +23 -0
- package/dist/cjs/schema/nodes/task-item.js +4 -0
- package/dist/cjs/schema/nodes/task-list.js +4 -0
- package/dist/cjs/steps/analytics.js +3 -3
- package/dist/cjs/steps/link-meta-step.js +112 -0
- package/dist/cjs/steps/table/add-column.js +1 -1
- package/dist/cjs/steps/table/constants.js +4 -4
- package/dist/cjs/steps/table/utils/cells-at-column.js +48 -50
- package/dist/cjs/steps/table/utils/side-effects/rows.js +1 -1
- package/dist/cjs/steps/type-ahead.js +4 -4
- package/dist/cjs/steps.js +8 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/schema/jira-schema.js +5 -0
- package/dist/es2019/schema/marks/alignment.js +5 -0
- package/dist/es2019/schema/marks/annotation.js +6 -6
- package/dist/es2019/schema/marks/border.js +7 -0
- package/dist/es2019/schema/marks/breakout.js +5 -0
- package/dist/es2019/schema/marks/data-consumer.js +6 -0
- package/dist/es2019/schema/marks/fragment.js +7 -0
- package/dist/es2019/schema/marks/indentation.js +5 -0
- package/dist/es2019/schema/marks/link.js +5 -0
- package/dist/es2019/schema/marks/subsup.js +5 -0
- package/dist/es2019/schema/marks/text-color.js +5 -0
- package/dist/es2019/schema/nodes/bodied-extension.js +9 -0
- package/dist/es2019/schema/nodes/code-block.js +13 -0
- package/dist/es2019/schema/nodes/decision-item.js +5 -0
- package/dist/es2019/schema/nodes/extension.js +9 -0
- package/dist/es2019/schema/nodes/heading.js +0 -2
- package/dist/es2019/schema/nodes/inline-extension.js +9 -0
- package/dist/es2019/schema/nodes/layout-section.js +0 -3
- package/dist/es2019/schema/nodes/media-inline.js +5 -0
- package/dist/es2019/schema/nodes/media.js +5 -0
- package/dist/es2019/schema/nodes/mention.js +8 -3
- package/dist/es2019/schema/nodes/panel.js +8 -3
- package/dist/es2019/schema/nodes/paragraph.js +0 -3
- package/dist/es2019/schema/nodes/tableNodes.js +23 -0
- package/dist/es2019/schema/nodes/task-item.js +5 -0
- package/dist/es2019/schema/nodes/task-list.js +5 -0
- package/dist/es2019/steps/analytics.js +3 -3
- package/dist/es2019/steps/link-meta-step.js +71 -0
- package/dist/es2019/steps/table/constants.js +3 -3
- package/dist/es2019/steps/type-ahead.js +3 -3
- package/dist/es2019/steps.js +2 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/schema/jira-schema.js +5 -0
- package/dist/esm/schema/marks/alignment.js +5 -0
- package/dist/esm/schema/marks/annotation.js +6 -6
- package/dist/esm/schema/marks/border.js +7 -0
- package/dist/esm/schema/marks/breakout.js +5 -0
- package/dist/esm/schema/marks/data-consumer.js +6 -0
- package/dist/esm/schema/marks/fragment.js +7 -0
- package/dist/esm/schema/marks/indentation.js +5 -0
- package/dist/esm/schema/marks/link.js +5 -0
- package/dist/esm/schema/marks/subsup.js +5 -0
- package/dist/esm/schema/marks/text-color.js +5 -0
- package/dist/esm/schema/nodes/bodied-extension.js +9 -0
- package/dist/esm/schema/nodes/code-block.js +13 -0
- package/dist/esm/schema/nodes/decision-item.js +5 -0
- package/dist/esm/schema/nodes/extension.js +9 -0
- package/dist/esm/schema/nodes/heading.js +0 -2
- package/dist/esm/schema/nodes/inline-extension.js +9 -0
- package/dist/esm/schema/nodes/layout-section.js +0 -3
- package/dist/esm/schema/nodes/media-inline.js +5 -0
- package/dist/esm/schema/nodes/media.js +5 -0
- package/dist/esm/schema/nodes/mention.js +8 -3
- package/dist/esm/schema/nodes/panel.js +8 -3
- package/dist/esm/schema/nodes/paragraph.js +0 -3
- package/dist/esm/schema/nodes/tableNodes.js +23 -0
- package/dist/esm/schema/nodes/task-item.js +5 -0
- package/dist/esm/schema/nodes/task-list.js +5 -0
- package/dist/esm/steps/analytics.js +3 -3
- package/dist/esm/steps/link-meta-step.js +103 -0
- package/dist/esm/steps/table/add-column.js +1 -1
- package/dist/esm/steps/table/constants.js +3 -3
- package/dist/esm/steps/table/utils/cells-at-column.js +48 -50
- package/dist/esm/steps/table/utils/side-effects/rows.js +1 -1
- package/dist/esm/steps/type-ahead.js +3 -3
- package/dist/esm/steps.js +2 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/steps/link-meta-step.d.ts +51 -0
- package/dist/types/steps.d.ts +2 -0
- package/package.json +2 -2
@@ -1,11 +1,11 @@
|
|
1
1
|
import { Slice } from 'prosemirror-model';
|
2
2
|
import { ReplaceStep, Step, StepMap, StepResult } from 'prosemirror-transform';
|
3
3
|
export const insertTypeAheadStepType = 'atlaskit-insert-type-ahead';
|
4
|
-
export let InsertTypeAheadStages
|
5
|
-
(function (InsertTypeAheadStages) {
|
4
|
+
export let InsertTypeAheadStages = /*#__PURE__*/function (InsertTypeAheadStages) {
|
6
5
|
InsertTypeAheadStages["DELETING_RAW_QUERY"] = "DELETING_RAW_QUERY";
|
7
6
|
InsertTypeAheadStages["INSERTING_ITEM"] = "INSERTING_ITEM";
|
8
|
-
|
7
|
+
return InsertTypeAheadStages;
|
8
|
+
}({});
|
9
9
|
export class InsertTypeAheadStep extends Step {
|
10
10
|
constructor({
|
11
11
|
stage,
|
package/dist/es2019/steps.js
CHANGED
@@ -3,4 +3,5 @@ export { TableSortStep } from './steps/table/sort-column';
|
|
3
3
|
export { InsertTypeAheadStages, InsertTypeAheadStep } from './steps/type-ahead';
|
4
4
|
export { AddColumnStep } from './steps/table/add-column';
|
5
5
|
export { SetAttrsStep } from './steps/set-attrs';
|
6
|
-
export { AnalyticsStep } from './steps/analytics';
|
6
|
+
export { AnalyticsStep } from './steps/analytics';
|
7
|
+
export { LinkMetaStep } from './steps/link-meta-step';
|
package/dist/es2019/version.json
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
import { createSchema } from './create-schema';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
|
5
|
+
**/
|
6
|
+
|
2
7
|
/**
|
3
8
|
* @deprecated [ED-15676] We have stopped supporting product specific schemas. Use `@atlaskit/adf-schema/schema-default` instead.
|
4
9
|
**/
|
@@ -5,15 +5,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
5
5
|
* @name annotation_mark
|
6
6
|
*/
|
7
7
|
|
8
|
-
export var AnnotationTypes
|
9
|
-
(function (AnnotationTypes) {
|
8
|
+
export var AnnotationTypes = /*#__PURE__*/function (AnnotationTypes) {
|
10
9
|
AnnotationTypes["INLINE_COMMENT"] = "inlineComment";
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
return AnnotationTypes;
|
11
|
+
}({});
|
12
|
+
export var AnnotationMarkStates = /*#__PURE__*/function (AnnotationMarkStates) {
|
14
13
|
AnnotationMarkStates["RESOLVED"] = "resolved";
|
15
14
|
AnnotationMarkStates["ACTIVE"] = "active";
|
16
|
-
|
15
|
+
return AnnotationMarkStates;
|
16
|
+
}({});
|
17
17
|
export function buildDataAttributes(_ref) {
|
18
18
|
var id = _ref.id,
|
19
19
|
annotationType = _ref.annotationType,
|
@@ -1,6 +1,13 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
2
|
import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
|
3
3
|
import { N300A, N600, N1000 } from '../../utils/colors';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @name border_mark
|
7
|
+
* @stage 0
|
8
|
+
* @description This mark adds decoration to an element, and any element decorated with it will also have a border style.
|
9
|
+
*/
|
10
|
+
|
4
11
|
var borderColorArrayPalette = [[N300A, 'Subtle gray'], [N600, 'Gray'], [N1000, 'Bold gray']];
|
5
12
|
export var borderColorPalette = new Map();
|
6
13
|
borderColorArrayPalette.forEach(function (_ref) {
|
@@ -11,6 +11,12 @@ import { isDOMElement } from '../../utils/parseDOM';
|
|
11
11
|
* // @minLength 1
|
12
12
|
*/
|
13
13
|
|
14
|
+
/**
|
15
|
+
* @name dataConsumer_mark
|
16
|
+
* @description This mark is used for metadata surrounding a node consuming data
|
17
|
+
* from a given source node
|
18
|
+
*/
|
19
|
+
|
14
20
|
var parseDataConsumer = function parseDataConsumer(maybeValue) {
|
15
21
|
var sources = isDOMElement(maybeValue) && maybeValue.getAttribute('data-sources');
|
16
22
|
try {
|
@@ -2,6 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
4
|
import { isDOMElement } from '../../utils/parseDOM';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @name fragment_mark
|
8
|
+
* @description Indicates that the elements decorated with this mark belong to a "fragment" entity, which represents a collection of ADF nodes.
|
9
|
+
* This entity can be referred to later by its `localId` attribute.
|
10
|
+
*/
|
11
|
+
|
5
12
|
var parseFragment = function parseFragment(maybeValue) {
|
6
13
|
var _maybeValue$getAttrib;
|
7
14
|
if (!isDOMElement(maybeValue)) {
|
@@ -3,6 +3,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
4
|
import { LINK } from '../groups';
|
5
5
|
import { isRootRelative, isSafeUrl, normalizeUrl } from '../../utils/url';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @name link_mark
|
9
|
+
*/
|
10
|
+
|
6
11
|
var getLinkAttrs = function getLinkAttrs(attribute) {
|
7
12
|
return function (domNode) {
|
8
13
|
var dom = domNode;
|
@@ -3,6 +3,11 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
|
4
4
|
import { COLOR } from '../groups';
|
5
5
|
import { rgbToHex, N0, N80, P50, P300, P500, T75, T300, T500, G75, G300, G500, R75, R300, R500, Y75, Y200, Y400, B75, B100, B500 } from '../../utils/colors';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @name textColor_mark
|
9
|
+
*/
|
10
|
+
|
6
11
|
// used for extended palette in text color picker
|
7
12
|
var colorArrayPalette = [
|
8
13
|
// default row - first color is added programatically
|
@@ -1,4 +1,13 @@
|
|
1
1
|
import { getExtensionAttrs } from '../../utils/extensions';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @name bodiedExtension_node
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @name bodiedExtension_with_marks_node
|
9
|
+
*/
|
10
|
+
|
2
11
|
var createBodiedExtensionNodeSpec = function createBodiedExtensionNodeSpec() {
|
3
12
|
var nodeSpec = {
|
4
13
|
inline: false,
|
@@ -1,4 +1,17 @@
|
|
1
1
|
import { Fragment } from 'prosemirror-model';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @name codeBlock_node
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @name codeBlock_with_no_marks_node
|
9
|
+
*/
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @name codeBlock_with_marks_node
|
13
|
+
*/
|
14
|
+
|
2
15
|
var getLanguageFromEditorStyle = function getLanguageFromEditorStyle(dom) {
|
3
16
|
return dom.getAttribute('data-language') || undefined;
|
4
17
|
};
|
@@ -1,4 +1,13 @@
|
|
1
1
|
import { getExtensionAttrs } from '../../utils/extensions';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @name extension_node
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @name extension_with_marks_node
|
9
|
+
*/
|
10
|
+
|
2
11
|
var createExtensionNodeSpec = function createExtensionNodeSpec() {
|
3
12
|
var nodeSpec = {
|
4
13
|
inline: false,
|
@@ -1,4 +1,13 @@
|
|
1
1
|
import { getExtensionAttrs } from '../../utils/extensions';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @name inlineExtension_node
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @name inlineExtension_with_marks_node
|
9
|
+
*/
|
10
|
+
|
2
11
|
var createInlineExtensionNodeSpec = function createInlineExtensionNodeSpec() {
|
3
12
|
var nodeSpec = {
|
4
13
|
inline: true,
|
@@ -5,16 +5,13 @@
|
|
5
5
|
/**
|
6
6
|
* Need duplicate `type` and `marks` to make both validator and json-schema satisfied
|
7
7
|
*/
|
8
|
-
|
9
8
|
/**
|
10
9
|
* @name layoutSection_full_node
|
11
10
|
*/
|
12
|
-
|
13
11
|
/**
|
14
12
|
* @stage 0
|
15
13
|
* @name layoutSection_with_single_column_node
|
16
14
|
*/
|
17
|
-
|
18
15
|
export var layoutSection = {
|
19
16
|
content: '(layoutColumn | unsupportedBlock){1,3} unsupportedBlock* | unsupportedBlock+',
|
20
17
|
marks: 'unsupportedMark unsupportedNodeAttribute',
|
@@ -1,9 +1,14 @@
|
|
1
|
-
export var USER_TYPES
|
2
|
-
(function (USER_TYPES) {
|
1
|
+
export var USER_TYPES = /*#__PURE__*/function (USER_TYPES) {
|
3
2
|
USER_TYPES["DEFAULT"] = "DEFAULT";
|
4
3
|
USER_TYPES["SPECIAL"] = "SPECIAL";
|
5
4
|
USER_TYPES["APP"] = "APP";
|
6
|
-
|
5
|
+
return USER_TYPES;
|
6
|
+
}({});
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @name mention_node
|
10
|
+
*/
|
11
|
+
|
7
12
|
export var mention = {
|
8
13
|
inline: true,
|
9
14
|
group: 'inline',
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
|
-
export var PanelType
|
5
|
-
(function (PanelType) {
|
4
|
+
export var PanelType = /*#__PURE__*/function (PanelType) {
|
6
5
|
PanelType["INFO"] = "info";
|
7
6
|
PanelType["NOTE"] = "note";
|
8
7
|
PanelType["TIP"] = "tip";
|
@@ -10,7 +9,13 @@ export var PanelType;
|
|
10
9
|
PanelType["ERROR"] = "error";
|
11
10
|
PanelType["SUCCESS"] = "success";
|
12
11
|
PanelType["CUSTOM"] = "custom";
|
13
|
-
|
12
|
+
return PanelType;
|
13
|
+
}({});
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @name panel_node
|
17
|
+
*/
|
18
|
+
|
14
19
|
var getDefaultAttrs = function getDefaultAttrs() {
|
15
20
|
var attrs = {
|
16
21
|
panelType: {
|
@@ -14,15 +14,12 @@
|
|
14
14
|
* type T1 = X | Y
|
15
15
|
* type T2 = A | T1 | B // T2 = A | X | Y | B
|
16
16
|
*/
|
17
|
-
|
18
17
|
/**
|
19
18
|
* @name paragraph_with_alignment_node
|
20
19
|
*/
|
21
|
-
|
22
20
|
/**
|
23
21
|
* @name paragraph_with_indentation_node
|
24
22
|
*/
|
25
|
-
|
26
23
|
var isImageNode = function isImageNode(node) {
|
27
24
|
return Boolean(node && node.nodeName.toLowerCase() === 'img');
|
28
25
|
};
|
@@ -117,6 +117,29 @@ export var tableBackgroundColorNames = new Map();
|
|
117
117
|
tableBackgroundColorPalette.set(colorValue.toLowerCase(), colorName);
|
118
118
|
tableBackgroundColorNames.set(colorName.toLowerCase(), colorValue.toLowerCase());
|
119
119
|
});
|
120
|
+
|
121
|
+
/**
|
122
|
+
* @name table_node
|
123
|
+
*/
|
124
|
+
|
125
|
+
/**
|
126
|
+
* @name table_row_node
|
127
|
+
*/
|
128
|
+
|
129
|
+
/**
|
130
|
+
* @name table_cell_content
|
131
|
+
* @minItems 1
|
132
|
+
* @allowUnsupportedBlock true
|
133
|
+
*/
|
134
|
+
|
135
|
+
/**
|
136
|
+
* @name table_cell_node
|
137
|
+
*/
|
138
|
+
|
139
|
+
/**
|
140
|
+
* @name table_header_node
|
141
|
+
*/
|
142
|
+
|
120
143
|
// TODO: Fix any, potential issue. ED-5048
|
121
144
|
var createTableSpec = function createTableSpec() {
|
122
145
|
var attrs = {
|
@@ -14,11 +14,11 @@ import { Step, StepResult, StepMap, ReplaceStep } from 'prosemirror-transform';
|
|
14
14
|
import { Slice } from 'prosemirror-model';
|
15
15
|
export var analyticsStepType = 'atlaskit-analytics';
|
16
16
|
export var analyticsInvertStepType = 'atlaskit-analytics-invert';
|
17
|
-
var HISTORY_ACTIONS
|
18
|
-
(function (HISTORY_ACTIONS) {
|
17
|
+
var HISTORY_ACTIONS = /*#__PURE__*/function (HISTORY_ACTIONS) {
|
19
18
|
HISTORY_ACTIONS["UNDID"] = "undid";
|
20
19
|
HISTORY_ACTIONS["REDID"] = "redid";
|
21
|
-
|
20
|
+
return HISTORY_ACTIONS;
|
21
|
+
}(HISTORY_ACTIONS || {});
|
22
22
|
/** Creates undo event from a normal analytics event */
|
23
23
|
function createUndoEvent(analyticsEvent) {
|
24
24
|
var _analyticsEvent$paylo;
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
7
|
+
var _excluded = ["sourceEvent"];
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
10
|
+
import { Slice } from 'prosemirror-model';
|
11
|
+
import { ReplaceStep, Step, StepMap, StepResult } from 'prosemirror-transform';
|
12
|
+
export var stepType = 'editor-linking-meta';
|
13
|
+
export var invertStepType = 'editor-linking-meta-invert';
|
14
|
+
/**
|
15
|
+
* Custom Prosemirror Step to attach metadata about user interactions with links
|
16
|
+
* Using a Step means that it will work with prosemirror-history and we get utilise when
|
17
|
+
* firing events on history change
|
18
|
+
*/
|
19
|
+
export var LinkMetaStep = /*#__PURE__*/function (_Step) {
|
20
|
+
_inherits(LinkMetaStep, _Step);
|
21
|
+
var _super = _createSuper(LinkMetaStep);
|
22
|
+
function LinkMetaStep(pos, metadata) {
|
23
|
+
var _this;
|
24
|
+
var isInverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
25
|
+
_classCallCheck(this, LinkMetaStep);
|
26
|
+
_this = _super.call(this);
|
27
|
+
_this.pos = pos;
|
28
|
+
_this.metadata = metadata;
|
29
|
+
_this.isInverted = isInverted;
|
30
|
+
return _this;
|
31
|
+
}
|
32
|
+
_createClass(LinkMetaStep, [{
|
33
|
+
key: "getMetadata",
|
34
|
+
value: function getMetadata() {
|
35
|
+
return this.metadata;
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Generate new undo/redo analytics event when step is inverted
|
40
|
+
*/
|
41
|
+
}, {
|
42
|
+
key: "invert",
|
43
|
+
value: function invert() {
|
44
|
+
/**
|
45
|
+
* Omit sourceEvent in history
|
46
|
+
*/
|
47
|
+
var _this$metadata = this.metadata,
|
48
|
+
sourceEvent = _this$metadata.sourceEvent,
|
49
|
+
metadata = _objectWithoutProperties(_this$metadata, _excluded);
|
50
|
+
return new LinkMetaStep(this.pos, metadata, true);
|
51
|
+
}
|
52
|
+
|
53
|
+
// Should make no modifications to the doc
|
54
|
+
}, {
|
55
|
+
key: "apply",
|
56
|
+
value: function apply(doc) {
|
57
|
+
return StepResult.ok(doc);
|
58
|
+
}
|
59
|
+
}, {
|
60
|
+
key: "map",
|
61
|
+
value: function map(mapping) {
|
62
|
+
var newPos = this.pos;
|
63
|
+
if (typeof newPos === 'number') {
|
64
|
+
newPos = mapping.map(newPos);
|
65
|
+
}
|
66
|
+
// Return the same events, this step will never be removed
|
67
|
+
return new LinkMetaStep(newPos, this.metadata, this.isInverted);
|
68
|
+
}
|
69
|
+
}, {
|
70
|
+
key: "getMap",
|
71
|
+
value: function getMap() {
|
72
|
+
return new StepMap([this.pos || 0, 0, 0]);
|
73
|
+
}
|
74
|
+
|
75
|
+
// Return null to avoid merging events
|
76
|
+
}, {
|
77
|
+
key: "merge",
|
78
|
+
value: function merge() {
|
79
|
+
return null;
|
80
|
+
}
|
81
|
+
}, {
|
82
|
+
key: "toJSON",
|
83
|
+
value: function toJSON() {
|
84
|
+
// When serialized we should create a noop Replace step
|
85
|
+
return {
|
86
|
+
stepType: 'replace',
|
87
|
+
from: 0,
|
88
|
+
to: 0
|
89
|
+
};
|
90
|
+
}
|
91
|
+
}], [{
|
92
|
+
key: "fromJSON",
|
93
|
+
value: function fromJSON(_, __) {
|
94
|
+
// This is a "local custom step" once serialized
|
95
|
+
// we need to transform it in a no-operation action
|
96
|
+
return new ReplaceStep(0, 0, Slice.empty);
|
97
|
+
}
|
98
|
+
}]);
|
99
|
+
return LinkMetaStep;
|
100
|
+
}(Step);
|
101
|
+
|
102
|
+
/** Register this step with Prosemirror */
|
103
|
+
Step.jsonID(stepType, LinkMetaStep);
|
@@ -11,7 +11,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
12
12
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
13
13
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
15
15
|
import { Step, StepMap, StepResult, Transform } from 'prosemirror-transform';
|
16
16
|
import { cellsAtColumn } from './utils/cells-at-column';
|
17
17
|
import { findColumn } from './utils/find-column';
|