@duskmoon-dev/el-markdown-input 1.7.2 → 1.7.3

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/esm/index.js CHANGED
@@ -89,8 +89,8 @@ var init_sanitize_schema = __esm(() => {
89
89
  // src/render.ts
90
90
  var exports_render = {};
91
91
  __export(exports_render, {
92
- renderMermaidBlocks: () => renderMermaidBlocks,
93
- renderMarkdown: () => renderMarkdown
92
+ renderMarkdown: () => renderMarkdown,
93
+ renderMermaidBlocks: () => renderMermaidBlocks
94
94
  });
95
95
  function renderFrontMatter() {
96
96
  return (tree) => {
@@ -1158,6 +1158,9 @@ class ElDmMarkdownInput extends BaseElement {
1158
1158
  resize: { type: String, reflect: true, default: "none" },
1159
1159
  noPreview: { type: Boolean, reflect: true, attribute: "no-preview" }
1160
1160
  };
1161
+ static get observedAttributes() {
1162
+ return [...super.observedAttributes, "id"];
1163
+ }
1161
1164
  #internals;
1162
1165
  #initialized = false;
1163
1166
  #activeTab = "write";
@@ -1209,6 +1212,12 @@ class ElDmMarkdownInput extends BaseElement {
1209
1212
  clearTimeout(this.#livePreviewTimer);
1210
1213
  super.disconnectedCallback();
1211
1214
  }
1215
+ attributeChangedCallback(name, oldValue, newValue) {
1216
+ super.attributeChangedCallback(name, oldValue, newValue);
1217
+ if (name === "id" && oldValue !== newValue && this.isConnected) {
1218
+ this.#syncEditorIdentity();
1219
+ }
1220
+ }
1212
1221
  update() {
1213
1222
  if (!this.#initialized) {
1214
1223
  super.update();
@@ -1233,6 +1242,7 @@ class ElDmMarkdownInput extends BaseElement {
1233
1242
  if (!ta)
1234
1243
  return;
1235
1244
  const placeholder = this.placeholder ?? "Write markdown…";
1245
+ this.#syncEditorIdentity();
1236
1246
  ta.placeholder = placeholder;
1237
1247
  ta.disabled = !!this.disabled;
1238
1248
  ta.readOnly = !!this.readonly;
@@ -1272,7 +1282,24 @@ class ElDmMarkdownInput extends BaseElement {
1272
1282
  }
1273
1283
  this.#updateStatusBarNow();
1274
1284
  }
1285
+ #syncEditorIdentity() {
1286
+ const ta = this.#textarea;
1287
+ if (!ta)
1288
+ return;
1289
+ const editorId = this.id;
1290
+ const name = this.name || "";
1291
+ if (editorId)
1292
+ ta.id = editorId;
1293
+ else
1294
+ ta.removeAttribute("id");
1295
+ if (name)
1296
+ ta.name = name;
1297
+ else
1298
+ ta.removeAttribute("name");
1299
+ }
1275
1300
  render() {
1301
+ const editorId = this.id;
1302
+ const name = this.name || "";
1276
1303
  const ph = this.placeholder ?? "Write markdown…";
1277
1304
  const disabled = !!this.disabled;
1278
1305
  const readonly = !!this.readonly;
@@ -1303,6 +1330,8 @@ class ElDmMarkdownInput extends BaseElement {
1303
1330
  <div class="write-area" id="write-panel" role="tabpanel" aria-labelledby="tab-write">
1304
1331
  <div class="render-layer" aria-hidden="true"></div>
1305
1332
  <textarea
1333
+ ${editorId ? `id="${escapeHtmlStr(editorId)}"` : ""}
1334
+ ${name ? `name="${escapeHtmlStr(name)}"` : ""}
1306
1335
  aria-label="Markdown editor"
1307
1336
  aria-haspopup="listbox"
1308
1337
  aria-expanded="false"
@@ -1973,10 +2002,10 @@ var MarkdownInputHook = {
1973
2002
  }
1974
2003
  };
1975
2004
  export {
1976
- register,
2005
+ ElDmMarkdownInput,
1977
2006
  MarkdownInputHook,
1978
- ElDmMarkdownInput
2007
+ register
1979
2008
  };
1980
2009
 
1981
- //# debugId=A55F11AEE048BDBA64756E2164756E21
2010
+ //# debugId=C5931BE01CF609BB64756E2164756E21
1982
2011
  //# sourceMappingURL=index.js.map