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 |
|
16 |
|
17 |
|
18 |
|
19 | export var LinkMetaStep = 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 |
|
40 |
|
41 | }, {
|
42 | key: "invert",
|
43 | value: function invert() {
|
44 | |
45 |
|
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 |
|
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 |
|
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 |
|
76 | }, {
|
77 | key: "merge",
|
78 | value: function merge() {
|
79 | return null;
|
80 | }
|
81 | }, {
|
82 | key: "toJSON",
|
83 | value: function toJSON() {
|
84 |
|
85 | return {
|
86 | stepType: 'replace',
|
87 | from: 0,
|
88 | to: 0
|
89 | };
|
90 | }
|
91 | }], [{
|
92 | key: "fromJSON",
|
93 | value: function fromJSON(_, __) {
|
94 |
|
95 |
|
96 | return new ReplaceStep(0, 0, Slice.empty);
|
97 | }
|
98 | }]);
|
99 | return LinkMetaStep;
|
100 | }(Step);
|
101 |
|
102 |
|
103 | Step.jsonID(stepType, LinkMetaStep); |
\ | No newline at end of file |