@atlaskit/editor-plugin-code-block-advanced 1.0.1 → 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.
- package/CHANGELOG.md +23 -0
- package/afm-cc/tsconfig.json +6 -0
- package/afm-jira/tsconfig.json +6 -0
- package/afm-post-office/tsconfig.json +6 -0
- package/dist/cjs/nodeviews/codeBlockAdvanced.js +31 -8
- package/dist/cjs/nodeviews/codeBlockNodeWithToDOMFixed.js +2 -1
- package/dist/cjs/nodeviews/codemirrorSync/syncCMWithPM.js +0 -1
- package/dist/cjs/nodeviews/extensions/keymap/index.js +23 -3
- package/dist/cjs/nodeviews/extensions/manageSelectionMarker.js +28 -0
- package/dist/cjs/nodeviews/extensions/prosemirrorDecorations.js +142 -0
- package/dist/es2019/nodeviews/codeBlockAdvanced.js +28 -10
- package/dist/es2019/nodeviews/codeBlockNodeWithToDOMFixed.js +2 -1
- package/dist/es2019/nodeviews/codemirrorSync/syncCMWithPM.js +0 -1
- package/dist/es2019/nodeviews/extensions/keymap/index.js +23 -3
- package/dist/es2019/nodeviews/extensions/manageSelectionMarker.js +22 -0
- package/dist/es2019/nodeviews/extensions/prosemirrorDecorations.js +107 -0
- package/dist/esm/nodeviews/codeBlockAdvanced.js +33 -10
- package/dist/esm/nodeviews/codeBlockNodeWithToDOMFixed.js +2 -1
- package/dist/esm/nodeviews/codemirrorSync/syncCMWithPM.js +0 -1
- package/dist/esm/nodeviews/extensions/keymap/index.js +23 -3
- package/dist/esm/nodeviews/extensions/manageSelectionMarker.js +22 -0
- package/dist/esm/nodeviews/extensions/prosemirrorDecorations.js +135 -0
- package/dist/types/codeBlockAdvancedPluginType.d.ts +9 -1
- package/dist/types/nodeviews/codeBlockAdvanced.d.ts +10 -2
- package/dist/types/nodeviews/extensions/keymap/index.d.ts +2 -1
- package/dist/types/nodeviews/extensions/manageSelectionMarker.d.ts +10 -0
- package/dist/types/nodeviews/extensions/prosemirrorDecorations.d.ts +20 -0
- package/dist/types-ts4.5/codeBlockAdvancedPluginType.d.ts +5 -1
- package/dist/types-ts4.5/nodeviews/codeBlockAdvanced.d.ts +10 -2
- package/dist/types-ts4.5/nodeviews/extensions/keymap/index.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/extensions/manageSelectionMarker.d.ts +10 -0
- package/dist/types-ts4.5/nodeviews/extensions/prosemirrorDecorations.d.ts +20 -0
- package/package.json +6 -4
- package/src/codeBlockAdvancedPluginType.ts +9 -1
- package/src/nodeviews/codeBlockAdvanced.ts +33 -7
- package/src/nodeviews/codeBlockNodeWithToDOMFixed.ts +1 -0
- package/src/nodeviews/codemirrorSync/syncCMWithPM.ts +0 -1
- package/src/nodeviews/extensions/keymap/index.ts +31 -1
- package/src/nodeviews/extensions/manageSelectionMarker.ts +28 -0
- package/src/nodeviews/extensions/prosemirrorDecorations.ts +156 -0
- package/tsconfig.app.json +6 -0
- package/dist/cjs/nodeviews/extensions/bidiCharWarning.js +0 -83
- package/dist/es2019/nodeviews/extensions/bidiCharWarning.js +0 -53
- package/dist/esm/nodeviews/extensions/bidiCharWarning.js +0 -77
- package/dist/types/nodeviews/extensions/bidiCharWarning.d.ts +0 -8
- package/dist/types-ts4.5/nodeviews/extensions/bidiCharWarning.d.ts +0 -8
- package/src/nodeviews/extensions/bidiCharWarning.ts +0 -72
|
@@ -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
|
-
}
|