Skip to content

Commit 48372a6

Browse files
authored
feat(markup): added markup search (#295)
* feat(markup): added markup search
1 parent fb97667 commit 48372a6

File tree

18 files changed

+442
-17
lines changed

18 files changed

+442
-17
lines changed

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
"@codemirror/commands": "6.5.0",
164164
"@codemirror/lang-markdown": "6.2.5",
165165
"@codemirror/language": "6.10.1",
166+
"@codemirror/search": "6.5.6",
166167
"@codemirror/state": "6.4.1",
167168
"@codemirror/view": "6.26.3",
168169
"@gravity-ui/i18n": "^1.1.0",
@@ -198,9 +199,9 @@
198199
"tslib": "^2.3.1"
199200
},
200201
"devDependencies": {
202+
"@diplodoc/html-extension": "1.2.7",
201203
"@diplodoc/latex-extension": "1.0.3",
202204
"@diplodoc/mermaid-extension": "1.2.1",
203-
"@diplodoc/html-extension": "1.2.7",
204205
"@diplodoc/transform": "4.5.0",
205206
"@gravity-ui/components": "3.0.0",
206207
"@gravity-ui/eslint-config": "3.1.1",
@@ -268,9 +269,9 @@
268269
}
269270
},
270271
"peerDependencies": {
272+
"@diplodoc/html-extension": "^1.2.7",
271273
"@diplodoc/latex-extension": "^1.0.3",
272274
"@diplodoc/mermaid-extension": "^1.0.0",
273-
"@diplodoc/html-extension": "^1.2.7",
274275
"@diplodoc/transform": "^4.5.0",
275276
"@gravity-ui/components": "^3.0.0",
276277
"@gravity-ui/uikit": "^6.11.0",

src/bundle/Editor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type ToolbarActionData = {
3131
attrs?: {[key: string]: any};
3232
};
3333

34-
interface EventMap {
34+
export interface EventMap {
3535
change: null;
3636
cancel: null;
3737
submit: null;
@@ -273,6 +273,7 @@ export class EditorImpl extends SafeEventEmitter<EventMapInt> implements EditorI
273273
uploadHandler: this.fileUploadHandler,
274274
needImgDimms: this.needToSetDimensionsForUploadedImages,
275275
extraMarkupExtensions: this.#extraMarkupExtensions,
276+
receiver: this,
276277
}),
277278
);
278279
}

src/bundle/MarkdownEditorView.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ export const MarkdownEditorView = React.forwardRef<HTMLDivElement, MarkdownEdito
271271
);
272272
MarkdownEditorView.displayName = 'MarkdownEditorView';
273273

274+
interface MarkupSearchAnchorProps extends Pick<EditorSettingsProps, 'mode'> {}
275+
276+
const MarkupSearchAnchor: React.FC<MarkupSearchAnchorProps> = ({mode}) => (
277+
<>{mode === 'markup' && <div className="g-md-search-anchor"></div>}</>
278+
);
279+
274280
function Settings(props: EditorSettingsProps & {stickyToolbar: boolean}) {
275281
const wrapperRef = useRef<HTMLDivElement>(null);
276282
const isSticky = useSticky(wrapperRef) && props.toolbarVisibility && props.stickyToolbar;
@@ -284,6 +290,7 @@ function Settings(props: EditorSettingsProps & {stickyToolbar: boolean}) {
284290
})}
285291
>
286292
<EditorSettings {...props} />
293+
<MarkupSearchAnchor {...props} />
287294
</div>
288295
</div>
289296
);

src/extensions/markdown/Link/plugins/LinkTooltipPlugin/TooltipView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type {TextInputProps} from '@gravity-ui/uikit';
55
import {TextInputFixed} from '../../../../../forms/TextInput';
66
import {UrlInputRow} from '../../../../../forms/UrlInputRow';
77
import Form from '../../../../../forms/base';
8-
import {enterKeyHandler} from '../../../../../forms/utils';
98
import {i18n} from '../../../../../i18n/forms';
9+
import {enterKeyHandler} from '../../../../../utils/handlers';
1010

1111
type LinkFormProps = {
1212
href: string;

src/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImageForm/ImageForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {EditorView} from 'prosemirror-view';
88
import {cn} from '../../../../../../classname';
99
import Form from '../../../../../../forms/base';
1010
import {NumberInput} from '../../../../../../forms/components';
11-
import {enterKeyHandler} from '../../../../../../forms/utils';
1211
import {i18n} from '../../../../../../i18n/forms';
1312
import {useAutoFocus} from '../../../../../../react-utils/useAutoFocus';
13+
import {enterKeyHandler} from '../../../../../../utils/handlers';
1414
import {LinkAttr, linkType} from '../../../../../markdown';
1515
import {ImgSizeAttr} from '../../../../../specs';
1616

src/forms/FileForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {Tabs, TextInput, TextInputProps} from '@gravity-ui/uikit';
55
import {ClassNameProps, cn} from '../classname';
66
import {i18n} from '../i18n/forms';
77
import {isFunction} from '../lodash';
8+
import {enterKeyHandler} from '../utils/handlers';
89

910
import {TextInputFixed} from './TextInput';
1011
import Form from './base';
1112
import {ButtonAttach} from './components';
12-
import {enterKeyHandler} from './utils';
1313

1414
const b = cn('file-form');
1515

src/forms/ImageForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import {Tabs, TextInput, TextInputProps} from '@gravity-ui/uikit';
55
import {ClassNameProps, cn} from '../classname';
66
import {i18n} from '../i18n/forms';
77
import {isFunction} from '../lodash';
8+
import {enterKeyHandler} from '../utils/handlers';
89

910
import {TextInputFixed} from './TextInput';
1011
import Form from './base';
1112
import {ButtonAttach, NumberInput} from './components';
12-
import {enterKeyHandler} from './utils';
1313

1414
import './ImageForm.scss';
1515

src/forms/LinkForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import {TextInput, TextInputProps} from '@gravity-ui/uikit';
44

55
import {ClassNameProps} from '../classname';
66
import {i18n} from '../i18n/forms';
7+
import {enterKeyHandler} from '../utils/handlers';
78

89
import {TextInputFixed} from './TextInput';
910
import {UrlInputRow} from './UrlInputRow';
1011
import Form from './base';
11-
import {enterKeyHandler} from './utils';
1212

1313
export type LinkFormSubmitParams = {
1414
url: string;

src/forms/utils.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)