Merge branch 'master' into feat/custom-children-list-style

pull/9269/head
charlie 2023-04-25 19:11:56 +08:00
commit 5baee5d87f
3 changed files with 34 additions and 24 deletions

View File

@ -57,6 +57,7 @@
(or
(gdom/getElementByClass "sidebar-item-list")
(app-scroll-container-node))))))
#?(:cljs (defonce el-visible-in-viewport? utils/elementIsVisibleInViewport))
(defn string-join-path
"Replace all `strings/join` used to construct paths with this function to reduce lint output.

View File

@ -374,10 +374,9 @@ export const nodePath = Object.assign({}, path, {
})
// https://stackoverflow.com/questions/376373/pretty-printing-xml-with-javascript
export const prettifyXml = function(sourceXml)
{
var xmlDoc = new DOMParser().parseFromString(sourceXml, 'application/xml');
var xsltDoc = new DOMParser().parseFromString([
export const prettifyXml = (sourceXml) => {
const xmlDoc = new DOMParser().parseFromString(sourceXml, 'application/xml')
const xsltDoc = new DOMParser().parseFromString([
// describes how we want to modify the XML - indent everything
'<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">',
' <xsl:strip-space elements="*"/>',
@ -389,13 +388,22 @@ export const prettifyXml = function(sourceXml)
' </xsl:template>',
' <xsl:output indent="yes"/>',
'</xsl:stylesheet>',
].join('\n'), 'application/xml');
].join('\n'), 'application/xml')
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDoc);
var resultDoc = xsltProcessor.transformToDocument(xmlDoc);
var resultXml = new XMLSerializer().serializeToString(resultDoc);
const xsltProcessor = new XSLTProcessor()
xsltProcessor.importStylesheet(xsltDoc)
const resultDoc = xsltProcessor.transformToDocument(xmlDoc)
const resultXml = new XMLSerializer().serializeToString(resultDoc)
// 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
}

View File

@ -495,7 +495,8 @@
(fn []
(when-let [input-id (state/get-edit-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
(fn []