orz-mdhtml 0.1.2 → 0.1.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/assets/app.js +12 -8
- package/package.json +1 -1
package/assets/app.js
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
+ 'try{if(window.mermaid){window.mermaid.run({querySelector:"#orz-doc .mermaid:not([data-processed])"})}}catch(e){}'
|
|
72
72
|
// SMILES: draw each canvas once (tracked via a JS prop so morphdom keeps
|
|
73
73
|
// the drawn canvas across edits — DOM attributes stay identical).
|
|
74
|
-
+ 'try{if(window.SmilesDrawer){document.querySelectorAll("#orz-doc canvas[data-smiles]").forEach(function(c){if(c.__orzSmilesDone)return;var s=c.getAttribute("data-smiles");if(!s)return;c.__orzSmilesDone=true;var dr=new window.SmilesDrawer.Drawer({width:c.
|
|
74
|
+
+ 'try{if(window.SmilesDrawer){document.querySelectorAll("#orz-doc canvas[data-smiles]").forEach(function(c){if(c.__orzSmilesDone)return;var s=c.getAttribute("data-smiles");if(!s)return;if(c.__orzOrigW===undefined){c.__orzOrigW=c.width;c.__orzOrigH=c.height;}c.width=c.__orzOrigW;c.height=c.__orzOrigH;c.__orzSmilesDone=true;var dr=new window.SmilesDrawer.Drawer({width:c.__orzOrigW,height:c.__orzOrigH});window.SmilesDrawer.parse(s,function(t){try{dr.draw(t,c,window.__orzSmilesTheme||"light",false)}catch(e){}},function(){})})}}catch(e){}'
|
|
75
75
|
// Tabs init runs in the runtime on load (empty #orz-doc); re-run now that
|
|
76
76
|
// content is injected, and after each incremental update. Idempotent.
|
|
77
77
|
+ 'try{if(window.OrzMarkdownRuntime&&window.OrzMarkdownRuntime.initTabs){window.OrzMarkdownRuntime.initTabs(document)}}catch(e){}'
|
|
@@ -103,13 +103,13 @@
|
|
|
103
103
|
if (typeof w.__orzEnhance === 'function') { try { w.__orzEnhance(); } catch (e) {} }
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
// Re-draw SMILES canvases
|
|
107
|
-
//
|
|
106
|
+
// Re-draw SMILES canvases in the current light/dark theme (after a theme
|
|
107
|
+
// switch). Just clear the done flag; the draw hook resets each canvas to its
|
|
108
|
+
// original dimensions before redrawing, so sizes never drift.
|
|
108
109
|
function redrawSmiles() {
|
|
109
110
|
var doc = frameDoc(); if (!doc) return;
|
|
110
111
|
Array.prototype.forEach.call(doc.querySelectorAll('#orz-doc canvas[data-smiles]'), function (c) {
|
|
111
|
-
|
|
112
|
-
if (c.parentNode) c.parentNode.replaceChild(fresh, c);
|
|
112
|
+
c.__orzSmilesDone = false;
|
|
113
113
|
});
|
|
114
114
|
enhance();
|
|
115
115
|
}
|
|
@@ -134,9 +134,13 @@
|
|
|
134
134
|
window.morphdom(container, next, {
|
|
135
135
|
onBeforeElUpdated: function (fromEl, toEl) {
|
|
136
136
|
if (fromEl.isEqualNode && fromEl.isEqualNode(toEl)) return false;
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
// Keep an already-rendered generated construct (mermaid / smiles / qr /
|
|
138
|
+
// youtube) when its source is unchanged. These are client-rendered into
|
|
139
|
+
// canvases / SVGs / iframes, so letting morphdom touch them would wipe
|
|
140
|
+
// the drawing (e.g. a SMILES canvas disappearing when nearby text is
|
|
141
|
+
// edited). data-md carries the source; skip the whole subtree on match.
|
|
142
|
+
var dm = fromEl.getAttribute && fromEl.getAttribute('data-md');
|
|
143
|
+
if (dm != null && toEl.getAttribute && dm === toEl.getAttribute('data-md')) return false;
|
|
140
144
|
// keep highlighted code when the text is unchanged
|
|
141
145
|
if (fromEl.nodeName === 'CODE' && fromEl.classList && fromEl.classList.contains('hljs') &&
|
|
142
146
|
fromEl.textContent === toEl.textContent) return false;
|
package/package.json
CHANGED