@wyttime04/react-vditor 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -230,14 +230,15 @@ const App = () => {
230
230
  |---|---|---|
231
231
  | 編輯器外框 | vditor `classic` | vditor `dark` |
232
232
  | 內容主題 | vditor `light` | vditor `dark` |
233
- | 程式碼上色 | highlight.js `github` | highlight.js `github-dark` |
233
+ | 程式碼上色 | highlight.js `github`(vditor 整頁載入的樣式) | highlight.js `github-dark` |
234
+ | 預覽的程式碼區塊背景色 | `#f6f8fa` | `#0d1117`(`github-dark`) |
234
235
  | `<VditorPreview>` 背景色 | 不設定 | `#2f363d`(與 vditor 深色編輯區相同) |
235
236
 
236
237
  ### 說明
237
238
 
238
239
  - 各元件的主題彼此獨立,同一頁面可混用不同主題。vditor 原生以整頁共用的 `<link>` 載入內容主題,
239
240
  同一頁面只能使用一種;本套件將主題樣式局部化並併入 `index.css`,改由元件容器上的
240
- `react-vditor--light` / `react-vditor--dark` class 套用。
241
+ `react-vditor--light` / `react-vditor--dark` class 套用。局部化不提高選擇器權重,除上表的預覽程式碼區塊背景色外,套用結果與原生 vditor 相同。
241
242
  - 切換主題不會重建編輯器。
242
243
  - `theme` prop 取代 vditor 原生的 `theme`(`classic` / `dark`)與 `preview.theme` 設定;ref 亦不提供 `setTheme`。
243
244
 
@@ -370,7 +371,7 @@ const html = await md2html(markdown, {transform: sanitize});
370
371
  - 網址不合法的連結轉為純文字,僅作用於 `<VditorPreview>`、`md2html()` 與編輯器的預覽區;ir / wysiwyg 模式的編輯區不套用 `transform`,連結仍會顯示
371
372
  - `$$ … $$` 區塊會以程式碼區塊呈現(Lute 未提供停用此語法的設定)
372
373
  - `:smile:` 等 emoji 代碼會轉為對應字元,YAML front matter 會以程式碼區塊呈現;兩者雖非 GFM 語法,仍予以保留
373
- - vditor 無論設定為何,都會整頁載入 highlight.js 的 `github.min.css`;`dark` 主題的程式碼樣式以局部化且優先權較高的規則覆寫
374
+ - vditor 無論設定為何,都會整頁載入 highlight.js 的 `github.min.css`;`light` 主題直接沿用,`dark` 主題的程式碼樣式以權重略高的局部化規則覆寫
374
375
  - 啟用 `cache` 且未提供 `value` 時,若快取內容包含 `$…$`,初次渲染會嘗試載入未輸出的 katex,產生本機 404
375
376
 
376
377
  ## 開發
package/dist/index.css CHANGED
@@ -1904,7 +1904,7 @@
1904
1904
  }
1905
1905
 
1906
1906
 
1907
- /* react-vditor light / dark 主題,只作用在 .react-vditor--light / .react-vditor--dark 容器裡 */
1907
+ /* react-vditor:light / dark 主題 */
1908
1908
  /*!
1909
1909
  * Vditor - A markdown editor written in TypeScript.
1910
1910
  *
@@ -1931,7 +1931,7 @@
1931
1931
  * SOFTWARE.
1932
1932
  *
1933
1933
  */
1934
- .react-vditor--light .vditor-reset {
1934
+ :where(.react-vditor--light) .vditor-reset {
1935
1935
  --callout-note-color: #0969da;
1936
1936
  --callout-note-background-color: rgba(9, 105, 218, 0.08);
1937
1937
  --callout-tip-color: #1a7f37;
@@ -1944,93 +1944,82 @@
1944
1944
  --callout-caution-background-color: rgba(207, 34, 46, 0.08);
1945
1945
  }
1946
1946
 
1947
- .react-vditor--light .vditor-reset h1, .react-vditor--light .vditor-reset h2 {
1947
+ :where(.react-vditor--light) .vditor-reset h1, :where(.react-vditor--light) .vditor-reset h2 {
1948
1948
  padding-bottom: 0.3em;
1949
1949
  border-bottom: 1px solid #eaecef;
1950
1950
  }
1951
1951
 
1952
- .react-vditor--light .vditor-reset hr {
1952
+ :where(.react-vditor--light) .vditor-reset hr {
1953
1953
  background-color: #eaecef;
1954
1954
  }
1955
1955
 
1956
- .react-vditor--light .vditor-reset blockquote {
1956
+ :where(.react-vditor--light) .vditor-reset blockquote {
1957
1957
  color: #6a737d;
1958
1958
  border-left: .25em solid #eaecef
1959
1959
  }
1960
1960
 
1961
- .react-vditor--light .vditor-reset iframe {
1961
+ :where(.react-vditor--light) .vditor-reset iframe {
1962
1962
  border: 1px solid #d1d5da
1963
1963
  }
1964
1964
 
1965
- .react-vditor--light .vditor-reset table tr {
1965
+ :where(.react-vditor--light) .vditor-reset table tr {
1966
1966
  border-top: 1px solid #c6cbd1;
1967
1967
  background-color: #fafbfc
1968
1968
  }
1969
1969
 
1970
- .react-vditor--light .vditor-reset table td, .react-vditor--light .vditor-reset table th {
1970
+ :where(.react-vditor--light) .vditor-reset table td, :where(.react-vditor--light) .vditor-reset table th {
1971
1971
  border: 1px solid #dfe2e5
1972
1972
  }
1973
1973
 
1974
- .react-vditor--light .vditor-reset table tbody tr:nth-child(2n) {
1974
+ :where(.react-vditor--light) .vditor-reset table tbody tr:nth-child(2n) {
1975
1975
  background-color: #fff
1976
1976
  }
1977
1977
 
1978
- .react-vditor--light .vditor-reset code:not(.hljs):not(.highlight-chroma) {
1978
+ :where(.react-vditor--light) .vditor-reset code:not(.hljs):not(.highlight-chroma) {
1979
1979
  background-color: rgba(27, 31, 35, .05);
1980
1980
  }
1981
1981
 
1982
- .react-vditor--light .vditor-reset kbd {
1982
+ :where(.react-vditor--light) .vditor-reset kbd {
1983
1983
  color: #24292e;
1984
1984
  background-color: #fafbfc;
1985
1985
  border: solid 1px #d1d5da;
1986
1986
  box-shadow: inset 0 -1px 0 #d1d5da;
1987
1987
  }
1988
1988
 
1989
- .react-vditor--light .vditor-speech {
1989
+ :where(.react-vditor--light) .vditor-speech {
1990
1990
  background-color: #f6f8fa;
1991
1991
  border: 1px solid #d1d5da;
1992
1992
  color: #586069;
1993
1993
  }
1994
1994
 
1995
- .react-vditor--light .vditor-speech--current, .react-vditor--light .vditor-speech:hover {
1995
+ :where(.react-vditor--light) .vditor-speech--current, :where(.react-vditor--light) .vditor-speech:hover {
1996
1996
  color: #4285f4;
1997
1997
  }
1998
1998
 
1999
- .react-vditor--light .vditor-linkcard a {
1999
+ :where(.react-vditor--light) .vditor-linkcard a {
2000
2000
  background-color: #f6f8fa;
2001
2001
  }
2002
2002
 
2003
- .react-vditor--light .vditor-linkcard a:visited .vditor-linkcard__abstract {
2003
+ :where(.react-vditor--light) .vditor-linkcard a:visited .vditor-linkcard__abstract {
2004
2004
  color: rgba(88, 96, 105, 0.36);
2005
2005
  }
2006
2006
 
2007
- .react-vditor--light .vditor-linkcard__title {
2007
+ :where(.react-vditor--light) .vditor-linkcard__title {
2008
2008
  color: #24292e;
2009
2009
  }
2010
2010
 
2011
- .react-vditor--light .vditor-linkcard__abstract {
2011
+ :where(.react-vditor--light) .vditor-linkcard__abstract {
2012
2012
  color: #586069;
2013
2013
  }
2014
2014
 
2015
- .react-vditor--light .vditor-linkcard__site {
2015
+ :where(.react-vditor--light) .vditor-linkcard__site {
2016
2016
  color: #4285f4;
2017
2017
  }
2018
2018
 
2019
- .react-vditor--light .vditor-linkcard__image {
2019
+ :where(.react-vditor--light) .vditor-linkcard__image {
2020
2020
  background-color: rgba(88, 96, 105, 0.36);
2021
2021
  }
2022
2022
 
2023
- .react-vditor--light pre code.hljs{display:block;overflow-x:auto;padding:1em}.react-vditor--light code.hljs{padding:3px 5px}/*!
2024
- Theme: GitHub
2025
- Description: Light theme as seen on github.com
2026
- Author: github.com
2027
- Maintainer: @Hirse
2028
- Updated: 2021-05-15
2029
-
2030
- Outdated base version: https://github.com/primer/github-syntax-light
2031
- Current colors taken from GitHub's CSS
2032
- */.react-vditor--light .hljs{color:#24292e;background:#fff}.react-vditor--light .hljs-doctag,.react-vditor--light .hljs-keyword,.react-vditor--light .hljs-meta .hljs-keyword,.react-vditor--light .hljs-template-tag,.react-vditor--light .hljs-template-variable,.react-vditor--light .hljs-type,.react-vditor--light .hljs-variable.language_{color:#d73a49}.react-vditor--light .hljs-title,.react-vditor--light .hljs-title.class_,.react-vditor--light .hljs-title.class_.inherited__,.react-vditor--light .hljs-title.function_{color:#6f42c1}.react-vditor--light .hljs-attr,.react-vditor--light .hljs-attribute,.react-vditor--light .hljs-literal,.react-vditor--light .hljs-meta,.react-vditor--light .hljs-number,.react-vditor--light .hljs-operator,.react-vditor--light .hljs-selector-attr,.react-vditor--light .hljs-selector-class,.react-vditor--light .hljs-selector-id,.react-vditor--light .hljs-variable{color:#005cc5}.react-vditor--light .hljs-meta .hljs-string,.react-vditor--light .hljs-regexp,.react-vditor--light .hljs-string{color:#032f62}.react-vditor--light .hljs-built_in,.react-vditor--light .hljs-symbol{color:#e36209}.react-vditor--light .hljs-code,.react-vditor--light .hljs-comment,.react-vditor--light .hljs-formula{color:#6a737d}.react-vditor--light .hljs-name,.react-vditor--light .hljs-quote,.react-vditor--light .hljs-selector-pseudo,.react-vditor--light .hljs-selector-tag{color:#22863a}.react-vditor--light .hljs-subst{color:#24292e}.react-vditor--light .hljs-section{color:#005cc5;font-weight:700}.react-vditor--light .hljs-bullet{color:#735c0f}.react-vditor--light .hljs-emphasis{color:#24292e;font-style:italic}.react-vditor--light .hljs-strong{color:#24292e;font-weight:700}.react-vditor--light .hljs-addition{color:#22863a;background-color:#f0fff4}.react-vditor--light .hljs-deletion{color:#b31d28;background-color:#ffeef0}
2033
-
2034
2023
  /*!
2035
2024
  * Vditor - A markdown editor written in TypeScript.
2036
2025
  *
@@ -2057,7 +2046,7 @@
2057
2046
  * SOFTWARE.
2058
2047
  *
2059
2048
  */
2060
- .react-vditor--dark .vditor-reset {
2049
+ :where(.react-vditor--dark) .vditor-reset {
2061
2050
  color: #d1d5da;
2062
2051
  --callout-note-color: #58a6ff;
2063
2052
  --callout-note-background-color: rgba(56, 139, 253, 0.15);
@@ -2071,101 +2060,101 @@
2071
2060
  --callout-caution-background-color: rgba(248, 81, 73, 0.15);
2072
2061
  }
2073
2062
 
2074
- .react-vditor--dark .vditor-reset a, .react-vditor--dark .vditor-ir__link {
2063
+ :where(.react-vditor--dark) .vditor-reset a, :where(.react-vditor--dark) .vditor-ir__link {
2075
2064
  color: #4285f4;
2076
2065
  }
2077
2066
 
2078
- .react-vditor--dark .vditor-reset h1, .react-vditor--dark .vditor-reset h2 {
2067
+ :where(.react-vditor--dark) .vditor-reset h1, :where(.react-vditor--dark) .vditor-reset h2 {
2079
2068
  padding-bottom: 0.3em;
2080
2069
  border-bottom: 1px solid #d1d5da
2081
2070
  }
2082
2071
 
2083
- .react-vditor--dark .vditor-reset hr {
2072
+ :where(.react-vditor--dark) .vditor-reset hr {
2084
2073
  background-color: #d1d5da
2085
2074
  }
2086
2075
 
2087
- .react-vditor--dark .vditor-reset blockquote {
2076
+ :where(.react-vditor--dark) .vditor-reset blockquote {
2088
2077
  padding: 0 1em;
2089
2078
  color: #b9b9b9;
2090
2079
  border-left: .25em solid #d1d5da
2091
2080
  }
2092
2081
 
2093
- .react-vditor--dark .vditor-reset iframe {
2082
+ :where(.react-vditor--dark) .vditor-reset iframe {
2094
2083
  border: 1px solid #141414
2095
2084
  }
2096
2085
 
2097
- .react-vditor--dark .vditor-reset table tr {
2086
+ :where(.react-vditor--dark) .vditor-reset table tr {
2098
2087
  background-color: #2f363d
2099
2088
  }
2100
2089
 
2101
- .react-vditor--dark .vditor-reset table td, .react-vditor--dark .vditor-reset table th {
2090
+ :where(.react-vditor--dark) .vditor-reset table td, :where(.react-vditor--dark) .vditor-reset table th {
2102
2091
  border: 1px solid #dfe2e5
2103
2092
  }
2104
2093
 
2105
- .react-vditor--dark .vditor-reset table tbody tr:nth-child(2n) {
2094
+ :where(.react-vditor--dark) .vditor-reset table tbody tr:nth-child(2n) {
2106
2095
  background-color: #24292e
2107
2096
  }
2108
2097
 
2109
- .react-vditor--dark .vditor-reset code:not(.hljs):not(.highlight-chroma) {
2098
+ :where(.react-vditor--dark) .vditor-reset code:not(.hljs):not(.highlight-chroma) {
2110
2099
  background-color: rgba(66, 133, 244, .36);
2111
2100
  }
2112
2101
 
2113
- .react-vditor--dark .vditor-reset .language-abc svg,
2114
- .react-vditor--dark .vditor-reset .language-abc path {
2102
+ :where(.react-vditor--dark) .vditor-reset .language-abc svg,
2103
+ :where(.react-vditor--dark) .vditor-reset .language-abc path {
2115
2104
  fill: currentColor;
2116
2105
  color: #d1d5da;
2117
2106
  }
2118
2107
 
2119
- .react-vditor--dark .language-graphviz polygon {
2108
+ :where(.react-vditor--dark) .language-graphviz polygon {
2120
2109
  fill: rgba(66, 133, 244, .36);
2121
2110
  }
2122
2111
 
2123
- .react-vditor--dark .vditor-reset kbd {
2112
+ :where(.react-vditor--dark) .vditor-reset kbd {
2124
2113
  color: #d1d5da;
2125
2114
  background-color: #2f363d;
2126
2115
  border: 1px solid #141414;
2127
2116
  box-shadow: inset 0 -1px 0 #141414
2128
2117
  }
2129
2118
 
2130
- .react-vditor--dark .vditor-copy svg {
2119
+ :where(.react-vditor--dark) .vditor-copy svg {
2131
2120
  color: #b9b9b9
2132
2121
  }
2133
2122
 
2134
- .react-vditor--dark .vditor-speech {
2123
+ :where(.react-vditor--dark) .vditor-speech {
2135
2124
  background-color: #1d2125;
2136
2125
  border: 1px solid #141414;
2137
2126
  color: #b9b9b9
2138
2127
  }
2139
2128
 
2140
- .react-vditor--dark .vditor-speech--current, .react-vditor--dark .vditor-speech:hover {
2129
+ :where(.react-vditor--dark) .vditor-speech--current, :where(.react-vditor--dark) .vditor-speech:hover {
2141
2130
  color: #fff
2142
2131
  }
2143
2132
 
2144
- .react-vditor--dark .vditor-linkcard a {
2133
+ :where(.react-vditor--dark) .vditor-linkcard a {
2145
2134
  background-color: #1d2125;
2146
2135
  }
2147
2136
 
2148
- .react-vditor--dark .vditor-linkcard a:visited .vditor-linkcard__abstract {
2137
+ :where(.react-vditor--dark) .vditor-linkcard a:visited .vditor-linkcard__abstract {
2149
2138
  color: hsla(0, 0%, 72.5%, .36)
2150
2139
  }
2151
2140
 
2152
- .react-vditor--dark .vditor-linkcard__title {
2141
+ :where(.react-vditor--dark) .vditor-linkcard__title {
2153
2142
  color: #d1d5da
2154
2143
  }
2155
2144
 
2156
- .react-vditor--dark .vditor-linkcard__abstract {
2145
+ :where(.react-vditor--dark) .vditor-linkcard__abstract {
2157
2146
  color: #b9b9b9
2158
2147
  }
2159
2148
 
2160
- .react-vditor--dark .vditor-linkcard__site {
2149
+ :where(.react-vditor--dark) .vditor-linkcard__site {
2161
2150
  color: #fff
2162
2151
  }
2163
2152
 
2164
- .react-vditor--dark .vditor-linkcard__image {
2153
+ :where(.react-vditor--dark) .vditor-linkcard__image {
2165
2154
  background-color: hsla(0, 0%, 72.5%, .36)
2166
2155
  }
2167
2156
 
2168
- .react-vditor--dark pre code.hljs{display:block;overflow-x:auto;padding:1em}.react-vditor--dark code.hljs{padding:3px 5px}/*!
2157
+ div:where(.react-vditor--dark) pre code.hljs{display:block;overflow-x:auto;padding:1em}div:where(.react-vditor--dark) code.hljs{padding:3px 5px}/*!
2169
2158
  Theme: GitHub Dark
2170
2159
  Description: Dark theme as seen on github.com
2171
2160
  Author: github.com
@@ -2174,6 +2163,7 @@
2174
2163
 
2175
2164
  Outdated base version: https://github.com/primer/github-syntax-dark
2176
2165
  Current colors taken from GitHub's CSS
2177
- */.react-vditor--dark .hljs{color:#c9d1d9;background:#0d1117}.react-vditor--dark .hljs-doctag,.react-vditor--dark .hljs-keyword,.react-vditor--dark .hljs-meta .hljs-keyword,.react-vditor--dark .hljs-template-tag,.react-vditor--dark .hljs-template-variable,.react-vditor--dark .hljs-type,.react-vditor--dark .hljs-variable.language_{color:#ff7b72}.react-vditor--dark .hljs-title,.react-vditor--dark .hljs-title.class_,.react-vditor--dark .hljs-title.class_.inherited__,.react-vditor--dark .hljs-title.function_{color:#d2a8ff}.react-vditor--dark .hljs-attr,.react-vditor--dark .hljs-attribute,.react-vditor--dark .hljs-literal,.react-vditor--dark .hljs-meta,.react-vditor--dark .hljs-number,.react-vditor--dark .hljs-operator,.react-vditor--dark .hljs-selector-attr,.react-vditor--dark .hljs-selector-class,.react-vditor--dark .hljs-selector-id,.react-vditor--dark .hljs-variable{color:#79c0ff}.react-vditor--dark .hljs-meta .hljs-string,.react-vditor--dark .hljs-regexp,.react-vditor--dark .hljs-string{color:#a5d6ff}.react-vditor--dark .hljs-built_in,.react-vditor--dark .hljs-symbol{color:#ffa657}.react-vditor--dark .hljs-code,.react-vditor--dark .hljs-comment,.react-vditor--dark .hljs-formula{color:#8b949e}.react-vditor--dark .hljs-name,.react-vditor--dark .hljs-quote,.react-vditor--dark .hljs-selector-pseudo,.react-vditor--dark .hljs-selector-tag{color:#7ee787}.react-vditor--dark .hljs-subst{color:#c9d1d9}.react-vditor--dark .hljs-section{color:#1f6feb;font-weight:700}.react-vditor--dark .hljs-bullet{color:#f2cc60}.react-vditor--dark .hljs-emphasis{color:#c9d1d9;font-style:italic}.react-vditor--dark .hljs-strong{color:#c9d1d9;font-weight:700}.react-vditor--dark .hljs-addition{color:#aff5b4;background-color:#033a16}.react-vditor--dark .hljs-deletion{color:#ffdcd7;background-color:#67060c}
2166
+ */div:where(.react-vditor--dark) .hljs{color:#c9d1d9;background:#0d1117}div:where(.react-vditor--dark) .hljs-doctag,div:where(.react-vditor--dark) .hljs-keyword,div:where(.react-vditor--dark) .hljs-meta .hljs-keyword,div:where(.react-vditor--dark) .hljs-template-tag,div:where(.react-vditor--dark) .hljs-template-variable,div:where(.react-vditor--dark) .hljs-type,div:where(.react-vditor--dark) .hljs-variable.language_{color:#ff7b72}div:where(.react-vditor--dark) .hljs-title,div:where(.react-vditor--dark) .hljs-title.class_,div:where(.react-vditor--dark) .hljs-title.class_.inherited__,div:where(.react-vditor--dark) .hljs-title.function_{color:#d2a8ff}div:where(.react-vditor--dark) .hljs-attr,div:where(.react-vditor--dark) .hljs-attribute,div:where(.react-vditor--dark) .hljs-literal,div:where(.react-vditor--dark) .hljs-meta,div:where(.react-vditor--dark) .hljs-number,div:where(.react-vditor--dark) .hljs-operator,div:where(.react-vditor--dark) .hljs-selector-attr,div:where(.react-vditor--dark) .hljs-selector-class,div:where(.react-vditor--dark) .hljs-selector-id,div:where(.react-vditor--dark) .hljs-variable{color:#79c0ff}div:where(.react-vditor--dark) .hljs-meta .hljs-string,div:where(.react-vditor--dark) .hljs-regexp,div:where(.react-vditor--dark) .hljs-string{color:#a5d6ff}div:where(.react-vditor--dark) .hljs-built_in,div:where(.react-vditor--dark) .hljs-symbol{color:#ffa657}div:where(.react-vditor--dark) .hljs-code,div:where(.react-vditor--dark) .hljs-comment,div:where(.react-vditor--dark) .hljs-formula{color:#8b949e}div:where(.react-vditor--dark) .hljs-name,div:where(.react-vditor--dark) .hljs-quote,div:where(.react-vditor--dark) .hljs-selector-pseudo,div:where(.react-vditor--dark) .hljs-selector-tag{color:#7ee787}div:where(.react-vditor--dark) .hljs-subst{color:#c9d1d9}div:where(.react-vditor--dark) .hljs-section{color:#1f6feb;font-weight:700}div:where(.react-vditor--dark) .hljs-bullet{color:#f2cc60}div:where(.react-vditor--dark) .hljs-emphasis{color:#c9d1d9;font-style:italic}div:where(.react-vditor--dark) .hljs-strong{color:#c9d1d9;font-weight:700}div:where(.react-vditor--dark) .hljs-addition{color:#aff5b4;background-color:#033a16}div:where(.react-vditor--dark) .hljs-deletion{color:#ffdcd7;background-color:#67060c}
2178
2167
 
2168
+ :where(.react-vditor--light) .vditor-reset pre > code.hljs { background-color: #f6f8fa; }
2179
2169
  .react-vditor-preview.react-vditor--dark { background-color: #2f363d; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wyttime04/react-vditor",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "React component for the Vditor Markdown editor, limited to GFM and fully offline",
5
5
  "keywords": [
6
6
  "react",