@ones-editor/editor 2.1.7-beta.28 → 2.1.7-beta.29

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/dist/index.js CHANGED
@@ -72253,11 +72253,35 @@ ${codeText}
72253
72253
  "style-custom-tag": true
72254
72254
  });
72255
72255
  }
72256
+ const StyleTags = {
72257
+ u: "style-underline",
72258
+ strong: "style-bold",
72259
+ em: "style-italic",
72260
+ del: "style-strikethrough",
72261
+ superscript: "style-superscript",
72262
+ subscript: "style-subscript"
72263
+ };
72264
+ function applyHtmlToText(htm, attributes) {
72265
+ const html = htm.toLowerCase();
72266
+ const tags = Object.keys(StyleTags);
72267
+ for (let i = 0; i < tags.length; i += 1) {
72268
+ const tag = tags[i];
72269
+ const startTag = `<${tag}>`;
72270
+ const endTag = `</${tag}>`;
72271
+ if (html.indexOf(startTag) >= 0) {
72272
+ attributes[StyleTags[tag]] = true;
72273
+ } else if (html.indexOf(endTag) >= 0) {
72274
+ delete attributes[StyleTags[tag]];
72275
+ }
72276
+ }
72277
+ }
72256
72278
  const logger$M = getLogger("token-to-text");
72257
72279
  function tokensToText(tokens, attributes, options) {
72258
72280
  const ops = tokens.map((token) => {
72259
72281
  if (token.type === "text") {
72260
- return textTokenToText(token, attributes, options);
72282
+ return textTokenToText(token, {
72283
+ ...attributes
72284
+ }, options);
72261
72285
  }
72262
72286
  if (token.type === "strong") {
72263
72287
  return options.tokensToText(token.tokens, {
@@ -72283,6 +72307,10 @@ ${codeText}
72283
72307
  if (token.type === "codespan") {
72284
72308
  return codespanToText(token, attributes);
72285
72309
  }
72310
+ if (token.type === "html") {
72311
+ const html = token.text;
72312
+ applyHtmlToText(html, attributes);
72313
+ }
72286
72314
  if (token.type === "br") {
72287
72315
  return [{
72288
72316
  insert: " ",
@@ -72864,11 +72892,11 @@ ${content}
72864
72892
  replacement(content, node, options) {
72865
72893
  const hLevel = Number(node.nodeName.charAt(1));
72866
72894
  if (options.headingStyle === "setext" && hLevel < 3) {
72867
- const underline = repeat(hLevel === 1 ? "=" : "-", content.length);
72895
+ const underline2 = repeat(hLevel === 1 ? "=" : "-", content.length);
72868
72896
  return `
72869
72897
 
72870
72898
  ${content}
72871
- ${underline}
72899
+ ${underline2}
72872
72900
 
72873
72901
  `;
72874
72902
  }
@@ -73957,6 +73985,16 @@ ${content}
73957
73985
  const newHtml = fragmentToHtml(fragment);
73958
73986
  return newHtml;
73959
73987
  }
73988
+ function underline(ts) {
73989
+ ts.addRule("underline", {
73990
+ filter: ["u"],
73991
+ replacement(content, node) {
73992
+ if (!content.trim())
73993
+ return "";
73994
+ return `<u>${content}</u>`;
73995
+ }
73996
+ });
73997
+ }
73960
73998
  const logger$K = getLogger("html-to-doc");
73961
73999
  const turndownService = new TurndownService();
73962
74000
  turndownService.use(codeListToCode);
@@ -73968,6 +74006,7 @@ ${content}
73968
74006
  turndownService.use(prismCodeToCode);
73969
74007
  turndownService.use(wechatMessageTimeToBlockQuote);
73970
74008
  turndownService.use(turndownPluginGfm.gfm);
74009
+ turndownService.use(underline);
73971
74010
  function htmlToBlocks$1(html, options) {
73972
74011
  const subDoc = processedHtmlToDocByMarkdown(html, options);
73973
74012
  if (!subDoc) {
@@ -89138,7 +89177,7 @@ ${data2.flowchartText}
89138
89177
  }
89139
89178
  }
89140
89179
  });
89141
- editor.version = "2.1.7-beta.28";
89180
+ editor.version = "2.1.7-beta.29";
89142
89181
  return editor;
89143
89182
  }
89144
89183
  function isDoc(doc2) {
@@ -89252,7 +89291,7 @@ ${data2.flowchartText}
89252
89291
  }
89253
89292
  }
89254
89293
  OnesEditorToolbar.register(editor);
89255
- editor.version = "2.1.7-beta.28";
89294
+ editor.version = "2.1.7-beta.29";
89256
89295
  return editor;
89257
89296
  }
89258
89297
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.1.7-beta.28",
3
+ "version": "2.1.7-beta.29",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",