(value: Value, plugins: MarkdownDeserializerPlugin[] = [])
| 190 | }, |
| 191 | |
| 192 | toMdast(value: Value, plugins: MarkdownDeserializerPlugin[] = []) { |
| 193 | const disable = defaultDisable.concat() |
| 194 | const extensions: Extension[] = [ |
| 195 | { |
| 196 | disable: { |
| 197 | null: disable, |
| 198 | }, |
| 199 | }, |
| 200 | ] |
| 201 | |
| 202 | const setExtensionsOrDisable = (ext: MarkdownDeserializerExtension) => { |
| 203 | if (Array.isArray(ext)) { |
| 204 | for (const e of ext) { |
| 205 | setExtensionsOrDisable(e) |
| 206 | } |
| 207 | } else if (typeof ext === 'string') { |
| 208 | const index = disable.indexOf(ext) |
| 209 | if (index > -1) disable.splice(index, 1) |
| 210 | } else { |
| 211 | extensions.push(ext) |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | const mdastExtensions: MarkdownDeserializerMdastExtension[] = [] |
| 216 | |
| 217 | const setMdastExtensions = (ext: MarkdownDeserializerMdastExtension) => { |
| 218 | if (Array.isArray(ext)) { |
| 219 | for (const e of ext) { |
| 220 | setMdastExtensions(e) |
| 221 | } |
| 222 | } else if (!mdastExtensions.some(e => e === ext)) { |
| 223 | mdastExtensions.push(ext) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | for (const plugin of this._plugins.concat(plugins)) { |
| 228 | if (plugin.extensions) setExtensionsOrDisable(plugin.extensions) |
| 229 | if (plugin.mdastExtensions) setMdastExtensions(plugin.mdastExtensions) |
| 230 | } |
| 231 | |
| 232 | return fromMarkdown(value, { |
| 233 | extensions, |
| 234 | mdastExtensions, |
| 235 | }) |
| 236 | }, |
| 237 | |
| 238 | toMdastWithEditor(editor: Editor, value: Value) { |
| 239 | const plugins = MARKDOWN_DESERIALIZER_PLUGINS.get(editor) ?? [] |
nothing calls this directly
no test coverage detected
searching dependent graphs…