@atlaskit/editor-plugin-show-diff 0.1.1 → 0.1.2
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 +10 -0
- package/dist/cjs/pm-plugins/main.js +17 -15
- package/dist/es2019/pm-plugins/main.js +15 -13
- package/dist/esm/pm-plugins/main.js +17 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7fe4c9e51271d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7fe4c9e51271d) -
|
|
8
|
+
Fix initial show diff after performance fix.
|
|
9
|
+
- [`b2d53a70dbaa5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b2d53a70dbaa5) -
|
|
10
|
+
Improve show diff performance by storing decorations in state.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
3
13
|
## 0.1.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -77,15 +77,16 @@ var createPlugin = exports.createPlugin = function createPlugin(config) {
|
|
|
77
77
|
var _config$steps, _config$steps2;
|
|
78
78
|
var schema = state.schema;
|
|
79
79
|
var isDisplayingChanges = ((_config$steps = config === null || config === void 0 ? void 0 : config.steps) !== null && _config$steps !== void 0 ? _config$steps : []).length > 0;
|
|
80
|
+
var steps = ((_config$steps2 = config === null || config === void 0 ? void 0 : config.steps) !== null && _config$steps2 !== void 0 ? _config$steps2 : []).map(function (step) {
|
|
81
|
+
return _transform.Step.fromJSON(schema, step);
|
|
82
|
+
});
|
|
80
83
|
return {
|
|
81
|
-
steps:
|
|
82
|
-
return _transform.Step.fromJSON(schema, step);
|
|
83
|
-
}),
|
|
84
|
+
steps: steps,
|
|
84
85
|
originalDoc: config !== null && config !== void 0 && config.originalDoc ? (0, _processRawValue.processRawValue)(state.schema, config.originalDoc) : undefined,
|
|
85
86
|
decorations: calculateDecorations({
|
|
86
87
|
state: state,
|
|
87
88
|
pluginState: {
|
|
88
|
-
steps:
|
|
89
|
+
steps: steps,
|
|
89
90
|
originalDoc: config !== null && config !== void 0 && config.originalDoc ? (0, _processRawValue.processRawValue)(state.schema, config.originalDoc) : undefined,
|
|
90
91
|
isDisplayingChanges: isDisplayingChanges
|
|
91
92
|
}
|
|
@@ -98,29 +99,30 @@ var createPlugin = exports.createPlugin = function createPlugin(config) {
|
|
|
98
99
|
var newPluginState = currentPluginState;
|
|
99
100
|
if (meta) {
|
|
100
101
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
|
|
102
|
+
// Calculate and store decorations in state
|
|
103
|
+
var decorations = calculateDecorations({
|
|
104
|
+
state: newState,
|
|
105
|
+
pluginState: {
|
|
106
|
+
steps: meta.steps,
|
|
107
|
+
originalDoc: meta.originalDoc,
|
|
108
|
+
isDisplayingChanges: true
|
|
109
|
+
}
|
|
110
|
+
});
|
|
101
111
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
112
|
+
decorations: decorations,
|
|
102
113
|
isDisplayingChanges: true
|
|
103
114
|
});
|
|
104
115
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
|
|
105
116
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
117
|
+
decorations: _view.DecorationSet.empty,
|
|
106
118
|
isDisplayingChanges: false
|
|
107
119
|
});
|
|
108
120
|
} else {
|
|
109
121
|
newPluginState = _objectSpread(_objectSpread({}, currentPluginState), meta);
|
|
110
122
|
}
|
|
111
123
|
}
|
|
112
|
-
|
|
113
|
-
// Calculate and store decorations in state
|
|
114
|
-
var decorations = calculateDecorations({
|
|
115
|
-
state: newState,
|
|
116
|
-
pluginState: {
|
|
117
|
-
steps: newPluginState.steps,
|
|
118
|
-
originalDoc: newPluginState.originalDoc,
|
|
119
|
-
isDisplayingChanges: newPluginState.isDisplayingChanges
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
124
|
return _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
123
|
-
decorations: decorations
|
|
125
|
+
decorations: newPluginState.decorations.map(tr.mapping, tr.doc)
|
|
124
126
|
});
|
|
125
127
|
}
|
|
126
128
|
},
|
|
@@ -61,13 +61,14 @@ export const createPlugin = config => {
|
|
|
61
61
|
var _config$steps, _config$steps2;
|
|
62
62
|
const schema = state.schema;
|
|
63
63
|
const isDisplayingChanges = ((_config$steps = config === null || config === void 0 ? void 0 : config.steps) !== null && _config$steps !== void 0 ? _config$steps : []).length > 0;
|
|
64
|
+
const steps = ((_config$steps2 = config === null || config === void 0 ? void 0 : config.steps) !== null && _config$steps2 !== void 0 ? _config$steps2 : []).map(step => ProseMirrorStep.fromJSON(schema, step));
|
|
64
65
|
return {
|
|
65
|
-
steps
|
|
66
|
+
steps,
|
|
66
67
|
originalDoc: config !== null && config !== void 0 && config.originalDoc ? processRawValue(state.schema, config.originalDoc) : undefined,
|
|
67
68
|
decorations: calculateDecorations({
|
|
68
69
|
state,
|
|
69
70
|
pluginState: {
|
|
70
|
-
steps
|
|
71
|
+
steps,
|
|
71
72
|
originalDoc: config !== null && config !== void 0 && config.originalDoc ? processRawValue(state.schema, config.originalDoc) : undefined,
|
|
72
73
|
isDisplayingChanges
|
|
73
74
|
}
|
|
@@ -80,15 +81,26 @@ export const createPlugin = config => {
|
|
|
80
81
|
let newPluginState = currentPluginState;
|
|
81
82
|
if (meta) {
|
|
82
83
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
|
|
84
|
+
// Calculate and store decorations in state
|
|
85
|
+
const decorations = calculateDecorations({
|
|
86
|
+
state: newState,
|
|
87
|
+
pluginState: {
|
|
88
|
+
steps: meta.steps,
|
|
89
|
+
originalDoc: meta.originalDoc,
|
|
90
|
+
isDisplayingChanges: true
|
|
91
|
+
}
|
|
92
|
+
});
|
|
83
93
|
newPluginState = {
|
|
84
94
|
...currentPluginState,
|
|
85
95
|
...meta,
|
|
96
|
+
decorations,
|
|
86
97
|
isDisplayingChanges: true
|
|
87
98
|
};
|
|
88
99
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
|
|
89
100
|
newPluginState = {
|
|
90
101
|
...currentPluginState,
|
|
91
102
|
...meta,
|
|
103
|
+
decorations: DecorationSet.empty,
|
|
92
104
|
isDisplayingChanges: false
|
|
93
105
|
};
|
|
94
106
|
} else {
|
|
@@ -98,19 +110,9 @@ export const createPlugin = config => {
|
|
|
98
110
|
};
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
|
-
|
|
102
|
-
// Calculate and store decorations in state
|
|
103
|
-
const decorations = calculateDecorations({
|
|
104
|
-
state: newState,
|
|
105
|
-
pluginState: {
|
|
106
|
-
steps: newPluginState.steps,
|
|
107
|
-
originalDoc: newPluginState.originalDoc,
|
|
108
|
-
isDisplayingChanges: newPluginState.isDisplayingChanges
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
113
|
return {
|
|
112
114
|
...newPluginState,
|
|
113
|
-
decorations
|
|
115
|
+
decorations: newPluginState.decorations.map(tr.mapping, tr.doc)
|
|
114
116
|
};
|
|
115
117
|
}
|
|
116
118
|
},
|
|
@@ -71,15 +71,16 @@ export var createPlugin = function createPlugin(config) {
|
|
|
71
71
|
var _config$steps, _config$steps2;
|
|
72
72
|
var schema = state.schema;
|
|
73
73
|
var isDisplayingChanges = ((_config$steps = config === null || config === void 0 ? void 0 : config.steps) !== null && _config$steps !== void 0 ? _config$steps : []).length > 0;
|
|
74
|
+
var steps = ((_config$steps2 = config === null || config === void 0 ? void 0 : config.steps) !== null && _config$steps2 !== void 0 ? _config$steps2 : []).map(function (step) {
|
|
75
|
+
return ProseMirrorStep.fromJSON(schema, step);
|
|
76
|
+
});
|
|
74
77
|
return {
|
|
75
|
-
steps:
|
|
76
|
-
return ProseMirrorStep.fromJSON(schema, step);
|
|
77
|
-
}),
|
|
78
|
+
steps: steps,
|
|
78
79
|
originalDoc: config !== null && config !== void 0 && config.originalDoc ? processRawValue(state.schema, config.originalDoc) : undefined,
|
|
79
80
|
decorations: calculateDecorations({
|
|
80
81
|
state: state,
|
|
81
82
|
pluginState: {
|
|
82
|
-
steps:
|
|
83
|
+
steps: steps,
|
|
83
84
|
originalDoc: config !== null && config !== void 0 && config.originalDoc ? processRawValue(state.schema, config.originalDoc) : undefined,
|
|
84
85
|
isDisplayingChanges: isDisplayingChanges
|
|
85
86
|
}
|
|
@@ -92,29 +93,30 @@ export var createPlugin = function createPlugin(config) {
|
|
|
92
93
|
var newPluginState = currentPluginState;
|
|
93
94
|
if (meta) {
|
|
94
95
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'SHOW_DIFF') {
|
|
96
|
+
// Calculate and store decorations in state
|
|
97
|
+
var decorations = calculateDecorations({
|
|
98
|
+
state: newState,
|
|
99
|
+
pluginState: {
|
|
100
|
+
steps: meta.steps,
|
|
101
|
+
originalDoc: meta.originalDoc,
|
|
102
|
+
isDisplayingChanges: true
|
|
103
|
+
}
|
|
104
|
+
});
|
|
95
105
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
106
|
+
decorations: decorations,
|
|
96
107
|
isDisplayingChanges: true
|
|
97
108
|
});
|
|
98
109
|
} else if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'HIDE_DIFF') {
|
|
99
110
|
newPluginState = _objectSpread(_objectSpread(_objectSpread({}, currentPluginState), meta), {}, {
|
|
111
|
+
decorations: DecorationSet.empty,
|
|
100
112
|
isDisplayingChanges: false
|
|
101
113
|
});
|
|
102
114
|
} else {
|
|
103
115
|
newPluginState = _objectSpread(_objectSpread({}, currentPluginState), meta);
|
|
104
116
|
}
|
|
105
117
|
}
|
|
106
|
-
|
|
107
|
-
// Calculate and store decorations in state
|
|
108
|
-
var decorations = calculateDecorations({
|
|
109
|
-
state: newState,
|
|
110
|
-
pluginState: {
|
|
111
|
-
steps: newPluginState.steps,
|
|
112
|
-
originalDoc: newPluginState.originalDoc,
|
|
113
|
-
isDisplayingChanges: newPluginState.isDisplayingChanges
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
118
|
return _objectSpread(_objectSpread({}, newPluginState), {}, {
|
|
117
|
-
decorations: decorations
|
|
119
|
+
decorations: newPluginState.decorations.map(tr.mapping, tr.doc)
|
|
118
120
|
});
|
|
119
121
|
}
|
|
120
122
|
},
|