@cloud-ru/ds-markdown 1.0.20-preview-9414fc09.0 → 1.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ds-markdown",
3
- "version": "1.0.20-preview-9414fc09.0",
3
+ "version": "1.0.20",
4
4
  "description": "Просмотр и редактирование markdown — рендер GFM и WYSIWYG-редактор на TipTap.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -62,20 +62,20 @@
62
62
  "rehype-highlight": "^7.0.2",
63
63
  "remark-gfm": "^4.0.1",
64
64
  "unified": "^11.0.5",
65
- "@cloud-ru/ds-divider": "1.0.1",
66
- "@cloud-ru/ds-button": "1.0.2",
67
- "@cloud-ru/ds-fields": "2.2.3-preview-9414fc09.0",
68
- "@cloud-ru/ds-icons": "1.1.0",
69
- "@cloud-ru/ds-modal": "1.1.1",
70
- "@cloud-ru/ds-portal-context": "1.0.1",
71
- "@cloud-ru/ds-materials": "1.0.1",
72
- "@cloud-ru/ds-scroll": "1.0.2",
73
- "@cloud-ru/ds-locale": "1.0.0",
74
- "@cloud-ru/ds-toggles": "1.1.3",
75
- "@cloud-ru/ds-list": "2.1.3",
76
- "@cloud-ru/ds-tooltip": "1.0.4",
77
- "@cloud-ru/ds-utils": "1.1.0",
78
- "@cloud-ru/ds-typography": "1.0.0"
65
+ "@cloud-ru/ds-button": "^1.0.2",
66
+ "@cloud-ru/ds-fields": "^2.2.2",
67
+ "@cloud-ru/ds-list": "^2.1.3",
68
+ "@cloud-ru/ds-icons": "^1.1.0",
69
+ "@cloud-ru/ds-divider": "^1.0.1",
70
+ "@cloud-ru/ds-portal-context": "^1.0.1",
71
+ "@cloud-ru/ds-modal": "^1.1.1",
72
+ "@cloud-ru/ds-toggles": "^1.1.3",
73
+ "@cloud-ru/ds-locale": "^1.0.0",
74
+ "@cloud-ru/ds-scroll": "^1.0.2",
75
+ "@cloud-ru/ds-materials": "^1.0.1",
76
+ "@cloud-ru/ds-tooltip": "^1.0.4",
77
+ "@cloud-ru/ds-typography": "^1.0.0",
78
+ "@cloud-ru/ds-utils": "^1.1.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "sass": "1.102.0",
package/src/mixins.scss CHANGED
@@ -51,6 +51,12 @@ $block-top-spacings: (
51
51
  }
52
52
  }
53
53
 
54
+ // У части брендовых шрифтов (SB Sans Interface) нет курсивного начертания — разрешаем браузерный наклон.
55
+ em,
56
+ i {
57
+ font-synthesis-style: auto;
58
+ }
59
+
54
60
  ul,
55
61
  ol {
56
62
  padding-left: base.$sn-primitive-dimension-24;
package/src/toolbarApi.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { TextSelection } from '@tiptap/pm/state';
1
2
  import { Editor } from '@tiptap/react';
2
3
  import { RefObject } from 'react';
3
4
 
@@ -84,14 +85,23 @@ export function createWysiwygApi(editor: Editor): ToolbarApi {
84
85
  return;
85
86
  }
86
87
 
87
- const chain = editor.chain().focus().extendMarkRange('link');
88
+ editor
89
+ .chain()
90
+ .focus()
91
+ .extendMarkRange('link')
92
+ // Текст из модалки отличается от текущего — заменяем его, иначе не трогаем (сохраняем вложенные марки).
93
+ .command(({ tr }) => {
94
+ const { from, to } = tr.selection;
88
95
 
89
- // Нет выделения, но задан текст — вставляем текст-ссылку. Иначе оборачиваем выделение.
90
- if (editor.state.selection.empty && title) {
91
- chain.insertContent({ type: 'text', text: title, marks: [{ type: 'link', attrs: { href } }] }).run();
92
- } else {
93
- chain.setLink({ href }).run();
94
- }
96
+ if (title && title !== tr.doc.textBetween(from, to)) {
97
+ tr.insertText(title, from, to);
98
+ tr.setSelection(TextSelection.create(tr.doc, from, from + title.length));
99
+ }
100
+
101
+ return true;
102
+ })
103
+ .setLink({ href })
104
+ .run();
95
105
  },
96
106
  insertImage: (src, alt) => editor.chain().focus().setImage({ src, alt }).run(),
97
107
  insertTable: (rows, cols) => editor.chain().focus().insertTable({ rows, cols, withHeaderRow: true }).run(),