Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
printWidth: 100,
singleQuote: true
singleQuote: true,
endOfLine: 'auto',
};
15 changes: 14 additions & 1 deletion apps/editor/demo/esm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
'',
'| name | type | description |',
'| --- | --- | --- |',
'| el | `HTMLElement` | container element |',
'| el | `HTMLElement` | [@Widget](Widget) |',
'',
'## Features',
'',
Expand Down Expand Up @@ -59,6 +59,19 @@
extendedAutolinks: true,
frontMatter: true,
initialValue: content,
widgetRules: [
{
rule: /\[(@\S+)\]\((\S+)\)/,
toDOM(text) {
const rule = /\[(@\S+)\]\((\S+)\)/;
const matched = text.match(rule);
const span = document.createElement('span');

span.innerHTML = `<a class="widget-anchor" href="${matched[2]}">${matched[1]}</a>`;
return span;
},
},
],
});

window.editor = editor;
Expand Down
2 changes: 1 addition & 1 deletion apps/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.7"
}
}
}
4 changes: 4 additions & 0 deletions apps/editor/src/convertors/toWysiwyg/htmlToWwConvertors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export function isInlineNode({ type }: MdNode) {
return includes(['text', 'strong', 'emph', 'strike', 'image', 'link', 'code'], type);
}

export function isCustomInline(node: MdNode) {
return node.type === 'customInline';
}

function isSoftbreak(mdNode: MdNode | null) {
return mdNode?.type === 'softbreak';
}
Expand Down
6 changes: 5 additions & 1 deletion apps/editor/src/convertors/toWysiwyg/toWwConvertors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
getTextWithoutTrailingNewline,
isInlineNode,
isCustomHTMLInlineNode,
isCustomInline,
} from './htmlToWwConvertors';

import { ToWwConvertorMap } from '@t/convertor';
Expand Down Expand Up @@ -235,7 +236,10 @@ const toWwConvertors: ToWwConvertorMap = {
tableCell(state, node, { entering }) {
if (!(node as TableCellMdNode).ignored) {
const hasParaNode = (childNode: MdNode | null) =>
childNode && (isInlineNode(childNode) || isCustomHTMLInlineNode(state, childNode));
childNode &&
(isInlineNode(childNode) ||
isCustomInline(childNode) ||
isCustomHTMLInlineNode(state, childNode));

if (entering) {
const { tableHeadCell, tableBodyCell, paragraph } = state.schema.nodes;
Expand Down