mirror of https://github.com/logseq/logseq
Merge branch 'master' into feat/custom-children-list-style
commit
5baee5d87f
|
@ -57,6 +57,7 @@
|
||||||
(or
|
(or
|
||||||
(gdom/getElementByClass "sidebar-item-list")
|
(gdom/getElementByClass "sidebar-item-list")
|
||||||
(app-scroll-container-node))))))
|
(app-scroll-container-node))))))
|
||||||
|
#?(:cljs (defonce el-visible-in-viewport? utils/elementIsVisibleInViewport))
|
||||||
|
|
||||||
(defn string-join-path
|
(defn string-join-path
|
||||||
"Replace all `strings/join` used to construct paths with this function to reduce lint output.
|
"Replace all `strings/join` used to construct paths with this function to reduce lint output.
|
||||||
|
|
|
@ -374,10 +374,9 @@ export const nodePath = Object.assign({}, path, {
|
||||||
})
|
})
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/376373/pretty-printing-xml-with-javascript
|
// https://stackoverflow.com/questions/376373/pretty-printing-xml-with-javascript
|
||||||
export const prettifyXml = function(sourceXml)
|
export const prettifyXml = (sourceXml) => {
|
||||||
{
|
const xmlDoc = new DOMParser().parseFromString(sourceXml, 'application/xml')
|
||||||
var xmlDoc = new DOMParser().parseFromString(sourceXml, 'application/xml');
|
const xsltDoc = new DOMParser().parseFromString([
|
||||||
var xsltDoc = new DOMParser().parseFromString([
|
|
||||||
// describes how we want to modify the XML - indent everything
|
// describes how we want to modify the XML - indent everything
|
||||||
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',
|
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',
|
||||||
' <xsl:strip-space elements="*"/>',
|
' <xsl:strip-space elements="*"/>',
|
||||||
|
@ -389,13 +388,22 @@ export const prettifyXml = function(sourceXml)
|
||||||
' </xsl:template>',
|
' </xsl:template>',
|
||||||
' <xsl:output indent="yes"/>',
|
' <xsl:output indent="yes"/>',
|
||||||
'</xsl:stylesheet>',
|
'</xsl:stylesheet>',
|
||||||
].join('\n'), 'application/xml');
|
].join('\n'), 'application/xml')
|
||||||
|
|
||||||
var xsltProcessor = new XSLTProcessor();
|
const xsltProcessor = new XSLTProcessor()
|
||||||
xsltProcessor.importStylesheet(xsltDoc);
|
xsltProcessor.importStylesheet(xsltDoc)
|
||||||
var resultDoc = xsltProcessor.transformToDocument(xmlDoc);
|
const resultDoc = xsltProcessor.transformToDocument(xmlDoc)
|
||||||
var resultXml = new XMLSerializer().serializeToString(resultDoc);
|
const resultXml = new XMLSerializer().serializeToString(resultDoc)
|
||||||
// if it has parsererror, then return the original text
|
// if it has parsererror, then return the original text
|
||||||
return resultXml.indexOf('<parsererror') === -1 ? resultXml : sourceXml;
|
return resultXml.indexOf('<parsererror') === -1 ? resultXml : sourceXml
|
||||||
|
}
|
||||||
|
|
||||||
};
|
export const elementIsVisibleInViewport = (el, partiallyVisible = false) => {
|
||||||
|
const { top, left, bottom, right } = el.getBoundingClientRect()
|
||||||
|
const { innerHeight, innerWidth } = window
|
||||||
|
return partiallyVisible
|
||||||
|
? ((top > 0 && top < innerHeight) ||
|
||||||
|
(bottom > 0 && bottom < innerHeight)) &&
|
||||||
|
((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))
|
||||||
|
: top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth
|
||||||
|
}
|
|
@ -495,7 +495,8 @@
|
||||||
(fn []
|
(fn []
|
||||||
(when-let [input-id (state/get-edit-input-id)]
|
(when-let [input-id (state/get-edit-input-id)]
|
||||||
(when-let [input (gdom/getElement input-id)]
|
(when-let [input (gdom/getElement input-id)]
|
||||||
(.focus input)))))
|
(when (util/el-visible-in-viewport? input)
|
||||||
|
(.focus input))))))
|
||||||
|
|
||||||
(def ^:export get_editing_cursor_position
|
(def ^:export get_editing_cursor_position
|
||||||
(fn []
|
(fn []
|
||||||
|
|
Loading…
Reference in New Issue