@atlaskit/editor-plugin-code-block-advanced 1.0.2 → 1.0.3

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 (49) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/afm-cc/tsconfig.json +6 -0
  3. package/afm-jira/tsconfig.json +6 -0
  4. package/afm-post-office/tsconfig.json +6 -0
  5. package/dist/cjs/nodeviews/codeBlockAdvanced.js +29 -26
  6. package/dist/cjs/nodeviews/codemirrorSync/syncCMWithPM.js +0 -1
  7. package/dist/cjs/nodeviews/extensions/keymap/index.js +23 -3
  8. package/dist/cjs/nodeviews/extensions/manageSelectionMarker.js +28 -0
  9. package/dist/cjs/nodeviews/extensions/prosemirrorDecorations.js +142 -0
  10. package/dist/es2019/nodeviews/codeBlockAdvanced.js +27 -27
  11. package/dist/es2019/nodeviews/codemirrorSync/syncCMWithPM.js +0 -1
  12. package/dist/es2019/nodeviews/extensions/keymap/index.js +23 -3
  13. package/dist/es2019/nodeviews/extensions/manageSelectionMarker.js +22 -0
  14. package/dist/es2019/nodeviews/extensions/prosemirrorDecorations.js +107 -0
  15. package/dist/esm/nodeviews/codeBlockAdvanced.js +30 -27
  16. package/dist/esm/nodeviews/codemirrorSync/syncCMWithPM.js +0 -1
  17. package/dist/esm/nodeviews/extensions/keymap/index.js +23 -3
  18. package/dist/esm/nodeviews/extensions/manageSelectionMarker.js +22 -0
  19. package/dist/esm/nodeviews/extensions/prosemirrorDecorations.js +135 -0
  20. package/dist/types/codeBlockAdvancedPluginType.d.ts +9 -1
  21. package/dist/types/nodeviews/codeBlockAdvanced.d.ts +10 -5
  22. package/dist/types/nodeviews/extensions/keymap/index.d.ts +2 -1
  23. package/dist/types/nodeviews/extensions/manageSelectionMarker.d.ts +10 -0
  24. package/dist/types/nodeviews/extensions/prosemirrorDecorations.d.ts +20 -0
  25. package/dist/types-ts4.5/codeBlockAdvancedPluginType.d.ts +5 -1
  26. package/dist/types-ts4.5/nodeviews/codeBlockAdvanced.d.ts +10 -5
  27. package/dist/types-ts4.5/nodeviews/extensions/keymap/index.d.ts +2 -1
  28. package/dist/types-ts4.5/nodeviews/extensions/manageSelectionMarker.d.ts +10 -0
  29. package/dist/types-ts4.5/nodeviews/extensions/prosemirrorDecorations.d.ts +20 -0
  30. package/package.json +3 -1
  31. package/src/codeBlockAdvancedPluginType.ts +9 -1
  32. package/src/nodeviews/codeBlockAdvanced.ts +31 -30
  33. package/src/nodeviews/codemirrorSync/syncCMWithPM.ts +0 -1
  34. package/src/nodeviews/extensions/keymap/index.ts +31 -1
  35. package/src/nodeviews/extensions/manageSelectionMarker.ts +28 -0
  36. package/src/nodeviews/extensions/prosemirrorDecorations.ts +156 -0
  37. package/tsconfig.app.json +6 -0
  38. package/dist/cjs/nodeviews/extensions/bidiCharWarning.js +0 -83
  39. package/dist/cjs/nodeviews/extensions/copyButtonDecorations.js +0 -22
  40. package/dist/es2019/nodeviews/extensions/bidiCharWarning.js +0 -53
  41. package/dist/es2019/nodeviews/extensions/copyButtonDecorations.js +0 -16
  42. package/dist/esm/nodeviews/extensions/bidiCharWarning.js +0 -77
  43. package/dist/esm/nodeviews/extensions/copyButtonDecorations.js +0 -16
  44. package/dist/types/nodeviews/extensions/bidiCharWarning.d.ts +0 -8
  45. package/dist/types/nodeviews/extensions/copyButtonDecorations.d.ts +0 -1
  46. package/dist/types-ts4.5/nodeviews/extensions/bidiCharWarning.d.ts +0 -8
  47. package/dist/types-ts4.5/nodeviews/extensions/copyButtonDecorations.d.ts +0 -1
  48. package/src/nodeviews/extensions/bidiCharWarning.ts +0 -72
  49. package/src/nodeviews/extensions/copyButtonDecorations.ts +0 -15
@@ -1,77 +0,0 @@
1
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
2
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
- import _createClass from "@babel/runtime/helpers/createClass";
6
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
7
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
- /**
9
- * Code based on warning from @atlaskit/code
10
- */
11
- import { EditorView as CodeMirror, ViewPlugin, Decoration, MatchDecorator, WidgetType } from '@codemirror/view';
12
- var bidiCharacterRegex = /[\u202A-\u202E\u2066-\u2069]/g;
13
- var placeholderMatcher = new MatchDecorator({
14
- regexp: bidiCharacterRegex,
15
- decoration: function decoration(match) {
16
- return Decoration.replace({
17
- widget: new PlaceholderWidget(match[0])
18
- });
19
- }
20
- });
21
- export var bidiCharWarningExtension = ViewPlugin.fromClass( /*#__PURE__*/function () {
22
- function _class(view) {
23
- _classCallCheck(this, _class);
24
- this.placeholders = placeholderMatcher.createDeco(view);
25
- }
26
- return _createClass(_class, [{
27
- key: "update",
28
- value: function update(_update) {
29
- this.placeholders = placeholderMatcher.updateDeco(_update, this.placeholders);
30
- }
31
- }]);
32
- }(), {
33
- decorations: function decorations(instance) {
34
- return instance.placeholders;
35
- },
36
- provide: function provide(plugin) {
37
- return CodeMirror.atomicRanges.of(function (view) {
38
- var _view$plugin;
39
- return ((_view$plugin = view.plugin(plugin)) === null || _view$plugin === void 0 ? void 0 : _view$plugin.placeholders) || Decoration.none;
40
- });
41
- }
42
- });
43
- function getBidiCharacterCode(bidiCharacter) {
44
- var _bidiCharacter$codePo;
45
- var bidiCharacterCode = (_bidiCharacter$codePo = bidiCharacter.codePointAt(0)) === null || _bidiCharacter$codePo === void 0 ? void 0 : _bidiCharacter$codePo.toString(16);
46
- return "U+".concat(bidiCharacterCode);
47
- }
48
- var PlaceholderWidget = /*#__PURE__*/function (_WidgetType) {
49
- function PlaceholderWidget(name) {
50
- var _this;
51
- _classCallCheck(this, PlaceholderWidget);
52
- _this = _callSuper(this, PlaceholderWidget);
53
- _this.name = name;
54
- return _this;
55
- }
56
- _inherits(PlaceholderWidget, _WidgetType);
57
- return _createClass(PlaceholderWidget, [{
58
- key: "eq",
59
- value: function eq(other) {
60
- return this.name === other.name;
61
- }
62
- }, {
63
- key: "toDOM",
64
- value: function toDOM() {
65
- var elt = document.createElement('span');
66
- elt.setAttribute('data-bidi-character-code', this.name);
67
- elt.style.cssText = "\n padding: 0 3px;\n color: ".concat("var(--ds-text-warning, #A54800)", ";\n\t\t\tbackground: ", "var(--ds-background-warning, #FFF7D6)", ";\n\t\t\taria-hidden=\"true\"");
68
- elt.textContent = "<".concat(getBidiCharacterCode(this.name), ">");
69
- return elt;
70
- }
71
- }, {
72
- key: "ignoreEvent",
73
- value: function ignoreEvent() {
74
- return false;
75
- }
76
- }]);
77
- }(WidgetType);
@@ -1,16 +0,0 @@
1
- import { RangeSetBuilder } from '@codemirror/state';
2
- import { EditorView as CodeMirror, Decoration } from '@codemirror/view';
3
- export var copyButtonDecorations = CodeMirror.decorations.compute([], function (state) {
4
- var allTextDecoration = Decoration.mark({
5
- attributes: {
6
- class: 'ProseMirror-fake-text-selection'
7
- }
8
- });
9
- // Create a set of decorations for the entire document
10
- var builder = new RangeSetBuilder();
11
- for (var i = 0; i < state.doc.lines; i++) {
12
- builder.add(state.doc.line(i + 1).from, state.doc.line(i + 1).to, allTextDecoration);
13
- }
14
- var decorations = builder.finish();
15
- return decorations;
16
- });
@@ -1,8 +0,0 @@
1
- /**
2
- * Code based on warning from @atlaskit/code
3
- */
4
- import { ViewPlugin, ViewUpdate, DecorationSet } from '@codemirror/view';
5
- export declare const bidiCharWarningExtension: ViewPlugin<{
6
- placeholders: DecorationSet;
7
- update(update: ViewUpdate): void;
8
- }>;
@@ -1 +0,0 @@
1
- export declare const copyButtonDecorations: import("@codemirror/state").Extension;
@@ -1,8 +0,0 @@
1
- /**
2
- * Code based on warning from @atlaskit/code
3
- */
4
- import { ViewPlugin, ViewUpdate, DecorationSet } from '@codemirror/view';
5
- export declare const bidiCharWarningExtension: ViewPlugin<{
6
- placeholders: DecorationSet;
7
- update(update: ViewUpdate): void;
8
- }>;
@@ -1 +0,0 @@
1
- export declare const copyButtonDecorations: import("@codemirror/state").Extension;
@@ -1,72 +0,0 @@
1
- /**
2
- * Code based on warning from @atlaskit/code
3
- */
4
- import {
5
- EditorView as CodeMirror,
6
- ViewPlugin,
7
- ViewUpdate,
8
- Decoration,
9
- MatchDecorator,
10
- DecorationSet,
11
- WidgetType,
12
- } from '@codemirror/view';
13
-
14
- import { token } from '@atlaskit/tokens';
15
-
16
- const bidiCharacterRegex = /[\u202A-\u202E\u2066-\u2069]/gu;
17
-
18
- const placeholderMatcher = new MatchDecorator({
19
- regexp: bidiCharacterRegex,
20
- decoration: (match) =>
21
- Decoration.replace({
22
- widget: new PlaceholderWidget(match[0]),
23
- }),
24
- });
25
-
26
- export const bidiCharWarningExtension = ViewPlugin.fromClass(
27
- class {
28
- placeholders: DecorationSet;
29
- constructor(view: CodeMirror) {
30
- this.placeholders = placeholderMatcher.createDeco(view);
31
- }
32
- update(update: ViewUpdate) {
33
- this.placeholders = placeholderMatcher.updateDeco(update, this.placeholders);
34
- }
35
- },
36
- {
37
- decorations: (instance) => instance.placeholders,
38
- provide: (plugin) =>
39
- CodeMirror.atomicRanges.of((view) => {
40
- return view.plugin(plugin)?.placeholders || Decoration.none;
41
- }),
42
- },
43
- );
44
-
45
- function getBidiCharacterCode(bidiCharacter: string) {
46
- const bidiCharacterCode = bidiCharacter.codePointAt(0)?.toString(16);
47
-
48
- return `U+${bidiCharacterCode}`;
49
- }
50
-
51
- class PlaceholderWidget extends WidgetType {
52
- constructor(readonly name: string) {
53
- super();
54
- }
55
- eq(other: PlaceholderWidget) {
56
- return this.name === other.name;
57
- }
58
- toDOM() {
59
- const elt = document.createElement('span');
60
- elt.setAttribute('data-bidi-character-code', this.name);
61
- elt.style.cssText = `
62
- padding: 0 3px;
63
- color: ${token('color.text.warning')};
64
- background: ${token('color.background.warning')};
65
- aria-hidden="true"`;
66
- elt.textContent = `<${getBidiCharacterCode(this.name)}>`;
67
- return elt;
68
- }
69
- ignoreEvent() {
70
- return false;
71
- }
72
- }
@@ -1,15 +0,0 @@
1
- import { RangeSetBuilder } from '@codemirror/state';
2
- import { EditorView as CodeMirror, Decoration } from '@codemirror/view';
3
-
4
- export const copyButtonDecorations = CodeMirror.decorations.compute([], (state) => {
5
- const allTextDecoration = Decoration.mark({
6
- attributes: { class: 'ProseMirror-fake-text-selection' },
7
- });
8
- // Create a set of decorations for the entire document
9
- const builder = new RangeSetBuilder<Decoration>();
10
- for (let i = 0; i < state.doc.lines; i++) {
11
- builder.add(state.doc.line(i + 1).from, state.doc.line(i + 1).to, allTextDecoration);
12
- }
13
- const decorations = builder.finish();
14
- return decorations;
15
- });